@webitel/ui-sdk 3.2.40 → 3.2.42

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.40",
3
+ "version": "3.2.42",
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
+ }
@@ -77,9 +77,13 @@ export default class FiltersStoreModule extends BaseStoreModule {
77
77
  });
78
78
  },
79
79
  RESTORE_FILTER: async (context, { filter }) => {
80
- const value = context.getters.GET_VALUE_FROM_QUERY({ filterQuery: filter });
80
+ const query = context.getters.GET_VALUE_FROM_QUERY({ filterQuery: filter });
81
+ // note: restore fn may still return value even if there's no query value
82
+ // from localStorage, for instance
83
+ const value = context.state[filter].restore ? context.state[filter].restore({ query }) : query;
81
84
  if (value) {
82
85
  if (filter === 'sort') await context.dispatch('RESTORE_SORT', { value });
86
+ else if (filter === 'fields') await context.dispatch('RESTORE_FIELDS', { value });
83
87
  await context.dispatch('SET_FILTER', ({ filter, value }));
84
88
  return true;
85
89
  }
@@ -114,6 +118,11 @@ export default class FiltersStoreModule extends BaseStoreModule {
114
118
  { value },
115
119
  { root: true },
116
120
  ),
121
+ RESTORE_FIELDS: (context, { value }) => context.dispatch(
122
+ `${context.getters.TABLE_NAMESPACE}/RESTORE_FIELDS_FROM_FILTER`,
123
+ { value },
124
+ { root: true },
125
+ ),
117
126
  };
118
127
 
119
128
  mutations = {
@@ -97,6 +97,13 @@ export default class TableStoreModule extends BaseStoreModule {
97
97
  const page = 1;
98
98
  context.commit('SET_PAGE', page);
99
99
  },
100
+ RESTORE_FIELDS_FROM_FILTER: (context, { value }) => {
101
+ const headers = context.state.headers.map((header) => ({
102
+ ...header,
103
+ show: value.includes(header.field),
104
+ }));
105
+ return context.dispatch('SET_HEADERS', headers);
106
+ },
100
107
  SET_HEADERS: (context, headers) => context.commit('SET_HEADERS', headers),
101
108
  SORT: async (context, { header, nextSortOrder }) => {
102
109
  const sort = nextSortOrder