@webitel/ui-datalist 1.0.93 → 1.0.95
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
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@webitel/ui-datalist",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.95",
|
|
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",
|
|
@@ -19,6 +19,7 @@
|
|
|
19
19
|
<section class="apply-preset-main-content">
|
|
20
20
|
<wt-search-bar
|
|
21
21
|
:value="search"
|
|
22
|
+
@input="handleSearchInput"
|
|
22
23
|
@search="search = $event"
|
|
23
24
|
/>
|
|
24
25
|
|
|
@@ -118,15 +119,30 @@ filtersManager.value.addFilter({
|
|
|
118
119
|
value: props.namespace,
|
|
119
120
|
});
|
|
120
121
|
|
|
122
|
+
const lastSetSearchValue = ref<string | null>(null);
|
|
123
|
+
|
|
121
124
|
const search = computed({
|
|
122
125
|
get: () => {
|
|
123
126
|
return filtersManager.value.getFilter('search')?.value || '';
|
|
124
127
|
},
|
|
125
128
|
set: (value) => {
|
|
129
|
+
// Skip if this value was already set via handleSearchInput
|
|
130
|
+
if (lastSetSearchValue.value === value) {
|
|
131
|
+
lastSetSearchValue.value = null;
|
|
132
|
+
return;
|
|
133
|
+
}
|
|
126
134
|
filtersManager.value.addFilter({ name: 'search', value });
|
|
127
135
|
},
|
|
128
136
|
});
|
|
129
137
|
|
|
138
|
+
const handleSearchInput = (value: string) => {
|
|
139
|
+
// Update search immediately when cleared to bypass debounce
|
|
140
|
+
if (!value) {
|
|
141
|
+
lastSetSearchValue.value = value;
|
|
142
|
+
filtersManager.value.addFilter({ name: 'search', value });
|
|
143
|
+
}
|
|
144
|
+
};
|
|
145
|
+
|
|
130
146
|
const {
|
|
131
147
|
showEmpty,
|
|
132
148
|
image: imageEmpty,
|
|
@@ -23,6 +23,7 @@ export const tableStoreBody = <Entity extends { id: string; etag?: string }>(
|
|
|
23
23
|
disablePersistence,
|
|
24
24
|
storeType,
|
|
25
25
|
isAppendDataList,
|
|
26
|
+
trackSelectedRowBy,
|
|
26
27
|
} = config;
|
|
27
28
|
const usePaginationStore = createTablePaginationStore(namespace, config);
|
|
28
29
|
const useHeadersStore = createTableHeadersStore(namespace, config, {
|
|
@@ -46,9 +47,14 @@ export const tableStoreBody = <Entity extends { id: string; etag?: string }>(
|
|
|
46
47
|
} = paginationStore;
|
|
47
48
|
|
|
48
49
|
const headersStore = useHeadersStore();
|
|
49
|
-
const {
|
|
50
|
-
|
|
51
|
-
|
|
50
|
+
const {
|
|
51
|
+
headers,
|
|
52
|
+
shownHeaders,
|
|
53
|
+
fields,
|
|
54
|
+
sort,
|
|
55
|
+
columnWidths,
|
|
56
|
+
isReorderingColumn,
|
|
57
|
+
} = makeThisToRefs<typeof headersStore>(headersStore, storeType);
|
|
52
58
|
const {
|
|
53
59
|
updateSort,
|
|
54
60
|
columnResize,
|
|
@@ -58,9 +64,11 @@ export const tableStoreBody = <Entity extends { id: string; etag?: string }>(
|
|
|
58
64
|
} = headersStore;
|
|
59
65
|
|
|
60
66
|
const filtersStore = useFiltersStore();
|
|
61
|
-
const {
|
|
62
|
-
|
|
63
|
-
|
|
67
|
+
const {
|
|
68
|
+
filtersManager,
|
|
69
|
+
isRestoring: isFiltersRestoring,
|
|
70
|
+
searchMode,
|
|
71
|
+
} = makeThisToRefs<typeof filtersStore>(filtersStore, storeType);
|
|
64
72
|
const {
|
|
65
73
|
hasFilter,
|
|
66
74
|
addFilter,
|
|
@@ -109,7 +117,9 @@ export const tableStoreBody = <Entity extends { id: string; etag?: string }>(
|
|
|
109
117
|
const { items, next } = await apiModule.getList(params);
|
|
110
118
|
|
|
111
119
|
dataList.value = items;
|
|
112
|
-
|
|
120
|
+
|
|
121
|
+
updateSelected(filterSelected(items));
|
|
122
|
+
|
|
113
123
|
$patchPaginationStore({ next });
|
|
114
124
|
} catch (err) {
|
|
115
125
|
error.value = err;
|
|
@@ -119,6 +129,11 @@ export const tableStoreBody = <Entity extends { id: string; etag?: string }>(
|
|
|
119
129
|
}
|
|
120
130
|
};
|
|
121
131
|
|
|
132
|
+
function filterSelected(items: Entity[]): Entity[] {
|
|
133
|
+
const trackBy = trackSelectedRowBy ?? ((item) => item.id);
|
|
134
|
+
return items.map(trackBy).filter((key) => selected.value.includes(key));
|
|
135
|
+
}
|
|
136
|
+
|
|
122
137
|
const appendToDataList = async () => {
|
|
123
138
|
isLoading.value = true;
|
|
124
139
|
$patchPaginationStore({ next: false });
|
|
@@ -203,9 +218,9 @@ export const tableStoreBody = <Entity extends { id: string; etag?: string }>(
|
|
|
203
218
|
[() => filtersManager.value.getAllValues(), sort, fields, size],
|
|
204
219
|
async () => {
|
|
205
220
|
/*
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
221
|
+
* @author @Lera24
|
|
222
|
+
* https://webitel.atlassian.net/browse/WTEL-7597?focusedCommentId=697115
|
|
223
|
+
* */
|
|
209
224
|
if (isReorderingColumn.value) {
|
|
210
225
|
return;
|
|
211
226
|
}
|
|
@@ -5,12 +5,15 @@ import { WtTableHeader } from '../../../../../src/components/wt-table/types/WtTa
|
|
|
5
5
|
import { IFiltersManager } from '../filters';
|
|
6
6
|
import { DatalistStoreProviderType } from './StoreProvider';
|
|
7
7
|
|
|
8
|
+
export type TrackSelectedRowBy<T> = (row: T) => T;
|
|
9
|
+
|
|
8
10
|
export interface useTableStoreConfig<Entity> {
|
|
9
11
|
apiModule: ApiModule<Entity>;
|
|
10
12
|
headers: WtTableHeader[];
|
|
11
13
|
disablePersistence?: boolean | [];
|
|
12
14
|
storeType?: DatalistStoreProviderType;
|
|
13
15
|
isAppendDataList?: boolean;
|
|
16
|
+
trackSelectedRowBy?: TrackSelectedRowBy<Entity>;
|
|
14
17
|
// etagMode: boolean;
|
|
15
18
|
}
|
|
16
19
|
|
|
@@ -3,12 +3,14 @@ import type { Ref } from 'vue';
|
|
|
3
3
|
import { WtTableHeader } from '../../../../../src/components/wt-table/types/WtTable';
|
|
4
4
|
import { IFiltersManager } from '../filters';
|
|
5
5
|
import { DatalistStoreProviderType } from './StoreProvider';
|
|
6
|
+
export type TrackSelectedRowBy<T> = (row: T) => T;
|
|
6
7
|
export interface useTableStoreConfig<Entity> {
|
|
7
8
|
apiModule: ApiModule<Entity>;
|
|
8
9
|
headers: WtTableHeader[];
|
|
9
10
|
disablePersistence?: boolean | [];
|
|
10
11
|
storeType?: DatalistStoreProviderType;
|
|
11
12
|
isAppendDataList?: boolean;
|
|
13
|
+
trackSelectedRowBy?: TrackSelectedRowBy<Entity>;
|
|
12
14
|
}
|
|
13
15
|
export interface PatchItemPropertyParams {
|
|
14
16
|
index: number;
|