@webitel/ui-sdk 3.1.6 → 3.1.7

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.6",
3
+ "version": "3.1.7",
4
4
  "private": false,
5
5
  "scripts": {
6
6
  "serve-lib": "vue-cli-service serve",
@@ -0,0 +1,40 @@
1
+ import { computed } from 'vue';
2
+ import { useStore } from 'vuex';
3
+ import getNamespacedState
4
+ from '@webitel/ui-sdk/src/store/helpers/getNamespacedState';
5
+
6
+ // eslint-disable-next-line import/prefer-default-export
7
+ export const useCardStore = (namespace) => {
8
+ const store = useStore();
9
+
10
+ const cardNamespace = `${namespace}/card`;
11
+
12
+ const id = computed(() => getNamespacedState(store.state, cardNamespace).itemId);
13
+ const itemInstance = computed(() => getNamespacedState(store.state, cardNamespace).itemInstance);
14
+
15
+ function loadItem(payload) {
16
+ return store.dispatch(`${cardNamespace}/LOAD_ITEM`, payload);
17
+ }
18
+
19
+ function addItem(payload) {
20
+ return store.dispatch(`${cardNamespace}/ADD_ITEM`, payload);
21
+ }
22
+
23
+ function updateItem(payload) {
24
+ return store.dispatch(`${cardNamespace}/UPDATE_ITEM`, payload);
25
+ }
26
+
27
+ function setId(payload) {
28
+ return store.dispatch(`${cardNamespace}/SET_ITEM_ID`, payload);
29
+ }
30
+
31
+ return {
32
+ id,
33
+ itemInstance,
34
+
35
+ loadItem,
36
+ addItem,
37
+ updateItem,
38
+ setId,
39
+ };
40
+ };
@@ -0,0 +1,68 @@
1
+ import { computed } from 'vue';
2
+ import { useStore } from 'vuex';
3
+ import getNamespacedState
4
+ from '@webitel/ui-sdk/src/store/helpers/getNamespacedState';
5
+
6
+ // eslint-disable-next-line import/prefer-default-export
7
+ export const useTableStore = (namespace) => {
8
+ const store = useStore();
9
+
10
+ const tableNamespace = `${namespace}/table`;
11
+
12
+ const dataList = computed(() => getNamespacedState(store.state, tableNamespace).dataList);
13
+
14
+ const isLoaded = computed(() => getNamespacedState(store.state, tableNamespace).isLoading);
15
+
16
+ const headers = computed(() => getNamespacedState(store.state, tableNamespace).headers);
17
+
18
+ const isNext = computed(() => getNamespacedState(store.state, tableNamespace).isNext);
19
+
20
+ const page = computed(() => getNamespacedState(store.state, tableNamespace).page);
21
+
22
+ const size = computed(() => getNamespacedState(store.state, tableNamespace).size);
23
+
24
+ async function loadData() {
25
+ await store.dispatch(`${tableNamespace}/LOAD_DATA_LIST`);
26
+ }
27
+
28
+ async function setSize(payload) {
29
+ await store.dispatch(`${tableNamespace}/SET_SIZE`, payload);
30
+ }
31
+
32
+ async function nextPage() {
33
+ await store.dispatch(`${tableNamespace}/SET_NEXT_PAGE`);
34
+ }
35
+
36
+ async function prevPage() {
37
+ await store.dispatch(`${tableNamespace}/PREV_PAGE`);
38
+ }
39
+
40
+ async function patchProperty(payload) {
41
+ await store.dispatch(`${tableNamespace}/PATCH_ITEM_PROPERTY`, payload);
42
+ }
43
+
44
+ async function deleteItem(payload) {
45
+ await store.dispatch(`${tableNamespace}/DELETE_ITEM`, payload);
46
+ }
47
+
48
+ async function sort(...params) {
49
+ await store.dispatch(`${tableNamespace}/SORT`, { header: params[0], nextSortOrder: params[1] });
50
+ }
51
+
52
+ return {
53
+ dataList,
54
+ isLoaded,
55
+ headers,
56
+ isNext,
57
+ page,
58
+ size,
59
+
60
+ loadData,
61
+ setSize,
62
+ nextPage,
63
+ prevPage,
64
+ patchProperty,
65
+ deleteItem,
66
+ sort,
67
+ };
68
+ };