@monoui/vuejs 1.1.17 → 1.1.20
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/dist/main.js +8 -8
- package/package.json +1 -1
- package/src/components/Table/Table.vue +184 -106
package/package.json
CHANGED
|
@@ -185,69 +185,73 @@
|
|
|
185
185
|
</div>
|
|
186
186
|
<slot name="pagination-seperator" />
|
|
187
187
|
<slot name="pagination">
|
|
188
|
-
<div class="
|
|
189
|
-
<
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
188
|
+
<div :class="paginationClass">
|
|
189
|
+
<div
|
|
190
|
+
class="d-flex justify-content-between align-items-center mt-2"
|
|
191
|
+
>
|
|
192
|
+
<slot name="pagination-filters">
|
|
193
|
+
<div>
|
|
194
|
+
<div v-show="!isDataEmpty">
|
|
195
|
+
<span>Show</span>
|
|
196
|
+
<b-dropdown
|
|
197
|
+
:text="itemPerPageText"
|
|
198
|
+
class="m-md-2"
|
|
199
|
+
size="sm"
|
|
200
|
+
variant="light"
|
|
201
201
|
>
|
|
202
|
-
<
|
|
203
|
-
|
|
204
|
-
@click="changeItemPerPage(perPage)"
|
|
202
|
+
<template
|
|
203
|
+
v-for="perPage in filteredPerPageValues"
|
|
205
204
|
>
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
v-if="inLimit()"
|
|
219
|
-
@click="
|
|
220
|
-
changeItemPerPage(
|
|
221
|
-
settings.totalItemCount
|
|
222
|
-
)
|
|
205
|
+
<b-dropdown-item
|
|
206
|
+
:key="'per-page-' + perPage"
|
|
207
|
+
@click="changeItemPerPage(perPage)"
|
|
208
|
+
>
|
|
209
|
+
{{ perPage }}
|
|
210
|
+
</b-dropdown-item>
|
|
211
|
+
</template>
|
|
212
|
+
<b-dropdown-divider
|
|
213
|
+
v-if="
|
|
214
|
+
filteredPerPageValues &&
|
|
215
|
+
filteredPerPageValues.length &&
|
|
216
|
+
inLimit()
|
|
223
217
|
"
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
218
|
+
/>
|
|
219
|
+
<template>
|
|
220
|
+
<b-dropdown-item
|
|
221
|
+
v-if="inLimit()"
|
|
222
|
+
@click="
|
|
223
|
+
changeItemPerPage(
|
|
224
|
+
settings.totalItemCount
|
|
225
|
+
)
|
|
226
|
+
"
|
|
227
|
+
>
|
|
228
|
+
All ({{ settings.totalItemCount }})
|
|
229
|
+
</b-dropdown-item>
|
|
230
|
+
</template>
|
|
231
|
+
</b-dropdown>
|
|
232
|
+
</div>
|
|
233
|
+
</div>
|
|
234
|
+
</slot>
|
|
235
|
+
<slot name="pagination-center" v-bind="settings">
|
|
236
|
+
<div>
|
|
237
|
+
<span v-show="!isDataEmpty">
|
|
238
|
+
{{ settings.totalItemCount }} rows
|
|
239
|
+
</span>
|
|
229
240
|
</div>
|
|
230
|
-
</
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
:total-rows="settings.totalItemCount"
|
|
245
|
-
:per-page="settings.itemPerPage"
|
|
246
|
-
@change="changePage"
|
|
247
|
-
v-bind="pagination"
|
|
248
|
-
/>
|
|
249
|
-
</div>
|
|
250
|
-
</slot>
|
|
241
|
+
</slot>
|
|
242
|
+
<slot name="pagination-buttons">
|
|
243
|
+
<div>
|
|
244
|
+
<b-pagination
|
|
245
|
+
v-if="settings.pageCount > 1"
|
|
246
|
+
v-model="settings.currentPage"
|
|
247
|
+
:total-rows="settings.totalItemCount"
|
|
248
|
+
:per-page="settings.itemPerPage"
|
|
249
|
+
@change="changePage"
|
|
250
|
+
v-bind="pagination"
|
|
251
|
+
/>
|
|
252
|
+
</div>
|
|
253
|
+
</slot>
|
|
254
|
+
</div>
|
|
251
255
|
</div>
|
|
252
256
|
</slot>
|
|
253
257
|
<slot name="footer" />
|
|
@@ -408,6 +412,16 @@ export default {
|
|
|
408
412
|
type: Number,
|
|
409
413
|
required: false,
|
|
410
414
|
default: 300
|
|
415
|
+
},
|
|
416
|
+
paginationClass: {
|
|
417
|
+
type: String,
|
|
418
|
+
required: false,
|
|
419
|
+
default: ""
|
|
420
|
+
},
|
|
421
|
+
perPage: {
|
|
422
|
+
type: Number,
|
|
423
|
+
required: false,
|
|
424
|
+
default: 10
|
|
411
425
|
}
|
|
412
426
|
},
|
|
413
427
|
watch: {
|
|
@@ -428,7 +442,8 @@ export default {
|
|
|
428
442
|
isDataEmpty: false,
|
|
429
443
|
isLoading: false,
|
|
430
444
|
limit: 250,
|
|
431
|
-
searchDebounceTimeout: null
|
|
445
|
+
searchDebounceTimeout: null,
|
|
446
|
+
initialSorting: []
|
|
432
447
|
};
|
|
433
448
|
},
|
|
434
449
|
computed: {
|
|
@@ -451,27 +466,43 @@ export default {
|
|
|
451
466
|
return this.settings.totalItemCount <= 0;
|
|
452
467
|
}
|
|
453
468
|
},
|
|
469
|
+
created() {
|
|
470
|
+
this.addPopStateListener();
|
|
471
|
+
},
|
|
454
472
|
async mounted() {
|
|
455
|
-
this.
|
|
456
|
-
|
|
457
|
-
this.settings.currentPage
|
|
458
|
-
);
|
|
459
|
-
this.settings.itemPerPage = this.getHistoryParameter(
|
|
460
|
-
"limit",
|
|
461
|
-
this.settings.itemPerPage
|
|
462
|
-
);
|
|
463
|
-
if (this.searchColumn) {
|
|
464
|
-
this.searchWord = this.getHistoryParameter(
|
|
465
|
-
`f-${this.searchColumn}`,
|
|
466
|
-
this.searchWord
|
|
467
|
-
);
|
|
468
|
-
}
|
|
469
|
-
this.loadHistoryFilters();
|
|
470
|
-
this.loadHistorySorting();
|
|
473
|
+
this.initialSorting = [...this.sorting];
|
|
474
|
+
this.loadHistory();
|
|
471
475
|
if (this.autoLoad) await this.getValues();
|
|
472
476
|
},
|
|
473
|
-
created() {},
|
|
474
477
|
methods: {
|
|
478
|
+
addPopStateListener() {
|
|
479
|
+
window.addEventListener("popstate", this.popStateEvent);
|
|
480
|
+
},
|
|
481
|
+
removePopStateListener() {
|
|
482
|
+
window.removeEventListener("popstate", this.popStateEvent);
|
|
483
|
+
},
|
|
484
|
+
async popStateEvent() {
|
|
485
|
+
this.loadHistory();
|
|
486
|
+
await this.getValues(false);
|
|
487
|
+
},
|
|
488
|
+
loadHistory() {
|
|
489
|
+
this.settings.currentPage = this.getHistoryParameter(
|
|
490
|
+
"page",
|
|
491
|
+
this.settings.currentPage
|
|
492
|
+
);
|
|
493
|
+
this.settings.itemPerPage = this.getHistoryParameter(
|
|
494
|
+
"limit",
|
|
495
|
+
this.perPage || this.settings.itemPerPage
|
|
496
|
+
);
|
|
497
|
+
if (this.searchColumn) {
|
|
498
|
+
this.searchWord = this.getHistoryParameter(
|
|
499
|
+
`f-${this.searchColumn}`,
|
|
500
|
+
""
|
|
501
|
+
);
|
|
502
|
+
}
|
|
503
|
+
this.loadHistoryFilters();
|
|
504
|
+
this.loadHistorySorting();
|
|
505
|
+
},
|
|
475
506
|
sortableIcon(column) {
|
|
476
507
|
const currentSort = this.sorting.find(x => x.Column === column);
|
|
477
508
|
if (!currentSort) {
|
|
@@ -522,7 +553,7 @@ export default {
|
|
|
522
553
|
row
|
|
523
554
|
);
|
|
524
555
|
},
|
|
525
|
-
async getValues() {
|
|
556
|
+
async getValues(addHistory = true) {
|
|
526
557
|
this.isLoading = true;
|
|
527
558
|
this.$emit("loading", this.isLoading);
|
|
528
559
|
const { currentPage, itemPerPage } = this.settings;
|
|
@@ -534,14 +565,30 @@ export default {
|
|
|
534
565
|
itemPerPage
|
|
535
566
|
);
|
|
536
567
|
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
this.
|
|
540
|
-
|
|
568
|
+
if (addHistory) {
|
|
569
|
+
let state = null;
|
|
570
|
+
this.clearHistoryParameters("f-");
|
|
571
|
+
for (const filter of this.filters) {
|
|
572
|
+
state = this.addHistoryParameter(
|
|
573
|
+
`f-${filter.Column}`,
|
|
574
|
+
filter.Value,
|
|
575
|
+
this.storage,
|
|
576
|
+
state,
|
|
577
|
+
false
|
|
578
|
+
);
|
|
579
|
+
}
|
|
541
580
|
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
581
|
+
this.clearHistoryParameters("s-");
|
|
582
|
+
for (const sort of this.sorting) {
|
|
583
|
+
state = this.addHistoryParameter(
|
|
584
|
+
`s-${sort.Column}`,
|
|
585
|
+
sort.Asc ? 1 : 0,
|
|
586
|
+
this.storage,
|
|
587
|
+
state,
|
|
588
|
+
false
|
|
589
|
+
);
|
|
590
|
+
}
|
|
591
|
+
this.replaceHistory(state);
|
|
545
592
|
}
|
|
546
593
|
|
|
547
594
|
if (!result || result.status !== 200) {
|
|
@@ -590,7 +637,7 @@ export default {
|
|
|
590
637
|
changePage(page) {
|
|
591
638
|
this.settings.currentPage = page;
|
|
592
639
|
this.addHistoryParameter("page", page);
|
|
593
|
-
this.getValues();
|
|
640
|
+
this.getValues(false);
|
|
594
641
|
},
|
|
595
642
|
changeItemPerPage(value) {
|
|
596
643
|
this.settings.itemPerPage = value;
|
|
@@ -626,12 +673,14 @@ export default {
|
|
|
626
673
|
return;
|
|
627
674
|
}
|
|
628
675
|
|
|
629
|
-
if (filter)
|
|
630
|
-
|
|
676
|
+
if (filter) {
|
|
677
|
+
filter.Value = value;
|
|
678
|
+
} else {
|
|
631
679
|
this.filters.push({
|
|
632
680
|
Column: column,
|
|
633
681
|
Value: value
|
|
634
682
|
});
|
|
683
|
+
}
|
|
635
684
|
this.getValues();
|
|
636
685
|
},
|
|
637
686
|
inLimit() {
|
|
@@ -647,7 +696,6 @@ export default {
|
|
|
647
696
|
storage = this.historyStorage
|
|
648
697
|
) {
|
|
649
698
|
if (!startsWith || !storage) return;
|
|
650
|
-
|
|
651
699
|
try {
|
|
652
700
|
const startsWithName = this.getHistoryName(startsWith);
|
|
653
701
|
|
|
@@ -795,42 +843,72 @@ export default {
|
|
|
795
843
|
|
|
796
844
|
if (filter && !value) {
|
|
797
845
|
this.filters.splice(this.filters.indexOf(filter), 1);
|
|
798
|
-
} else if (
|
|
799
|
-
filter
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
846
|
+
} else if (value) {
|
|
847
|
+
if (filter) {
|
|
848
|
+
filter.Value = value;
|
|
849
|
+
} else {
|
|
850
|
+
this.filters.push({
|
|
851
|
+
Column: column,
|
|
852
|
+
Value: value
|
|
853
|
+
});
|
|
854
|
+
}
|
|
805
855
|
}
|
|
806
856
|
}
|
|
807
857
|
},
|
|
808
858
|
loadHistorySorting() {
|
|
859
|
+
const latestSorting = [...this.initialSorting];
|
|
809
860
|
const parameters = this.getHistoryParameters("s-");
|
|
810
861
|
const trimName = this.getHistoryName("s-");
|
|
811
862
|
const names = Object.keys(parameters);
|
|
812
863
|
for (const paramName of names) {
|
|
813
|
-
|
|
864
|
+
var paramValue = parameters[paramName];
|
|
865
|
+
let value = undefined;
|
|
866
|
+
if (paramValue && paramValue === "1") value = true;
|
|
867
|
+
else if (paramValue && paramValue === "0") value = false;
|
|
814
868
|
const column = paramName.replace(trimName, "");
|
|
815
869
|
|
|
816
|
-
let sort =
|
|
870
|
+
let sort = latestSorting.find(x => x.Column === column);
|
|
817
871
|
|
|
818
|
-
if (
|
|
819
|
-
sort
|
|
820
|
-
|
|
821
|
-
|
|
872
|
+
if (value !== undefined) {
|
|
873
|
+
if (sort) {
|
|
874
|
+
sort.Value = value;
|
|
875
|
+
} else {
|
|
876
|
+
latestSorting.push({ Column: column, Asc: value });
|
|
877
|
+
}
|
|
822
878
|
}
|
|
823
879
|
}
|
|
880
|
+
this.sorting.length = 0;
|
|
881
|
+
for (const sort of latestSorting) {
|
|
882
|
+
this.sorting.push(sort);
|
|
883
|
+
}
|
|
884
|
+
},
|
|
885
|
+
replaceHistory(state, storage = this.historyStorage) {
|
|
886
|
+
if (!state) return;
|
|
887
|
+
if (storage === "query") {
|
|
888
|
+
window.history.pushState({ url: state.href }, "", state);
|
|
889
|
+
return;
|
|
890
|
+
}
|
|
824
891
|
},
|
|
825
|
-
addHistoryParameter(
|
|
892
|
+
addHistoryParameter(
|
|
893
|
+
name,
|
|
894
|
+
value,
|
|
895
|
+
storage = this.historyStorage,
|
|
896
|
+
state = null,
|
|
897
|
+
replace = true
|
|
898
|
+
) {
|
|
826
899
|
if (!this.history || !name || !storage) return;
|
|
827
|
-
|
|
828
900
|
try {
|
|
829
901
|
if (storage === "query") {
|
|
830
|
-
|
|
902
|
+
let url;
|
|
903
|
+
if (state) url = state;
|
|
904
|
+
else url = new URL(window.location);
|
|
831
905
|
const historyName = this.getHistoryName(name);
|
|
832
906
|
url.searchParams.set(historyName, value);
|
|
833
|
-
|
|
907
|
+
if (!replace) {
|
|
908
|
+
state = url;
|
|
909
|
+
return state;
|
|
910
|
+
}
|
|
911
|
+
window.history.pushState({ url: url.href }, "", url.href);
|
|
834
912
|
return;
|
|
835
913
|
}
|
|
836
914
|
|