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

feat: add price_count to ProofCard (create new PriceCountChip component) #279

Merged
merged 4 commits into from
Feb 4, 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
11 changes: 0 additions & 11 deletions src/components/PriceCard.vue
Original file line number Diff line number Diff line change
Expand Up @@ -105,17 +105,6 @@ export default {
return utils.getCategoryName(this.price.category_tag)
}
},
getProductPriceCountColor() {
if (this.product.price_count === 0) {
return 'error'
}
if (this.product.price_count === 1) {
return 'warning'
}
if (this.product.price_count > 1) {
return 'success'
}
},
getProductBrandsList() {
if (this.hasProductBrands) {
return this.product.brands.split(',')
Expand Down
29 changes: 29 additions & 0 deletions src/components/PriceCountChip.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<template>
<v-chip label size="small" density="comfortable" :color="getColor()" class="mr-1">
<v-icon start icon="mdi-tag-outline"></v-icon>
<span v-if="withLabel">{{ $t('PriceCountChip.PriceCount', { count: count }) }}</span>
<span v-if="!withLabel">{{ count }}</span>
</v-chip>
</template>

<script>
export default {
props: {
'count': null,
'withLabel': false
},
methods: {
getColor() {
if (this.count === 0) {
return 'error'
}
if (this.count === 1) {
return 'warning'
}
if (this.count > 1) {
return 'success'
}
},
}
}
</script>
18 changes: 3 additions & 15 deletions src/components/ProductCard.vue
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,7 @@

<p class="mb-2">
<span>
<v-chip label size="small" density="comfortable" :color="getProductPriceCountColor" class="mr-1" @click="goToProduct()">
<v-icon start icon="mdi-tag-outline"></v-icon>
{{ product.price_count }}
</v-chip>
<PriceCountChip :count="product.price_count" @click="goToProduct()"></PriceCountChip>
</span>
<span v-if="hasProductBrands">
<v-chip v-for="brand in getProductBrandsList" label size="small" density="comfortable" class="mr-1" @click="goToBrand(brand)">
Expand Down Expand Up @@ -45,11 +42,13 @@
</template>

<script>
import PriceCountChip from '../components/PriceCountChip.vue'
import PricePrice from '../components/PricePrice.vue'
import PriceFooter from '../components/PriceFooter.vue'

export default {
components: {
PriceCountChip,
PricePrice,
PriceFooter,
},
Expand All @@ -72,17 +71,6 @@ export default {
hasProductQuantity() {
return !!this.product.product_quantity
},
getProductPriceCountColor() {
if (this.product.price_count === 0) {
return 'error'
}
if (this.product.price_count === 1) {
return 'warning'
}
if (this.product.price_count > 1) {
return 'success'
}
},
getProductBrandsList() {
if (this.hasProductBrands) {
return this.product.brands.split(',')
Expand Down
3 changes: 3 additions & 0 deletions src/components/ProofCard.vue
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,20 @@
<v-icon start icon="mdi-paperclip"></v-icon>
{{ proof.type }}
</v-chip>
<PriceCountChip :count="proof.price_count" :withLabel="true"></PriceCountChip>
<RelativeDateTimeChip :dateTime="proof.created"></RelativeDateTimeChip>
</div>
</v-card-text>
</v-card>
</template>

<script>
import PriceCountChip from '../components/PriceCountChip.vue'
import RelativeDateTimeChip from '../components/RelativeDateTimeChip.vue'

export default {
components: {
PriceCountChip,
RelativeDateTimeChip,
},
props: {
Expand Down
15 changes: 7 additions & 8 deletions src/i18n/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -121,14 +121,12 @@
"LocationDetail": {
"LatestPrices": "Latest prices",
"LoadMore": "Load more",
"LocationNotFound": "Location not found in OpenStreetMap... Don't hesitate to add it :)",
"LocationPriceTotal": "{count} prices"
"LocationNotFound": "Location not found in OpenStreetMap... Don't hesitate to add it :)"
},
"LocationList": {
"Title": "Top locations",
"LoadMore": "Load more",
"LocationTotal": "{count} locations",
"LocationPriceCount": "{count} prices"
"LocationTotal": "{count} locations"
},
"LocationSelector": {
"Clear": "Clear",
Expand Down Expand Up @@ -156,6 +154,9 @@
"FullPrice": "Full price",
"UnknownProduct": "Unknown product"
},
"PriceCountChip": {
"PriceCount": "{count} prices"
},
"PriceList": {
"LoadMore": "Load more",
"Title": "Latest prices"
Expand Down Expand Up @@ -248,14 +249,12 @@
},
"UserDetail": {
"LatestPrices": "Latest prices",
"LoadMore": "Load more",
"UserPriceTotal": "{count} prices"
"LoadMore": "Load more"
},
"UserList": {
"LoadMore": "Load more",
"Title": "Top contributors",
"UserTotal": "{count} contributors",
"UserPriceCount": "{count} prices"
"UserTotal": "{count} contributors"
},
"UserSettings": {
"AddingPrices": "Adding prices",
Expand Down
7 changes: 3 additions & 4 deletions src/views/LocationDetail.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,7 @@
:subtitle="location ? location.osm_display_name : ''"
:prepend-icon="location ? 'mdi-map-marker-outline' : 'mdi-map-marker-remove-variant'">
<v-card-text>
<v-chip label size="small" density="comfortable" class="mr-1">
<v-icon start icon="mdi-tag-outline"></v-icon>
{{ $t('LocationDetail.LocationPriceTotal', { count: locationPriceTotal }) }}
</v-chip>
<PriceCountChip :count="locationPriceTotal" :withLabel="true"></PriceCountChip>
</v-card-text>
</v-card>
</v-col>
Expand Down Expand Up @@ -50,11 +47,13 @@
<script>
import api from '../services/api'
import utils from '../utils.js'
import PriceCountChip from '../components/PriceCountChip.vue'
import PriceCard from '../components/PriceCard.vue'
import ShareButton from '../components/ShareButton.vue'

export default {
components: {
PriceCountChip,
PriceCard,
ShareButton,
},
Expand Down
20 changes: 5 additions & 15 deletions src/views/LocationList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,7 @@
height="100%"
@click="goToLocation(location)">
<v-card-text>
<v-chip label size="small" density="comfortable" :color="getLocationPriceCountColor(location)" class="mr-1">
<v-icon start icon="mdi-tag-outline"></v-icon>
{{ $t('LocationList.LocationPriceCount', { count: location.price_count }) }}
</v-chip>
<PriceCountChip :count="location.price_count" :withLabel="true"></PriceCountChip>
</v-card-text>
</v-card>
</v-col>
Expand All @@ -41,8 +38,12 @@
<script>
import api from '../services/api'
import utils from '../utils.js'
import PriceCountChip from '../components/PriceCountChip.vue'

export default {
components: {
PriceCountChip,
},
data() {
return {
// data
Expand Down Expand Up @@ -75,17 +76,6 @@ export default {
getLocationTitle(location) {
return utils.getLocationTitle(location, true, false, true, true)
},
getLocationPriceCountColor(location) {
if (location.price_count === 0) {
return 'error'
}
if (location.price_count === 1) {
return 'warning'
}
if (location.price_count > 1) {
return 'success'
}
},
goToLocation(location) {
this.$router.push({ path: `/locations/${location.id}` })
},
Expand Down
7 changes: 3 additions & 4 deletions src/views/UserDetail.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,7 @@
<v-col cols="12" sm="6">
<v-card :title="username" prepend-icon="mdi-account">
<v-card-text>
<v-chip label size="small" density="comfortable" class="mr-1">
<v-icon start icon="mdi-tag-outline"></v-icon>
{{ $t('UserDetail.UserPriceTotal', { count: userPriceTotal }) }}
</v-chip>
<PriceCountChip :count="userPriceTotal" :withLabel="true"></PriceCountChip>
</v-card-text>
</v-card>
</v-col>
Expand Down Expand Up @@ -43,12 +40,14 @@
import { mapStores } from 'pinia'
import { useAppStore } from '../store'
import api from '../services/api'
import PriceCountChip from '../components/PriceCountChip.vue'
import PriceCard from '../components/PriceCard.vue'
import OpenFoodFactsButton from '../components/OpenFoodFactsButton.vue'
import ShareButton from '../components/ShareButton.vue'

export default {
components: {
PriceCountChip,
PriceCard,
OpenFoodFactsButton,
ShareButton,
Expand Down
20 changes: 5 additions & 15 deletions src/views/UserList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,7 @@
height="100%"
@click="goToUser(user)">
<v-card-text>
<v-chip label size="small" density="comfortable" :color="getUserPriceCountColor(user)" class="mr-1">
<v-icon start icon="mdi-tag-outline"></v-icon>
{{ $t('UserList.UserPriceCount', { count: user.price_count }) }}
</v-chip>
<PriceCountChip :count="user.price_count" :withLabel="true"></PriceCountChip>
</v-card-text>
</v-card>
</v-col>
Expand All @@ -39,8 +36,12 @@

<script>
import api from '../services/api'
import PriceCountChip from '../components/PriceCountChip.vue'

export default {
components: {
PriceCountChip,
},
data() {
return {
// data
Expand Down Expand Up @@ -70,17 +71,6 @@ export default {
this.loading = false
})
},
getUserPriceCountColor(user) {
if (user.price_count === 0) {
return 'error'
}
if (user.price_count === 1) {
return 'warning'
}
if (user.price_count > 1) {
return 'success'
}
},
goToUser(user) {
this.$router.push({ path: `/users/${user.user_id}` })
},
Expand Down
Loading