Skip to content

Commit 61b1838

Browse files
Zorin95670jcabannes
authored andcommitted
feat(catalog-ui): integrate favorites panel in smart-filter
1 parent 6bd0e5c commit 61b1838

4 files changed

Lines changed: 39 additions & 8 deletions

File tree

apps/catalog-ui/docs/components/smart-filter/LinidSmartFilter.md

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,13 @@ The **LinidSmartFilter** component provides a filtering interface with a toggle-
2626

2727
## **Events**
2828

29-
| Event | Payload | Description |
30-
| ---------------- | --------------- | ----------------------------------------------------------------------------------------------------------------------------------------- |
31-
| `update:filters` | `LinidFilter[]` | Emitted whenever the user applies or removes a filter. The payload contains only the filters that have at least one active value applied. |
29+
| Event | Payload | Description |
30+
| ------------------- | ---------------- | ----------------------------------------------------------------------------------------------------------------------------------------- |
31+
| `update:filters` | `LinidFilter[]` | Emitted whenever the user applies or removes a filter. The payload contains only the filters that have at least one active value applied. |
32+
| `apply:favorite` | `LinidFilterSet` | Emitted when a favorite filter set is applied. The payload contains the applied favorite filter set. |
33+
| `delete:favorite` | `LinidFilterSet` | Emitted when a favorite filter set is deleted. The payload contains the deleted favorite filter set. |
34+
| `create:favorite` | - | Emitted when the user wants to create a new favorite filter set. |
35+
| `override:favorite` | - | Emitted when the user wants to override an existing favorite filter set. |
3236

3337
---
3438

@@ -107,11 +111,12 @@ Each applied filter is displayed as a chip in the search field. The chip shows t
107111
```vue
108112
<script setup lang="ts">
109113
import { ref } from 'vue';
110-
import { LinidFilter } from '@linagora/linid-im-front-corelib';
114+
import { LinidFilter, LinidFilterSet } from '@linagora/linid-im-front-corelib';
111115
112116
const filters = ref([]);
113117
114118
const filterDefinitions = [new LinidFilter('firstname', 'text', { fieldName: 'firstname' }, []), new LinidFilter('lastname', 'text', { fieldName: 'lastname' }, [])];
119+
const filterSet = [new LinidFilterSet('id', 'label', [])];
115120
116121
function onUpdateFilters(updated) {
117122
filters.value = updated;
@@ -123,7 +128,7 @@ function onUpdateFilters(updated) {
123128
ui-namespace="myApp"
124129
i18n-scope="myScope"
125130
:filters="filters"
126-
:options="{ filters: filterDefinitions }"
131+
:options="{ filters: filterDefinitions, filterSet: filterSets }"
127132
@update:filters="onUpdateFilters"
128133
/>
129134
</template>
@@ -134,7 +139,7 @@ function onUpdateFilters(updated) {
134139
```vue
135140
<script setup lang="ts">
136141
import { ref } from 'vue';
137-
import { LinidFilter } from '@linagora/linid-im-front-corelib';
142+
import { LinidFilter, LinidFilterSet } from '@linagora/linid-im-front-corelib';
138143
139144
const filters = ref([]);
140145
@@ -165,14 +170,15 @@ const filterDefinitions = [
165170
[]
166171
),
167172
];
173+
const filterSet = [new LinidFilterSet('id', 'label', [])];
168174
</script>
169175
170176
<template>
171177
<linid-smart-filter
172178
ui-namespace="myApp"
173179
i18n-scope="myScope"
174180
:filters="filters"
175-
:options="{ filters: filterDefinitions }"
181+
:options="{ filters: filterDefinitions, filterSet: filterSets }"
176182
@update:filters="filters = $event"
177183
/>
178184
</template>
@@ -238,6 +244,7 @@ The component uses the LinID design system through `useUiDesign()` and applies p
238244
| ------------------------------------------------------------------------------------- | ---------------- | ----------------------------------------------------------------------------------------------------------- |
239245
| `{uiNamespace}.linid-smart-filter` | `q-field` | Filter field container styling and configuration |
240246
| `{uiNamespace}.linid-smart-filter` | `q-menu` | Dropdown menu styling and configuration |
247+
| `{uiNamespace}.linid-smart-filter` | `q-separator` | Separator between panel in menu. |
241248
| `{uiNamespace}.linid-smart-filter.iconSearch` | `q-icon` | Search icon styling |
242249
| `{uiNamespace}.linid-smart-filter.iconMenuClose` | `q-icon` | Right dropdown icon styling (menu open) |
243250
| `{uiNamespace}.linid-smart-filter.iconMenuOpen` | `q-icon` | Right dropdown icon styling (menu closed) |

apps/catalog-ui/docs/design.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -339,6 +339,7 @@ Smart filtering component with toggle-able menu for managing active filters and
339339
"q-menu": {
340340
"autoClose": true
341341
},
342+
"q-separator": {},
342343
"iconSearch": {
343344
"q-icon": {
344345
"name": "search"
@@ -773,6 +774,7 @@ A full example showing all CatalogUI components configured together:
773774
"linid-smart-filter": {
774775
"q-field": { "outlined": true, "dense": true },
775776
"q-menu": { "autoClose": true },
777+
"q-separator": {},
776778
"iconSearch": {
777779
"q-icon": { "name": "search" }
778780
},

apps/catalog-ui/src/components/smart-filter/LinidSmartFilter.vue

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@
7777

7878
<q-menu
7979
v-model="isFilterMenuOpen"
80-
class="linid-smart-filter--menu"
80+
class="row linid-smart-filter--menu"
8181
data-cy="linid-smart-filter-menu"
8282
v-bind="uiProps.menu"
8383
>
@@ -102,6 +102,22 @@
102102
/>
103103
</template>
104104
</linid-filter-panel>
105+
106+
<q-separator
107+
v-bind="uiProps.separator"
108+
vertical
109+
/>
110+
111+
<linid-favorite-panel
112+
:favorites="options?.filterSets ?? []"
113+
:ui-namespace="localUiNamespace"
114+
:i18n-scope="localI18nScope"
115+
data-cy="linid-smart-favorite-panel"
116+
@apply="(data) => emit('apply:favorite', data)"
117+
@delete="(data) => emit('delete:favorite', data)"
118+
@create="emit('create:favorite')"
119+
@override="emit('override:favorite')"
120+
/>
105121
</q-menu>
106122
</q-field>
107123
</div>
@@ -134,6 +150,7 @@ import ListSearchFilterPanel from './ListSearchFilterPanel.vue';
134150
import NumberSearchFilterPanel from './NumberSearchFilterPanel.vue';
135151
import TextSearchFilterPanel from './TextSearchFilterPanel.vue';
136152
import TreeSearchFilterPanel from './TreeSearchFilterPanel.vue';
153+
import LinidFavoritePanel from './LinidFavoritePanel.vue';
137154
138155
const PANEL_COMPONENTS: Record<LinidFilterType, Component> = {
139156
text: TextSearchFilterPanel,
@@ -170,6 +187,7 @@ const uiProps = {
170187
field: ui<LinidQFieldProps>(`${localUiNamespace}`, 'q-field'),
171188
menu: ui<LinidQMenuProps>(`${localUiNamespace}`, 'q-menu'),
172189
iconSearch: ui<LinidQIconProps>(`${localUiNamespace}.iconSearch`, 'q-icon'),
190+
separator: ui<LinidQIconProps>(`${localUiNamespace}`, 'q-separator'),
173191
iconMenuClose: ui<LinidQIconProps>(
174192
`${localUiNamespace}.iconMenuClose`,
175193
'q-icon'

apps/catalog-ui/src/types/smartFilter.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,4 +60,8 @@ export interface LinidSmartFilterProps extends CommonComponentProps {
6060
*/
6161
export type LinidSmartFilterOutputs = {
6262
(e: 'update:filters', filters: LinidFilter[]): void;
63+
(e: 'apply:favorite', favorite: LinidFilterSet): void;
64+
(e: 'delete:favorite', favorite: LinidFilterSet): void;
65+
(e: 'create:favorite'): void;
66+
(e: 'override:favorite'): void;
6367
};

0 commit comments

Comments
 (0)