aloha-vue 1.0.52 → 1.0.53

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.
@@ -106,6 +106,25 @@ export default {
106
106
  callback: this.clickMe,
107
107
  },
108
108
  ],
109
+ multipleActions: [
110
+ {
111
+ label: "Aloha1",
112
+ title: "Aloha1 Title",
113
+ isHidden: false,
114
+ callback: this.clickMe,
115
+ disabled: true,
116
+ icon: "Plus",
117
+ isConfirm: true,
118
+ },
119
+ {
120
+ label: "Aloha1 modal",
121
+ title: "Aloha1 Title",
122
+ isHidden: false,
123
+ callback: this.clickMeModal,
124
+ disabled: true,
125
+ icon: "Plus",
126
+ },
127
+ ],
109
128
  tableActions: [
110
129
  {
111
130
  label: "Aloha1",
@@ -180,5 +199,12 @@ export default {
180
199
  clickMe({ row, rowIndex } = {}) {
181
200
  console.log("row, rowIndex", row, rowIndex);
182
201
  },
202
+
203
+ clickMeModal({ rows, close }) {
204
+ console.log("rows", rows,);
205
+ setTimeout(() => {
206
+ close();
207
+ }, 5000);
208
+ },
183
209
  },
184
210
  };
@@ -7,6 +7,7 @@ div
7
7
  label="Example table"
8
8
  :row-actions="rowActions"
9
9
  :table-actions="tableActions"
10
+ :multiple-actions="multipleActions"
10
11
  preview="right"
11
12
  :is-quick-search="true"
12
13
  :is-action-column-visible="true"
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "aloha-vue",
3
3
  "description": "Project aloha",
4
- "version": "1.0.52",
4
+ "version": "1.0.53",
5
5
  "author": "Ilia Brykin",
6
6
  "scripts": {
7
7
  "build-icons": "node scriptsNode/iconsSvgToJs.js bootstrap3 && node scriptsNode/iconsSvgToJs.js bootstrap-1-9-1"
@@ -14,7 +14,9 @@ import ATablePreviewRight from "./ATablePreviewRight/ATablePreviewRight";
14
14
  import ATableTopPanel from "./ATableTopPanel/ATableTopPanel";
15
15
  import ATableTr from "./ATableTr/ATableTr";
16
16
 
17
+ import MultipleActionAPI from "./compositionAPI/MultipleActionAPI";
17
18
  import PreviewAPI from "./compositionAPI/PreviewAPI";
19
+ import RowsAPI from "./compositionAPI/RowsAPI";
18
20
  import ScrollControlAPI from "./compositionAPI/ScrollControlAPI";
19
21
 
20
22
  import {
@@ -29,21 +31,12 @@ import {
29
31
  isNil,
30
32
  isPlainObject,
31
33
  keyBy,
32
- orderBy,
33
- startsWith,
34
34
  uniqueId,
35
35
  } from "lodash-es";
36
36
 
37
37
 
38
38
  export default {
39
39
  name: "ATable",
40
- components: {
41
- ATableCountProPage,
42
- ATableHeader,
43
- ATablePagination,
44
- ATableTopPanel,
45
- ATableTr,
46
- },
47
40
  props: {
48
41
  id: {
49
42
  type: String,
@@ -141,6 +134,11 @@ export default {
141
134
  required: false,
142
135
  default: () => [],
143
136
  },
137
+ multipleActions: {
138
+ type: Array,
139
+ required: false,
140
+ default: () => [],
141
+ },
144
142
  isPagination: {
145
143
  type: Boolean,
146
144
  required: false,
@@ -243,6 +241,30 @@ export default {
243
241
  return MODEL_COLUMNS;
244
242
  });
245
243
 
244
+ const {
245
+ hasRows,
246
+ limit,
247
+ modelSort,
248
+ offset,
249
+ rowsLocal,
250
+ rowsLocalLength,
251
+ } = RowsAPI(props);
252
+
253
+ const {
254
+ areAllRowsSelected,
255
+ areSomeRowsSelected,
256
+ closeMultipleActionsActive,
257
+ isMultipleActionsActive,
258
+ selectedRows,
259
+ selectedRowsIndexes,
260
+ setEmptySelectedRowsIndexes,
261
+ setSelectedRowsIndexes,
262
+ toggleMultipleActionsActive,
263
+ } = MultipleActionAPI({
264
+ rowsLocal,
265
+ rowsLocalLength,
266
+ });
267
+
246
268
  const {
247
269
  aTableRef,
248
270
  changeModelIsTableWithoutScroll,
@@ -253,6 +275,7 @@ export default {
253
275
  modelIsTableWithoutScroll,
254
276
  } = ScrollControlAPI(props, context, {
255
277
  columnsOrdered,
278
+ isMultipleActionsActive,
256
279
  modelColumnsVisibleMapping,
257
280
  });
258
281
 
@@ -279,6 +302,7 @@ export default {
279
302
  provide("columnsScrollInvisible", columnsScrollInvisible);
280
303
  provide("hasPreview", hasPreview);
281
304
  provide("indexFirstScrollInvisibleColumn", indexFirstScrollInvisibleColumn);
305
+ provide("isMultipleActionsActive", isMultipleActionsActive);
282
306
  provide("modelIsTableWithoutScroll", modelIsTableWithoutScroll);
283
307
  provide("onTogglePreview", onTogglePreview);
284
308
  provide("previewRightRowIndex", previewRightRowIndex);
@@ -305,54 +329,32 @@ export default {
305
329
  previewDownRowIndexes,
306
330
  previewRightRowIndex,
307
331
  togglePreviewResize,
332
+
333
+ hasRows,
334
+ limit,
335
+ modelSort,
336
+ offset,
337
+ rowsLocal,
338
+ rowsLocalLength,
339
+
340
+ areAllRowsSelected,
341
+ areSomeRowsSelected,
342
+ closeMultipleActionsActive,
343
+ isMultipleActionsActive,
344
+ selectedRows,
345
+ selectedRowsIndexes,
346
+ setEmptySelectedRowsIndexes,
347
+ setSelectedRowsIndexes,
348
+ toggleMultipleActionsActive,
308
349
  };
309
350
  },
310
351
  data() {
311
352
  return {
312
353
  resolved: undefined,
313
354
  error: undefined,
314
- modelSort: this.sortingStart,
315
- limit: this.limitStart,
316
- offset: this.offsetStart,
317
355
  };
318
356
  },
319
357
  computed: {
320
- rowsLocal() {
321
- return this.dataPaginated;
322
- },
323
-
324
- dataPaginated() {
325
- if (this.limit && !this.isPaginationOutside && this.isPagination) {
326
- const DATA_SORTED = cloneDeep(this.dataSorted);
327
- const INDEX_START = this.offset;
328
- const INDEX_END = INDEX_START + this.limit;
329
- return DATA_SORTED.slice(INDEX_START, INDEX_END);
330
- }
331
- return this.dataSorted;
332
- },
333
-
334
- dataSorted() {
335
- if (this.modelSort && !this.isSortingOutside) {
336
- return orderBy(this.data, [this.sortOptions.model], [this.sortOptions.direction]);
337
- }
338
- return this.data;
339
- },
340
-
341
- sortOptions() {
342
- if (this.modelSort) {
343
- let directionSort = "asc";
344
- let modelSort = this.modelSort;
345
- if (startsWith(this.modelSort, "-")) {
346
- directionSort = "desc";
347
- modelSort = this.modelSort.slice(1);
348
- }
349
- return {
350
- direction: directionSort,
351
- model: modelSort,
352
- };
353
- }
354
- },
355
-
356
358
  totalRowsCountLocal() {
357
359
  return this.totalRowsCount;
358
360
  },
@@ -380,10 +382,6 @@ export default {
380
382
  isDataArray() {
381
383
  return isArray(this.data);
382
384
  },
383
-
384
- hasRows() {
385
- return !!this.rowsLocal.length;
386
- },
387
385
  },
388
386
  created() {
389
387
  this.initModelColumnsOrderingLocal();
@@ -417,6 +415,7 @@ export default {
417
415
  this.$emit("changeSorting", {
418
416
  modelSort: this.modelSort,
419
417
  });
418
+ this.setEmptySelectedRowsIndexes();
420
419
  this.closePreviewAll();
421
420
  },
422
421
 
@@ -432,6 +431,7 @@ export default {
432
431
  offset,
433
432
  limit: this.limit,
434
433
  });
434
+ this.setEmptySelectedRowsIndexes();
435
435
  this.closePreviewAll();
436
436
  },
437
437
 
@@ -442,6 +442,7 @@ export default {
442
442
  offset: this.offset,
443
443
  limit,
444
444
  });
445
+ this.setEmptySelectedRowsIndexes();
445
446
  this.closePreviewAll();
446
447
  },
447
448
 
@@ -476,20 +477,28 @@ export default {
476
477
  }],
477
478
  }, [
478
479
  h(ATableTopPanel, {
480
+ areSomeRowsSelected: this.areSomeRowsSelected,
481
+ closeMultipleActionsActive: this.closeMultipleActionsActive,
479
482
  countAllRows: this.countAllRowsLocal,
480
483
  label: this.label,
481
484
  labelTag: this.labelTag,
482
485
  tableActions: this.tableActions,
486
+ multipleActions: this.multipleActions,
483
487
  isQuickSearch: this.isQuickSearch,
484
488
  modelQuickSearch: this.modelQuickSearch,
489
+ selectedRows: this.selectedRows,
485
490
  onUpdateModelQuickSearch: this.updateModelQuickSearch,
491
+ onToggleMultipleActionsActive: this.toggleMultipleActionsActive,
486
492
  }, this.$slots),
487
493
  h("div", {
488
494
  class: "a_table",
489
495
  role: "table",
490
496
  }, [
491
497
  h(ATableHeader, {
498
+ areAllRowsSelected: this.areAllRowsSelected,
499
+ areSomeRowsSelected: this.areSomeRowsSelected,
492
500
  modelSort: this.modelSort,
501
+ onSetSelectedRowsIndexes: this.setSelectedRowsIndexes,
493
502
  }),
494
503
  h("div", {
495
504
  class: "a_table__body",
@@ -498,6 +507,8 @@ export default {
498
507
  return h(ATableTr, {
499
508
  row,
500
509
  rowIndex,
510
+ selectedRowsIndexes: this.selectedRowsIndexes,
511
+ onSetSelectedRowsIndexes: this.setSelectedRowsIndexes,
501
512
  }, {
502
513
  get: vm => [
503
514
  h(AGet, {
@@ -2,6 +2,7 @@ import {
2
2
  h,
3
3
  } from "vue";
4
4
 
5
+ import AOneCheckbox from "../../ui/AOneCheckbox/AOneCheckbox";
5
6
  import ATableHeaderTh from "../ATableHeaderTh/ATableHeaderTh";
6
7
  import ATableHeaderThAction from "../ATableHeaderThAction/ATableHeaderThAction";
7
8
 
@@ -14,17 +15,29 @@ export default {
14
15
  ATableHeaderThAction,
15
16
  },
16
17
  props: {
18
+ areAllRowsSelected: {
19
+ type: Boolean,
20
+ required: true,
21
+ },
22
+ areSomeRowsSelected: {
23
+ type: Boolean,
24
+ required: true,
25
+ },
17
26
  modelSort: {
18
27
  type: String,
19
28
  required: false,
20
29
  },
21
30
  },
31
+ emits: [
32
+ "setSelectedRowsIndexes",
33
+ ],
22
34
  inject: [
23
35
  "isActionColumnVisible",
24
36
  "changeColumnsOrdering",
25
37
  "columnsOrdered",
38
+ "isMultipleActionsActive",
26
39
  ],
27
- setup() {
40
+ setup(props, { emit }) {
28
41
  const {
29
42
  dragstart,
30
43
  dragenter,
@@ -38,6 +51,10 @@ export default {
38
51
  classOverParent: "a_table__th"
39
52
  });
40
53
 
54
+ const toggleCheckbox = () => {
55
+ emit("setSelectedRowsIndexes", { isAll: true });
56
+ };
57
+
41
58
  return {
42
59
  dragstart,
43
60
  dragenter,
@@ -46,6 +63,8 @@ export default {
46
63
  drop,
47
64
  isDragstart,
48
65
  root,
66
+
67
+ toggleCheckbox,
49
68
  };
50
69
  },
51
70
  render() {
@@ -61,6 +80,18 @@ export default {
61
80
  role: "row",
62
81
  onDrop: this.drop,
63
82
  }, [
83
+ this.isMultipleActionsActive && h("div", {
84
+ scope: "col",
85
+ role: "columnheader",
86
+ class: "a_table__th a_table__cell a_table__cell_checkbox",
87
+ style: `width: 50px; min-width: 50px; max-width: 50px;`,
88
+ }, [
89
+ h(AOneCheckbox, {
90
+ modelValue: this.areAllRowsSelected,
91
+ indeterminate: this.areSomeRowsSelected && !this.areAllRowsSelected,
92
+ "onUpdate:modelValue": this.toggleCheckbox,
93
+ }),
94
+ ]),
64
95
  this.columnsOrdered.map((column, columnIndex) => {
65
96
  return h(ATableHeaderTh, {
66
97
  ref: "th",
@@ -112,7 +112,6 @@ export default {
112
112
  this.isRowActionsDropdownVisible && h(ADropdown, {
113
113
  id: this.buttonActionsId,
114
114
  buttonClass: "a_btn a_btn_secondary a_table__cell_action__btn",
115
- dropdownClass: "a_p_0",
116
115
  isCaret: false,
117
116
  placement: "bottom-end",
118
117
  }, {
@@ -2,6 +2,8 @@ import {
2
2
  h,
3
3
  } from "vue";
4
4
 
5
+ import ADropdown from "../../ADropdown/ADropdown";
6
+ import AIcon from "../../AIcon/AIcon";
5
7
  import AInput from "../../ui/AInput/AInput";
6
8
  import ATableActionItem from "../ATableActionItem/ATableActionItem";
7
9
 
@@ -11,6 +13,10 @@ import TableActionsAPI from "../compositionAPI/TableActionsAPI";
11
13
  export default {
12
14
  name: "ATableTopPanel",
13
15
  props: {
16
+ areSomeRowsSelected: {
17
+ type: Boolean,
18
+ required: true,
19
+ },
14
20
  countAllRows: {
15
21
  type: Number,
16
22
  required: true,
@@ -28,6 +34,10 @@ export default {
28
34
  type: Array,
29
35
  required: true,
30
36
  },
37
+ multipleActions: {
38
+ type: Array,
39
+ required: true,
40
+ },
31
41
  isQuickSearch: {
32
42
  type: Boolean,
33
43
  required: false,
@@ -36,21 +46,45 @@ export default {
36
46
  type: String,
37
47
  required: true,
38
48
  },
49
+ closeMultipleActionsActive: {
50
+ type: Function,
51
+ required: true,
52
+ },
53
+ selectedRows: {
54
+ type: Array,
55
+ required: true,
56
+ },
39
57
  },
40
58
  emits: [
41
59
  "updateModelQuickSearch",
60
+ "toggleMultipleActionsActive"
61
+ ],
62
+ inject: [
63
+ "isMultipleActionsActive",
42
64
  ],
43
- setup(props) {
65
+ setup(props, context) {
44
66
  const {
45
67
  filterCurrency,
46
68
  } = AFiltersAPI();
47
69
 
48
70
  const {
71
+ currentMultipleActions,
72
+ isMultipleActionsFiltered,
73
+ multipleActionsFiltered,
74
+ onCancelMultipleActions,
75
+ onClickMultipleActions,
76
+ onOpenModalMultipleActions,
49
77
  tableActionFiltered,
50
- } = TableActionsAPI(props);
78
+ } = TableActionsAPI(props, context);
51
79
 
52
80
  return {
81
+ currentMultipleActions,
53
82
  filterCurrency,
83
+ isMultipleActionsFiltered,
84
+ multipleActionsFiltered,
85
+ onCancelMultipleActions,
86
+ onClickMultipleActions,
87
+ onOpenModalMultipleActions,
54
88
  tableActionFiltered,
55
89
  };
56
90
  },
@@ -83,13 +117,52 @@ export default {
83
117
  ]),
84
118
  h("div", {
85
119
  class: "a_table__top_panel__actions",
86
- }, [
120
+ }, this.isMultipleActionsActive ? [
121
+ h("button", {
122
+ class: "a_btn a_btn_primary a_table__action",
123
+ type: "button",
124
+ disabled: !this.areSomeRowsSelected,
125
+ onClick: this.onOpenModalMultipleActions,
126
+ }, this.currentMultipleActions.label),
127
+ h("button", {
128
+ class: "a_btn a_btn_secondary a_table__action",
129
+ type: "button",
130
+ onClick: this.onCancelMultipleActions,
131
+ }, "Mehrfachaktion abbrechen"),
132
+ ] : [
87
133
  this.$slots.tableActions && this.$slots.tableActions(),
88
134
  this.tableActionFiltered.map(action => {
89
135
  return h(ATableActionItem, {
90
136
  action,
91
137
  });
92
138
  }),
139
+ this.isMultipleActionsFiltered && h(ADropdown, {
140
+ buttonClass: "a_btn a_btn_secondary a_table__action",
141
+ placement: "bottom-end",
142
+ }, {
143
+ button: () => [
144
+ h("span", null, "Mehrfachaktionen"),
145
+ ],
146
+ dropdown: () => [
147
+ this.multipleActionsFiltered.map((action, actionIndex) => {
148
+ return h("li", {}, [
149
+ h("button", {
150
+ key: actionIndex,
151
+ class: "a_dropdown__item",
152
+ type: "button",
153
+ title: action.title,
154
+ onClick: () => this.onClickMultipleActions({ action }),
155
+ }, [
156
+ action.icon && h(AIcon, {
157
+ class: "a_mr_2",
158
+ icon: action.icon,
159
+ }),
160
+ action.label,
161
+ ]),
162
+ ]);
163
+ }),
164
+ ],
165
+ }),
93
166
  this.isQuickSearch && h(AInput, {
94
167
  label: "Schnellsuche",
95
168
  class: "a_table__top_panel__actions__quick_search",
@@ -4,13 +4,10 @@ import {
4
4
 
5
5
  import ATableTd from "../ATableTd/ATableTd";
6
6
  import ATableTdAction from "../ATableTdAction/ATableTdAction";
7
+ import AOneCheckbox from "../../ui/AOneCheckbox/AOneCheckbox";
7
8
 
8
9
  export default {
9
10
  name: "ATableTr",
10
- components: {
11
- ATableTd,
12
- ATableTdAction,
13
- },
14
11
  props: {
15
12
  row: {
16
13
  type: Object,
@@ -20,11 +17,19 @@ export default {
20
17
  type: Number,
21
18
  required: true,
22
19
  },
20
+ selectedRowsIndexes: {
21
+ type: Object,
22
+ required: true,
23
+ },
23
24
  },
25
+ emits: [
26
+ "setSelectedRowsIndexes",
27
+ ],
24
28
  inject: [
25
29
  "columnsOrdered",
26
30
  "hasPreview",
27
31
  "isActionColumnVisible",
32
+ "isMultipleActionsActive",
28
33
  "previewRightRowIndex",
29
34
  "previewRightRowIndexLast",
30
35
  "tableId",
@@ -61,9 +66,28 @@ export default {
61
66
  return !this.isPreviewRightForCurrentRowOpen &&
62
67
  this.rowIndex === this.previewRightRowIndexLast;
63
68
  },
69
+
70
+ isRowSelected() {
71
+ return !!this.selectedRowsIndexes[this.rowIndex];
72
+ },
73
+ },
74
+ methods: {
75
+ toggleCheckbox() {
76
+ this.$emit("setSelectedRowsIndexes", { rowIndex: this.rowIndex });
77
+ },
64
78
  },
65
79
  render() {
66
80
  return h("div", this.rowAttributes, [
81
+ this.isMultipleActionsActive && h("div", {
82
+ scope: "row",
83
+ class: "a_table__td a_table__cell a_table__cell_checkbox",
84
+ style: `width: 50px; min-width: 50px; max-width: 50px;`,
85
+ }, [
86
+ h(AOneCheckbox, {
87
+ modelValue: this.isRowSelected,
88
+ "onUpdate:modelValue": this.toggleCheckbox,
89
+ }),
90
+ ]),
67
91
  this.columnsOrdered.map((column, columnIndex) => {
68
92
  return h(ATableTd, {
69
93
  column,
@@ -0,0 +1,84 @@
1
+ import {
2
+ computed,
3
+ ref,
4
+ } from "vue";
5
+
6
+ import {
7
+ filter,
8
+ size,
9
+ times,
10
+ } from "lodash-es";
11
+
12
+ export default function MultipleActionAPI({
13
+ rowsLocal = computed(() => []),
14
+ rowsLocalLength = computed(() => 0),
15
+ }) {
16
+ const isMultipleActionsActive = ref(undefined);
17
+ const selectedRowsIndexes = ref({});
18
+ const selectedRows = computed(() => {
19
+ return filter(rowsLocal.value, (row, index) => {
20
+ return selectedRowsIndexes.value[index];
21
+ });
22
+ });
23
+
24
+ const setEmptySelectedRowsIndexes = () => {
25
+ selectedRowsIndexes.value = {};
26
+ };
27
+
28
+ const closeMultipleActionsActive = () => {
29
+ isMultipleActionsActive.value = false;
30
+ setEmptySelectedRowsIndexes();
31
+ };
32
+
33
+ const toggleMultipleActionsActive = () => {
34
+ if (isMultipleActionsActive.value) {
35
+ closeMultipleActionsActive();
36
+ } else {
37
+ isMultipleActionsActive.value = true;
38
+ }
39
+ };
40
+
41
+ const selectedRowsIndexesLength = computed(() => {
42
+ return size(selectedRowsIndexes.value);
43
+ });
44
+
45
+ const areAllRowsSelected = computed(() => {
46
+ return rowsLocalLength.value === selectedRowsIndexesLength.value;
47
+ });
48
+
49
+ const areSomeRowsSelected = computed(() => {
50
+ return selectedRowsIndexesLength.value > 0;
51
+ });
52
+
53
+ const setSelectedRowsIndexes = ({ rowIndex, isAll }) => {
54
+ if (isAll) {
55
+ if (areSomeRowsSelected.value) {
56
+ setEmptySelectedRowsIndexes();
57
+ } else {
58
+ const SELECTED_ROWS_INDEXES = {};
59
+ times(rowsLocalLength.value, index => {
60
+ SELECTED_ROWS_INDEXES[index] = true;
61
+ });
62
+ selectedRowsIndexes.value = SELECTED_ROWS_INDEXES;
63
+ }
64
+ return;
65
+ }
66
+ if (selectedRowsIndexes.value[rowIndex]) {
67
+ delete selectedRowsIndexes.value[rowIndex];
68
+ } else {
69
+ selectedRowsIndexes.value[rowIndex] = true;
70
+ }
71
+ };
72
+
73
+ return {
74
+ areAllRowsSelected,
75
+ areSomeRowsSelected,
76
+ closeMultipleActionsActive,
77
+ isMultipleActionsActive,
78
+ selectedRows,
79
+ selectedRowsIndexes,
80
+ setEmptySelectedRowsIndexes,
81
+ setSelectedRowsIndexes,
82
+ toggleMultipleActionsActive,
83
+ };
84
+ }
@@ -0,0 +1,79 @@
1
+ import {
2
+ computed,
3
+ ref,
4
+ toRef,
5
+ } from "vue";
6
+
7
+ import {
8
+ cloneDeep,
9
+ orderBy,
10
+ startsWith,
11
+ } from "lodash-es";
12
+
13
+ export default function RowsAPI(props) {
14
+ const sortingStart = toRef(props, "sortingStart");
15
+ const limitStart = toRef(props, "limitStart");
16
+ const offsetStart = toRef(props, "offsetStart");
17
+
18
+ const modelSort = ref(sortingStart.value);
19
+ const limit = ref(limitStart.value);
20
+ const offset = ref(offsetStart.value);
21
+
22
+ const sortOptions = computed(() => {
23
+ if (modelSort.value) {
24
+ let directionSort = "asc";
25
+ let modelSortLocal = modelSort.value;
26
+ if (startsWith(modelSort.value, "-")) {
27
+ directionSort = "desc";
28
+ modelSortLocal = modelSort.value.slice(1);
29
+ }
30
+ return {
31
+ direction: directionSort,
32
+ model: modelSortLocal,
33
+ };
34
+ }
35
+ return {};
36
+ });
37
+
38
+ const isSortingOutside = toRef(props, "isSortingOutside");
39
+ const data = toRef(props, "data");
40
+ const dataSorted = computed(() => {
41
+ if (modelSort.value && !isSortingOutside.value) {
42
+ return orderBy(data.value, [sortOptions.value.model], [sortOptions.value.direction]);
43
+ }
44
+ return data.value;
45
+ });
46
+
47
+ const isPaginationOutside = toRef(props, "isPaginationOutside");
48
+ const isPagination = toRef(props, "isPagination");
49
+ const dataPaginated = computed(() => {
50
+ if (limit.value && !isPaginationOutside.value && isPagination.value) {
51
+ const DATA_SORTED = cloneDeep(dataSorted.value);
52
+ const INDEX_START = offset.value;
53
+ const INDEX_END = INDEX_START + limit.value;
54
+ return DATA_SORTED.slice(INDEX_START, INDEX_END);
55
+ }
56
+ return dataSorted.value;
57
+ });
58
+
59
+ const rowsLocal = computed(() => {
60
+ return dataPaginated.value;
61
+ });
62
+
63
+ const rowsLocalLength = computed(() => {
64
+ return rowsLocal.value.length;
65
+ });
66
+
67
+ const hasRows = computed(() => {
68
+ return !!rowsLocalLength.value;
69
+ });
70
+
71
+ return {
72
+ hasRows,
73
+ limit,
74
+ modelSort,
75
+ offset,
76
+ rowsLocal,
77
+ rowsLocalLength,
78
+ };
79
+ }
@@ -14,10 +14,15 @@ import {
14
14
 
15
15
  export default function ScrollControlAPI(props, { emit }, {
16
16
  columnsOrdered = computed(() => []),
17
+ isMultipleActionsActive = ref(undefined),
17
18
  modelColumnsVisibleMapping = computed(() => ({})),
18
19
  }) {
19
20
  const columnWidthDefault = toRef(props, "columnWidthDefault");
20
21
  const columnActionsWidth = toRef(props, "columnActionsWidth");
22
+ const columnsSpecialWidth = computed(() => {
23
+ const columnMultipleActionsWidth = isMultipleActionsActive.value ? 50 : 0;
24
+ return columnMultipleActionsWidth + columnActionsWidth.value;
25
+ });
21
26
 
22
27
  const tableWidth = ref(undefined);
23
28
  const aTableRef = ref(undefined);
@@ -63,7 +68,7 @@ export default function ScrollControlAPI(props, { emit }, {
63
68
  if (!modelIsTableWithoutScroll.value) {
64
69
  return;
65
70
  }
66
- const TABLE_WIDTH_WITHOUT_ACTIONS = tableWidth.value - columnActionsWidth.value;
71
+ const TABLE_WIDTH_WITHOUT_ACTIONS = tableWidth.value - columnsSpecialWidth.value;
67
72
 
68
73
  let columnsWidthInOrder = 0;
69
74
  let indexFirstScrollInvisibleColumnLocal = 0;
@@ -1,15 +1,23 @@
1
1
  import {
2
2
  computed,
3
+ ref,
3
4
  toRef,
4
5
  } from "vue";
5
6
 
7
+ import AConfirmAPI from "../../compositionAPI/AConfirmAPI";
8
+
6
9
  import {
7
10
  cloneDeep,
8
11
  filter,
9
12
  forEach,
10
13
  } from "lodash-es";
11
14
 
12
- export default function TableActionsAPI(props) {
15
+ export default function TableActionsAPI(props, { emit }) {
16
+ const {
17
+ closeConfirm,
18
+ openConfirm,
19
+ } = AConfirmAPI();
20
+
13
21
  const tableActions = toRef(props, "tableActions");
14
22
 
15
23
  const tableActionFiltered = computed(() => {
@@ -34,7 +42,57 @@ export default function TableActionsAPI(props) {
34
42
  return TABLE_ACTIONS;
35
43
  });
36
44
 
45
+ const multipleActions = toRef(props, "multipleActions");
46
+ const multipleActionsFiltered = computed(() => {
47
+ return filter(multipleActions.value, action => {
48
+ return !action.isHidden;
49
+ });
50
+ });
51
+
52
+ const isMultipleActionsFiltered = computed(() => {
53
+ return multipleActionsFiltered.value.length > 0;
54
+ });
55
+
56
+ const currentMultipleActions = ref(undefined);
57
+
58
+ const onClickMultipleActions = ({ action }) => {
59
+ emit("toggleMultipleActionsActive");
60
+ currentMultipleActions.value = action;
61
+ };
62
+
63
+ const onCancelMultipleActions = () => {
64
+ emit("toggleMultipleActionsActive");
65
+ currentMultipleActions.value = undefined;
66
+ };
67
+
68
+ const closeMultipleActionsActive = toRef(props, "closeMultipleActionsActive");
69
+ const selectedRows = toRef(props, "selectedRows");
70
+
71
+ const onStartModalMultipleActions = async() => {
72
+ await currentMultipleActions.value.callback({ rows: selectedRows.value });
73
+ closeConfirm();
74
+ onCancelMultipleActions();
75
+ };
76
+
77
+ const onOpenModalMultipleActions = () => {
78
+ if (currentMultipleActions.value.isConfirm) {
79
+ openConfirm({
80
+ headerText: "Mehrfachaktion durchführen?",
81
+ bodyHtml: `<div>Möchten Sie die Aktion <strong>${ currentMultipleActions.value.label }</strong> auf <strong>${ selectedRows.value.length }</strong> Objekten durchführen?</div>`,
82
+ save: onStartModalMultipleActions,
83
+ });
84
+ } else {
85
+ currentMultipleActions.value.callback({ close: closeMultipleActionsActive.value, rows: selectedRows.value });
86
+ }
87
+ };
88
+
37
89
  return {
90
+ currentMultipleActions,
91
+ isMultipleActionsFiltered,
92
+ multipleActionsFiltered,
93
+ onCancelMultipleActions,
94
+ onClickMultipleActions,
95
+ onOpenModalMultipleActions,
38
96
  tableActionFiltered,
39
97
  };
40
98
  }
@@ -43,7 +43,7 @@
43
43
  border-width: 0;
44
44
  }
45
45
  .a_table__cell {
46
- padding: var(--a_table_cell_padding_x) var(--a_table_cell_padding_y);
46
+ padding: var(--a_table_cell_padding_y) var(--a_table_cell_padding_x) ;
47
47
  background-color: var(--a_table_bg);
48
48
  border-bottom-width: 1px;
49
49
  .a_table__row_hover:hover &,
@@ -57,6 +57,9 @@
57
57
  background-color: var(--a_table_row_preview_focus_was_bg);
58
58
  }
59
59
  }
60
+ .a_table__cell_checkbox {
61
+ --a_table_cell_padding_x: 0;
62
+ }
60
63
 
61
64
  .a_table__empty_text {
62
65
  padding: var(--a_table_cell_padding_x) var(--a_table_cell_padding_y);
@@ -27,6 +27,10 @@ export default {
27
27
  type: Boolean,
28
28
  required: false,
29
29
  },
30
+ indeterminate: {
31
+ type: Boolean,
32
+ required: false,
33
+ },
30
34
  },
31
35
  setup(props, context) {
32
36
  const {
@@ -61,14 +65,14 @@ export default {
61
65
  $event,
62
66
  });
63
67
  });
68
+ $event.stopPropagation();
69
+ $event.preventDefault();
64
70
  };
65
71
 
66
72
  const onKeydown = $event => {
67
73
  if ($event.key === "Enter" ||
68
74
  $event.keyCode === KEY_CODE_SPACE) {
69
75
  onClick($event);
70
- $event.stopPropagation();
71
- $event.preventDefault();
72
76
  }
73
77
  };
74
78
 
@@ -113,6 +117,7 @@ export default {
113
117
  ariaRequired: this.required,
114
118
  ariaInvalid: this.isErrors,
115
119
  "aria-describedby": this.ariaDescribedbyLocal,
120
+ indeterminate: this.indeterminate,
116
121
  ...this.inputAttributes,
117
122
  onClick: this.onClick,
118
123
  onKeydown: this.onKeydown,