Skip to content
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

fix(Proof add multiple): show done button only when ALL proofs have been uploaded #1232

Merged
merged 2 commits into from
Jan 4, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 21 additions & 19 deletions src/components/ProofUploadCard.vue
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ export default {
default: false
}
},
emits: ['proof'],
emits: ['proof', 'done'],
data() {
return {
proofForm: {
Expand All @@ -121,8 +121,8 @@ export default {
proofDateSuccessMessage: false,
proofSelectedSuccessMessage: false,
proofSuccessMessage: false,
proofImageList: [],
proofObjectList: [],
proofImageList: [], // images to upload
proofObjectList: [], // images uploaded
loading: false,
}
},
Expand Down Expand Up @@ -158,11 +158,13 @@ export default {
},
watch: {
proofImageList(newProofImageList, oldProofImageList) { // eslint-disable-line no-unused-vars
this.handleProofSelectedList(newProofImageList)
this.handleProofImageList()
},
proofObjectList(newProofObjectList, oldProofObjectList) { // eslint-disable-line no-unused-vars
// TODO: update to proofList?
this.$emit('proof', newProofObjectList[0])
if (this.proofObjectList.length === this.proofImageList.length) {
this.$emit('done')
}
}
},
mounted() {
Expand All @@ -175,31 +177,31 @@ export default {
}
this.proofForm.currency = this.appStore.getUserLastCurrencyUsed
},
handleProofSelectedList(proofSelectedList) {
handleProofImageList() {
// can be an existing proof, or a file
// existing proof: update proofForm + set proofObject
if (proofSelectedList[0].id) {
if (this.proofImageList[0].id) {
// update proofForm
this.proofForm.type = proofSelectedList[0].type
this.proofForm.proof_id = proofSelectedList[0].id
if (proofSelectedList[0].location) {
this.proofForm.location_id = proofSelectedList[0].location.id
this.proofForm.location_osm_id = (proofSelectedList[0].location.type === constants.LOCATION_TYPE_OSM) ? proofSelectedList[0].location_osm_id : null
this.proofForm.location_osm_type = (proofSelectedList[0].location.type === constants.LOCATION_TYPE_OSM) ? proofSelectedList[0].location_osm_type : ''
this.proofForm.type = this.proofImageList[0].type
this.proofForm.proof_id = this.proofImageList[0].id
if (this.proofImageList[0].location) {
this.proofForm.location_id = this.proofImageList[0].location.id
this.proofForm.location_osm_id = (this.proofImageList[0].location.type === constants.LOCATION_TYPE_OSM) ? this.proofImageList[0].location_osm_id : null
this.proofForm.location_osm_type = (this.proofImageList[0].location.type === constants.LOCATION_TYPE_OSM) ? this.proofImageList[0].location_osm_type : ''
}
if (proofSelectedList[0].date) {
this.proofForm.date = proofSelectedList[0].date
if (this.proofImageList[0].date) {
this.proofForm.date = this.proofImageList[0].date
}
if (proofSelectedList[0].currency) {
this.proofForm.currency = proofSelectedList[0].currency
if (this.proofImageList[0].currency) {
this.proofForm.currency = this.proofImageList[0].currency
}
// set proofObject
this.proofSelectedSuccessMessage = true
this.proofObjectList = [proofSelectedList[0]]
this.proofObjectList = [this.proofImageList[0]]
}
// new proof: extract exif data from file
else {
ExifReader.load(proofSelectedList[0]).then((tags) => {
ExifReader.load(this.proofImageList[0]).then((tags) => {
if (tags['DateTimeOriginal'] && tags['DateTimeOriginal'].description) {
// exif DateTimeOriginal format: '2024:01:31 20:23:52'
const imageDateString = tags['DateTimeOriginal'].description.substring(0, 10).replaceAll(':', '-')
Expand Down
8 changes: 4 additions & 4 deletions src/views/ProofAddMultiple.vue
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<template>
<v-row>
<v-col cols="12" md="6">
<ProofUploadCard :typePriceTagOnly="true" :hideRecentProofChoice="true" :multiple="true" @proof="proofUploaded = true" />
<ProofUploadCard :typePriceTagOnly="true" :hideRecentProofChoice="true" :multiple="true" @done="proofListUploaded = true" />
</v-col>
</v-row>

Expand All @@ -10,8 +10,8 @@
<v-btn
class="float-right"
type="submit"
:color="proofUploaded ? 'success' : ''"
:disabled="!proofUploaded"
:color="proofListUploaded ? 'success' : ''"
:disabled="!proofListUploaded"
@click="done"
>
{{ $t('Common.Done') }}
Expand All @@ -29,7 +29,7 @@ export default {
},
data() {
return {
proofUploaded: false
proofListUploaded: false
}
},
methods: {
Expand Down
Loading