Skip to content

Commit

Permalink
refactor: homogenise getShareLinkUrl. Add missing data-name
Browse files Browse the repository at this point in the history
  • Loading branch information
raphodn committed Sep 5, 2024
1 parent 5b9de39 commit 5a51628
Show file tree
Hide file tree
Showing 9 changed files with 30 additions and 7 deletions.
7 changes: 6 additions & 1 deletion src/components/LocationActionMenuButton.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<v-icon>mdi-dots-vertical</v-icon>
<v-menu activator="parent" scroll-strategy="close" transition="slide-y-transition">
<v-list>
<ShareLink :overrideUrl="'/locations/' + location.id" display="list-item" />
<ShareLink :overrideUrl="getShareLinkUrl" display="list-item" />
<v-divider />
<OpenStreetMapLink :location="location" display="list-item" />
</v-list>
Expand All @@ -28,6 +28,11 @@ export default {
type: String,
default: 'position:absolute;bottom:6px;right:0;'
}
},
computed: {
getShareLinkUrl() {
return `/locations/${this.location.id}`
}
}
}
</script>
1 change: 1 addition & 0 deletions src/components/LocationCard.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
:title="getLocationTitle(location)"
:subtitle="location ? location.osm_display_name : ''"
:prepend-icon="location ? 'mdi-map-marker-outline' : 'mdi-map-marker-remove-variant'"
data-name="location-card"
@click="goToLocation(location)"
>
<v-card-text v-if="location">
Expand Down
5 changes: 4 additions & 1 deletion src/components/PriceActionMenuButton.vue
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
{{ $t('Common.Price') }}
</v-list-subheader>
<v-divider />
<ShareLink v-if="showPriceShare" :overrideUrl="getPriceDetailUrl" display="list-item" />
<ShareLink v-if="showPriceShare" :overrideUrl="getShareLinkUrl" display="list-item" />
<v-list-item :slim="true" prepend-icon="mdi-eye-outline" :to="getPriceDetailUrl">
{{ $t('Common.Details') }}
</v-list-item>
Expand Down Expand Up @@ -115,6 +115,9 @@ export default {
showPriceShare() {
return this.$route.path === this.getPriceDetailUrl
},
getShareLinkUrl() {
return this.getPriceDetailUrl
},
userIsPriceOwner() {
return this.username && (this.price.owner === this.username)
}
Expand Down
7 changes: 6 additions & 1 deletion src/components/ProductActionMenuButton.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<v-menu activator="parent" scroll-strategy="close" transition="slide-y-transition">
<v-list>
<PriceAddLink :productCode="product.code" display="list-item" />
<ShareLink :overrideUrl="'/products/' + product.code" display="list-item" />
<ShareLink :overrideUrl="getShareLinkUrl" display="list-item" />
<v-divider />
<OpenFoodFactsLink :source="product.source" facet="product" :value="product.code" display="list-item" />
</v-list>
Expand All @@ -30,6 +30,11 @@ export default {
type: String,
default: 'position:absolute;bottom:6px;right:0;'
}
},
computed: {
getShareLinkUrl() {
return `/products/${this.product.code}`
}
}
}
</script>
2 changes: 1 addition & 1 deletion src/components/ProductCard.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<template>
<v-card data-name="product-card">
<v-card :id="'product_' + product.code" data-name="product-card">
<v-container class="pa-2" :style="latestPrice ? 'position:relative;' : ''">
<v-row v-if="product">
<v-col class="pr-0" style="max-width:20%">
Expand Down
2 changes: 1 addition & 1 deletion src/components/ProofCard.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<template>
<v-card :id="'proof_' + proof.id" @click="selectProof">
<v-card :id="'proof_' + proof.id" data-name="proof-card" @click="selectProof">
<v-card-title v-if="!hideProofHeader">
{{ $t('Common.Proof') }} <v-btn style="float:right;" variant="text" density="compact" icon="mdi-close" @click="close" />
</v-card-title>
Expand Down
7 changes: 6 additions & 1 deletion src/components/UserActionMenuButton.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<v-icon>mdi-dots-vertical</v-icon>
<v-menu activator="parent" scroll-strategy="close" transition="slide-y-transition">
<v-list>
<ShareLink :overrideUrl="'/users/' + user.user_id" display="list-item" />
<ShareLink :overrideUrl="getShareLinkUrl" display="list-item" />
<v-divider />
<OpenFoodFactsLink facet="editor" :value="user.user_id" display="list-item" />
</v-list>
Expand All @@ -28,6 +28,11 @@ export default {
type: String,
default: 'position:absolute;bottom:6px;right:0;'
}
},
computed: {
getShareLinkUrl() {
return `/users/${this.user.user_id}`
}
}
}
</script>
1 change: 1 addition & 0 deletions src/components/UserCard.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
<v-card
:title="user.user_id"
prepend-icon="mdi-account"
data-name="user-card"
@click="goToUser(user)"
>
<v-card-text>
Expand Down
5 changes: 4 additions & 1 deletion src/views/UserDashboardPriceList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<v-btn size="small" prepend-icon="mdi-arrow-left" to="/dashboard">
{{ $t('UserDashboard.Title') }}
</v-btn>
<ShareLink :overrideUrl="'/users/' + username" display="button" />
<ShareLink :overrideUrl="getShareLinkUrl" display="button" />
</v-col>
</v-row>

Expand Down Expand Up @@ -65,6 +65,9 @@ export default {
username() {
return this.appStore.user.username
},
getShareLinkUrl() {
return `/users/${this.username}`
}
},
mounted() {
this.getUserPrices()
Expand Down

0 comments on commit 5a51628

Please sign in to comment.