@webitel/ui-sdk 3.2.41 → 3.2.43

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-sdk",
3
- "version": "3.2.41",
3
+ "version": "3.2.43",
4
4
  "private": false,
5
5
  "scripts": {
6
6
  "serve-lib": "vue-cli-service serve",
@@ -0,0 +1,13 @@
1
+ export default class BaseFilterSchema {
2
+ constructor({
3
+ value = '',
4
+ defaultValue = '',
5
+ restore,
6
+ localStorageKey,
7
+ } = {}) {
8
+ this.value = value;
9
+ this.defaultValue = defaultValue;
10
+ this.restore = restore;
11
+ this.localStorageKey = localStorageKey;
12
+ }
13
+ }
@@ -83,6 +83,7 @@ export default class FiltersStoreModule extends BaseStoreModule {
83
83
  const value = context.state[filter].restore ? context.state[filter].restore({ query }) : query;
84
84
  if (value) {
85
85
  if (filter === 'sort') await context.dispatch('RESTORE_SORT', { value });
86
+ else if (filter === 'fields') await context.dispatch('RESTORE_FIELDS', { value });
86
87
  await context.dispatch('SET_FILTER', ({ filter, value }));
87
88
  return true;
88
89
  }
@@ -117,6 +118,11 @@ export default class FiltersStoreModule extends BaseStoreModule {
117
118
  { value },
118
119
  { root: true },
119
120
  ),
121
+ RESTORE_FIELDS: (context, { value }) => context.dispatch(
122
+ `${context.getters.TABLE_NAMESPACE}/RESTORE_FIELDS_FROM_FILTER`,
123
+ { value },
124
+ { root: true },
125
+ ),
120
126
  };
121
127
 
122
128
  mutations = {
@@ -18,21 +18,15 @@ export default class TableStoreModule extends BaseStoreModule {
18
18
  // required fields to send as "fields" param with GET_LIST
19
19
  REQUIRED_FIELDS: () => ['id'],
20
20
 
21
- // fields to send with GET_LIST
22
- FIELDS: (state) => {
23
- let fields = state.headers
24
- .filter((header) => header.show)
25
- .map((header) => header.field);
26
- fields = [...new Set(fields)];
27
- return fields;
28
- },
29
-
30
21
  // main GET_LIST params collector
31
22
  GET_LIST_PARAMS: (state, getters) => (overrideFilters) => {
32
- const fields = getters.FIELDS.concat(getters.REQUIRED_FIELDS);
33
-
34
23
  const filters = getters.GET_FILTERS || getters['filters/GET_FILTERS'];
35
24
 
25
+ const fields = (filters.fields || [
26
+ ...new Set(state.headers.filter((header) => header.show)
27
+ .map((header) => header.field)),
28
+ ]).concat(getters.REQUIRED_FIELDS);
29
+
36
30
  return {
37
31
  ...filters,
38
32
  fields,
@@ -97,6 +91,13 @@ export default class TableStoreModule extends BaseStoreModule {
97
91
  const page = 1;
98
92
  context.commit('SET_PAGE', page);
99
93
  },
94
+ RESTORE_FIELDS_FROM_FILTER: (context, { value }) => {
95
+ const headers = context.state.headers.map((header) => ({
96
+ ...header,
97
+ show: value.includes(header.field),
98
+ }));
99
+ return context.dispatch('SET_HEADERS', headers);
100
+ },
100
101
  SET_HEADERS: (context, headers) => context.commit('SET_HEADERS', headers),
101
102
  SORT: async (context, { header, nextSortOrder }) => {
102
103
  const sort = nextSortOrder