@monoui/vuejs 1.1.19 → 1.1.22
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 +4 -4
- package/package.json +2 -1
- package/src/components/Table/Table.vue +116 -63
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@monoui/vuejs",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.22",
|
|
4
4
|
"description": "This project will contain MonoFor UI Framework",
|
|
5
5
|
"main": "./dist/main.js",
|
|
6
6
|
"repository": "git@gitlab.com:monoui/vuejs.git",
|
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
"license": "MIT",
|
|
9
9
|
"scripts": {
|
|
10
10
|
"docs": "vuepress dev docs",
|
|
11
|
+
"dev": "vuepress dev docs",
|
|
11
12
|
"styleguide": "vue-styleguidist server",
|
|
12
13
|
"styleguide:build": "vue-styleguidist build",
|
|
13
14
|
"deploy": "cross-env NODE_ENV=production webpack --config webpack.config.js",
|
|
@@ -417,21 +417,22 @@ export default {
|
|
|
417
417
|
type: String,
|
|
418
418
|
required: false,
|
|
419
419
|
default: ""
|
|
420
|
+
},
|
|
421
|
+
perPage: {
|
|
422
|
+
type: Number,
|
|
423
|
+
required: false,
|
|
424
|
+
default: 10
|
|
420
425
|
}
|
|
421
426
|
},
|
|
422
427
|
watch: {
|
|
423
|
-
searchWord
|
|
424
|
-
|
|
428
|
+
searchWord: {
|
|
429
|
+
handler: function(newValue) {
|
|
430
|
+
if (!this.comingFromPopState) this.addFilter(newValue);
|
|
431
|
+
}
|
|
425
432
|
}
|
|
426
433
|
},
|
|
427
434
|
data() {
|
|
428
435
|
return {
|
|
429
|
-
defaultSettings: {
|
|
430
|
-
currentPage: 1,
|
|
431
|
-
pageCount: 0,
|
|
432
|
-
itemPerPage: 10,
|
|
433
|
-
totalItemCount: 0
|
|
434
|
-
},
|
|
435
436
|
settings: {
|
|
436
437
|
currentPage: 1,
|
|
437
438
|
pageCount: 0,
|
|
@@ -443,7 +444,9 @@ export default {
|
|
|
443
444
|
isDataEmpty: false,
|
|
444
445
|
isLoading: false,
|
|
445
446
|
limit: 250,
|
|
446
|
-
searchDebounceTimeout: null
|
|
447
|
+
searchDebounceTimeout: null,
|
|
448
|
+
comingFromPopState: false,
|
|
449
|
+
skipWatch: false
|
|
447
450
|
};
|
|
448
451
|
},
|
|
449
452
|
computed: {
|
|
@@ -470,8 +473,15 @@ export default {
|
|
|
470
473
|
this.addPopStateListener();
|
|
471
474
|
},
|
|
472
475
|
async mounted() {
|
|
473
|
-
this.
|
|
474
|
-
|
|
476
|
+
var filterPrefix = this.getHistoryName("f-");
|
|
477
|
+
var sortingPrefix = this.getHistoryName("s-");
|
|
478
|
+
let url = new URL(window.location).toString();
|
|
479
|
+
if (url.indexOf(filterPrefix) >= 0 || url.indexOf(sortingPrefix) >= 0) {
|
|
480
|
+
this.loadHistory();
|
|
481
|
+
}
|
|
482
|
+
if (this.autoLoad) {
|
|
483
|
+
await this.getValues();
|
|
484
|
+
}
|
|
475
485
|
},
|
|
476
486
|
methods: {
|
|
477
487
|
addPopStateListener() {
|
|
@@ -481,29 +491,24 @@ export default {
|
|
|
481
491
|
window.removeEventListener("popstate", this.popStateEvent);
|
|
482
492
|
},
|
|
483
493
|
async popStateEvent() {
|
|
494
|
+
this.comingFromPopState = true;
|
|
484
495
|
this.loadHistory();
|
|
485
|
-
|
|
496
|
+
this.getValues(false);
|
|
486
497
|
},
|
|
487
498
|
loadHistory() {
|
|
488
|
-
this.settings.currentPage = this.getHistoryParameter(
|
|
489
|
-
"page",
|
|
490
|
-
this.defaultSettings.currentPage
|
|
491
|
-
);
|
|
499
|
+
this.settings.currentPage = this.getHistoryParameter("page", 1);
|
|
492
500
|
this.settings.itemPerPage = this.getHistoryParameter(
|
|
493
501
|
"limit",
|
|
494
|
-
this.
|
|
502
|
+
this.perPage || this.settings.itemPerPage
|
|
495
503
|
);
|
|
496
504
|
if (this.searchColumn) {
|
|
497
505
|
this.searchWord = this.getHistoryParameter(
|
|
498
506
|
`f-${this.searchColumn}`,
|
|
499
|
-
|
|
507
|
+
""
|
|
500
508
|
);
|
|
501
509
|
}
|
|
502
510
|
this.loadHistoryFilters();
|
|
503
511
|
this.loadHistorySorting();
|
|
504
|
-
// console.log("loadHistory:settings", this.settings);
|
|
505
|
-
// console.log("loadHistory:filters", this.filters);
|
|
506
|
-
// console.log("loadHistory:sorting", this.sorting);
|
|
507
512
|
},
|
|
508
513
|
sortableIcon(column) {
|
|
509
514
|
const currentSort = this.sorting.find(x => x.Column === column);
|
|
@@ -555,7 +560,7 @@ export default {
|
|
|
555
560
|
row
|
|
556
561
|
);
|
|
557
562
|
},
|
|
558
|
-
async getValues() {
|
|
563
|
+
async getValues(addHistory = true) {
|
|
559
564
|
this.isLoading = true;
|
|
560
565
|
this.$emit("loading", this.isLoading);
|
|
561
566
|
const { currentPage, itemPerPage } = this.settings;
|
|
@@ -567,15 +572,47 @@ export default {
|
|
|
567
572
|
itemPerPage
|
|
568
573
|
);
|
|
569
574
|
|
|
570
|
-
this.
|
|
571
|
-
|
|
572
|
-
this.
|
|
573
|
-
|
|
575
|
+
if (addHistory && !this.comingFromPopState) {
|
|
576
|
+
const filterPrefix = this.getHistoryName("f-");
|
|
577
|
+
const sortPrefix = this.getHistoryName("s-");
|
|
578
|
+
let url = new URL(window.location);
|
|
579
|
+
let params = new URLSearchParams(url.search);
|
|
580
|
+
//console.log("url start: " + url);
|
|
581
|
+
for (const searchParam of params) {
|
|
582
|
+
if (searchParam[0].startsWith(filterPrefix)) {
|
|
583
|
+
url.searchParams.delete(searchParam[0]);
|
|
584
|
+
//console.log("url later: " + url);
|
|
585
|
+
}
|
|
574
586
|
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
587
|
+
if (searchParam[0].startsWith(sortPrefix)) {
|
|
588
|
+
url.searchParams.delete(searchParam[0]);
|
|
589
|
+
//console.log("url later: " + url);
|
|
590
|
+
}
|
|
591
|
+
}
|
|
592
|
+
|
|
593
|
+
for (const filter of this.filters) {
|
|
594
|
+
url = this.addHistoryParameter(
|
|
595
|
+
`f-${filter.Column}`,
|
|
596
|
+
filter.Value,
|
|
597
|
+
this.storage,
|
|
598
|
+
url,
|
|
599
|
+
false
|
|
600
|
+
);
|
|
601
|
+
}
|
|
602
|
+
|
|
603
|
+
for (const sort of this.sorting) {
|
|
604
|
+
url = this.addHistoryParameter(
|
|
605
|
+
`s-${sort.Column}`,
|
|
606
|
+
sort.Asc ? 1 : 0,
|
|
607
|
+
this.storage,
|
|
608
|
+
url,
|
|
609
|
+
false
|
|
610
|
+
);
|
|
611
|
+
}
|
|
612
|
+
this.replaceHistory(url);
|
|
578
613
|
}
|
|
614
|
+
this.comingFromPopState = false;
|
|
615
|
+
this.skipWatch = false;
|
|
579
616
|
|
|
580
617
|
if (!result || result.status !== 200) {
|
|
581
618
|
this.isLoading = false;
|
|
@@ -623,19 +660,19 @@ export default {
|
|
|
623
660
|
changePage(page) {
|
|
624
661
|
this.settings.currentPage = page;
|
|
625
662
|
this.addHistoryParameter("page", page);
|
|
626
|
-
this.getValues();
|
|
663
|
+
this.getValues(false);
|
|
627
664
|
},
|
|
628
665
|
changeItemPerPage(value) {
|
|
629
666
|
this.settings.itemPerPage = value;
|
|
630
667
|
this.addHistoryParameter("limit", value);
|
|
631
|
-
this.getValues();
|
|
668
|
+
this.getValues(false);
|
|
632
669
|
},
|
|
633
670
|
isLessThanTotalItemCount(val) {
|
|
634
671
|
return this.settings.totalItemCount > val;
|
|
635
672
|
},
|
|
636
673
|
/** */
|
|
637
674
|
refresh() {
|
|
638
|
-
this.getValues();
|
|
675
|
+
if (!this.comingFromPopState) this.getValues();
|
|
639
676
|
},
|
|
640
677
|
addFilter(word) {
|
|
641
678
|
if (!this.searchColumn) return;
|
|
@@ -651,6 +688,7 @@ export default {
|
|
|
651
688
|
);
|
|
652
689
|
},
|
|
653
690
|
searchColumnValue(column, value, limit = -1) {
|
|
691
|
+
if (this.skipWatch) return;
|
|
654
692
|
let filter = this.filters.find(x => x.Column === column);
|
|
655
693
|
|
|
656
694
|
if (filter && (!value || value.length < limit)) {
|
|
@@ -659,12 +697,14 @@ export default {
|
|
|
659
697
|
return;
|
|
660
698
|
}
|
|
661
699
|
|
|
662
|
-
if (filter)
|
|
663
|
-
|
|
700
|
+
if (filter) {
|
|
701
|
+
filter.Value = value;
|
|
702
|
+
} else {
|
|
664
703
|
this.filters.push({
|
|
665
704
|
Column: column,
|
|
666
705
|
Value: value
|
|
667
706
|
});
|
|
707
|
+
}
|
|
668
708
|
this.getValues();
|
|
669
709
|
},
|
|
670
710
|
inLimit() {
|
|
@@ -680,7 +720,6 @@ export default {
|
|
|
680
720
|
storage = this.historyStorage
|
|
681
721
|
) {
|
|
682
722
|
if (!startsWith || !storage) return;
|
|
683
|
-
|
|
684
723
|
try {
|
|
685
724
|
const startsWithName = this.getHistoryName(startsWith);
|
|
686
725
|
|
|
@@ -691,8 +730,7 @@ export default {
|
|
|
691
730
|
url.searchParams.delete(searchParam[0]);
|
|
692
731
|
}
|
|
693
732
|
}
|
|
694
|
-
|
|
695
|
-
return;
|
|
733
|
+
return url;
|
|
696
734
|
}
|
|
697
735
|
|
|
698
736
|
if (storage === "local") {
|
|
@@ -820,23 +858,16 @@ export default {
|
|
|
820
858
|
const parameters = this.getHistoryParameters("f-");
|
|
821
859
|
const trimName = this.getHistoryName("f-");
|
|
822
860
|
const names = Object.keys(parameters);
|
|
861
|
+
this.filters.splice(0, this.filters.length);
|
|
823
862
|
for (const paramName of names) {
|
|
824
863
|
const value = parameters[paramName];
|
|
825
864
|
const column = paramName.replace(trimName, "");
|
|
826
865
|
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
if (filter) {
|
|
833
|
-
filter.Value = value;
|
|
834
|
-
} else {
|
|
835
|
-
this.filters.push({
|
|
836
|
-
Column: column,
|
|
837
|
-
Value: value
|
|
838
|
-
});
|
|
839
|
-
}
|
|
866
|
+
if (value) {
|
|
867
|
+
this.filters.push({
|
|
868
|
+
Column: column,
|
|
869
|
+
Value: value
|
|
870
|
+
});
|
|
840
871
|
}
|
|
841
872
|
}
|
|
842
873
|
},
|
|
@@ -844,6 +875,7 @@ export default {
|
|
|
844
875
|
const parameters = this.getHistoryParameters("s-");
|
|
845
876
|
const trimName = this.getHistoryName("s-");
|
|
846
877
|
const names = Object.keys(parameters);
|
|
878
|
+
this.sorting.splice(0, this.sorting.length);
|
|
847
879
|
for (const paramName of names) {
|
|
848
880
|
var paramValue = parameters[paramName];
|
|
849
881
|
let value = undefined;
|
|
@@ -851,26 +883,46 @@ export default {
|
|
|
851
883
|
else if (paramValue && paramValue === "0") value = false;
|
|
852
884
|
const column = paramName.replace(trimName, "");
|
|
853
885
|
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
886
|
+
this.sorting.push({
|
|
887
|
+
Column: column,
|
|
888
|
+
Asc: value
|
|
889
|
+
});
|
|
890
|
+
}
|
|
891
|
+
},
|
|
892
|
+
replaceHistory(state, storage = this.historyStorage) {
|
|
893
|
+
if (storage === "query") {
|
|
894
|
+
let url;
|
|
895
|
+
if (state) url = state;
|
|
896
|
+
else
|
|
897
|
+
url = new URL(
|
|
898
|
+
window.location.origin + window.location.pathname
|
|
899
|
+
);
|
|
900
|
+
//console.log("Pushing(3): " + url);
|
|
901
|
+
window.history.pushState({ url: url.href }, "", url.href);
|
|
902
|
+
return;
|
|
863
903
|
}
|
|
864
904
|
},
|
|
865
|
-
addHistoryParameter(
|
|
905
|
+
addHistoryParameter(
|
|
906
|
+
name,
|
|
907
|
+
value,
|
|
908
|
+
storage = this.historyStorage,
|
|
909
|
+
state = null,
|
|
910
|
+
replace = true
|
|
911
|
+
) {
|
|
866
912
|
if (!this.history || !name || !storage) return;
|
|
867
|
-
// console.log("addHistoryParameter", name, value, storage);
|
|
868
913
|
try {
|
|
869
914
|
if (storage === "query") {
|
|
870
|
-
|
|
915
|
+
let url;
|
|
916
|
+
if (state) url = state;
|
|
917
|
+
else url = new URL(window.location);
|
|
871
918
|
const historyName = this.getHistoryName(name);
|
|
872
919
|
url.searchParams.set(historyName, value);
|
|
873
|
-
|
|
920
|
+
if (!replace) {
|
|
921
|
+
state = url;
|
|
922
|
+
return state;
|
|
923
|
+
}
|
|
924
|
+
//console.log("Pushing(2): " + url.href);
|
|
925
|
+
window.history.pushState({ url: url.href }, "", url.href);
|
|
874
926
|
return;
|
|
875
927
|
}
|
|
876
928
|
|
|
@@ -964,6 +1016,7 @@ export default {
|
|
|
964
1016
|
if (storage === "query") {
|
|
965
1017
|
const url = new URL(window.location);
|
|
966
1018
|
url.searchParams.delete(historyName);
|
|
1019
|
+
//console.log("Pushing(1): " + url);
|
|
967
1020
|
window.history.pushState({}, "", url);
|
|
968
1021
|
return;
|
|
969
1022
|
}
|