aloha-vue 1.2.136 → 1.2.137
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 +1 -1
- package/src/ATable/ATable.js +9 -5
- package/src/ATable/ATableGroupedHeader/ATableGroupedHeader.js +5 -13
- package/src/ATable/ATableSortingAdditional/ATableSortingAdditional.js +7 -3
- package/src/ATable/ATableSortingAdditional/compositionAPI/ColumnsAPI.js +6 -0
- package/src/ATable/ATableSortingAdditional/compositionAPI/FormAPI.js +26 -26
- package/src/ATable/ATableSortingAdditional/compositionAPI/ModelAPI.js +11 -5
- package/src/ATable/compositionAPI/ColumnsAPI.js +3 -8
- package/src/ATable/{ATableGroupedHeader/compositionAPI → compositionAPI}/ColumnsGroupedAPI.js +172 -171
- package/src/ATable/compositionAPI/VariablesAPI.js +0 -2
package/package.json
CHANGED
package/src/ATable/ATable.js
CHANGED
|
@@ -47,6 +47,7 @@ import {
|
|
|
47
47
|
isPlainObject,
|
|
48
48
|
uniqueId,
|
|
49
49
|
} from "lodash-es";
|
|
50
|
+
import ColumnsGroupedAPI from "./compositionAPI/ColumnsGroupedAPI";
|
|
50
51
|
|
|
51
52
|
export default {
|
|
52
53
|
name: "ATable",
|
|
@@ -439,7 +440,6 @@ export default {
|
|
|
439
440
|
|
|
440
441
|
const {
|
|
441
442
|
columnsScrollInvisible,
|
|
442
|
-
groupedHeaderRef,
|
|
443
443
|
indexFirstScrollInvisibleColumn,
|
|
444
444
|
isMultipleActionsActive,
|
|
445
445
|
modelColumnsVisibleLocal,
|
|
@@ -464,6 +464,11 @@ export default {
|
|
|
464
464
|
closePreviewAll,
|
|
465
465
|
});
|
|
466
466
|
|
|
467
|
+
const {
|
|
468
|
+
columnsOrderedFromSimpleTable,
|
|
469
|
+
renderedGroupedColumns,
|
|
470
|
+
} = ColumnsGroupedAPI(props);
|
|
471
|
+
|
|
467
472
|
const {
|
|
468
473
|
columnIdsGroupByLocked,
|
|
469
474
|
columnsFilteredForRender,
|
|
@@ -472,10 +477,10 @@ export default {
|
|
|
472
477
|
countNotHiddenColumns,
|
|
473
478
|
} = ColumnsAPI(props, {
|
|
474
479
|
columnsScrollInvisible,
|
|
475
|
-
groupedHeaderRef,
|
|
476
480
|
indexFirstScrollInvisibleColumn,
|
|
477
481
|
modelColumnsVisibleLocal,
|
|
478
482
|
modelIsTableWithoutScrollComputed,
|
|
483
|
+
columnsOrderedFromSimpleTable,
|
|
479
484
|
});
|
|
480
485
|
|
|
481
486
|
const {
|
|
@@ -537,7 +542,6 @@ export default {
|
|
|
537
542
|
checkVisibleColumns,
|
|
538
543
|
columnIdsGroupByLocked,
|
|
539
544
|
columnsFilteredForRenderIndexesMapping,
|
|
540
|
-
groupedHeaderRef,
|
|
541
545
|
});
|
|
542
546
|
|
|
543
547
|
const {
|
|
@@ -687,7 +691,6 @@ export default {
|
|
|
687
691
|
columnsOrdered,
|
|
688
692
|
deleteRow,
|
|
689
693
|
emptyText,
|
|
690
|
-
groupedHeaderRef,
|
|
691
694
|
hasMultipleActions,
|
|
692
695
|
hasRows,
|
|
693
696
|
hasViews,
|
|
@@ -707,6 +710,7 @@ export default {
|
|
|
707
710
|
onTogglePreview,
|
|
708
711
|
previewDownRowIndexes,
|
|
709
712
|
previewRightRowIndex,
|
|
713
|
+
renderedGroupedColumns,
|
|
710
714
|
rowsLocal,
|
|
711
715
|
rowsLocalAll,
|
|
712
716
|
rowsLocalLength,
|
|
@@ -839,7 +843,6 @@ export default {
|
|
|
839
843
|
}, [
|
|
840
844
|
this.isSimpleTable ?
|
|
841
845
|
h(ATableGroupedHeader, {
|
|
842
|
-
ref: "groupedHeaderRef",
|
|
843
846
|
areAllRowsSelected: this.areAllRowsSelected,
|
|
844
847
|
areAllVisibleRowsSelected: this.areAllVisibleRowsSelected,
|
|
845
848
|
areSomeRowsSelected: this.areSomeRowsSelected,
|
|
@@ -853,6 +856,7 @@ export default {
|
|
|
853
856
|
showFirstSortingSequenceNumber: this.showFirstSortingSequenceNumber,
|
|
854
857
|
sortingSequenceNumberClass: this.sortingSequenceNumberClass,
|
|
855
858
|
onSetSelectedRowsIndexes: this.setSelectedRowsIndexes,
|
|
859
|
+
columnsForRender: this.renderedGroupedColumns,
|
|
856
860
|
}) :
|
|
857
861
|
h(ATableHeader, {
|
|
858
862
|
areAllRowsSelected: this.areAllRowsSelected,
|
|
@@ -4,7 +4,6 @@ import {
|
|
|
4
4
|
|
|
5
5
|
import ATableHeaderTh from "../ATableHeaderTh/ATableHeaderTh";
|
|
6
6
|
import ATableHeaderThAction from "../ATableHeaderThAction/ATableHeaderThAction";
|
|
7
|
-
import ColumnsGroupedAPI from "./compositionAPI/ColumnsGroupedAPI";
|
|
8
7
|
|
|
9
8
|
export default {
|
|
10
9
|
name: "ATableGroupedHeader",
|
|
@@ -25,6 +24,10 @@ export default {
|
|
|
25
24
|
type: Boolean,
|
|
26
25
|
required: true,
|
|
27
26
|
},
|
|
27
|
+
columnsForRender: {
|
|
28
|
+
type: Array,
|
|
29
|
+
required: true,
|
|
30
|
+
},
|
|
28
31
|
disabledOptions: {
|
|
29
32
|
type: Boolean,
|
|
30
33
|
required: false,
|
|
@@ -72,17 +75,6 @@ export default {
|
|
|
72
75
|
"isMobile",
|
|
73
76
|
"isMultipleActionsActive",
|
|
74
77
|
],
|
|
75
|
-
setup(props) {
|
|
76
|
-
const {
|
|
77
|
-
columnsOrdered,
|
|
78
|
-
renderedGroupedColumns,
|
|
79
|
-
} = ColumnsGroupedAPI(props);
|
|
80
|
-
|
|
81
|
-
return {
|
|
82
|
-
columnsOrdered,
|
|
83
|
-
renderedGroupedColumns,
|
|
84
|
-
};
|
|
85
|
-
},
|
|
86
78
|
render() {
|
|
87
79
|
return h("div", {
|
|
88
80
|
ref: "root",
|
|
@@ -93,7 +85,7 @@ export default {
|
|
|
93
85
|
class: "a_table__row a_table__head__row",
|
|
94
86
|
role: "row",
|
|
95
87
|
}, [
|
|
96
|
-
this.
|
|
88
|
+
this.columnsForRender,
|
|
97
89
|
this.isActionColumnVisible && h(ATableHeaderThAction, {
|
|
98
90
|
disabledOptions: this.disabledOptions,
|
|
99
91
|
isRowActionsStickyLocal: this.isRowActionsStickyLocal,
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
h,
|
|
3
3
|
onBeforeUnmount,
|
|
4
|
+
ref,
|
|
4
5
|
} from "vue";
|
|
5
6
|
|
|
6
7
|
import ADropdown from "../../ADropdown/ADropdown";
|
|
@@ -32,17 +33,21 @@ export default {
|
|
|
32
33
|
},
|
|
33
34
|
},
|
|
34
35
|
setup(props) {
|
|
36
|
+
const unappliedModelSort = ref([]);
|
|
37
|
+
|
|
35
38
|
const {
|
|
36
39
|
columnsAll,
|
|
40
|
+
columnsAllKeyBySortId,
|
|
37
41
|
countColumnsAll,
|
|
38
42
|
} = ColumnsAPI(props);
|
|
39
43
|
|
|
40
44
|
const {
|
|
41
45
|
dataForForm,
|
|
42
|
-
hasLastSelectOnlyOneColumn,
|
|
43
46
|
initDataForForm,
|
|
44
47
|
} = FormAPI(props, {
|
|
45
48
|
columnsAll,
|
|
49
|
+
columnsAllKeyBySortId,
|
|
50
|
+
unappliedModelSort,
|
|
46
51
|
});
|
|
47
52
|
|
|
48
53
|
const {
|
|
@@ -62,13 +67,12 @@ export default {
|
|
|
62
67
|
initUnappliedModelSort,
|
|
63
68
|
removeUnappliedModelSort,
|
|
64
69
|
textCountModelSort,
|
|
65
|
-
unappliedModelSort,
|
|
66
70
|
updateUnappliedModelSort,
|
|
67
71
|
} = ModelAPI(props, {
|
|
68
72
|
closeDropdown,
|
|
69
73
|
countColumnsAll,
|
|
70
|
-
hasLastSelectOnlyOneColumn,
|
|
71
74
|
initDataForForm,
|
|
75
|
+
unappliedModelSort,
|
|
72
76
|
wasOpenDropdown,
|
|
73
77
|
});
|
|
74
78
|
|
|
@@ -6,6 +6,7 @@ import {
|
|
|
6
6
|
|
|
7
7
|
import {
|
|
8
8
|
filter,
|
|
9
|
+
keyBy,
|
|
9
10
|
} from "lodash-es";
|
|
10
11
|
|
|
11
12
|
export default function ColumnsAPI(props) {
|
|
@@ -22,12 +23,17 @@ export default function ColumnsAPI(props) {
|
|
|
22
23
|
];
|
|
23
24
|
});
|
|
24
25
|
|
|
26
|
+
const columnsAllKeyBySortId = computed(() => {
|
|
27
|
+
return keyBy(columnsAll.value, "sortId");
|
|
28
|
+
});
|
|
29
|
+
|
|
25
30
|
const countColumnsAll = computed(() => {
|
|
26
31
|
return columnsAll.value.length;
|
|
27
32
|
});
|
|
28
33
|
|
|
29
34
|
return {
|
|
30
35
|
columnsAll,
|
|
36
|
+
columnsAllKeyBySortId,
|
|
31
37
|
countColumnsAll,
|
|
32
38
|
};
|
|
33
39
|
}
|
|
@@ -4,38 +4,43 @@ import {
|
|
|
4
4
|
} from "vue";
|
|
5
5
|
|
|
6
6
|
import {
|
|
7
|
+
cloneDeep,
|
|
7
8
|
filter,
|
|
9
|
+
find,
|
|
8
10
|
forEach,
|
|
9
|
-
last,
|
|
10
11
|
} from "lodash-es";
|
|
11
12
|
|
|
12
13
|
export default function FormAPI(props, {
|
|
13
14
|
columnsAll = computed(() => []),
|
|
15
|
+
columnsAllKeyBySortId = computed(() => ({})),
|
|
16
|
+
unappliedModelSort = ref([]),
|
|
14
17
|
}) {
|
|
15
18
|
const dataForForm = ref([]);
|
|
19
|
+
const DATA_MODES = [
|
|
20
|
+
{
|
|
21
|
+
label: "_A_TABLE_SORT_ADDITIONAL_DIRECTION_ASC_",
|
|
22
|
+
id: "asc",
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
label: "_A_TABLE_SORT_ADDITIONAL_DIRECTION_DESC_",
|
|
26
|
+
id: "desc",
|
|
27
|
+
},
|
|
28
|
+
];
|
|
16
29
|
|
|
17
|
-
const
|
|
30
|
+
const columnsAllNotSelected = computed(() => {
|
|
31
|
+
return filter(columnsAll.value, column => {
|
|
32
|
+
return !find(unappliedModelSort.value, ["sortId", column.sortId]);
|
|
33
|
+
});
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
const initDataForForm = () => {
|
|
18
37
|
const DATA = [];
|
|
19
|
-
|
|
20
|
-
{
|
|
21
|
-
label: "_A_TABLE_SORT_ADDITIONAL_DIRECTION_ASC_",
|
|
22
|
-
id: "asc",
|
|
23
|
-
},
|
|
24
|
-
{
|
|
25
|
-
label: "_A_TABLE_SORT_ADDITIONAL_DIRECTION_DESC_",
|
|
26
|
-
id: "desc",
|
|
27
|
-
},
|
|
28
|
-
];
|
|
29
|
-
let columnsAllFiltered = columnsAll.value;
|
|
30
|
-
let lastSortId;
|
|
31
|
-
forEach(unappliedModelSort, ({ sortId }, index) => {
|
|
38
|
+
forEach(unappliedModelSort.value, ({ sortId }, index) => {
|
|
32
39
|
const isFirst = index === 0;
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
});
|
|
40
|
+
const COLUMNS_FILTERED = cloneDeep(columnsAllNotSelected.value);
|
|
41
|
+
if (sortId && columnsAllKeyBySortId.value[sortId]) {
|
|
42
|
+
COLUMNS_FILTERED.unshift(columnsAllKeyBySortId.value[sortId]);
|
|
37
43
|
}
|
|
38
|
-
lastSortId = sortId;
|
|
39
44
|
|
|
40
45
|
DATA.push({
|
|
41
46
|
type: "fieldset",
|
|
@@ -49,7 +54,7 @@ export default function FormAPI(props, {
|
|
|
49
54
|
type: "select",
|
|
50
55
|
classColumn: "a_column a_column_12_touch a_column_7_fullhd a_column_7_widescreen a_column_7_desktop",
|
|
51
56
|
deselectable: false,
|
|
52
|
-
data:
|
|
57
|
+
data: COLUMNS_FILTERED,
|
|
53
58
|
keyId: "sortId",
|
|
54
59
|
keyLabel: "label",
|
|
55
60
|
translateData: true,
|
|
@@ -80,13 +85,8 @@ export default function FormAPI(props, {
|
|
|
80
85
|
dataForForm.value = DATA;
|
|
81
86
|
};
|
|
82
87
|
|
|
83
|
-
const hasLastSelectOnlyOneColumn = computed(() => {
|
|
84
|
-
return last(dataForForm.value)?.children?.[0]?.data?.length === 1;
|
|
85
|
-
});
|
|
86
|
-
|
|
87
88
|
return {
|
|
88
89
|
dataForForm,
|
|
89
|
-
hasLastSelectOnlyOneColumn,
|
|
90
90
|
initDataForForm,
|
|
91
91
|
};
|
|
92
92
|
}
|
|
@@ -9,14 +9,15 @@ import EventBus from "../../../utils/EventBus";
|
|
|
9
9
|
import {
|
|
10
10
|
cloneDeep,
|
|
11
11
|
forEach,
|
|
12
|
+
last,
|
|
12
13
|
startsWith,
|
|
13
14
|
} from "lodash-es";
|
|
14
15
|
|
|
15
16
|
export default function ModelAPI(props, {
|
|
16
17
|
closeDropdown = () => {},
|
|
17
18
|
countColumnsAll = computed(() => 0),
|
|
18
|
-
hasLastSelectOnlyOneColumn = computed(() => false),
|
|
19
19
|
initDataForForm = () => {},
|
|
20
|
+
unappliedModelSort = ref([]),
|
|
20
21
|
wasOpenDropdown = ref(false),
|
|
21
22
|
}) {
|
|
22
23
|
const modelSort = toRef(props, "modelSort");
|
|
@@ -24,8 +25,6 @@ export default function ModelAPI(props, {
|
|
|
24
25
|
const changeModelSort = inject("changeModelSort");
|
|
25
26
|
const tableId = inject("tableId");
|
|
26
27
|
|
|
27
|
-
const unappliedModelSort = ref([]);
|
|
28
|
-
|
|
29
28
|
const initUnappliedModelSort = ({ model } = {}) => {
|
|
30
29
|
if (wasOpenDropdown.value && !model) {
|
|
31
30
|
return;
|
|
@@ -53,8 +52,16 @@ export default function ModelAPI(props, {
|
|
|
53
52
|
initDataForForm({ unappliedModelSort: UNAPPLIED_MODEL });
|
|
54
53
|
};
|
|
55
54
|
|
|
55
|
+
const needAddModelUndefined = ({ model }) => {
|
|
56
|
+
if (model.length >= countColumnsAll.value) {
|
|
57
|
+
return false;
|
|
58
|
+
}
|
|
59
|
+
const MODEL_LAST_ITEM = last(model);
|
|
60
|
+
return !!MODEL_LAST_ITEM.sortId;
|
|
61
|
+
};
|
|
62
|
+
|
|
56
63
|
const updateUnappliedModelSort = ({ model }) => {
|
|
57
|
-
if (model
|
|
64
|
+
if (needAddModelUndefined({ model })) {
|
|
58
65
|
model.push({
|
|
59
66
|
sortId: undefined,
|
|
60
67
|
sortMode: "asc",
|
|
@@ -131,7 +138,6 @@ export default function ModelAPI(props, {
|
|
|
131
138
|
initUnappliedModelSort,
|
|
132
139
|
removeUnappliedModelSort,
|
|
133
140
|
textCountModelSort,
|
|
134
|
-
unappliedModelSort,
|
|
135
141
|
updateUnappliedModelSort,
|
|
136
142
|
};
|
|
137
143
|
}
|
|
@@ -10,16 +10,15 @@ import {
|
|
|
10
10
|
import {
|
|
11
11
|
cloneDeep,
|
|
12
12
|
forEach,
|
|
13
|
-
get,
|
|
14
13
|
keyBy,
|
|
15
14
|
} from "lodash-es";
|
|
16
15
|
|
|
17
16
|
export default function ColumnsAPI(props, {
|
|
18
17
|
columnsScrollInvisible = ref([]),
|
|
19
|
-
groupedHeaderRef = ref({}),
|
|
20
18
|
indexFirstScrollInvisibleColumn = ref(undefined),
|
|
21
19
|
modelColumnsVisibleLocal = ref({}),
|
|
22
20
|
modelIsTableWithoutScrollComputed = computed(() => false),
|
|
21
|
+
columnsOrderedFromSimpleTable = computed(() => []),
|
|
23
22
|
}) {
|
|
24
23
|
const columns = toRef(props, "columns");
|
|
25
24
|
const isActionColumnVisible = toRef(props, "isActionColumnVisible");
|
|
@@ -30,10 +29,6 @@ export default function ColumnsAPI(props, {
|
|
|
30
29
|
return keyBy(columns.value, "id");
|
|
31
30
|
});
|
|
32
31
|
|
|
33
|
-
const columnsFromGroupedHeader = computed(() => {
|
|
34
|
-
return get(groupedHeaderRef, "value.columnsOrdered");
|
|
35
|
-
});
|
|
36
|
-
|
|
37
32
|
const columnIdsGroupByLocked = computed(() => {
|
|
38
33
|
const COLUMNS_GROUP_BY_LOCKED = {
|
|
39
34
|
true: [],
|
|
@@ -59,8 +54,8 @@ export default function ColumnsAPI(props, {
|
|
|
59
54
|
});
|
|
60
55
|
|
|
61
56
|
const columnsOrdered = computed(() => {
|
|
62
|
-
if (
|
|
63
|
-
return
|
|
57
|
+
if (columnsOrderedFromSimpleTable.value && columnsOrderedFromSimpleTable.value.length) {
|
|
58
|
+
return columnsOrderedFromSimpleTable.value;
|
|
64
59
|
}
|
|
65
60
|
if (!modelColumnsOrdering.value.length) {
|
|
66
61
|
return [...columnIdsGroupByLocked.value.trueColumns, ...columnIdsGroupByLocked.value.falseColumns];
|
package/src/ATable/{ATableGroupedHeader/compositionAPI → compositionAPI}/ColumnsGroupedAPI.js
RENAMED
|
@@ -1,171 +1,172 @@
|
|
|
1
|
-
import {
|
|
2
|
-
computed,
|
|
3
|
-
h,
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
import
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
const
|
|
25
|
-
const
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
_firstLevelGroupObject
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
...
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
"
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
map(group.
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
...
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
}
|
|
1
|
+
import {
|
|
2
|
+
computed,
|
|
3
|
+
h,
|
|
4
|
+
toRef,
|
|
5
|
+
} from "vue";
|
|
6
|
+
|
|
7
|
+
import ATableHeaderTh from "../ATableHeaderTh/ATableHeaderTh";
|
|
8
|
+
import ATranslation from "../../ATranslation/ATranslation";
|
|
9
|
+
|
|
10
|
+
import {
|
|
11
|
+
filter,
|
|
12
|
+
get,
|
|
13
|
+
includes,
|
|
14
|
+
isArray,
|
|
15
|
+
map,
|
|
16
|
+
min,
|
|
17
|
+
sortBy,
|
|
18
|
+
uniqBy,
|
|
19
|
+
} from "lodash-es";
|
|
20
|
+
|
|
21
|
+
export default function ColumnsGroupedAPI(props) {
|
|
22
|
+
const columns = toRef(props, "columns");
|
|
23
|
+
const modelSort = toRef(props, "modelSort");
|
|
24
|
+
const showFirstSortingSequenceNumber = toRef(props, "showFirstSortingSequenceNumber");
|
|
25
|
+
const sortingSequenceNumberClass = toRef(props, "sortingSequenceNumberClass");
|
|
26
|
+
|
|
27
|
+
const columnsLocal = computed(() => {
|
|
28
|
+
return map(columns.value, (column, index) => {
|
|
29
|
+
return {
|
|
30
|
+
...column,
|
|
31
|
+
_index: column.prio || index,
|
|
32
|
+
};
|
|
33
|
+
});
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
const columnsWithIndexedGroups = computed(() => {
|
|
37
|
+
return map(columnsLocal.value, column => {
|
|
38
|
+
if (column.group && column.group.length) {
|
|
39
|
+
column.group = map(column.group, (_group, groupIndex) => {
|
|
40
|
+
return [
|
|
41
|
+
_group,
|
|
42
|
+
groupIndex,
|
|
43
|
+
].join("%%%");
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
return column;
|
|
48
|
+
});
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
const getRecursiveChildrenForGroup = ({ groups, group, level, columnsOrderedFromGroups, firstLevelGroupObject }) => {
|
|
52
|
+
const foundGroupsForCurrentLevel = group ? filter(groups, _group => {
|
|
53
|
+
return includes(_group, group[level - 1]);
|
|
54
|
+
}) : groups;
|
|
55
|
+
|
|
56
|
+
const uniqGroupsForCurrentLevel = uniqBy(foundGroupsForCurrentLevel, _group => _group[level]);
|
|
57
|
+
|
|
58
|
+
const recursiveGroup = map(uniqGroupsForCurrentLevel, _group => {
|
|
59
|
+
const groupObjectToReturn = {
|
|
60
|
+
id: _group[level].split("%%%")[0],
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
let _firstLevelGroupObject;
|
|
64
|
+
if (level === 0) {
|
|
65
|
+
_firstLevelGroupObject = groupObjectToReturn;
|
|
66
|
+
_firstLevelGroupObject.columnIndexes = [];
|
|
67
|
+
} else {
|
|
68
|
+
_firstLevelGroupObject = firstLevelGroupObject;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
if (_group.length > level + 1) {
|
|
72
|
+
groupObjectToReturn.children = get(
|
|
73
|
+
getRecursiveChildrenForGroup({
|
|
74
|
+
groups,
|
|
75
|
+
group: _group,
|
|
76
|
+
level: level + 1,
|
|
77
|
+
columnsOrderedFromGroups,
|
|
78
|
+
firstLevelGroupObject: _firstLevelGroupObject,
|
|
79
|
+
}),
|
|
80
|
+
"recursiveGroup"
|
|
81
|
+
);
|
|
82
|
+
} else if (_group.length === level + 1) {
|
|
83
|
+
groupObjectToReturn.columns = filter(columnsWithIndexedGroups.value, column => includes(column.group, _group[level]));
|
|
84
|
+
_firstLevelGroupObject.columnIndexes.push(...map(groupObjectToReturn.columns, "_index"));
|
|
85
|
+
columnsOrderedFromGroups.push(...groupObjectToReturn.columns);
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
return groupObjectToReturn;
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
return {
|
|
92
|
+
columnsOrderedFromGroups,
|
|
93
|
+
recursiveGroup,
|
|
94
|
+
};
|
|
95
|
+
};
|
|
96
|
+
|
|
97
|
+
const plainGroupsAndColumns = computed(() => {
|
|
98
|
+
return map(columnsWithIndexedGroups.value, column => {
|
|
99
|
+
return get(column, "group", column);
|
|
100
|
+
});
|
|
101
|
+
});
|
|
102
|
+
const onlyGroups = computed(() => {
|
|
103
|
+
return filter(plainGroupsAndColumns.value, group => isArray(group));
|
|
104
|
+
});
|
|
105
|
+
const onlyColumns = computed(() => {
|
|
106
|
+
return filter(plainGroupsAndColumns.value, group => !isArray(group));
|
|
107
|
+
});
|
|
108
|
+
const columnsGrouped = computed(() => {
|
|
109
|
+
const columnsOrderedFromGroupsLocal = [];
|
|
110
|
+
|
|
111
|
+
return getRecursiveChildrenForGroup({ groups: onlyGroups.value, group: null, level: 0, columnsOrderedFromGroups: columnsOrderedFromGroupsLocal });
|
|
112
|
+
});
|
|
113
|
+
const columnsOrderedFromSimpleTable = computed(() => {
|
|
114
|
+
return sortBy([
|
|
115
|
+
...columnsGrouped.value.columnsOrderedFromGroups,
|
|
116
|
+
...onlyColumns.value,
|
|
117
|
+
], "_index");
|
|
118
|
+
});
|
|
119
|
+
|
|
120
|
+
const getColumnsForRender = col => {
|
|
121
|
+
return h(ATableHeaderTh, {
|
|
122
|
+
ref: "th",
|
|
123
|
+
class: "a_table__cell__child_group",
|
|
124
|
+
column: col,
|
|
125
|
+
columnGroupNames: map(col.group, group => group.split("%%%")[0]),
|
|
126
|
+
columnIndex: col._index,
|
|
127
|
+
hasMultipleActions: false,
|
|
128
|
+
modelSort: modelSort.value,
|
|
129
|
+
showFirstSortingSequenceNumber: showFirstSortingSequenceNumber.value,
|
|
130
|
+
sortingSequenceNumberClass: sortingSequenceNumberClass.value,
|
|
131
|
+
});
|
|
132
|
+
};
|
|
133
|
+
const getRecursiveGroupForRender = group => {
|
|
134
|
+
return h("div", {
|
|
135
|
+
class: "a_table__th_group",
|
|
136
|
+
}, [
|
|
137
|
+
h("div", {
|
|
138
|
+
class: "a_table__th_child_group",
|
|
139
|
+
}, [
|
|
140
|
+
h("div", {
|
|
141
|
+
class: "a_table__cell_group",
|
|
142
|
+
}, [
|
|
143
|
+
group.id && h(ATranslation, {
|
|
144
|
+
html: group.id,
|
|
145
|
+
tag: "span",
|
|
146
|
+
"aria-hidden": true,
|
|
147
|
+
}),
|
|
148
|
+
]),
|
|
149
|
+
h("div", {
|
|
150
|
+
class: "a_table__th_group_container",
|
|
151
|
+
}, group.children ?
|
|
152
|
+
map(group.children, _gr => getRecursiveGroupForRender(_gr)) :
|
|
153
|
+
map(group.columns, _col => getColumnsForRender(_col))),
|
|
154
|
+
]),
|
|
155
|
+
]);
|
|
156
|
+
};
|
|
157
|
+
const renderedGroupedColumns = computed(() => {
|
|
158
|
+
const mixedColumnsAndGroups = sortBy([
|
|
159
|
+
...columnsGrouped.value.recursiveGroup,
|
|
160
|
+
...onlyColumns.value,
|
|
161
|
+
], column => column.columnIndexes ? min(column.columnIndexes) : column._index);
|
|
162
|
+
|
|
163
|
+
return map(mixedColumnsAndGroups, column => {
|
|
164
|
+
return column.columnIndexes ? getRecursiveGroupForRender(column) : getColumnsForRender(column);
|
|
165
|
+
});
|
|
166
|
+
});
|
|
167
|
+
|
|
168
|
+
return {
|
|
169
|
+
columnsOrderedFromSimpleTable,
|
|
170
|
+
renderedGroupedColumns,
|
|
171
|
+
};
|
|
172
|
+
}
|
|
@@ -4,7 +4,6 @@ import {
|
|
|
4
4
|
|
|
5
5
|
export default function VariablesAPI() {
|
|
6
6
|
const columnsScrollInvisible = ref([]);
|
|
7
|
-
const groupedHeaderRef = ref(undefined);
|
|
8
7
|
const indexFirstScrollInvisibleColumn = ref(undefined);
|
|
9
8
|
const isMultipleActionsActive = ref(undefined);
|
|
10
9
|
const modelColumnsVisibleLocal = ref({});
|
|
@@ -13,7 +12,6 @@ export default function VariablesAPI() {
|
|
|
13
12
|
|
|
14
13
|
return {
|
|
15
14
|
columnsScrollInvisible,
|
|
16
|
-
groupedHeaderRef,
|
|
17
15
|
indexFirstScrollInvisibleColumn,
|
|
18
16
|
isMultipleActionsActive,
|
|
19
17
|
modelColumnsVisibleLocal,
|