@webitel/ui-datalist 1.0.73 → 1.0.75
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/modules/filters/components/search-bar/dynamic-filter-search.vue +28 -9
- package/src/modules/filters/createTableFiltersStore.ts +27 -3
- package/src/modules/table/createTableStore.store.ts +6 -2
- package/types/modules/filter-presets/stores/createFilterPresetsStore.d.ts +4 -0
- package/types/modules/filters/components/search-bar/dynamic-filter-search.vue.d.ts +8 -2
- package/types/modules/filters/createTableFiltersStore.d.ts +7 -3
- package/types/modules/table/createTableStore.store.d.ts +4 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@webitel/ui-datalist",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.75",
|
|
4
4
|
"description": "Toolkit for building data lists in webitel ui system",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"make-all": "npm version patch --git-tag-version false && ( npm run lint:fix || true) && (npm run build:types || true) && npm run utils:publish",
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
|
|
13
13
|
<script lang="ts" setup>
|
|
14
14
|
import { WtSearchBar } from '@webitel/ui-sdk/components';
|
|
15
|
-
import { computed,
|
|
15
|
+
import { computed, ref, watch } from 'vue';
|
|
16
16
|
import { useI18n } from 'vue-i18n';
|
|
17
17
|
|
|
18
18
|
import { FilterInitParams, FilterName } from '../../classes/Filter';
|
|
@@ -28,10 +28,13 @@ const props = defineProps<{
|
|
|
28
28
|
* default search name is used when there are no search modes
|
|
29
29
|
*/
|
|
30
30
|
singleSearchName?: string;
|
|
31
|
+
searchMode?: string;
|
|
31
32
|
}>();
|
|
32
33
|
|
|
33
34
|
const defaultSearchName = props.singleSearchName || 'search';
|
|
34
35
|
|
|
36
|
+
const searchMode = defineModel<string>('searchMode');
|
|
37
|
+
|
|
35
38
|
const emit = defineEmits<{
|
|
36
39
|
'filter:add': [FilterInitParams];
|
|
37
40
|
'filter:update': [FilterInitParams];
|
|
@@ -40,7 +43,6 @@ const emit = defineEmits<{
|
|
|
40
43
|
|
|
41
44
|
const { t } = useI18n();
|
|
42
45
|
|
|
43
|
-
const searchMode: Ref<FilterName> = ref();
|
|
44
46
|
const localSearchValue = ref('');
|
|
45
47
|
|
|
46
48
|
const hasFilter = (filterName = searchMode.value) => {
|
|
@@ -56,13 +58,14 @@ const deleteFilter = ({ name }: { name: FilterName }) => {
|
|
|
56
58
|
return emit('filter:delete', { name });
|
|
57
59
|
};
|
|
58
60
|
|
|
61
|
+
const restoreLocalSearchValue = (searchMode: string) => {
|
|
62
|
+
return localSearchValue.value = props.filtersManager.filters.get(searchMode)?.value;
|
|
63
|
+
}
|
|
64
|
+
|
|
59
65
|
const hasSearchModes = computed(() => {
|
|
60
66
|
return props.searchModeOptions && props.searchModeOptions.length > 0;
|
|
61
67
|
});
|
|
62
68
|
|
|
63
|
-
if (hasSearchModes.value) {
|
|
64
|
-
searchMode.value = props.searchModeOptions[0].value;
|
|
65
|
-
}
|
|
66
69
|
|
|
67
70
|
const currentSearchName = computed(() => {
|
|
68
71
|
if (hasSearchModes.value) {
|
|
@@ -109,10 +112,26 @@ const updateSearchMode = (
|
|
|
109
112
|
name: currentSearchName.value,
|
|
110
113
|
});
|
|
111
114
|
}
|
|
112
|
-
searchMode.value = nextSearchMode.value;
|
|
113
115
|
localSearchValue.value = '';
|
|
116
|
+
searchMode.value = nextSearchMode.value;
|
|
114
117
|
};
|
|
115
118
|
|
|
119
|
+
const initialize = () => {
|
|
120
|
+
if(hasSearchModes.value) {
|
|
121
|
+
if(!searchMode.value) {
|
|
122
|
+
searchMode.value = props.searchModeOptions[0].value;
|
|
123
|
+
}
|
|
124
|
+
restoreLocalSearchValue(searchMode.value);
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* @description
|
|
129
|
+
* Initializing search mode (if there are search modes)
|
|
130
|
+
* and localSearchValue at teh first load
|
|
131
|
+
*/
|
|
132
|
+
|
|
133
|
+
initialize();
|
|
134
|
+
|
|
116
135
|
/**
|
|
117
136
|
* @description
|
|
118
137
|
* Restoring search value after filters were restored
|
|
@@ -124,19 +143,19 @@ watch(
|
|
|
124
143
|
|
|
125
144
|
let searchModes = [defaultSearchName];
|
|
126
145
|
if (hasSearchModes.value) {
|
|
127
|
-
|
|
146
|
+
searchMode.value = props.searchModeOptions?.map((option) => option.value)[0] || '';
|
|
128
147
|
}
|
|
129
148
|
|
|
130
149
|
for (const mode of searchModes) {
|
|
131
150
|
if (hasFilter(mode)) {
|
|
132
151
|
searchMode.value = mode;
|
|
133
|
-
|
|
134
|
-
|
|
152
|
+
restoreLocalSearchValue(mode);
|
|
135
153
|
break;
|
|
136
154
|
}
|
|
137
155
|
}
|
|
138
156
|
},
|
|
139
157
|
);
|
|
158
|
+
|
|
140
159
|
</script>
|
|
141
160
|
|
|
142
161
|
<style scoped></style>
|
|
@@ -9,7 +9,7 @@ import {
|
|
|
9
9
|
FiltersManagerConfig,
|
|
10
10
|
} from './classes/FiltersManager';
|
|
11
11
|
|
|
12
|
-
export const tableFiltersStoreBody = (config?: {
|
|
12
|
+
export const tableFiltersStoreBody = (namespace, config?: {
|
|
13
13
|
filtersManagerConfig: FiltersManagerConfig;
|
|
14
14
|
}) => {
|
|
15
15
|
const filtersManager = reactive(
|
|
@@ -19,6 +19,12 @@ export const tableFiltersStoreBody = (config?: {
|
|
|
19
19
|
/* for watchers in filter components */
|
|
20
20
|
const isRestoring = ref(false);
|
|
21
21
|
|
|
22
|
+
const searchMode = ref('');
|
|
23
|
+
|
|
24
|
+
const updateSearchMode = (newSearch: string) => {
|
|
25
|
+
searchMode.value = newSearch;
|
|
26
|
+
};
|
|
27
|
+
|
|
22
28
|
/*
|
|
23
29
|
wrapping filtersManager methods to extend their functionality
|
|
24
30
|
if it will be needed in future
|
|
@@ -60,12 +66,28 @@ export const tableFiltersStoreBody = (config?: {
|
|
|
60
66
|
},
|
|
61
67
|
});
|
|
62
68
|
|
|
63
|
-
|
|
69
|
+
const { restore: restoreSearchMode } = usePersistedStorage({
|
|
70
|
+
name: 'searchMode',
|
|
71
|
+
value: searchMode,
|
|
72
|
+
storages: [PersistedStorageType.LocalStorage],
|
|
73
|
+
storagePath: namespace,
|
|
74
|
+
|
|
75
|
+
onStore: async (save, { name }) => {
|
|
76
|
+
return save({ name, value: searchMode.value });
|
|
77
|
+
},
|
|
78
|
+
onRestore: async (restore, name) => {
|
|
79
|
+
const value = await restore(name);
|
|
80
|
+
if (value) searchMode.value = value as string;
|
|
81
|
+
},
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
return Promise.all([restoreFilters(), restoreSearchMode()]);
|
|
64
85
|
};
|
|
65
86
|
|
|
66
87
|
return {
|
|
67
88
|
filtersManager,
|
|
68
89
|
isRestoring,
|
|
90
|
+
searchMode,
|
|
69
91
|
|
|
70
92
|
filtersList,
|
|
71
93
|
|
|
@@ -74,6 +96,8 @@ export const tableFiltersStoreBody = (config?: {
|
|
|
74
96
|
updateFilter,
|
|
75
97
|
deleteFilter,
|
|
76
98
|
|
|
99
|
+
updateSearchMode,
|
|
100
|
+
|
|
77
101
|
setupPersistence,
|
|
78
102
|
};
|
|
79
103
|
};
|
|
@@ -86,7 +110,7 @@ export const createTableFiltersStore = <Entity>(
|
|
|
86
110
|
) => {
|
|
87
111
|
const id = `${namespace}/filters`;
|
|
88
112
|
return createDatalistStore({
|
|
89
|
-
storeBody: tableFiltersStoreBody,
|
|
113
|
+
storeBody: () => tableFiltersStoreBody(namespace, config),
|
|
90
114
|
config,
|
|
91
115
|
namespace: id,
|
|
92
116
|
});
|
|
@@ -56,7 +56,7 @@ export const tableStoreBody = <Entity extends { id: string; etag?: string }>(
|
|
|
56
56
|
} = headersStore;
|
|
57
57
|
|
|
58
58
|
const filtersStore = useFiltersStore();
|
|
59
|
-
const { filtersManager, isRestoring: isFiltersRestoring } = makeThisToRefs<
|
|
59
|
+
const { filtersManager, isRestoring: isFiltersRestoring, searchMode } = makeThisToRefs<
|
|
60
60
|
typeof filtersStore
|
|
61
61
|
>(filtersStore, storeType);
|
|
62
62
|
const {
|
|
@@ -65,6 +65,7 @@ export const tableStoreBody = <Entity extends { id: string; etag?: string }>(
|
|
|
65
65
|
updateFilter,
|
|
66
66
|
deleteFilter,
|
|
67
67
|
setupPersistence: setupFiltersPersistence,
|
|
68
|
+
updateSearchMode,
|
|
68
69
|
} = filtersStore;
|
|
69
70
|
|
|
70
71
|
/**
|
|
@@ -72,7 +73,7 @@ export const tableStoreBody = <Entity extends { id: string; etag?: string }>(
|
|
|
72
73
|
* @description
|
|
73
74
|
* This flag is used to check if the store is set up.
|
|
74
75
|
* It is used to prevent multiple setup calls.
|
|
75
|
-
*
|
|
76
|
+
*
|
|
76
77
|
* @link
|
|
77
78
|
* https://webitel.atlassian.net/browse/WTEL-7495
|
|
78
79
|
*/
|
|
@@ -240,6 +241,7 @@ export const tableStoreBody = <Entity extends { id: string; etag?: string }>(
|
|
|
240
241
|
shownHeaders,
|
|
241
242
|
fields,
|
|
242
243
|
sort,
|
|
244
|
+
searchMode,
|
|
243
245
|
|
|
244
246
|
filtersManager,
|
|
245
247
|
isFiltersRestoring,
|
|
@@ -254,6 +256,8 @@ export const tableStoreBody = <Entity extends { id: string; etag?: string }>(
|
|
|
254
256
|
patchItemProperty,
|
|
255
257
|
deleteEls,
|
|
256
258
|
|
|
259
|
+
updateSearchMode,
|
|
260
|
+
|
|
257
261
|
updatePage,
|
|
258
262
|
updateSize,
|
|
259
263
|
|
|
@@ -14,6 +14,7 @@ export declare const filterPresetsStoreBody: (namespace?: string) => {
|
|
|
14
14
|
shownHeaders: import("vue").ComputedRef<any>;
|
|
15
15
|
fields: import("vue").ComputedRef<any>;
|
|
16
16
|
sort: import("vue").ComputedRef<string>;
|
|
17
|
+
searchMode: import("vue").Ref<string, string>;
|
|
17
18
|
filtersManager: import("vue").Ref<{
|
|
18
19
|
filters: Map<string, {
|
|
19
20
|
name: import("../../filters").FilterName;
|
|
@@ -85,6 +86,7 @@ export declare const filterPresetsStoreBody: (namespace?: string) => {
|
|
|
85
86
|
updateSelected: (value: EnginePresetQuery[]) => void;
|
|
86
87
|
patchItemProperty: ({ index, path, value, }: import("../../types/tableStore.types").PatchItemPropertyParams) => Promise<void>;
|
|
87
88
|
deleteEls: (_els: EnginePresetQuery[]) => Promise<void>;
|
|
89
|
+
updateSearchMode: (newSearch: string) => void;
|
|
88
90
|
updatePage: (newPage: number) => void;
|
|
89
91
|
updateSize: (newSize: number) => void;
|
|
90
92
|
updateSort: (column: any) => void;
|
|
@@ -110,6 +112,7 @@ export declare const createFilterPresetsStore: (namespace: string) => () => {
|
|
|
110
112
|
shownHeaders: import("vue").ComputedRef<any>;
|
|
111
113
|
fields: import("vue").ComputedRef<any>;
|
|
112
114
|
sort: import("vue").ComputedRef<string>;
|
|
115
|
+
searchMode: import("vue").Ref<string, string>;
|
|
113
116
|
filtersManager: import("vue").Ref<{
|
|
114
117
|
filters: Map<string, {
|
|
115
118
|
name: import("../../filters").FilterName;
|
|
@@ -181,6 +184,7 @@ export declare const createFilterPresetsStore: (namespace: string) => () => {
|
|
|
181
184
|
updateSelected: (value: EnginePresetQuery[]) => void;
|
|
182
185
|
patchItemProperty: ({ index, path, value, }: import("../../types/tableStore.types").PatchItemPropertyParams) => Promise<void>;
|
|
183
186
|
deleteEls: (_els: EnginePresetQuery[]) => Promise<void>;
|
|
187
|
+
updateSearchMode: (newSearch: string) => void;
|
|
184
188
|
updatePage: (newPage: number) => void;
|
|
185
189
|
updateSize: (newSize: number) => void;
|
|
186
190
|
updateSort: (column: any) => void;
|
|
@@ -10,18 +10,24 @@ type __VLS_Props = {
|
|
|
10
10
|
* default search name is used when there are no search modes
|
|
11
11
|
*/
|
|
12
12
|
singleSearchName?: string;
|
|
13
|
+
searchMode?: string;
|
|
13
14
|
};
|
|
14
|
-
|
|
15
|
+
type __VLS_PublicProps = __VLS_Props & {
|
|
16
|
+
'searchMode'?: string;
|
|
17
|
+
};
|
|
18
|
+
declare const _default: import("vue").DefineComponent<__VLS_PublicProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
15
19
|
"filter:add": (args_0: FilterInitParams) => any;
|
|
16
20
|
"filter:update": (args_0: FilterInitParams) => any;
|
|
17
21
|
"filter:delete": (args_0: {
|
|
18
22
|
name: FilterName;
|
|
19
23
|
}) => any;
|
|
20
|
-
|
|
24
|
+
"update:searchMode": (value: string) => any;
|
|
25
|
+
}, string, import("vue").PublicProps, Readonly<__VLS_PublicProps> & Readonly<{
|
|
21
26
|
"onFilter:add"?: (args_0: FilterInitParams) => any;
|
|
22
27
|
"onFilter:update"?: (args_0: FilterInitParams) => any;
|
|
23
28
|
"onFilter:delete"?: (args_0: {
|
|
24
29
|
name: FilterName;
|
|
25
30
|
}) => any;
|
|
31
|
+
"onUpdate:searchMode"?: (value: string) => any;
|
|
26
32
|
}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
27
33
|
export default _default;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { useTableStoreConfig } from '../types/tableStore.types';
|
|
2
2
|
import { FiltersManagerConfig } from './classes/FiltersManager';
|
|
3
|
-
export declare const tableFiltersStoreBody: (config?: {
|
|
3
|
+
export declare const tableFiltersStoreBody: (namespace: any, config?: {
|
|
4
4
|
filtersManagerConfig: FiltersManagerConfig;
|
|
5
5
|
}) => {
|
|
6
6
|
filtersManager: {
|
|
@@ -35,12 +35,14 @@ export declare const tableFiltersStoreBody: (config?: {
|
|
|
35
35
|
}) => import(".").IFilter[];
|
|
36
36
|
};
|
|
37
37
|
isRestoring: import("vue").Ref<boolean, boolean>;
|
|
38
|
+
searchMode: import("vue").Ref<string, string>;
|
|
38
39
|
filtersList: import("vue").ComputedRef<import(".").IFilter[]>;
|
|
39
40
|
hasFilter: any;
|
|
40
41
|
addFilter: any;
|
|
41
42
|
updateFilter: any;
|
|
42
43
|
deleteFilter: any;
|
|
43
|
-
|
|
44
|
+
updateSearchMode: (newSearch: string) => void;
|
|
45
|
+
setupPersistence: () => Promise<[void, void]>;
|
|
44
46
|
};
|
|
45
47
|
export declare const createTableFiltersStore: <Entity>(namespace: string, config: useTableStoreConfig<Entity> & {
|
|
46
48
|
filtersManagerConfig?: FiltersManagerConfig;
|
|
@@ -77,10 +79,12 @@ export declare const createTableFiltersStore: <Entity>(namespace: string, config
|
|
|
77
79
|
}) => import(".").IFilter[];
|
|
78
80
|
};
|
|
79
81
|
isRestoring: import("vue").Ref<boolean, boolean>;
|
|
82
|
+
searchMode: import("vue").Ref<string, string>;
|
|
80
83
|
filtersList: import("vue").ComputedRef<import(".").IFilter[]>;
|
|
81
84
|
hasFilter: any;
|
|
82
85
|
addFilter: any;
|
|
83
86
|
updateFilter: any;
|
|
84
87
|
deleteFilter: any;
|
|
85
|
-
|
|
88
|
+
updateSearchMode: (newSearch: string) => void;
|
|
89
|
+
setupPersistence: () => Promise<[void, void]>;
|
|
86
90
|
}>;
|
|
@@ -16,6 +16,7 @@ export declare const tableStoreBody: <Entity extends {
|
|
|
16
16
|
shownHeaders: import("vue").ComputedRef<any>;
|
|
17
17
|
fields: import("vue").ComputedRef<any>;
|
|
18
18
|
sort: import("vue").ComputedRef<string>;
|
|
19
|
+
searchMode: Ref<string, string>;
|
|
19
20
|
filtersManager: Ref<{
|
|
20
21
|
filters: Map<string, {
|
|
21
22
|
name: import("../filters").FilterName;
|
|
@@ -87,6 +88,7 @@ export declare const tableStoreBody: <Entity extends {
|
|
|
87
88
|
updateSelected: (value: Entity[]) => void;
|
|
88
89
|
patchItemProperty: ({ index, path, value, }: PatchItemPropertyParams) => Promise<void>;
|
|
89
90
|
deleteEls: (_els: Entity[]) => Promise<void>;
|
|
91
|
+
updateSearchMode: (newSearch: string) => void;
|
|
90
92
|
updatePage: (newPage: number) => void;
|
|
91
93
|
updateSize: (newSize: number) => void;
|
|
92
94
|
updateSort: (column: any) => void;
|
|
@@ -112,6 +114,7 @@ export declare const createTableStore: <Entity extends {
|
|
|
112
114
|
shownHeaders: import("vue").ComputedRef<any>;
|
|
113
115
|
fields: import("vue").ComputedRef<any>;
|
|
114
116
|
sort: import("vue").ComputedRef<string>;
|
|
117
|
+
searchMode: Ref<string, string>;
|
|
115
118
|
filtersManager: Ref<{
|
|
116
119
|
filters: Map<string, {
|
|
117
120
|
name: import("../filters").FilterName;
|
|
@@ -183,6 +186,7 @@ export declare const createTableStore: <Entity extends {
|
|
|
183
186
|
updateSelected: (value: Entity[]) => void;
|
|
184
187
|
patchItemProperty: ({ index, path, value, }: PatchItemPropertyParams) => Promise<void>;
|
|
185
188
|
deleteEls: (_els: Entity[]) => Promise<void>;
|
|
189
|
+
updateSearchMode: (newSearch: string) => void;
|
|
186
190
|
updatePage: (newPage: number) => void;
|
|
187
191
|
updateSize: (newSize: number) => void;
|
|
188
192
|
updateSort: (column: any) => void;
|