Skip to content

Commit

Permalink
New ProductLabelsChip
Browse files Browse the repository at this point in the history
  • Loading branch information
raphodn committed Mar 8, 2024
1 parent 4a633e6 commit ab58834
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 15 deletions.
17 changes: 2 additions & 15 deletions src/components/ProductCard.vue
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,7 @@
<br />
<span>
<ProductCategoriesChip :productCategories="product.categories_tags"></ProductCategoriesChip>
<v-chip label size="small" density="comfortable" @click="showProductLabelsDialog">
{{ $t('ProductCard.LabelTotal', { count: (product && product.labels_tags) ? product.labels_tags.length : 0 }) }}
</v-chip>
<ProductLabelsChip :productLabels="product.labels_tags"></ProductLabelsChip>
</span>
<br />
<span>
Expand All @@ -44,13 +42,6 @@
</v-sheet>
</v-container>
</v-card>

<ProductLabelsDialog
v-if="product && product.labels_tags && productLabelsDialog"
:labels="product.labels_tags"
v-model="productLabelsDialog"
@close="productLabelsDialog = false"
></ProductLabelsDialog>
</template>

<script>
Expand All @@ -61,9 +52,9 @@ export default {
'PriceCountChip': defineAsyncComponent(() => import('../components/PriceCountChip.vue')),
'ProductQuantityChip': defineAsyncComponent(() => import('../components/ProductQuantityChip.vue')),
'ProductCategoriesChip': defineAsyncComponent(() => import('../components/ProductCategoriesChip.vue')),
'ProductLabelsChip': defineAsyncComponent(() => import('../components/ProductLabelsChip.vue')),
'PricePrice': defineAsyncComponent(() => import('../components/PricePrice.vue')),
'PriceFooter': defineAsyncComponent(() => import('../components/PriceFooter.vue')),
'ProductLabelsDialog': defineAsyncComponent(() => import('../components/ProductLabelsDialog.vue')),
},
props: {
'product': null,
Expand All @@ -73,7 +64,6 @@ export default {
data() {
return {
productImageDefault: 'https://world.openfoodfacts.org/images/icons/dist/packaging.svg',
productLabelsDialog: false
}
},
mounted() {
Expand All @@ -98,9 +88,6 @@ export default {
getProductTitle() {
return this.hasProductSource ? (this.product.product_name || this.$t('ProductCard.UnknownProduct')) : this.product.code
},
showProductLabelsDialog() {
this.productLabelsDialog = true
},
goToProduct() {
if (this.readonly) {
return
Expand Down
37 changes: 37 additions & 0 deletions src/components/ProductLabelsChip.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<template>
<v-chip label size="small" density="comfortable" class="mr-1" @click="showProductLabelsDialog">
{{ $t('ProductCard.LabelTotal', { count: productLabels ? productLabels.length : 0 }) }}
</v-chip>

<ProductLabelsDialog
v-if="productLabels && productLabelsDialog"
:labels="productLabels"
v-model="productLabelsDialog"
@close="productLabelsDialog = false"
></ProductLabelsDialog>
</template>

<script>
import { defineAsyncComponent } from 'vue'
export default {
components: {
'ProductLabelsDialog': defineAsyncComponent(() => import('../components/ProductLabelsDialog.vue')),
},
props: {
productLabels: null,
},
data() {
return {
productLabelsDialog: false
}
},
computed: {
},
methods: {
showProductLabelsDialog() {
this.productLabelsDialog = true
},
}
}
</script>

0 comments on commit ab58834

Please sign in to comment.