Skip to content

Commit e38c297

Browse files
committed
feat: add quick search to list view
1 parent e79b0e2 commit e38c297

File tree

3 files changed

+103
-1
lines changed

3 files changed

+103
-1
lines changed
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
<script setup lang="ts">
2+
import { mdiChevronUp, mdiChevronDown } from '@mdi/js'
3+
import { ref } from 'vue'
4+
import type { PropType } from 'vue'
5+
6+
// Props
7+
defineProps({
8+
searchGroups: {
9+
type: Array as PropType<{
10+
title: string
11+
items: string[]
12+
}[]>,
13+
default: () => [],
14+
},
15+
})
16+
17+
// Component state
18+
const search = defineModel<string>({ default: '' })
19+
const showQuickSearch = ref(true)
20+
</script>
21+
22+
<template>
23+
<div
24+
v-if="searchGroups.length"
25+
class="px-4"
26+
>
27+
<h2 class="text-subtitle-1 font-weight-bold">
28+
Quick search
29+
30+
<span
31+
class="text-caption text-secondary cursor-pointer ml-2"
32+
@click="showQuickSearch = !showQuickSearch"
33+
>
34+
{{ showQuickSearch ? 'Hide' : 'Show' }}
35+
<v-icon
36+
:icon="showQuickSearch ? mdiChevronUp : mdiChevronDown"
37+
/>
38+
</span>
39+
</h2>
40+
41+
<v-expand-transition>
42+
<div
43+
v-if="showQuickSearch"
44+
class="d-flex flex-wrap ga-2"
45+
>
46+
<div
47+
v-for="group in searchGroups"
48+
:key="group.title"
49+
>
50+
<h3 class="text-subtitle-2 text-medium-emphasis">
51+
{{ group.title }}
52+
</h3>
53+
<v-chip-group>
54+
<v-chip
55+
v-for="item in group.items"
56+
:key="item"
57+
:text="item"
58+
label
59+
size="small"
60+
class="mr-2"
61+
:variant="search === item ? 'flat' : 'outlined'"
62+
:color="search === item ? 'secondary' : 'primary'"
63+
@click="search === item ? search = '' : search = item"
64+
/>
65+
</v-chip-group>
66+
</div>
67+
</div>
68+
</v-expand-transition>
69+
</div>
70+
</template>
71+
72+
<style scoped>
73+
:deep(.v-chip__overlay) {
74+
--v-activated-opacity: 0;
75+
}
76+
</style>

src/runtime/components/firebase/FirebaseListTable.vue

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,13 @@ const props = defineProps({
7777
type: Function,
7878
default: () => '',
7979
},
80+
searchGroups: {
81+
type: Array as PropType<{
82+
title: string
83+
items: string[]
84+
}[]>,
85+
default: () => [],
86+
},
8087
})
8188
8289
// App state
@@ -112,7 +119,13 @@ const viewItem = (pointerEvent: PointerEvent, item: any) => {
112119
/>
113120
</div>
114121

115-
<v-card>
122+
<v-card flat>
123+
<!-- Quick search -->
124+
<QuickSearch
125+
v-model="search"
126+
:search-groups
127+
/>
128+
116129
<!-- Search -->
117130
<v-text-field
118131
v-if="!disableSearch"

src/runtime/pages/admin/users/UsersIndex.vue

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,18 @@ const headers = [
8585
filterable: false,
8686
},
8787
]
88+
89+
// Define search groups
90+
const searchGroups = [
91+
{
92+
title: 'Role',
93+
items: ['Admin', 'User'],
94+
},
95+
{
96+
title: 'Status',
97+
items: ['Active', 'Inactive'],
98+
},
99+
]
88100
</script>
89101

90102
<template>
@@ -102,6 +114,7 @@ const headers = [
102114
disable-create
103115
disable-delete
104116
:export-formats="['CSV']"
117+
:search-groups
105118
/>
106119
</v-col>
107120
</v-row>

0 commit comments

Comments
 (0)