aloha-vue 1.0.320 → 1.0.322
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/docs/package.json +2 -3
- package/docs/src/main.js +1 -2
- package/docs/src/views/PageTable/PageTable.js +16 -1
- package/package.json +1 -1
- package/src/AInfiniteScroll/AInfiniteScroll.js +74 -0
- package/src/AInfiniteScroll/compositionAPI/ObserverAPI.js +61 -0
- package/src/ATable/ATable.js +48 -31
- package/src/ATable/ATableHeaderThAction/ATableHeaderThActionItem.js +1 -0
- package/src/ATable/ATableListItem/ATableListItem.js +50 -31
- package/src/ATable/ATableTd/ATableTd.js +37 -125
- package/src/ATable/ATableTd/compositionAPI/LinkAPI.js +59 -0
- package/src/ATable/ATableTd/compositionAPI/MobileAPI.js +21 -0
- package/src/ATable/ATableTd/compositionAPI/SlotAPI.js +25 -0
- package/src/ATable/ATableTd/compositionAPI/TextAPI.js +126 -0
- package/src/ATable/ATableTopPanel/compositionAPI/ActionsAPI.js +3 -3
- package/src/ATable/ATableTr/ATableTr.js +2 -0
- package/src/ATable/compositionAPI/MultipleActionAPI.js +3 -3
- package/src/ATable/compositionAPI/PreviewAPI.js +4 -4
- package/src/ATable/compositionAPI/RowsAPI.js +37 -5
- package/src/compositionAPI/AHttpAPI.js +36 -4
package/docs/package.json
CHANGED
package/docs/src/main.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import App from "./App/App.vue";
|
|
2
2
|
import { createApp } from "vue";
|
|
3
|
-
import store from "./store/index";
|
|
4
3
|
import router from "./router/index";
|
|
5
4
|
import AI18nPlugin from "../../src/plugins/AI18nPlugin";
|
|
6
5
|
import AMobilePlugin from "../../src/plugins/AMobilePlugin";
|
|
@@ -36,4 +35,4 @@ APP.use(AGroupButtonDropdownPlugin, {
|
|
|
36
35
|
});
|
|
37
36
|
APP.config.unwrapInjectedRef = true;
|
|
38
37
|
APP.directive("SafeHtml", ASafeHtml);
|
|
39
|
-
APP.use(
|
|
38
|
+
APP.use(router).mount("#app");
|
|
@@ -85,7 +85,7 @@ export default {
|
|
|
85
85
|
{
|
|
86
86
|
label: "Test",
|
|
87
87
|
id: "test",
|
|
88
|
-
|
|
88
|
+
keyLabelSafeHtml: "test",
|
|
89
89
|
sortId: "test",
|
|
90
90
|
width: 200,
|
|
91
91
|
},
|
|
@@ -121,6 +121,20 @@ export default {
|
|
|
121
121
|
slot: "slot1",
|
|
122
122
|
hide: true,
|
|
123
123
|
},
|
|
124
|
+
{
|
|
125
|
+
label: "safeHtml",
|
|
126
|
+
id: "safeHtml",
|
|
127
|
+
keyLabelSafeHtml: "test",
|
|
128
|
+
sortId: "test",
|
|
129
|
+
width: 200,
|
|
130
|
+
},
|
|
131
|
+
{
|
|
132
|
+
label: "html",
|
|
133
|
+
id: "html",
|
|
134
|
+
keyLabelHtml: "test",
|
|
135
|
+
sortId: "test",
|
|
136
|
+
width: 200,
|
|
137
|
+
},
|
|
124
138
|
],
|
|
125
139
|
rowsFooter: [
|
|
126
140
|
{
|
|
@@ -424,6 +438,7 @@ export default {
|
|
|
424
438
|
const DATA = [];
|
|
425
439
|
times(1001, item => {
|
|
426
440
|
DATA.push({
|
|
441
|
+
id: item,
|
|
427
442
|
number: +item,
|
|
428
443
|
aloha: `aloha1111dfdsfdsfdsfaasasadadsadasdsadsa1111111${ item }`,
|
|
429
444
|
hola: `hola ${ item }`,
|
package/package.json
CHANGED
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import {
|
|
2
|
+
h,
|
|
3
|
+
onBeforeUnmount,
|
|
4
|
+
onMounted,
|
|
5
|
+
} from "vue";
|
|
6
|
+
|
|
7
|
+
import ObserverAPI from "./compositionAPI/ObserverAPI";
|
|
8
|
+
|
|
9
|
+
export default {
|
|
10
|
+
name: "AInfiniteScroll",
|
|
11
|
+
props: {
|
|
12
|
+
callback: {
|
|
13
|
+
type: Function,
|
|
14
|
+
required: true,
|
|
15
|
+
},
|
|
16
|
+
disabled: {
|
|
17
|
+
type: Boolean,
|
|
18
|
+
required: false,
|
|
19
|
+
},
|
|
20
|
+
rootMargin: {
|
|
21
|
+
type: String,
|
|
22
|
+
required: false,
|
|
23
|
+
default: "300px",
|
|
24
|
+
},
|
|
25
|
+
sentinelTag: {
|
|
26
|
+
type: String,
|
|
27
|
+
required: false,
|
|
28
|
+
default: "span",
|
|
29
|
+
},
|
|
30
|
+
tag: {
|
|
31
|
+
type: String,
|
|
32
|
+
required: false,
|
|
33
|
+
default: "div",
|
|
34
|
+
},
|
|
35
|
+
threshold: {
|
|
36
|
+
type: [Number, Array],
|
|
37
|
+
required: false,
|
|
38
|
+
default: 0.5,
|
|
39
|
+
},
|
|
40
|
+
},
|
|
41
|
+
setup(props) {
|
|
42
|
+
const {
|
|
43
|
+
disconnectObserver,
|
|
44
|
+
sentinelRef,
|
|
45
|
+
setIntersectionObserver,
|
|
46
|
+
setObserverOptions,
|
|
47
|
+
startObserver,
|
|
48
|
+
} = ObserverAPI(props);
|
|
49
|
+
|
|
50
|
+
onMounted(() => {
|
|
51
|
+
setObserverOptions();
|
|
52
|
+
setIntersectionObserver();
|
|
53
|
+
startObserver();
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
onBeforeUnmount(() => {
|
|
57
|
+
disconnectObserver();
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
return {
|
|
61
|
+
sentinelRef,
|
|
62
|
+
};
|
|
63
|
+
},
|
|
64
|
+
render() {
|
|
65
|
+
return h(this.tag, {}, [
|
|
66
|
+
this.$slots.default ? this.$slots.default() : null,
|
|
67
|
+
h(this.sentinelTag, {
|
|
68
|
+
ref: "sentinelRef",
|
|
69
|
+
style: "height: 1px; display: block;",
|
|
70
|
+
ariaHidden: true,
|
|
71
|
+
}),
|
|
72
|
+
]);
|
|
73
|
+
},
|
|
74
|
+
};
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ref,
|
|
3
|
+
toRef,
|
|
4
|
+
watch,
|
|
5
|
+
} from "vue";
|
|
6
|
+
|
|
7
|
+
export default function ObserverAPI(props) {
|
|
8
|
+
const callback = toRef(props, "callback");
|
|
9
|
+
const disabled = toRef(props, "disabled");
|
|
10
|
+
const rootMargin = toRef(props, "rootMargin");
|
|
11
|
+
const threshold = toRef(props, "threshold");
|
|
12
|
+
|
|
13
|
+
let observerOptions = {};
|
|
14
|
+
const sentinelRef = ref(undefined);
|
|
15
|
+
let intersectionObserver = undefined;
|
|
16
|
+
|
|
17
|
+
const setObserverOptions = () => {
|
|
18
|
+
observerOptions = {
|
|
19
|
+
rootMargin: rootMargin.value,
|
|
20
|
+
threshold: threshold.value,
|
|
21
|
+
};
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
const setIntersectionObserver = () => {
|
|
25
|
+
intersectionObserver = new IntersectionObserver(entries => {
|
|
26
|
+
const [entry] = entries;
|
|
27
|
+
if (entry.isIntersecting) {
|
|
28
|
+
callback.value();
|
|
29
|
+
}
|
|
30
|
+
}, observerOptions);
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
const startObserver = () => {
|
|
34
|
+
if (disabled.value) {
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
intersectionObserver.observe(sentinelRef.value);
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
const disconnectObserver = () => {
|
|
41
|
+
if (intersectionObserver) {
|
|
42
|
+
intersectionObserver.disconnect();
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
watch(disabled, newValue => {
|
|
47
|
+
if (newValue === true) {
|
|
48
|
+
startObserver();
|
|
49
|
+
} else {
|
|
50
|
+
disconnectObserver();
|
|
51
|
+
}
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
return {
|
|
55
|
+
disconnectObserver,
|
|
56
|
+
sentinelRef,
|
|
57
|
+
setIntersectionObserver,
|
|
58
|
+
setObserverOptions,
|
|
59
|
+
startObserver,
|
|
60
|
+
};
|
|
61
|
+
}
|
package/src/ATable/ATable.js
CHANGED
|
@@ -39,6 +39,7 @@ import ViewsAPI from "./compositionAPI/ViewsAPI";
|
|
|
39
39
|
import {
|
|
40
40
|
get,
|
|
41
41
|
isArray,
|
|
42
|
+
isInteger,
|
|
42
43
|
isNil,
|
|
43
44
|
isPlainObject,
|
|
44
45
|
uniqueId,
|
|
@@ -66,6 +67,11 @@ export default {
|
|
|
66
67
|
required: false,
|
|
67
68
|
default: 250,
|
|
68
69
|
},
|
|
70
|
+
keyId: {
|
|
71
|
+
type: String,
|
|
72
|
+
required: false,
|
|
73
|
+
default: "id",
|
|
74
|
+
},
|
|
69
75
|
countAllRows: {
|
|
70
76
|
type: Number,
|
|
71
77
|
required: false,
|
|
@@ -252,6 +258,12 @@ export default {
|
|
|
252
258
|
required: false,
|
|
253
259
|
default: undefined,
|
|
254
260
|
},
|
|
261
|
+
rowsCountRenderPerTick: {
|
|
262
|
+
type: Number,
|
|
263
|
+
required: false,
|
|
264
|
+
default: 25,
|
|
265
|
+
validator: value => isInteger(value) && value > 0,
|
|
266
|
+
},
|
|
255
267
|
rowsFooter: {
|
|
256
268
|
type: Array,
|
|
257
269
|
required: false,
|
|
@@ -373,6 +385,7 @@ export default {
|
|
|
373
385
|
limit,
|
|
374
386
|
offset,
|
|
375
387
|
rowsLocal,
|
|
388
|
+
rowsLocalAll,
|
|
376
389
|
rowsLocalLength,
|
|
377
390
|
} = RowsAPI(props, {
|
|
378
391
|
dataSorted,
|
|
@@ -423,7 +436,7 @@ export default {
|
|
|
423
436
|
} = MultipleActionAPI({
|
|
424
437
|
checkVisibleColumns,
|
|
425
438
|
isMultipleActionsActive,
|
|
426
|
-
|
|
439
|
+
rowsLocalAll,
|
|
427
440
|
rowsLocalLength,
|
|
428
441
|
});
|
|
429
442
|
|
|
@@ -449,8 +462,8 @@ export default {
|
|
|
449
462
|
togglePreviewResize,
|
|
450
463
|
} = PreviewAPI(props, context, {
|
|
451
464
|
aTableRef,
|
|
465
|
+
rowsLocalAll,
|
|
452
466
|
tableGrandparentRef,
|
|
453
|
-
rowsLocal,
|
|
454
467
|
});
|
|
455
468
|
|
|
456
469
|
const {
|
|
@@ -537,7 +550,7 @@ export default {
|
|
|
537
550
|
provide("previewRightRowIndex", previewRightRowIndex);
|
|
538
551
|
provide("previewRightRowIndexLast", previewRightRowIndexLast);
|
|
539
552
|
|
|
540
|
-
provide("
|
|
553
|
+
provide("rowsLocalAll", rowsLocalAll);
|
|
541
554
|
provide("modelColumnsVisibleLocal", modelColumnsVisibleLocal);
|
|
542
555
|
provide("onUpdateModelFilters", onUpdateModelFilters);
|
|
543
556
|
provide("updateDataKeyByIdFromFilter", updateDataKeyByIdFromFilter);
|
|
@@ -589,6 +602,7 @@ export default {
|
|
|
589
602
|
previewDownRowIndexes,
|
|
590
603
|
previewRightRowIndex,
|
|
591
604
|
rowsLocal,
|
|
605
|
+
rowsLocalAll,
|
|
592
606
|
rowsLocalLength,
|
|
593
607
|
selectedRows,
|
|
594
608
|
selectedRowsIndexes,
|
|
@@ -724,31 +738,34 @@ export default {
|
|
|
724
738
|
h("div", {
|
|
725
739
|
class: "a_table__body",
|
|
726
740
|
role: this.tableChildRole,
|
|
727
|
-
},
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
741
|
+
}, {
|
|
742
|
+
default: () => this.rowsLocal.map((row, rowIndex) => {
|
|
743
|
+
return h(ATableTr, {
|
|
744
|
+
key: row[this.keyId] || rowIndex,
|
|
745
|
+
allVisibleMobileColumns: this.allVisibleMobileColumns,
|
|
746
|
+
areAllRowsSelected: this.areAllRowsSelected,
|
|
747
|
+
countVisibleMobileColumns: this.countVisibleMobileColumns,
|
|
748
|
+
row,
|
|
749
|
+
rowIndex,
|
|
750
|
+
isRowActionsStickyLocal: this.isRowActionsStickyLocal,
|
|
751
|
+
selectedRowsIndexes: this.selectedRowsIndexes,
|
|
752
|
+
rowActionsClass: this.rowActionsClass,
|
|
753
|
+
onSetSelectedRowsIndexes: this.setSelectedRowsIndexes,
|
|
754
|
+
}, {
|
|
755
|
+
get: vm => [
|
|
756
|
+
h(AGet, {
|
|
757
|
+
data: vm.row,
|
|
758
|
+
keyLabel: vm.column.keyLabel,
|
|
759
|
+
filter: vm.column.filter,
|
|
760
|
+
filterParameters: vm.column.filterParameters,
|
|
761
|
+
defaultValue: vm.column.defaultValue,
|
|
762
|
+
tag: vm.column.filterTag || "div",
|
|
763
|
+
}),
|
|
764
|
+
],
|
|
765
|
+
...this.$slots,
|
|
766
|
+
});
|
|
767
|
+
})
|
|
768
|
+
}),
|
|
752
769
|
(this.hasRows && this.hasRowsFooter) && h("div", {
|
|
753
770
|
class: "a_table__footer",
|
|
754
771
|
role: this.tableChildRole,
|
|
@@ -780,7 +797,7 @@ export default {
|
|
|
780
797
|
]),
|
|
781
798
|
(!this.isViewTableVisible && this.viewCurrent && this.$slots[this.viewCurrent.type]) &&
|
|
782
799
|
this.$slots[this.viewCurrent.type]({
|
|
783
|
-
rows: this.
|
|
800
|
+
rows: this.rowsLocalAll,
|
|
784
801
|
}),
|
|
785
802
|
(this.isViewTableVisible && !this.hasRows) && h("div", {
|
|
786
803
|
class: "a_table__empty_text",
|
|
@@ -794,7 +811,7 @@ export default {
|
|
|
794
811
|
isLoadingTable: this.isLoadingTable,
|
|
795
812
|
limit: this.limit,
|
|
796
813
|
offset: this.offset,
|
|
797
|
-
rowsLength: this.
|
|
814
|
+
rowsLength: this.rowsLocalLength,
|
|
798
815
|
hasRows: this.hasRows,
|
|
799
816
|
perPageView: this.perPageView,
|
|
800
817
|
isMobile: this.isMobile,
|
|
@@ -812,7 +829,7 @@ export default {
|
|
|
812
829
|
]),
|
|
813
830
|
this.isPreviewRightOpen && h(ATablePreviewRight, {
|
|
814
831
|
rowIndex: this.previewRightRowIndex,
|
|
815
|
-
rows: this.
|
|
832
|
+
rows: this.rowsLocalAll,
|
|
816
833
|
previewHeaderTag: this.previewHeaderTag,
|
|
817
834
|
onClosePreview: this.closePreview,
|
|
818
835
|
onMousedownResizePreviewRight: this.mousedownResizePreviewRight,
|
|
@@ -193,6 +193,7 @@ export default {
|
|
|
193
193
|
methods: {
|
|
194
194
|
toggleColumnVisible($event) {
|
|
195
195
|
$event.stopPropagation();
|
|
196
|
+
$event.preventDefault();
|
|
196
197
|
const MODEL_COLUMNS = cloneDeep(this.modelColumnsVisibleLocal);
|
|
197
198
|
MODEL_COLUMNS[this.columnId] = !this.isColumnVisible;
|
|
198
199
|
this.changeModelColumnsVisible(MODEL_COLUMNS);
|
|
@@ -1,15 +1,17 @@
|
|
|
1
1
|
import {
|
|
2
|
-
h,
|
|
2
|
+
h, resolveComponent,
|
|
3
3
|
} from "vue";
|
|
4
4
|
|
|
5
5
|
import ATranslation from "../../ATranslation/ATranslation";
|
|
6
6
|
|
|
7
|
-
import
|
|
7
|
+
import TextAPI from "../ATableTd/compositionAPI/TextAPI";
|
|
8
|
+
import SlotAPI from "../ATableTd/compositionAPI/SlotAPI";
|
|
9
|
+
import LinkAPI from "../ATableTd/compositionAPI/LinkAPI";
|
|
8
10
|
|
|
9
11
|
export default {
|
|
10
12
|
name: "ATableListItem",
|
|
11
13
|
inject: [
|
|
12
|
-
"
|
|
14
|
+
"rowsLocalAll",
|
|
13
15
|
],
|
|
14
16
|
props: {
|
|
15
17
|
column: {
|
|
@@ -33,24 +35,30 @@ export default {
|
|
|
33
35
|
required: false,
|
|
34
36
|
},
|
|
35
37
|
},
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
38
|
+
setup(props) {
|
|
39
|
+
const {
|
|
40
|
+
classForLink,
|
|
41
|
+
isLink,
|
|
42
|
+
toLocal,
|
|
43
|
+
} = LinkAPI(props);
|
|
40
44
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
return this.column.slot;
|
|
46
|
-
},
|
|
45
|
+
const {
|
|
46
|
+
hasSlot,
|
|
47
|
+
slotName,
|
|
48
|
+
} = SlotAPI(props);
|
|
47
49
|
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
50
|
+
const {
|
|
51
|
+
textOrHtmlRender,
|
|
52
|
+
} = TextAPI(props);
|
|
53
|
+
|
|
54
|
+
return {
|
|
55
|
+
classForLink,
|
|
56
|
+
hasSlot,
|
|
57
|
+
isLink,
|
|
58
|
+
slotName,
|
|
59
|
+
textOrHtmlRender,
|
|
60
|
+
toLocal,
|
|
61
|
+
};
|
|
54
62
|
},
|
|
55
63
|
render() {
|
|
56
64
|
return [
|
|
@@ -58,19 +66,30 @@ export default {
|
|
|
58
66
|
text: this.column.label,
|
|
59
67
|
tag: "dt",
|
|
60
68
|
}),
|
|
61
|
-
h("dd", null, [
|
|
62
|
-
this.
|
|
63
|
-
this
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
69
|
+
h("dd", null, (this.hasSlot && this.$slots[this.slotName]) ?
|
|
70
|
+
this.$slots[this.slotName]({
|
|
71
|
+
column: this.column,
|
|
72
|
+
columnIndex: this.columnIndex,
|
|
73
|
+
row: this.row,
|
|
74
|
+
rowIndex: this.rowIndex,
|
|
75
|
+
rows: this.rowsLocalAll,
|
|
76
|
+
}) :
|
|
77
|
+
(this.isLink && this.toLocal) ?
|
|
78
|
+
[
|
|
79
|
+
h(resolveComponent("RouterLink"), {
|
|
80
|
+
class: [
|
|
81
|
+
this.column.class,
|
|
82
|
+
this.classForLink,
|
|
83
|
+
this.column.classRow,
|
|
84
|
+
],
|
|
85
|
+
to: this.toLocal,
|
|
86
|
+
}, () => [
|
|
87
|
+
this.textOrHtmlRender,
|
|
88
|
+
]),
|
|
89
|
+
] :
|
|
90
|
+
[
|
|
91
|
+
this.textOrHtmlRender,
|
|
72
92
|
])
|
|
73
|
-
]),
|
|
74
93
|
];
|
|
75
94
|
},
|
|
76
95
|
};
|
|
@@ -1,27 +1,16 @@
|
|
|
1
1
|
import {
|
|
2
|
-
computed,
|
|
3
2
|
h,
|
|
4
|
-
inject,
|
|
5
3
|
resolveComponent,
|
|
6
|
-
withDirectives,
|
|
7
4
|
} from "vue";
|
|
8
5
|
|
|
9
6
|
import ATranslation from "../../ATranslation/ATranslation";
|
|
10
7
|
|
|
11
|
-
import ASafeHtml from "../../directives/ASafeHtml";
|
|
12
|
-
|
|
13
8
|
import AttributesAPI from "./compositionAPI/AttributesAPI";
|
|
14
9
|
import ColumnVisibleAPI from "../compositionAPI/ColumnVisibleAPI";
|
|
15
|
-
|
|
16
|
-
import
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
get,
|
|
20
|
-
isPlainObject,
|
|
21
|
-
isString,
|
|
22
|
-
isUndefined,
|
|
23
|
-
} from "lodash-es";
|
|
24
|
-
|
|
10
|
+
import LinkAPI from "./compositionAPI/LinkAPI";
|
|
11
|
+
import MobileAPI from "./compositionAPI/MobileAPI";
|
|
12
|
+
import SlotAPI from "./compositionAPI/SlotAPI";
|
|
13
|
+
import TextAPI from "./compositionAPI/TextAPI";
|
|
25
14
|
|
|
26
15
|
export default {
|
|
27
16
|
name: "ATableTd",
|
|
@@ -48,16 +37,10 @@ export default {
|
|
|
48
37
|
},
|
|
49
38
|
},
|
|
50
39
|
inject: [
|
|
51
|
-
"columnsDefaultValue",
|
|
52
|
-
"hasPreview",
|
|
53
40
|
"isMobile",
|
|
54
|
-
"
|
|
55
|
-
"rowsLocal",
|
|
56
|
-
"valuesForColumnDefault",
|
|
41
|
+
"rowsLocalAll",
|
|
57
42
|
],
|
|
58
43
|
setup(props) {
|
|
59
|
-
const isMobile = inject("isMobile");
|
|
60
|
-
|
|
61
44
|
const {
|
|
62
45
|
attributesForTd,
|
|
63
46
|
} = AttributesAPI(props);
|
|
@@ -66,110 +49,43 @@ export default {
|
|
|
66
49
|
isColumnVisible,
|
|
67
50
|
} = ColumnVisibleAPI(props);
|
|
68
51
|
|
|
69
|
-
const
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
52
|
+
const {
|
|
53
|
+
classForLink,
|
|
54
|
+
isLink,
|
|
55
|
+
toLocal,
|
|
56
|
+
} = LinkAPI(props);
|
|
57
|
+
|
|
58
|
+
const {
|
|
59
|
+
hasSlot,
|
|
60
|
+
slotName,
|
|
61
|
+
} = SlotAPI(props);
|
|
62
|
+
|
|
63
|
+
const {
|
|
64
|
+
textOrHtmlRender,
|
|
65
|
+
} = TextAPI(props);
|
|
66
|
+
|
|
67
|
+
const {
|
|
68
|
+
styleMobile,
|
|
69
|
+
} = MobileAPI({
|
|
70
|
+
isColumnVisible,
|
|
74
71
|
});
|
|
75
72
|
|
|
76
73
|
return {
|
|
77
|
-
styleMobile,
|
|
78
74
|
attributesForTd,
|
|
75
|
+
classForLink,
|
|
76
|
+
hasSlot,
|
|
77
|
+
isLink,
|
|
78
|
+
slotName,
|
|
79
|
+
styleMobile,
|
|
80
|
+
textOrHtmlRender,
|
|
81
|
+
toLocal,
|
|
79
82
|
};
|
|
80
83
|
},
|
|
81
|
-
computed: {
|
|
82
|
-
text() {
|
|
83
|
-
let text;
|
|
84
|
-
if (this.isFooter) {
|
|
85
|
-
text = get(this.row, this.column.footerKeyLabel);
|
|
86
|
-
} else {
|
|
87
|
-
text = get(this.row, this.column.keyLabel);
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
let isTextInValuesForColumnDefault = false;
|
|
91
|
-
forEach(this.valuesForColumnDefault, item => {
|
|
92
|
-
if (text === item) {
|
|
93
|
-
isTextInValuesForColumnDefault = true;
|
|
94
|
-
return false;
|
|
95
|
-
}
|
|
96
|
-
});
|
|
97
|
-
if (isTextInValuesForColumnDefault) {
|
|
98
|
-
return this.defaultValue;
|
|
99
|
-
}
|
|
100
|
-
return text;
|
|
101
|
-
},
|
|
102
|
-
|
|
103
|
-
defaultValue() {
|
|
104
|
-
if (this.isFooter && "footerDefaultValue" in this.column) {
|
|
105
|
-
return this.column.footerDefaultValue;
|
|
106
|
-
}
|
|
107
|
-
if ("defaultValue" in this.column) {
|
|
108
|
-
return this.column.defaultValue;
|
|
109
|
-
}
|
|
110
|
-
if (!isUndefined(this.columnsDefaultValue)) {
|
|
111
|
-
return this.columnsDefaultValue;
|
|
112
|
-
}
|
|
113
|
-
return "";
|
|
114
|
-
},
|
|
115
|
-
|
|
116
|
-
path() {
|
|
117
|
-
if (this.isFooter) {
|
|
118
|
-
return this.column.footerKeyLabel;
|
|
119
|
-
}
|
|
120
|
-
return this.column.keyLabel;
|
|
121
|
-
},
|
|
122
|
-
|
|
123
|
-
isSlot() {
|
|
124
|
-
return !!this.slot;
|
|
125
|
-
},
|
|
126
|
-
|
|
127
|
-
isLink() {
|
|
128
|
-
return !!this.column.to;
|
|
129
|
-
},
|
|
130
|
-
|
|
131
|
-
toLocal() {
|
|
132
|
-
if (isString(this.column.to)) {
|
|
133
|
-
return this.column.to;
|
|
134
|
-
}
|
|
135
|
-
if (isPlainObject(this.column.to)) {
|
|
136
|
-
const TO = cloneDeep(this.column.to);
|
|
137
|
-
const PARAMS = TO.params || {};
|
|
138
|
-
if (this.column.to.paramsDynamic) {
|
|
139
|
-
let hasParamsDynamicError = false;
|
|
140
|
-
forEach(this.column.to.paramsDynamic, (value, key) => {
|
|
141
|
-
const PARAMS_VALUE = get(this.row, value);
|
|
142
|
-
if (isUndefined(PARAMS_VALUE)) {
|
|
143
|
-
hasParamsDynamicError = true;
|
|
144
|
-
return false;
|
|
145
|
-
}
|
|
146
|
-
PARAMS[key] = PARAMS_VALUE;
|
|
147
|
-
});
|
|
148
|
-
if (hasParamsDynamicError) {
|
|
149
|
-
return undefined;
|
|
150
|
-
}
|
|
151
|
-
}
|
|
152
|
-
TO.params = PARAMS;
|
|
153
|
-
return TO;
|
|
154
|
-
}
|
|
155
|
-
return undefined;
|
|
156
|
-
},
|
|
157
|
-
|
|
158
|
-
classForLink() {
|
|
159
|
-
return "a_btn a_btn_link a_p_0 a_text_left";
|
|
160
|
-
},
|
|
161
|
-
|
|
162
|
-
slot() {
|
|
163
|
-
if (this.isFooter) {
|
|
164
|
-
return this.column.footerSlot;
|
|
165
|
-
}
|
|
166
|
-
return this.column.slot;
|
|
167
|
-
},
|
|
168
|
-
},
|
|
169
84
|
render() {
|
|
170
85
|
if (this.column.isRender === false) {
|
|
171
86
|
return "";
|
|
172
87
|
}
|
|
88
|
+
|
|
173
89
|
const TD = h(
|
|
174
90
|
"div",
|
|
175
91
|
this.attributesForTd,
|
|
@@ -180,13 +96,13 @@ export default {
|
|
|
180
96
|
this.column.class,
|
|
181
97
|
this.column.classRow,
|
|
182
98
|
],
|
|
183
|
-
}, (this.
|
|
184
|
-
this.$slots[this.
|
|
99
|
+
}, (this.hasSlot && this.$slots[this.slotName]) ?
|
|
100
|
+
this.$slots[this.slotName]({
|
|
185
101
|
column: this.column,
|
|
186
102
|
columnIndex: this.columnIndex,
|
|
187
103
|
row: this.row,
|
|
188
104
|
rowIndex: this.rowIndex,
|
|
189
|
-
rows: this.
|
|
105
|
+
rows: this.rowsLocalAll,
|
|
190
106
|
}) :
|
|
191
107
|
(this.isLink && this.toLocal) ?
|
|
192
108
|
[
|
|
@@ -198,15 +114,11 @@ export default {
|
|
|
198
114
|
],
|
|
199
115
|
to: this.toLocal,
|
|
200
116
|
}, () => [
|
|
201
|
-
|
|
202
|
-
[ASafeHtml, this.text],
|
|
203
|
-
]),
|
|
117
|
+
this.textOrHtmlRender,
|
|
204
118
|
]),
|
|
205
119
|
] :
|
|
206
120
|
[
|
|
207
|
-
|
|
208
|
-
[ASafeHtml, this.text],
|
|
209
|
-
]),
|
|
121
|
+
this.textOrHtmlRender,
|
|
210
122
|
])
|
|
211
123
|
]
|
|
212
124
|
);
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import {
|
|
2
|
+
computed,
|
|
3
|
+
toRef,
|
|
4
|
+
} from "vue";
|
|
5
|
+
|
|
6
|
+
import {
|
|
7
|
+
cloneDeep,
|
|
8
|
+
forEach,
|
|
9
|
+
get,
|
|
10
|
+
isPlainObject,
|
|
11
|
+
isString,
|
|
12
|
+
isUndefined,
|
|
13
|
+
} from "lodash-es";
|
|
14
|
+
|
|
15
|
+
export default function LinkAPI(props) {
|
|
16
|
+
const column = toRef(props, "column");
|
|
17
|
+
const row = toRef(props, "row");
|
|
18
|
+
|
|
19
|
+
const isLink = computed(() => {
|
|
20
|
+
return !!column.value.to;
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
const toLocal = computed(() => {
|
|
24
|
+
if (isString(column.value.to)) {
|
|
25
|
+
return column.value.to;
|
|
26
|
+
}
|
|
27
|
+
if (isPlainObject(column.value.to)) {
|
|
28
|
+
const TO = cloneDeep(column.value.to);
|
|
29
|
+
const PARAMS = TO.params || {};
|
|
30
|
+
if (column.value.to.paramsDynamic) {
|
|
31
|
+
let hasParamsDynamicError = false;
|
|
32
|
+
forEach(column.value.to.paramsDynamic, (value, key) => {
|
|
33
|
+
const PARAMS_VALUE = get(row.value, value);
|
|
34
|
+
if (isUndefined(PARAMS_VALUE)) {
|
|
35
|
+
hasParamsDynamicError = true;
|
|
36
|
+
return false;
|
|
37
|
+
}
|
|
38
|
+
PARAMS[key] = PARAMS_VALUE;
|
|
39
|
+
});
|
|
40
|
+
if (hasParamsDynamicError) {
|
|
41
|
+
return undefined;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
TO.params = PARAMS;
|
|
45
|
+
return TO;
|
|
46
|
+
}
|
|
47
|
+
return undefined;
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
const classForLink = computed(() => {
|
|
51
|
+
return "a_btn a_btn_link a_p_0 a_text_left";
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
return {
|
|
55
|
+
classForLink,
|
|
56
|
+
isLink,
|
|
57
|
+
toLocal,
|
|
58
|
+
};
|
|
59
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import {
|
|
2
|
+
computed,
|
|
3
|
+
inject,
|
|
4
|
+
} from "vue";
|
|
5
|
+
|
|
6
|
+
export default function MobileAPI({
|
|
7
|
+
isColumnVisible = computed(() => false),
|
|
8
|
+
}) {
|
|
9
|
+
const isMobile = inject("isMobile");
|
|
10
|
+
|
|
11
|
+
const styleMobile = computed(() => {
|
|
12
|
+
if (isMobile.value) {
|
|
13
|
+
return !isColumnVisible.value ? "display: none;" : "";
|
|
14
|
+
}
|
|
15
|
+
return "";
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
return {
|
|
19
|
+
styleMobile,
|
|
20
|
+
};
|
|
21
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import {
|
|
2
|
+
computed,
|
|
3
|
+
toRef,
|
|
4
|
+
} from "vue";
|
|
5
|
+
|
|
6
|
+
export default function SlotAPI(props) {
|
|
7
|
+
const column = toRef(props, "column");
|
|
8
|
+
const isFooter = toRef(props, "isFooter");
|
|
9
|
+
|
|
10
|
+
const slotName = computed(() => {
|
|
11
|
+
if (isFooter.value) {
|
|
12
|
+
return column.value.footerSlot;
|
|
13
|
+
}
|
|
14
|
+
return column.value.slot;
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
const hasSlot = computed(() => {
|
|
18
|
+
return !!slotName.value;
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
return {
|
|
22
|
+
hasSlot,
|
|
23
|
+
slotName,
|
|
24
|
+
};
|
|
25
|
+
}
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
import {
|
|
2
|
+
computed,
|
|
3
|
+
h,
|
|
4
|
+
inject,
|
|
5
|
+
toRef,
|
|
6
|
+
withDirectives,
|
|
7
|
+
} from "vue";
|
|
8
|
+
|
|
9
|
+
import ASafeHtml from "../../../directives/ASafeHtml";
|
|
10
|
+
|
|
11
|
+
import {
|
|
12
|
+
forEach,
|
|
13
|
+
get,
|
|
14
|
+
isUndefined,
|
|
15
|
+
} from "lodash-es";
|
|
16
|
+
|
|
17
|
+
export default function TextAPI(props) {
|
|
18
|
+
const column = toRef(props, "column");
|
|
19
|
+
const isFooter = toRef(props, "isFooter");
|
|
20
|
+
const row = toRef(props, "row");
|
|
21
|
+
|
|
22
|
+
const columnsDefaultValue = inject("columnsDefaultValue");
|
|
23
|
+
const valuesForColumnDefault = inject("valuesForColumnDefault");
|
|
24
|
+
|
|
25
|
+
const defaultValue = computed(() => {
|
|
26
|
+
if (isFooter.value && "footerDefaultValue" in column.value) {
|
|
27
|
+
return column.value.footerDefaultValue;
|
|
28
|
+
}
|
|
29
|
+
if ("defaultValue" in column.value) {
|
|
30
|
+
return column.value.defaultValue;
|
|
31
|
+
}
|
|
32
|
+
if (!isUndefined(columnsDefaultValue.value)) {
|
|
33
|
+
return columnsDefaultValue.value;
|
|
34
|
+
}
|
|
35
|
+
return "";
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
const textKeyLabel = computed(() => {
|
|
39
|
+
if (isFooter.value) {
|
|
40
|
+
return column.value.footerKeyLabel;
|
|
41
|
+
}
|
|
42
|
+
return column.value.keyLabel;
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
const safeHtmlKeyLabel = computed(() => {
|
|
46
|
+
if (isFooter.value) {
|
|
47
|
+
return column.value.footerKeyLabelSafeHtml;
|
|
48
|
+
}
|
|
49
|
+
return column.value.keyLabelSafeHtml;
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
const htmlKeyLabel = computed(() => {
|
|
53
|
+
if (isFooter.value) {
|
|
54
|
+
return column.value.footerKeyLabelHtml;
|
|
55
|
+
}
|
|
56
|
+
return column.value.keyLabelHtml;
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
const text = computed(() => {
|
|
60
|
+
if (textKeyLabel.value) {
|
|
61
|
+
return get(row.value, textKeyLabel.value);
|
|
62
|
+
}
|
|
63
|
+
return undefined;
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
const safeHtml = computed(() => {
|
|
67
|
+
if (safeHtmlKeyLabel.value) {
|
|
68
|
+
return get(row.value, safeHtmlKeyLabel.value);
|
|
69
|
+
}
|
|
70
|
+
return undefined;
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
const html = computed(() => {
|
|
74
|
+
if (htmlKeyLabel.value) {
|
|
75
|
+
return get(row.value, htmlKeyLabel.value);
|
|
76
|
+
}
|
|
77
|
+
return undefined;
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
const getTextWithDefault = textLocal => {
|
|
81
|
+
let isTextInValuesForColumnDefault = false;
|
|
82
|
+
forEach(valuesForColumnDefault.value, item => {
|
|
83
|
+
if (textLocal === item) {
|
|
84
|
+
isTextInValuesForColumnDefault = true;
|
|
85
|
+
return false;
|
|
86
|
+
}
|
|
87
|
+
});
|
|
88
|
+
if (isTextInValuesForColumnDefault) {
|
|
89
|
+
return defaultValue.value;
|
|
90
|
+
}
|
|
91
|
+
return textLocal;
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
const textWithDefault = computed(() => {
|
|
95
|
+
return getTextWithDefault(text.value);
|
|
96
|
+
});
|
|
97
|
+
|
|
98
|
+
const safeHtmlWithDefault = computed(() => {
|
|
99
|
+
return getTextWithDefault(safeHtml.value);
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
const htmlWithDefault = computed(() => {
|
|
103
|
+
return getTextWithDefault(html.value);
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
const textOrHtmlRender = computed(() => {
|
|
107
|
+
if (textKeyLabel.value) {
|
|
108
|
+
return h("span", null, textWithDefault.value);
|
|
109
|
+
}
|
|
110
|
+
if (safeHtmlKeyLabel.value) {
|
|
111
|
+
return h("span", {
|
|
112
|
+
innerHTML: safeHtmlWithDefault.value,
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
if (htmlKeyLabel.value) {
|
|
116
|
+
return withDirectives(h("span"), [
|
|
117
|
+
[ASafeHtml, htmlWithDefault.value],
|
|
118
|
+
]);
|
|
119
|
+
}
|
|
120
|
+
return undefined;
|
|
121
|
+
});
|
|
122
|
+
|
|
123
|
+
return {
|
|
124
|
+
textOrHtmlRender,
|
|
125
|
+
};
|
|
126
|
+
}
|
|
@@ -22,7 +22,7 @@ export default function ActionsAPI(props, { emit }) {
|
|
|
22
22
|
|
|
23
23
|
const tableId = inject("tableId");
|
|
24
24
|
const currentMultipleActions = inject("currentMultipleActions");
|
|
25
|
-
const
|
|
25
|
+
const rowsLocalAll = inject("rowsLocalAll");
|
|
26
26
|
|
|
27
27
|
const {
|
|
28
28
|
closeConfirm,
|
|
@@ -76,7 +76,7 @@ export default function ActionsAPI(props, { emit }) {
|
|
|
76
76
|
const onStartModalMultipleActions = async() => {
|
|
77
77
|
await currentMultipleActions.value.callback({
|
|
78
78
|
rows: selectedRows.value,
|
|
79
|
-
rowsVisible:
|
|
79
|
+
rowsVisible: rowsLocalAll.value,
|
|
80
80
|
id: buttonMultipleId.value,
|
|
81
81
|
areAllRowsSelected: areAllRowsSelected.value,
|
|
82
82
|
modelFilters: modelFilters.value,
|
|
@@ -97,7 +97,7 @@ export default function ActionsAPI(props, { emit }) {
|
|
|
97
97
|
currentMultipleActions.value.callback({
|
|
98
98
|
close: closeMultipleActionsActive.value,
|
|
99
99
|
rows: selectedRows.value,
|
|
100
|
-
rowsVisible:
|
|
100
|
+
rowsVisible: rowsLocalAll.value,
|
|
101
101
|
id: buttonMultipleId.value,
|
|
102
102
|
areAllRowsSelected: areAllRowsSelected.value,
|
|
103
103
|
modelFilters: modelFilters.value,
|
|
@@ -104,6 +104,7 @@ export default {
|
|
|
104
104
|
}
|
|
105
105
|
tds.push(
|
|
106
106
|
h(ATableTd, {
|
|
107
|
+
key: column.id,
|
|
107
108
|
column,
|
|
108
109
|
columnIndex,
|
|
109
110
|
row: this.row,
|
|
@@ -115,6 +116,7 @@ export default {
|
|
|
115
116
|
} else {
|
|
116
117
|
tds = this.columnsOrdered.map((column, columnIndex) => {
|
|
117
118
|
return h(ATableTd, {
|
|
119
|
+
key: column.id,
|
|
118
120
|
column,
|
|
119
121
|
columnIndex,
|
|
120
122
|
row: this.row,
|
|
@@ -14,7 +14,7 @@ import {
|
|
|
14
14
|
export default function MultipleActionAPI({
|
|
15
15
|
checkVisibleColumns = () => {},
|
|
16
16
|
isMultipleActionsActive = ref(undefined),
|
|
17
|
-
|
|
17
|
+
rowsLocalAll = computed(() => []),
|
|
18
18
|
rowsLocalLength = computed(() => 0),
|
|
19
19
|
}) {
|
|
20
20
|
const currentMultipleActions = ref(undefined);
|
|
@@ -26,7 +26,7 @@ export default function MultipleActionAPI({
|
|
|
26
26
|
});
|
|
27
27
|
|
|
28
28
|
const selectedRows = computed(() => {
|
|
29
|
-
return filter(
|
|
29
|
+
return filter(rowsLocalAll.value, (row, index) => {
|
|
30
30
|
return selectedRowsIndexes.value[index];
|
|
31
31
|
});
|
|
32
32
|
});
|
|
@@ -84,7 +84,7 @@ export default function MultipleActionAPI({
|
|
|
84
84
|
if (hasCurrentMultipleActionsIsHiddenCallback.value) {
|
|
85
85
|
times(rowsLocalLength.value, index => {
|
|
86
86
|
if (!currentMultipleActions.value.isHiddenCallback({
|
|
87
|
-
row:
|
|
87
|
+
row: rowsLocalAll.value[index],
|
|
88
88
|
rowIndex: index,
|
|
89
89
|
})) {
|
|
90
90
|
SELECTED_ROWS_INDEXES[index] = true;
|
|
@@ -17,8 +17,8 @@ import {
|
|
|
17
17
|
|
|
18
18
|
export default function PreviewAPI(props, context, {
|
|
19
19
|
aTableRef = ref({}),
|
|
20
|
+
rowsLocalAll = computed(() => []),
|
|
20
21
|
tableGrandparentRef = ref({}),
|
|
21
|
-
rowsLocal = computed(() => []),
|
|
22
22
|
}) {
|
|
23
23
|
const {
|
|
24
24
|
isDropdownGlobalOpen,
|
|
@@ -63,7 +63,7 @@ export default function PreviewAPI(props, context, {
|
|
|
63
63
|
rowIndex: previewRightRowIndex.value,
|
|
64
64
|
});
|
|
65
65
|
emit("togglePreview", {
|
|
66
|
-
row:
|
|
66
|
+
row: rowsLocalAll.value[previewRightRowIndex.value],
|
|
67
67
|
rowIndex: previewRightRowIndex.value,
|
|
68
68
|
typeToggle: "close",
|
|
69
69
|
});
|
|
@@ -73,7 +73,7 @@ export default function PreviewAPI(props, context, {
|
|
|
73
73
|
};
|
|
74
74
|
const closePreviewRightAll = () => {
|
|
75
75
|
emit("togglePreview", {
|
|
76
|
-
row:
|
|
76
|
+
row: rowsLocalAll.value[previewRightRowIndex.value],
|
|
77
77
|
rowIndex: previewRightRowIndex.value,
|
|
78
78
|
typeToggle: "close",
|
|
79
79
|
});
|
|
@@ -116,7 +116,7 @@ export default function PreviewAPI(props, context, {
|
|
|
116
116
|
addEventListenerWindowResize();
|
|
117
117
|
}
|
|
118
118
|
emit("togglePreview", {
|
|
119
|
-
row:
|
|
119
|
+
row: rowsLocalAll.value[rowIndex],
|
|
120
120
|
rowIndex: rowIndex,
|
|
121
121
|
typeToggle: "open",
|
|
122
122
|
});
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
computed,
|
|
3
3
|
ref,
|
|
4
|
-
toRef,
|
|
4
|
+
toRef, watch,
|
|
5
5
|
} from "vue";
|
|
6
6
|
|
|
7
7
|
import {
|
|
@@ -11,14 +11,18 @@ import {
|
|
|
11
11
|
export default function RowsAPI(props, {
|
|
12
12
|
dataSorted = computed(() => []),
|
|
13
13
|
}) {
|
|
14
|
+
const isPagination = toRef(props, "isPagination");
|
|
15
|
+
const isPaginationOutside = toRef(props, "isPaginationOutside");
|
|
14
16
|
const limitStart = toRef(props, "limitStart");
|
|
15
17
|
const offsetStart = toRef(props, "offsetStart");
|
|
18
|
+
const rowsCountRenderPerTick = toRef(props, "rowsCountRenderPerTick");
|
|
16
19
|
|
|
17
20
|
const limit = ref(limitStart.value);
|
|
18
21
|
const offset = ref(offsetStart.value);
|
|
22
|
+
const rowsLocal = ref([]);
|
|
23
|
+
let rowsLocalIndex = 0;
|
|
24
|
+
let rowsLocalInterval = undefined;
|
|
19
25
|
|
|
20
|
-
const isPaginationOutside = toRef(props, "isPaginationOutside");
|
|
21
|
-
const isPagination = toRef(props, "isPagination");
|
|
22
26
|
const dataPaginated = computed(() => {
|
|
23
27
|
if (limit.value && !isPaginationOutside.value && isPagination.value) {
|
|
24
28
|
const DATA_SORTED = cloneDeep(dataSorted.value);
|
|
@@ -29,23 +33,51 @@ export default function RowsAPI(props, {
|
|
|
29
33
|
return dataSorted.value;
|
|
30
34
|
});
|
|
31
35
|
|
|
32
|
-
const
|
|
36
|
+
const rowsLocalAll = computed(() => {
|
|
33
37
|
return dataPaginated.value;
|
|
34
38
|
});
|
|
35
39
|
|
|
36
40
|
const rowsLocalLength = computed(() => {
|
|
37
|
-
return
|
|
41
|
+
return rowsLocalAll.value.length;
|
|
38
42
|
});
|
|
39
43
|
|
|
40
44
|
const hasRows = computed(() => {
|
|
41
45
|
return !!rowsLocalLength.value;
|
|
42
46
|
});
|
|
43
47
|
|
|
48
|
+
const addRowsPartToRowsLocal = () => {
|
|
49
|
+
const INDEX_START = rowsLocalIndex * rowsCountRenderPerTick.value;
|
|
50
|
+
const INDEX_END = INDEX_START + rowsCountRenderPerTick.value;
|
|
51
|
+
rowsLocal.value.push(...dataPaginated.value.slice(INDEX_START, INDEX_END));
|
|
52
|
+
rowsLocalIndex++;
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
const addAllRowsToRowsLocal = () => {
|
|
56
|
+
rowsLocalInterval = setInterval(() => {
|
|
57
|
+
if (rowsLocalIndex * rowsCountRenderPerTick.value >= dataPaginated.value.length) {
|
|
58
|
+
clearInterval(rowsLocalInterval);
|
|
59
|
+
} else {
|
|
60
|
+
addRowsPartToRowsLocal();
|
|
61
|
+
}
|
|
62
|
+
});
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
watch(dataPaginated, () => {
|
|
66
|
+
rowsLocal.value = [];
|
|
67
|
+
rowsLocalIndex = 0;
|
|
68
|
+
clearInterval(rowsLocalInterval);
|
|
69
|
+
addRowsPartToRowsLocal();
|
|
70
|
+
addAllRowsToRowsLocal();
|
|
71
|
+
}, {
|
|
72
|
+
immediate: true,
|
|
73
|
+
});
|
|
74
|
+
|
|
44
75
|
return {
|
|
45
76
|
hasRows,
|
|
46
77
|
limit,
|
|
47
78
|
offset,
|
|
48
79
|
rowsLocal,
|
|
80
|
+
rowsLocalAll,
|
|
49
81
|
rowsLocalLength,
|
|
50
82
|
};
|
|
51
83
|
}
|
|
@@ -22,6 +22,7 @@ const HEADER_PARAMS = ref({});
|
|
|
22
22
|
const abortGroupController = {
|
|
23
23
|
_global: new AbortController(),
|
|
24
24
|
};
|
|
25
|
+
const abortGroupPending = {};
|
|
25
26
|
|
|
26
27
|
export function create({ axiosCreateOptions = {} }) {
|
|
27
28
|
API.value = axios.create(axiosCreateOptions);
|
|
@@ -54,6 +55,9 @@ export function abortHttp({
|
|
|
54
55
|
abortController.abort();
|
|
55
56
|
if (abortKey !== "_global") {
|
|
56
57
|
delete abortGroupController[abortKey];
|
|
58
|
+
if (abortGroupPending[abortGroup]) {
|
|
59
|
+
delete abortGroupPending[abortGroup];
|
|
60
|
+
}
|
|
57
61
|
}
|
|
58
62
|
});
|
|
59
63
|
} else if (abortGroup) {
|
|
@@ -71,6 +75,9 @@ export function abortHttp({
|
|
|
71
75
|
abortGroupController[abortKey].abort();
|
|
72
76
|
if (abortKey !== "_global") {
|
|
73
77
|
delete abortGroupController[abortKey];
|
|
78
|
+
if (abortGroupPending[abortGroup]) {
|
|
79
|
+
delete abortGroupPending[abortGroup];
|
|
80
|
+
}
|
|
74
81
|
}
|
|
75
82
|
}
|
|
76
83
|
});
|
|
@@ -356,10 +363,7 @@ export function callHttpRequestAndCheckSavedApi({
|
|
|
356
363
|
};
|
|
357
364
|
|
|
358
365
|
const signal = getAbortGroupSignal({ abortGroup, abortable });
|
|
359
|
-
|
|
360
|
-
// signal = getAbortGroupSignal({ abortGroup })
|
|
361
|
-
// signal = _abortController ? _abortController.signal : abortController.signal;
|
|
362
|
-
// }
|
|
366
|
+
setAbortGroupPendingCurrent({ abortGroup, abortable });
|
|
363
367
|
|
|
364
368
|
API.value({
|
|
365
369
|
method: methodHttp,
|
|
@@ -390,6 +394,10 @@ export function callHttpRequestAndCheckSavedApi({
|
|
|
390
394
|
return reject(error.response);
|
|
391
395
|
}
|
|
392
396
|
}
|
|
397
|
+
).finally(
|
|
398
|
+
() => {
|
|
399
|
+
removeAbortGroupCurrent({ abortGroup, abortable });
|
|
400
|
+
}
|
|
393
401
|
);
|
|
394
402
|
});
|
|
395
403
|
|
|
@@ -508,3 +516,27 @@ function getExcludeAbortGroup({ excludeAbortGroup }) {
|
|
|
508
516
|
}
|
|
509
517
|
return EXCLUDE_ABORT_GROUP_OBJ;
|
|
510
518
|
}
|
|
519
|
+
|
|
520
|
+
function setAbortGroupPendingCurrent({ abortGroup, abortable }) {
|
|
521
|
+
if (!abortable || !abortGroup) {
|
|
522
|
+
return;
|
|
523
|
+
}
|
|
524
|
+
if (abortGroupPending[abortGroup]) {
|
|
525
|
+
abortGroupPending[abortGroup]++;
|
|
526
|
+
} else {
|
|
527
|
+
abortGroupPending[abortGroup] = 1;
|
|
528
|
+
}
|
|
529
|
+
}
|
|
530
|
+
|
|
531
|
+
function removeAbortGroupCurrent({ abortGroup, abortable }) {
|
|
532
|
+
if (!abortable || !abortGroup) {
|
|
533
|
+
return;
|
|
534
|
+
}
|
|
535
|
+
if (abortGroupPending[abortGroup]) {
|
|
536
|
+
abortGroupPending[abortGroup]--;
|
|
537
|
+
}
|
|
538
|
+
if (abortGroupPending[abortGroup] === 0 && abortGroupController[abortGroup]) {
|
|
539
|
+
delete abortGroupPending[abortGroup];
|
|
540
|
+
delete abortGroupController[abortGroup];
|
|
541
|
+
}
|
|
542
|
+
}
|