Skip to content

Commit

Permalink
refactor(Product card): move Share action to menu (#704)
Browse files Browse the repository at this point in the history
  • Loading branch information
raphodn authored Aug 16, 2024
1 parent 44d402c commit 2823199
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 9 deletions.
6 changes: 3 additions & 3 deletions src/components/OpenFoodFactsAddMenu.vue
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ import constants from '../constants'
export default {
props: {
product: {
type: Object,
productCode: {
type: String,
required: true
}
},
Expand All @@ -56,7 +56,7 @@ export default {
return constants[`${source.key.toUpperCase()}_URL`]
},
getSourceAddUrlWithLocale(source) {
const SOURCE_ADD_URL = `${this.getSourceUrl(source)}/cgi/product.pl?type=search_or_add&action=display&code=${this.product.code}`
const SOURCE_ADD_URL = `${this.getSourceUrl(source)}/cgi/product.pl?type=search_or_add&action=display&code=${this.productCode}`
return SOURCE_ADD_URL.replace('world', this.appStore.user.language)
},
}
Expand Down
2 changes: 2 additions & 0 deletions src/components/ProductActionMenuButton.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +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" />
<v-divider />
<OpenFoodFactsLink :source="product.source" facet="product" :value="product.code" display="list-item" />
</v-list>
Expand All @@ -17,6 +18,7 @@ import { defineAsyncComponent } from 'vue'
export default {
components: {
PriceAddLink: defineAsyncComponent(() => import('../components/PriceAddLink.vue')),
ShareLink: defineAsyncComponent(() => import('../components/ShareLink.vue')),
OpenFoodFactsLink: defineAsyncComponent(() => import('../components/OpenFoodFactsLink.vue'))
},
props: {
Expand Down
8 changes: 2 additions & 6 deletions src/views/ProductDetail.vue
Original file line number Diff line number Diff line change
Expand Up @@ -15,23 +15,20 @@
</i18n-t>
</i>
<br>
<OpenFoodFactsAddMenu :product="product" />
<OpenFoodFactsAddMenu :productCode="productId" />
</v-alert>
<v-alert v-if="categoryNotFound" type="error" variant="outlined" icon="mdi-alert">
<i>{{ $t('ProductDetail.CategoryNotFound') }}</i>
</v-alert>
</v-col>
</v-row>

<v-row v-if="!productOrCategoryNotFound" class="mt-0">
<v-row v-if="!categoryNotFound" class="mt-0">
<v-col cols="12">
<PriceAddLink v-if="category" class="mr-2" :productCode="category.name" />
<ShareLink display="button" />
</v-col>
</v-row>

<br>

<v-row>
<v-col>
<h2 class="text-h6 d-inline mr-2">
Expand Down Expand Up @@ -89,7 +86,6 @@ export default {
PriceCard: defineAsyncComponent(() => import('../components/PriceCard.vue')),
LeafletMap: defineAsyncComponent(() => import('../components/LeafletMap.vue')),
OpenFoodFactsAddMenu: defineAsyncComponent(() => import('../components/OpenFoodFactsAddMenu.vue')),
ShareLink: defineAsyncComponent(() => import('../components/ShareLink.vue'))
},
data() {
return {
Expand Down

0 comments on commit 2823199

Please sign in to comment.