@webitel/ui-sdk 0.9.59 → 0.9.63

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": "0.9.59",
3
+ "version": "0.9.63",
4
4
  "private": false,
5
5
  "scripts": {
6
6
  "serve-lib": "vue-cli-service serve",
@@ -8,7 +8,8 @@
8
8
  "test:unit": "vue-cli-service test:unit",
9
9
  "lint": "vue-cli-service lint --fix",
10
10
  "build-lib": "vue-cli-service build --target lib --name ui-sdk ./src/install.js",
11
- "build-publish-lib": "npm run test:unit && npm run build-lib && npm publish --access public"
11
+ "build-publish-lib": "npm run test:unit && npm run build-lib && npm publish --access public",
12
+ "build-publish-lib:testless": "npm run build-lib && npm publish --access public"
12
13
  },
13
14
  "main": "./dist/@webitel/ui-sdk.common.js",
14
15
  "files": [
@@ -20,6 +20,9 @@ describe('Abstract Enum Filter', () => {
20
20
  state: {
21
21
  [filterQuery]: filterSchema,
22
22
  },
23
+ getters: {
24
+ GET_VALUE_FROM_QUERY: () => {},
25
+ },
23
26
  },
24
27
  },
25
28
  });
@@ -32,9 +32,9 @@ export default {
32
32
  if (!this.$store) throw new Error('Vuex is required for default setValueToQuery() baseFilterMixin method');
33
33
  return this.$store.dispatch(`${this.namespace}/SET_VALUE_TO_QUERY`, payload);
34
34
  },
35
- getValueFromQuery(payload) {
35
+ getValueFromQuery({ filterQuery }) {
36
36
  if (!this.$store) throw new Error('Vuex is required for default getValueFromQuery() baseFilterMixin method');
37
- return this.$store.dispatch(`${this.namespace}/GET_VALUE_FROM_QUERY`, payload);
37
+ return this.$route.query[filterQuery];
38
38
  },
39
39
  },
40
40
  };
@@ -2,9 +2,14 @@ import deepEqual from 'deep-equal';
2
2
  import BaseStoreModule from '../../../store/BaseStoreModules/BaseStoreModule';
3
3
 
4
4
  export default class QueryControllerStoreModule extends BaseStoreModule {
5
+ getters = {
6
+ GET_VALUE_FROM_QUERY: (state) => ({ filterQuery }) => state.router.currentRoute.query[filterQuery],
7
+ }
8
+
5
9
  actions = {
6
10
  // OVERRIDE ME
7
- BEFORE_CHANGE_ROUTE_QUERY_HOOK: (context, { query }) => query,
11
+ // eslint-disable-next-line no-unused-vars
12
+ BEFORE_CHANGE_ROUTE_QUERY_HOOK: (context, { query, filterQuery, value }) => query,
8
13
  // OVERRIDE ME
9
14
  AFTER_CHANGE_ROUTE_QUERY_HOOK: (context, { query }) => query,
10
15
  _CHANGE_ROUTE_QUERY: async (context, { filterQuery, value }) => {
@@ -12,7 +17,7 @@ export default class QueryControllerStoreModule extends BaseStoreModule {
12
17
  const { router } = context.state;
13
18
  let query = { ...router.currentRoute.query };
14
19
  query[filterQuery] = value;
15
- query = await context.dispatch('BEFORE_CHANGE_ROUTE_QUERY_HOOK', { query });
20
+ query = await context.dispatch('BEFORE_CHANGE_ROUTE_QUERY_HOOK', { query, filterQuery, value });
16
21
  await router.replace({
17
22
  name: router.currentRoute.name,
18
23
  query,
@@ -49,7 +54,6 @@ export default class QueryControllerStoreModule extends BaseStoreModule {
49
54
  throw err;
50
55
  }
51
56
  },
52
- GET_VALUE_FROM_QUERY: (context, { filterQuery }) => context.state.router.currentRoute.query[filterQuery],
53
57
  };
54
58
 
55
59
  constructor({ router } = {}) {
@@ -46,6 +46,7 @@ export default class QueryFiltersStoreModule extends BaseStoreModule {
46
46
  generateQueryControllerActions(controllerNamespace) {
47
47
  this.actions.SET_VALUE_TO_QUERY = (context, payload) => context.dispatch(`${controllerNamespace}/SET_VALUE_TO_QUERY`, payload, { root: true });
48
48
  this.actions.GET_VALUE_FROM_QUERY = (context, payload) => context.dispatch(`${controllerNamespace}/GET_VALUE_FROM_QUERY`, payload, { root: true });
49
+ return this;
49
50
  }
50
51
 
51
52
  constructor({ state = {} } = {}) {
@@ -22,21 +22,21 @@ describe('Query Controller Store Module Actions', () => {
22
22
  it('Array of objects', async () => {
23
23
  const value = [{ name: 'team 1', id: '1' }, { name: 'team 2', id: '2' }];
24
24
  await store.dispatch('SET_VALUE_TO_QUERY', { filterQuery, value });
25
- const queryValue = await store.dispatch('GET_VALUE_FROM_QUERY', { filterQuery });
25
+ const queryValue = await store.getters.GET_VALUE_FROM_QUERY({ filterQuery });
26
26
  expect(queryValue).toEqual(['1', '2']);
27
27
  });
28
28
 
29
29
  it('Array of values', async () => {
30
30
  const value = ['hello', '1'];
31
31
  await store.dispatch('SET_VALUE_TO_QUERY', { filterQuery, value });
32
- const queryValue = await store.dispatch('GET_VALUE_FROM_QUERY', { filterQuery });
32
+ const queryValue = await store.getters.GET_VALUE_FROM_QUERY({ filterQuery });
33
33
  expect(queryValue).toEqual(value);
34
34
  });
35
35
 
36
36
  it('String value', async () => {
37
37
  const value = 'hello there';
38
38
  await store.dispatch('SET_VALUE_TO_QUERY', { filterQuery, value });
39
- const queryValue = await store.dispatch('GET_VALUE_FROM_QUERY', { filterQuery });
39
+ const queryValue = await store.getters.GET_VALUE_FROM_QUERY({ filterQuery });
40
40
  expect(queryValue).toEqual(value);
41
41
  });
42
42
  });