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(Price Validation Assistant): open price validation to all proofs (not just owned) #1219

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft
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
3 changes: 2 additions & 1 deletion src/components/FilterMenu.vue
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ export default {
kind: {
type: String,
default: 'product',
examples: ['product', 'price', 'proof', 'location', 'user']
examples: ['product', 'price', 'proof', 'priceTag', 'location', 'user']
},
currentFilter: {
type: String,
Expand Down Expand Up @@ -98,6 +98,7 @@ export default {
productFilterList: constants.PRODUCT_FILTER_LIST,
priceFilterList: constants.PRICE_FILTER_LIST,
proofFilterList: constants.PROOF_FILTER_LIST,
priceTagFilterList: constants.PRICE_TAG_FILTER_LIST,
locationFilterList: constants.LOCATION_FILTER_LIST,
userFilterList: constants.USER_FILTER_LIST,
// other filters
Expand Down
3 changes: 3 additions & 0 deletions src/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,9 @@ export default {
PROOF_FILTER_LIST: [
{ key: 'hide_price_count_gte_1', value: 'FilterProofWithPriceCountHide' },
],
PRICE_TAG_FILTER_LIST: [
{ key: 'show_proof_owner', value: 'FilterPriceTagWithProofOwner' },
],
LOCATION_FILTER_LIST: [
{ key: 'hide_price_count_gte_1', value: 'FilterLocationWithPriceCountHide' },
],
Expand Down
1 change: 1 addition & 0 deletions src/i18n/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,7 @@
"FilterProductWithoutPriceCount": "Without prices",
"FilterPriceMoreThan30DaysHide": "Hide prices older than 30 days",
"FilterProofWithPriceCountHide": "Hide proofs with prices",
"FilterPriceTagWithProofOwner": "Show only my proofs",
"FilterLocationWithPriceCountHide": "Hide locations with prices",
"FilterUserWithPriceCountHide": "Hide contributors with prices",
"FAQ": "FAQ",
Expand Down
35 changes: 34 additions & 1 deletion src/views/PriceValidationAssistant.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
<v-chip label variant="text" prepend-icon="mdi-checkbox-marked-circle-plus-outline">
{{ $t('Common.PriceToValidateCount', { count: priceTagTotal }) }}
</v-chip>
<FilterMenu kind="priceTag" :currentFilter="currentFilter" @update:currentFilter="togglePriceTagFilter($event)" />
</v-col>
</v-row>

Expand Down Expand Up @@ -45,6 +46,7 @@ import utils from '../utils.js'

export default {
components: {
FilterMenu: defineAsyncComponent(() => import('../components/FilterMenu.vue')),
ContributionAssistantPriceFormCard: defineAsyncComponent(() => import('../components/ContributionAssistantPriceFormCard.vue')),
},
data() {
Expand All @@ -55,6 +57,7 @@ export default {
loading: false,
productPriceForms: [],
// filter & order
currentFilter: '',
currentOrder: '-proof_id', // order by most recent proof
// feedback
priceRemovedMessage: false,
Expand All @@ -72,10 +75,28 @@ export default {
return 6
},
getPriceTagsParams() {
return { proof__owner: this.username, proof__ready_for_price_tag_validation: true, status__isnull: true, order_by: this.currentOrder, size: this.getApiSize, page: this.priceTagPage }
let defaultParams = {
proof__ready_for_price_tag_validation: true,
status__isnull: true,
order_by: this.currentOrder,
size: this.getApiSize,
page: this.priceTagPage
}
if (this.currentFilter === 'show_proof_owner') {
defaultParams['proof__owner'] = this.username
}
return defaultParams
},
},
watch: {
$route (newRoute, oldRoute) { // only called when query changes to avoid having an API call when the path changes
if (oldRoute.path === newRoute.path && JSON.stringify(oldRoute.query) !== JSON.stringify(newRoute.query)) {
this.initPriceTags()
}
}
},
mounted() {
this.currentFilter = this.$route.query[constants.FILTER_PARAM] || this.currentFilter
this.getPriceTags()
// load more
this.handleDebouncedScroll = utils.debounce(this.handleScroll, 100)
Expand All @@ -85,6 +106,13 @@ export default {
window.removeEventListener('scroll', this.handleDebouncedScroll)
},
methods: {
initPriceTags() {
this.locationId = this.$route.params.id
this.priceTagList = []
this.priceTagTotal = null
this.priceTagPage = 0
this.getPriceTags()
},
removePriceTag(index, status) {
/**
* - update the price_tag (API)
Expand Down Expand Up @@ -198,6 +226,11 @@ export default {
this.createPriceLoading = false
})
},
togglePriceTagFilter(filterKey) {
this.currentFilter = this.currentFilter ? '' : filterKey
this.$router.push({ query: { ...this.$route.query, [constants.FILTER_PARAM]: this.currentFilter } })
// this.initPriceTags() will be called in watch $route
},
handleScroll(event) { // eslint-disable-line no-unused-vars
if (utils.getDocumentScrollPercentage() > 90) {
this.getPriceTags()
Expand Down
Loading