aloha-vue 1.2.149 → 1.2.151

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.149",
17
+ "version": "1.2.151",
18
18
  "author": {
19
19
  "name": "Ilia Brykin",
20
20
  "email": "brykin.ilia@gmail.com"
@@ -17,6 +17,7 @@ import {
17
17
 
18
18
  export default function FiltersAPI(props, { emit }) {
19
19
  const filters = toRef(props, "filters");
20
+ const filterMain = toRef(props, "filterMain");
20
21
  const unappliedModel = toRef(props, "unappliedModel");
21
22
 
22
23
  const filtersDataKeyById = ref({});
@@ -24,7 +25,7 @@ export default function FiltersAPI(props, { emit }) {
24
25
  const filtersVisibleIds = ref([]);
25
26
 
26
27
  const hasFilters = computed(() => {
27
- return filters.value.length > 0;
28
+ return !!(filters.value.length || filterMain.value);
28
29
  });
29
30
 
30
31
  const filtersKeyById = computed(() => {
@@ -825,6 +825,7 @@ export default {
825
825
  isLabelVisible: this.isLabelVisible,
826
826
  isLoadingMultipleActions: this.isLoadingMultipleActions,
827
827
  isQuickSearch: this.isQuickSearch,
828
+ isSortingMultiColumn: this.isSortingMultiColumn,
828
829
  label: this.label,
829
830
  labelClass: this.labelClass,
830
831
  labelTag: this.labelTag,
@@ -27,6 +27,11 @@ export default {
27
27
  type: Boolean,
28
28
  required: false,
29
29
  },
30
+ isSortingMultiColumn: {
31
+ type: Boolean,
32
+ required: false,
33
+ default: false,
34
+ },
30
35
  modelSort: {
31
36
  type: Array,
32
37
  required: false,
@@ -12,7 +12,9 @@ describe("ATableSortingAdditional ModelAPI", () => {
12
12
  const {
13
13
  initUnappliedModelSort,
14
14
  } = ModelAPI({
15
- modelSort: ref([]) }, {
15
+ modelSort: ref([]),
16
+ isSortingMultiColumn: ref(true),
17
+ }, {
16
18
  countColumnsAll,
17
19
  unappliedModelSort,
18
20
  });
@@ -33,7 +35,10 @@ describe("ATableSortingAdditional ModelAPI", () => {
33
35
 
34
36
  const {
35
37
  updateUnappliedModelSort
36
- } = ModelAPI({ modelSort: modelSortProvided }, {
38
+ } = ModelAPI({
39
+ isSortingMultiColumn: ref(true),
40
+ modelSort: modelSortProvided,
41
+ }, {
37
42
  countColumnsAll,
38
43
  unappliedModelSort,
39
44
  });
@@ -55,7 +60,9 @@ describe("ATableSortingAdditional ModelAPI", () => {
55
60
  const {
56
61
  removeUnappliedModelSort,
57
62
  } = ModelAPI({
58
- modelSort: ref([]) }, {
63
+ isSortingMultiColumn: ref(true),
64
+ modelSort: ref([]),
65
+ }, {
59
66
  countColumnsAll,
60
67
  unappliedModelSort,
61
68
  });
@@ -93,7 +100,9 @@ describe("ATableSortingAdditional ModelAPI", () => {
93
100
  const {
94
101
  updateUnappliedModelSort,
95
102
  } = ModelAPI({
96
- modelSort: ref([]) }, {
103
+ isSortingMultiColumn: ref(true),
104
+ modelSort: ref([]),
105
+ }, {
97
106
  countColumnsAll,
98
107
  unappliedModelSort,
99
108
  });
@@ -142,4 +151,45 @@ describe("ATableSortingAdditional ModelAPI", () => {
142
151
  { sortId: "3", sortMode: "asc" },
143
152
  ]);
144
153
  });
154
+
155
+ it("Initializes, updates, and removes unapplied model sort while maintaining a single-column sort constraint", () => {
156
+ const countColumnsAll = computed(() => 3);
157
+ const unappliedModelSort = ref([]);
158
+ const {
159
+ initUnappliedModelSort,
160
+ removeUnappliedModelSort,
161
+ updateUnappliedModelSort,
162
+ } = ModelAPI({
163
+ modelSort: ref([]),
164
+ isSortingMultiColumn: ref(false),
165
+ }, {
166
+ countColumnsAll,
167
+ unappliedModelSort,
168
+ });
169
+
170
+ initUnappliedModelSort();
171
+
172
+ expect(unappliedModelSort.value).toHaveLength(1);
173
+ expect(unappliedModelSort.value[0].sortId).toBeUndefined();
174
+ expect(unappliedModelSort.value[0].sortMode).toBe("asc");
175
+
176
+ let model = [
177
+ { sortId: "1", sortMode: "asc" },
178
+ ];
179
+ updateUnappliedModelSort({ model });
180
+
181
+ expect(unappliedModelSort.value).toHaveLength(1);
182
+ expect(unappliedModelSort.value).toStrictEqual([
183
+ { sortId: "1", sortMode: "asc" },
184
+ ]);
185
+
186
+ removeUnappliedModelSort({
187
+ item: { additionalProps: { index: 0 } },
188
+ });
189
+
190
+ expect(unappliedModelSort.value).toHaveLength(1);
191
+ expect(unappliedModelSort.value).toStrictEqual([
192
+ { sortId: undefined, sortMode: "asc" },
193
+ ]);
194
+ });
145
195
  });
@@ -20,6 +20,7 @@ export default function ModelAPI(props, {
20
20
  unappliedModelSort = ref([]),
21
21
  wasOpenDropdown = ref(false),
22
22
  }) {
23
+ const isSortingMultiColumn = toRef(props, "isSortingMultiColumn");
23
24
  const modelSort = toRef(props, "modelSort");
24
25
 
25
26
  const changeModelSort = inject("changeModelSort");
@@ -36,6 +37,12 @@ export default function ModelAPI(props, {
36
37
  MODEL_SORT.push(undefined);
37
38
  }
38
39
 
40
+ if (!isSortingMultiColumn.value) {
41
+ if (MODEL_SORT.length > 1) {
42
+ MODEL_SORT.length = 1;
43
+ }
44
+ }
45
+
39
46
  const UNAPPLIED_MODEL = [];
40
47
  forEach(MODEL_SORT, model => {
41
48
  const sortId = model ? model.replace(/^-/, "") : model;
@@ -53,7 +60,7 @@ export default function ModelAPI(props, {
53
60
  };
54
61
 
55
62
  const needAddModelUndefined = ({ model }) => {
56
- if (model.length >= countColumnsAll.value) {
63
+ if (!isSortingMultiColumn.value || model.length >= countColumnsAll.value) {
57
64
  return false;
58
65
  }
59
66
  const MODEL_LAST_ITEM = last(model);
@@ -76,6 +76,11 @@ export default {
76
76
  type: Boolean,
77
77
  required: false,
78
78
  },
79
+ isSortingMultiColumn: {
80
+ type: Boolean,
81
+ required: false,
82
+ default: false,
83
+ },
79
84
  label: {
80
85
  type: [String, Number],
81
86
  required: false,
@@ -322,6 +327,7 @@ export default {
322
327
  h(ATableSortingAdditional, {
323
328
  additionalSortingColumns: this.additionalSortingColumns,
324
329
  disabledSort: this.disabledSort,
330
+ isSortingMultiColumn: this.isSortingMultiColumn,
325
331
  modelSort: this.modelSort,
326
332
  }) :
327
333
  "",
@@ -48,11 +48,6 @@ export default function ScrollControlAPI(props, { emit }, {
48
48
  const aTableRef = ref(undefined);
49
49
  const columnsVisibleAdditionalSpaceForOneGrow = ref(0);
50
50
 
51
- const changeModelIsTableWithoutScroll = model => {
52
- modelIsTableWithoutScroll.value = model;
53
- emit("updateModelIsTableWithoutScroll", model);
54
- };
55
-
56
51
  const setAdditionalSpaceColumnsForOneGrow = ({
57
52
  sumGrows = 0,
58
53
  freeSpaceWidth = 0,
@@ -178,6 +173,14 @@ export default function ScrollControlAPI(props, { emit }, {
178
173
  }
179
174
  };
180
175
 
176
+ const changeModelIsTableWithoutScroll = model => {
177
+ modelIsTableWithoutScroll.value = model;
178
+ emit("updateModelIsTableWithoutScroll", model);
179
+ if (modelIsTableWithoutScroll.value) {
180
+ checkVisibleColumns();
181
+ }
182
+ };
183
+
181
184
  onMounted(() => {
182
185
  if (!isMobile.value) {
183
186
  resizeOb.observe(aTableRef.value);