@webitel/ui-sdk 3.1.3 → 3.1.4

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.1.3",
3
+ "version": "3.1.4",
4
4
  "private": false,
5
5
  "scripts": {
6
6
  "serve-lib": "vue-cli-service serve",
@@ -1,29 +1,37 @@
1
- import BaseStoreModule
2
- from '@webitel/ui-sdk/src/store/BaseStoreModules/BaseStoreModule';
1
+ import BaseStoreModule from './BaseStoreModule';
3
2
 
4
3
  export default class ApiStoreModule extends BaseStoreModule {
5
4
  generateAPIActions(api) {
6
5
  if (!api) throw new ReferenceError('pass API module!');
7
6
  this.actions
8
7
  .GET_LIST = (
9
- context,
10
- params = {},
11
- ) => api.getList({ ...context.state, ...params });
8
+ _,
9
+ { context: callerContext = {}, params = {} },
10
+ ) => api.getList({ ...callerContext.state, ...params });
12
11
  this.actions
13
12
  .GET_ITEM = (
14
- context,
15
- params = {},
16
- ) => api.get({ ...context.state, ...params });
13
+ _,
14
+ { context: callerContext = {}, params = {} } = {},
15
+ ) => api.get({ ...callerContext.state, ...params });
17
16
  this.actions
18
- .POST_ITEM = (context) => api.add(context.state);
17
+ .POST_ITEM = (
18
+ _,
19
+ { context: callerContext = {} } = {},
20
+ ) => api.add(callerContext.state);
19
21
  this.actions
20
- .PATCH_ITEM = (context, { id, changes }) => (
21
- api.patch({ ...context.state, id, changes })
22
+ .PATCH_ITEM = (_, { context: callerContext = {}, id, changes }) => (
23
+ api.patch({ ...callerContext.state, id, changes })
22
24
  );
23
25
  this.actions
24
- .UPD_ITEM = (context) => api.update(context.state);
26
+ .UPD_ITEM = (
27
+ _,
28
+ { context: callerContext = {} } = {},
29
+ ) => api.update(callerContext.state);
25
30
  this.actions
26
- .DELETE_ITEM = (context, id) => api.delete({ ...context.state, id });
31
+ .DELETE_ITEM = (
32
+ _,
33
+ { context: callerContext = {}, id },
34
+ ) => api.delete({ ...callerContext.state, id });
27
35
  return this;
28
36
  }
29
37
  }
@@ -1,6 +1,5 @@
1
- import BaseStoreModule
2
- from '@webitel/ui-sdk/src/store/BaseStoreModules/BaseStoreModule';
3
1
  import deepCopy from 'deep-copy';
2
+ import BaseStoreModule from './BaseStoreModule';
4
3
 
5
4
  export default class CardStoreModule extends BaseStoreModule {
6
5
  state = {
@@ -18,20 +17,20 @@ export default class CardStoreModule extends BaseStoreModule {
18
17
  },
19
18
  LOAD_ITEM: async (context) => {
20
19
  if (context.state.itemId) {
21
- const item = await context.dispatch('api/GET_ITEM');
20
+ const item = await context.dispatch('api/GET_ITEM', { context });
22
21
  context.commit('SET_ITEM', item);
23
22
  }
24
23
  },
25
24
  ADD_ITEM: async (context) => {
26
25
  if (!context.state.itemId) {
27
- const { id } = await context.dispatch('api/POST_ITEM');
26
+ const { id } = await context.dispatch('api/POST_ITEM', { context });
28
27
  await context.dispatch('SET_ITEM_ID', id);
29
28
  context.dispatch('LOAD_ITEM');
30
29
  }
31
30
  },
32
31
  UPDATE_ITEM: async (context) => {
33
32
  if (context.state.itemInstance._dirty) {
34
- await context.dispatch('api/UPD_ITEM');
33
+ await context.dispatch('api/UPD_ITEM', { context });
35
34
  context.dispatch('LOAD_ITEM');
36
35
  }
37
36
  },
@@ -1,9 +1,8 @@
1
1
  import {
2
2
  SortSymbols,
3
3
  sortToQueryAdapter,
4
- } from '@webitel/ui-sdk/src/scripts/sortQueryAdapters';
5
- import BaseStoreModule
6
- from '@webitel/ui-sdk/src/store/BaseStoreModules/BaseStoreModule';
4
+ } from '../../scripts/sortQueryAdapters';
5
+ import BaseStoreModule from './BaseStoreModule';
7
6
 
8
7
  export default class TableStoreModule extends BaseStoreModule {
9
8
  state = {
@@ -27,7 +26,7 @@ export default class TableStoreModule extends BaseStoreModule {
27
26
  let {
28
27
  items = [],
29
28
  next = false,
30
- } = await context.dispatch('api/GET_LIST', query);
29
+ } = await context.dispatch('api/GET_LIST', { context, params: query });
31
30
  /* we should set _isSelected property to all items in tables cause their checkbox selection
32
31
  * is based on this property. Previously, this prop was set it api consumers, but now
33
32
  * admin-specific were replaced by webitel-sdk consumers and i supposed it will be
@@ -100,7 +99,7 @@ export default class TableStoreModule extends BaseStoreModule {
100
99
  const id = item?.id || context.state.dataList[index].id;
101
100
  const changes = { [prop]: value };
102
101
  try {
103
- await context.dispatch('api/PATCH_ITEM', { id, changes });
102
+ await context.dispatch('api/PATCH_ITEM', { context, id, changes });
104
103
  context.commit('PATCH_ITEM_PROPERTY', {
105
104
  item, index, prop, value,
106
105
  });
@@ -124,7 +123,7 @@ export default class TableStoreModule extends BaseStoreModule {
124
123
  },
125
124
  DELETE_SINGLE: async (context, { id }) => {
126
125
  try {
127
- await context.dispatch('api/DELETE_ITEM', id);
126
+ await context.dispatch('api/DELETE_ITEM', { context, id });
128
127
  } catch (err) {
129
128
  throw err;
130
129
  }