aloha-vue 1.2.98 → 1.2.99

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
@@ -14,7 +14,7 @@
14
14
  "Vue.js"
15
15
  ],
16
16
  "homepage": "https://github.com/ilia-brykin/aloha/#README.md",
17
- "version": "1.2.98",
17
+ "version": "1.2.99",
18
18
  "author": {
19
19
  "name": "Ilia Brykin",
20
20
  "email": "brykin.ilia@gmail.com"
@@ -7,6 +7,8 @@ import AFilterCenterItem from "./AFilterCenterItem/AFilterCenterItem";
7
7
 
8
8
  import VisibleFiltersAPI from "./compositionAPI/VisibleFiltersAPI";
9
9
  import AButton from "../../AButton/AButton";
10
+ import LoadingFiltersAPI from "./compositionAPI/LoadingFiltersAPI";
11
+ import ASpinner from "../../ASpinner/ASpinner";
10
12
 
11
13
  export default {
12
14
  name: "AFilterCenter",
@@ -50,8 +52,15 @@ export default {
50
52
  updateVisibleChildFilters,
51
53
  } = VisibleFiltersAPI(props);
52
54
 
55
+ const {
56
+ isLeastOneChildFilterLoading,
57
+ updateLoadingChildFilters,
58
+ } = LoadingFiltersAPI(props);
59
+
53
60
  return {
61
+ isLeastOneChildFilterLoading,
54
62
  styleHide,
63
+ updateLoadingChildFilters,
55
64
  updateVisibleChildFilters,
56
65
  };
57
66
  },
@@ -75,8 +84,16 @@ export default {
75
84
  dataKeyByKeyIdPerFilter: this.dataKeyByKeyIdPerFilter,
76
85
  model: this.appliedModel[filter.modelId || filter.id],
77
86
  onUpdateVisibleChildFilters: this.updateVisibleChildFilters,
87
+ onUpdateLoadingChildFilters: this.updateLoadingChildFilters,
78
88
  }, this.$slots);
79
89
  }),
90
+ this.isLeastOneChildFilterLoading && h("div", {
91
+ class: "a_filters_center__item",
92
+ }, [
93
+ h(ASpinner, {
94
+ class: "a_spinner_small",
95
+ }),
96
+ ]),
80
97
  h("div", {
81
98
  class: "a_filters_center__item",
82
99
  }, [
@@ -11,6 +11,7 @@ import GoToAPI from "./compositionAPI/GoToAPI";
11
11
  import HasFilterAPI from "./compositionAPI/HasFilterAPI";
12
12
  import LabelAPI from "./compositionAPI/LabelAPI";
13
13
  import ModelValuesAPI from "./compositionAPI/ModelValuesAPI";
14
+ import IsDataLoadingAPI from "./compositionAPI/IsDataLoadingAPI";
14
15
 
15
16
  export default {
16
17
  name: "AFilterCenterItem",
@@ -44,12 +45,18 @@ export default {
44
45
  },
45
46
  emits: [
46
47
  "updateVisibleChildFilters",
48
+ "updateLoadingChildFilters",
47
49
  ],
48
50
  setup(props, context) {
49
51
  const {
50
52
  hasCurrentFilter,
51
53
  } = HasFilterAPI(props);
52
54
 
55
+ const {
56
+ isFilterLoading,
57
+ updateLoadingChildFilters,
58
+ } = IsDataLoadingAPI(props, context);
59
+
53
60
  const {
54
61
  filterLabel,
55
62
  } = LabelAPI(props, {
@@ -83,6 +90,12 @@ export default {
83
90
  immediate: true,
84
91
  });
85
92
 
93
+ watch(isFilterLoading, () => {
94
+ updateLoadingChildFilters();
95
+ }, {
96
+ immediate: true,
97
+ });
98
+
86
99
  onBeforeUnmount(() => {
87
100
  updateVisibleChildFilters({
88
101
  destroy: true,
@@ -0,0 +1,30 @@
1
+ import {
2
+ computed,
3
+ toRef,
4
+ } from "vue";
5
+
6
+ import {
7
+ isEmpty,
8
+ } from "lodash-es";
9
+
10
+ export default function IsDataLoadingAPI(props, { emit }) {
11
+ const filter = toRef(props, "filter");
12
+ const model = toRef(props, "model");
13
+ const dataKeyByKeyIdPerFilter = toRef(props, "dataKeyByKeyIdPerFilter");
14
+
15
+ const isFilterLoading = computed(() => {
16
+ return !isEmpty(model.value) && isEmpty(dataKeyByKeyIdPerFilter.value[filter.value.id]);
17
+ });
18
+
19
+ const updateLoadingChildFilters = () => {
20
+ emit("updateLoadingChildFilters", {
21
+ id: filter.value.id,
22
+ isLoading: isFilterLoading.value,
23
+ });
24
+ };
25
+
26
+ return {
27
+ isFilterLoading,
28
+ updateLoadingChildFilters,
29
+ };
30
+ }
@@ -0,0 +1,32 @@
1
+ import {
2
+ computed,
3
+ ref,
4
+ } from "vue";
5
+
6
+ import {
7
+ forEach,
8
+ } from "lodash-es";
9
+
10
+ export default function LoadingFiltersAPI() {
11
+ const loadingChildFilters = ref({});
12
+
13
+ const updateLoadingChildFilters = ({ id, isLoading }) => {
14
+ loadingChildFilters.value[id] = isLoading;
15
+ };
16
+
17
+ const isLeastOneChildFilterLoading = computed(() => {
18
+ let isLoading = false;
19
+ forEach(loadingChildFilters.value, _isLoading => {
20
+ if (_isLoading) {
21
+ isLoading = true;
22
+ return false;
23
+ }
24
+ });
25
+ return isLoading;
26
+ });
27
+
28
+ return {
29
+ isLeastOneChildFilterLoading,
30
+ updateLoadingChildFilters,
31
+ };
32
+ }
@@ -427,6 +427,8 @@ export default {
427
427
  } = SortAPI(props);
428
428
 
429
429
  const {
430
+ addRow,
431
+ deleteRow,
430
432
  hasRows,
431
433
  limit,
432
434
  offset,
@@ -603,6 +605,7 @@ export default {
603
605
  initModelSort();
604
606
 
605
607
  return {
608
+ addRow,
606
609
  allVisibleMobileColumns,
607
610
  areAllRowsSelected,
608
611
  areAllVisibleRowsSelected,
@@ -617,6 +620,7 @@ export default {
617
620
  closePreviewAll,
618
621
  columnsFilteredForRender,
619
622
  columnsOrdered,
623
+ deleteRow,
620
624
  emptyText,
621
625
  hasMultipleActions,
622
626
  hasRows,
@@ -73,6 +73,14 @@ export default function RowsAPI(props, {
73
73
  rowsLocal.value[rowIndex] = row;
74
74
  };
75
75
 
76
+ const addRow = ({ row }) => {
77
+ rowsLocal.value.unshift(row);
78
+ };
79
+
80
+ const deleteRow = ({ index }) => {
81
+ rowsLocal.value.splice(index, 1);
82
+ };
83
+
76
84
  watch(dataPaginated, () => {
77
85
  rowsLocal.value = [];
78
86
  rowsLocalIndex = 0;
@@ -89,6 +97,8 @@ export default function RowsAPI(props, {
89
97
  });
90
98
 
91
99
  return {
100
+ addRow,
101
+ deleteRow,
92
102
  hasRows,
93
103
  limit,
94
104
  offset,