diff --git a/app/components/place-photo-upload.gjs b/app/components/place-photo-upload.gjs index 5aca5b4..af2c36c 100644 --- a/app/components/place-photo-upload.gjs +++ b/app/components/place-photo-upload.gjs @@ -8,6 +8,10 @@ import { task } from 'ember-concurrency'; import Geohash from 'latlon-geohash'; import PlacePhotoUploadItem from './place-photo-upload-item'; import Icon from '#components/icon'; +import { getSuggestedPhotoTags } from '../utils/photo-tag-suggestions'; +import capitalize from '../helpers/capitalize'; +import includes from '../helpers/includes'; +import { fn } from '@ember/helper'; import { or, not } from 'ember-truth-helpers'; export default class PlacePhotoUpload extends Component { @@ -22,6 +26,7 @@ export default class PlacePhotoUpload extends Component { @tracked error = ''; @tracked isPublishing = false; @tracked isDragging = false; + @tracked selectedTags = []; get place() { return this.args.place || {}; @@ -37,6 +42,10 @@ export default class PlacePhotoUpload extends Component { ); } + get suggestedTags() { + return getSuggestedPhotoTags(this.place); + } + @action handleFileSelect(event) { this.addFile(event.target.files[0]); @@ -93,11 +102,22 @@ export default class PlacePhotoUpload extends Component { } this.file = null; this.uploadedPhoto = null; + this.selectedTags = []; if (this.args.onUploadStateChange) { this.args.onUploadStateChange(false); } } + @action + toggleTag(tag) { + if (this.selectedTags.includes(tag)) { + this.selectedTags = []; + return; + } + + this.selectedTags = [tag]; + } + deletePhotoTask = task(async (photoData) => { try { if (photoData.hash) { @@ -139,6 +159,10 @@ export default class PlacePhotoUpload extends Component { const tags = [['i', `osm:${osmType}:${osmId}`]]; + for (const tag of this.selectedTags) { + tags.push(['t', tag]); + } + if (lat && lon) { tags.push(['g', Geohash.encode(lat, lon, 4)]); tags.push(['g', Geohash.encode(lat, lon, 6)]); @@ -227,6 +251,26 @@ export default class PlacePhotoUpload extends Component { /> + {{#if this.suggestedTags.length}} +
+

+ Choose a tag/category (optional): +

+
+ {{#each this.suggestedTags as |tag|}} + + {{/each}} +
+
+ {{/if}} +