-
Notifications
You must be signed in to change notification settings - Fork 4
Improve photo tagging #1075
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: staging
Are you sure you want to change the base?
Improve photo tagging #1075
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -8,25 +8,54 @@ | |||||||||||||||||||||
| export default class PhotoTags extends Component { | ||||||||||||||||||||||
| @service store; | ||||||||||||||||||||||
| @service flashNotice; | ||||||||||||||||||||||
| @service router; | ||||||||||||||||||||||
| @tracked newTagX; | ||||||||||||||||||||||
| @tracked newTagY; | ||||||||||||||||||||||
| @tracked selectApi; | ||||||||||||||||||||||
| @tracked showTags = false; | ||||||||||||||||||||||
| @tracked users = []; | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| get users() { | ||||||||||||||||||||||
| return this.store.findAll('user'); | ||||||||||||||||||||||
| get includeOldMembers() { | ||||||||||||||||||||||
| return this.router.currentRoute.queryParams.includeOldMembers === 'true'; | ||||||||||||||||||||||
| } | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| async fetchUsers() { | ||||||||||||||||||||||
| if (this.includeOldMembers) { | ||||||||||||||||||||||
| this.users = await this.store.findAll('user'); | ||||||||||||||||||||||
| } else { | ||||||||||||||||||||||
| const params = { filter: { group: 'Leden' } }; | ||||||||||||||||||||||
| this.users = await this.store.query('user', params); | ||||||||||||||||||||||
| } | ||||||||||||||||||||||
| } | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| @action | ||||||||||||||||||||||
| toggleShowTags() { | ||||||||||||||||||||||
| this.showTags = !this.showTags; | ||||||||||||||||||||||
| } | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| @action | ||||||||||||||||||||||
| toggleIncludeOldMembers() { | ||||||||||||||||||||||
| const newValue = !this.includeOldMembers; | ||||||||||||||||||||||
| this.router.transitionTo({ queryParams: { includeOldMembers: newValue ? 'true' : 'false' } }); | ||||||||||||||||||||||
| this.fetchUsers(); | ||||||||||||||||||||||
|
Comment on lines
+37
to
+40
|
||||||||||||||||||||||
| } | ||||||||||||||||||||||
|
Comment on lines
+36
to
+41
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Unawaited
Await the transition first, then fetch (and handle errors): 🛠️ Proposed fix `@action`
- toggleIncludeOldMembers() {
+ async toggleIncludeOldMembers() {
const newValue = !this.includeOldMembers;
- this.router.transitionTo({ queryParams: { includeOldMembers: newValue ? 'true' : 'false' } });
- this.fetchUsers();
+ await this.router.transitionTo({ queryParams: { includeOldMembers: newValue ? 'true' : 'false' } });
+ await this.fetchUsers();
}Error handling in Also, ESLint/Prettier requires a trailing comma on line 39: - this.router.transitionTo({ queryParams: { includeOldMembers: newValue ? 'true' : 'false' } });
+ this.router.transitionTo({ queryParams: { includeOldMembers: newValue ? 'true' : 'false' }, });🧰 Tools🪛 ESLint[error] 39-39: Replace (prettier/prettier) 🤖 Prompt for AI Agents |
||||||||||||||||||||||
|
|
||||||||||||||||||||||
| @action | ||||||||||||||||||||||
| onSearchChange(searchResults) { | ||||||||||||||||||||||
| // Auto-select the user if there's only one search result | ||||||||||||||||||||||
| if (searchResults && searchResults.length === 1 && this.selectApi) { | ||||||||||||||||||||||
| next(this, () => { | ||||||||||||||||||||||
| this.selectApi.actions.choose(searchResults[0]); | ||||||||||||||||||||||
| }); | ||||||||||||||||||||||
| } | ||||||||||||||||||||||
| } | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| @action | ||||||||||||||||||||||
| addTag(e) { | ||||||||||||||||||||||
| if (e.target.tagName.toLowerCase() != 'img' || this.newTagX || this.newTagY) | ||||||||||||||||||||||
|
||||||||||||||||||||||
| if (e.target.tagName.toLowerCase() != 'img' || this.newTagX || this.newTagY) | |
| if (e.target.tagName.toLowerCase() !== 'img' || this.newTagX || this.newTagY) |
Copilot
AI
Feb 25, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The fetchUsers() method is called in addTag without awaiting it, which means the PowerSelect dropdown might open with an empty or stale users list. Consider awaiting fetchUsers() before opening the select dropdown to ensure users are loaded first.
| addTag(e) { | |
| if (e.target.tagName.toLowerCase() != 'img' || this.newTagX || this.newTagY) | |
| return; | |
| e.stopPropagation(); | |
| this.fetchUsers(); | |
| async addTag(e) { | |
| if (e.target.tagName.toLowerCase() != 'img' || this.newTagX || this.newTagY) | |
| return; | |
| e.stopPropagation(); | |
| await this.fetchUsers(); |
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -1,7 +1,11 @@ | ||||||||||||||||||||||
| import { ApplicationRoute } from 'amber-ui/routes/application/application'; | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| export default class PhotoRoute extends ApplicationRoute { | ||||||||||||||||||||||
| queryParams = {}; | ||||||||||||||||||||||
| queryParams = { | ||||||||||||||||||||||
| includeOldMembers: { | ||||||||||||||||||||||
| replace: true | ||||||||||||||||||||||
| } | ||||||||||||||||||||||
| }; | ||||||||||||||||||||||
|
Comment on lines
+4
to
+8
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fix missing trailing commas flagged by ESLint/Prettier. 🔧 Proposed fix queryParams = {
includeOldMembers: {
- replace: true
- }
+ replace: true,
+ },
};📝 Committable suggestion
Suggested change
🧰 Tools🪛 ESLint[error] 6-6: Insert (prettier/prettier) [error] 7-7: Insert (prettier/prettier) 🤖 Prompt for AI Agents |
||||||||||||||||||||||
|
|
||||||||||||||||||||||
| model(params) { | ||||||||||||||||||||||
| return this.store.findRecord('photo', params.photo_id, params); | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| Original file line number | Diff line number | Diff line change | ||
|---|---|---|---|---|
|
|
@@ -45,3 +45,29 @@ | |||
| right: 8px; | ||||
| color: #fff; | ||||
| } | ||||
|
|
||||
| .photo-tag-controls { | ||||
| border-bottom: 1px solid rgb(255 255 255 / 20%); | ||||
| padding: 8px 0; | ||||
|
|
||||
| .form-check { | ||||
| margin-bottom: 0; | ||||
| } | ||||
|
|
||||
| .form-check-label { | ||||
| color: #fff; | ||||
| margin-bottom: 0; | ||||
| margin-left: 4px; | ||||
| font-size: 12px; | ||||
| } | ||||
|
|
||||
| .form-check-input { | ||||
| border-color: rgb(255 255 255 / 50%); | ||||
| background-color: rgb(255 255 255 / 20%); | ||||
|
|
||||
|
||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The fetchUsers() method lacks error handling. If the API call fails, there's no indication to the user, and the users list will remain empty. Consider adding try-catch error handling and displaying an error message to the user if the fetch fails.