Skip to content

Commit

Permalink
feat(Dashboard): New filtering menu to hide proofs with prices (#723)
Browse files Browse the repository at this point in the history
  • Loading branch information
raphodn authored Aug 18, 2024
1 parent 91f511a commit 53310db
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 5 deletions.
7 changes: 4 additions & 3 deletions src/components/FilterMenu.vue
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,9 @@ export default {
default: null
},
kind: {
// product, price
type: String,
default: 'product'
default: 'product',
examples: ['product', 'price', 'proof']
},
hideSource: {
type: Boolean,
Expand All @@ -56,14 +56,15 @@ export default {
productSourceList: constants.PRODUCT_SOURCE_LIST,
productFilterList: constants.PRODUCT_FILTER_LIST,
priceFilterList: constants.PRICE_FILTER_LIST,
proofFilterList: constants.PROOF_FILTER_LIST,
}
},
computed: {
showSource() {
return this.kind === 'product' && !this.hideSource
},
filterList() {
return this.kind === 'product' ? this.productFilterList : this.priceFilterList
return this[`${this.kind}FilterList`]
},
currentFilterOrSource() {
return !!this.currentFilter || !!this.currentSource
Expand Down
3 changes: 3 additions & 0 deletions src/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@ export default {
PRICE_FILTER_LIST: [
{ key: 'only_last_30d', value: 'FilterPriceMoreThan30DaysHide' },
],
PROOF_FILTER_LIST: [
{ key: 'hide_price_count_gte_1', value: 'FilterProofWithPriceCountHide' },
],
ORDER_PARAM: 'order',
PRODUCT_ORDER_LIST: [
{ key: '-unique_scans_n', value: 'OrderProductUniqueScansDESC', icon: 'mdi-barcode-scan' },
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 @@ -136,6 +136,7 @@
"Filter": "Filter",
"FilterProductWithPriceCountHide": "Hide products with prices",
"FilterPriceMoreThan30DaysHide": "Hide prices older than 30 days",
"FilterProofWithPriceCountHide": "Hide proofs with prices",
"Help": "Help",
"Image": "Image",
"LinkCopySuccess": "Link copied",
Expand Down
15 changes: 13 additions & 2 deletions src/views/UserDashboardProofList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@
<h2 class="text-h6 mb-1">
{{ $t('UserDashboard.LatestProofs') }}
<v-progress-circular v-if="loading" indeterminate :size="30" />
<OrderMenu v-if="!loading" kind="proof" :currentOrder="currentOrder" @update:currentOrder="selectProofOrder($event)" />
<FilterMenu v-if="!loading" kind="proof" :currentFilter="currentFilter" @update:currentFilter="toggleProofFilter($event)" />
<OrderMenu v-if="!loading" kind="proof" :currentOrder="currentOrder" @update:currentOrder="selectProofOrder($event)" />
</h2>

<v-row>
Expand Down Expand Up @@ -54,6 +55,7 @@ import api from '../services/api'
export default {
components: {
FilterMenu: defineAsyncComponent(() => import('../components/FilterMenu.vue')),
OrderMenu: defineAsyncComponent(() => import('../components/OrderMenu.vue')),
ProofCard: defineAsyncComponent(() => import('../components/ProofCard.vue')),
},
Expand All @@ -64,7 +66,8 @@ export default {
userProofPage: 0,
loading: false,
proofUpdated: false,
// order
// filter & order
currentFilter: '',
currentOrder: constants.PROOF_ORDER_LIST[2].key,
}
},
Expand All @@ -75,6 +78,9 @@ export default {
},
getUserProofsParams() {
let defaultParams = { owner: this.username, order_by: `${this.currentOrder}`, page: this.userProofPage }
if (this.currentFilter && this.currentFilter === 'hide_price_count_gte_1') {
defaultParams['price_count'] = 0
}
return defaultParams
},
},
Expand Down Expand Up @@ -109,6 +115,11 @@ export default {
handleProofUpdated() {
this.proofUpdated = true
},
toggleProofFilter(filterKey) {
this.currentFilter = this.currentFilter ? '' : filterKey
this.$router.push({ query: { ...this.$route.query, [constants.FILTER_PARAM]: this.currentFilter } })
// this.initUserProofs() will be called in watch $route
},
selectProofOrder(orderKey) {
if (this.currentOrder !== orderKey) {
this.currentOrder = orderKey
Expand Down

0 comments on commit 53310db

Please sign in to comment.