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

refactor(proof card): if location missing, show chip with error & tooltip #657

Merged
merged 1 commit into from
Jun 24, 2024
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
20 changes: 16 additions & 4 deletions src/components/LocationChip.vue
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
<template>
<v-chip label size="small" density="comfortable" @click="goToLocation()">
<v-icon start icon="mdi-map-marker-outline" />
{{ locationTitle }}
<v-chip label size="small" prepend-icon="mdi-map-marker-outline" density="comfortable" :color="locationMissingAndShowError ? 'error' : 'default'" @click="goToLocation()">
<span v-if="locationId">{{ locationTitle }}</span>
<span v-if="locationEmoji" style="margin-inline-start:5px">{{ locationEmoji }}</span>
<span v-else-if="locationMissingAndShowError">
<i class="text-lowercase">{{ $t('Common.Location') }}</i>
<v-tooltip activator="parent" open-on-click location="top">
{{ $t('Common.LocationMissing') }}
</v-tooltip>
</span>
</v-chip>
</template>

Expand All @@ -23,6 +28,10 @@ export default {
type: Boolean,
default: false
},
showErrorIfLocationMissing: {
type: Boolean,
default: false
}
},
computed: {
locationTitle() {
Expand All @@ -36,11 +45,14 @@ export default {
return utils.getCountryEmojiFromCode(this.location.osm_address_country_code)
}
return null
},
locationMissingAndShowError() {
return !this.locationId && this.showErrorIfLocationMissing
}
},
methods: {
goToLocation() {
if (this.readonly) {
if (!this.locationId || this.readonly) {
return
}
this.$router.push({ path: `/locations/${this.locationId}` })
Expand Down
2 changes: 1 addition & 1 deletion src/components/ProofFooter.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<v-row>
<v-col :cols="userIsProofOwner ? '11' : '12'">
<ProofTypeChip class="mr-1" :proof="proof" />
<LocationChip class="mr-1" :location="proof.location" :locationId="proof.location_id" :readonly="readonly" />
<LocationChip class="mr-1" :location="proof.location" :locationId="proof.location_id" :readonly="readonly" :showErrorIfLocationMissing="true" />
<DateChip class="mr-1" :date="proof.date" :showErrorIfDateMissing="true" />
<PriceCountChip :count="proof.price_count" :withLabel="true" @click="goToProof()" />
<CurrencyChip class="mr-1" :currency="proof.currency" :showErrorIfCurrencyMissing="true" />
Expand Down
2 changes: 2 additions & 0 deletions src/i18n/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,9 @@
"Currency": "Currency",
"CurrencyMissing": "Currency missing",
"Language": "Languages",
"Location": "Location",
"Locations": "Locations",
"LocationMissing": "Location missing",
"Date": "Date",
"DateMissing": "Date missing",
"Details": "Details",
Expand Down
Loading