feat: select category
This commit is contained in:
parent
79ce34467c
commit
22e32c9513
2 changed files with 21 additions and 6 deletions
|
|
@ -74,6 +74,8 @@ const market = async () => {
|
||||||
},
|
},
|
||||||
|
|
||||||
searchNostr: false,
|
searchNostr: false,
|
||||||
|
filterCategories: [],
|
||||||
|
|
||||||
drawer: true,
|
drawer: true,
|
||||||
pubkeys: new Set(),
|
pubkeys: new Set(),
|
||||||
relays: new Set(),
|
relays: new Set(),
|
||||||
|
|
@ -157,8 +159,12 @@ const market = async () => {
|
||||||
return all
|
return all
|
||||||
}, {})
|
}, {})
|
||||||
const x = Object.keys(countedCategories)
|
const x = Object.keys(countedCategories)
|
||||||
.map(category => ({ category, count: countedCategories[category] }))
|
.map(category => ({
|
||||||
.sort((a,b) => b.count - a.count)
|
category,
|
||||||
|
count: countedCategories[category],
|
||||||
|
selected: this.filterCategories.indexOf(category) !== -1
|
||||||
|
}))
|
||||||
|
.sort((a, b) => b.count - a.count)
|
||||||
console.log('### x', x)
|
console.log('### x', x)
|
||||||
return x
|
return x
|
||||||
}
|
}
|
||||||
|
|
@ -861,7 +867,6 @@ const market = async () => {
|
||||||
order = order.eventCreatedAt < eventCreatedAt ? { ...order, ...orderUpdate } : { ...orderUpdate, ...order }
|
order = order.eventCreatedAt < eventCreatedAt ? { ...order, ...orderUpdate } : { ...orderUpdate, ...order }
|
||||||
}
|
}
|
||||||
|
|
||||||
// orders = [order].concat(orders.filter(o => o.id !== order.id))
|
|
||||||
orders.splice(orderIndex, 1, order)
|
orders.splice(orderIndex, 1, order)
|
||||||
this.orders[pubkey] = orders
|
this.orders[pubkey] = orders
|
||||||
this.orders = { ...this.orders }
|
this.orders = { ...this.orders }
|
||||||
|
|
@ -877,6 +882,15 @@ const market = async () => {
|
||||||
dismissMsg: null,
|
dismissMsg: null,
|
||||||
show: true
|
show: true
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
toggleCategoryFilter(category) {
|
||||||
|
const index = this.filterCategories.indexOf(category)
|
||||||
|
if (index === -1) {
|
||||||
|
this.filterCategories.push(category)
|
||||||
|
} else {
|
||||||
|
this.filterCategories.splice(index, 1)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -213,9 +213,10 @@
|
||||||
<div v-if="products?.length" class="gt-sm">
|
<div v-if="products?.length" class="gt-sm">
|
||||||
<q-virtual-scroll :items="allCategories" virtual-scroll-horizontal>
|
<q-virtual-scroll :items="allCategories" virtual-scroll-horizontal>
|
||||||
<template v-slot="{ item, index }">
|
<template v-slot="{ item, index }">
|
||||||
<q-chip :key="index" class="cursor-pointer q-mb-md">
|
<q-chip :key="index" :color="item.selected ? 'grey': ''" class="cursor-pointer q-mb-md">
|
||||||
<span v-text="item.category"></span>
|
<span v-text="item.category" @click="toggleCategoryFilter(item.category)"></span>
|
||||||
<q-badge rounded class="q-ml-sm" color="secondary"> <span v-text="item.count"></span></q-badge>
|
<q-badge @click="toggleCategoryFilter(item.category)" rounded class="q-ml-sm" color="secondary"> <span
|
||||||
|
v-text="item.count"></span></q-badge>
|
||||||
</q-chip>
|
</q-chip>
|
||||||
</template>
|
</template>
|
||||||
</q-virtual-scroll>
|
</q-virtual-scroll>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue