@monoui/vuejs 1.1.20 → 1.1.23
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 +2 -1
- package/src/components/Table/Table.vue +74 -53
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@monoui/vuejs",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.23",
|
|
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",
|
|
@@ -425,8 +425,10 @@ export default {
|
|
|
425
425
|
}
|
|
426
426
|
},
|
|
427
427
|
watch: {
|
|
428
|
-
searchWord
|
|
429
|
-
|
|
428
|
+
searchWord: {
|
|
429
|
+
handler: function(newValue) {
|
|
430
|
+
if (!this.comingFromPopState) this.addFilter(newValue);
|
|
431
|
+
}
|
|
430
432
|
}
|
|
431
433
|
},
|
|
432
434
|
data() {
|
|
@@ -443,7 +445,8 @@ export default {
|
|
|
443
445
|
isLoading: false,
|
|
444
446
|
limit: 250,
|
|
445
447
|
searchDebounceTimeout: null,
|
|
446
|
-
|
|
448
|
+
comingFromPopState: false,
|
|
449
|
+
skipWatch: false
|
|
447
450
|
};
|
|
448
451
|
},
|
|
449
452
|
computed: {
|
|
@@ -470,9 +473,15 @@ export default {
|
|
|
470
473
|
this.addPopStateListener();
|
|
471
474
|
},
|
|
472
475
|
async mounted() {
|
|
473
|
-
|
|
474
|
-
this.
|
|
475
|
-
|
|
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
|
+
}
|
|
476
485
|
},
|
|
477
486
|
methods: {
|
|
478
487
|
addPopStateListener() {
|
|
@@ -482,14 +491,12 @@ export default {
|
|
|
482
491
|
window.removeEventListener("popstate", this.popStateEvent);
|
|
483
492
|
},
|
|
484
493
|
async popStateEvent() {
|
|
494
|
+
this.comingFromPopState = true;
|
|
485
495
|
this.loadHistory();
|
|
486
|
-
|
|
496
|
+
this.getValues(false);
|
|
487
497
|
},
|
|
488
498
|
loadHistory() {
|
|
489
|
-
this.settings.currentPage = this.getHistoryParameter(
|
|
490
|
-
"page",
|
|
491
|
-
this.settings.currentPage
|
|
492
|
-
);
|
|
499
|
+
this.settings.currentPage = this.getHistoryParameter("page", 1);
|
|
493
500
|
this.settings.itemPerPage = this.getHistoryParameter(
|
|
494
501
|
"limit",
|
|
495
502
|
this.perPage || this.settings.itemPerPage
|
|
@@ -565,31 +572,47 @@ export default {
|
|
|
565
572
|
itemPerPage
|
|
566
573
|
);
|
|
567
574
|
|
|
568
|
-
if (addHistory) {
|
|
569
|
-
|
|
570
|
-
this.
|
|
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
|
+
}
|
|
586
|
+
|
|
587
|
+
if (searchParam[0].startsWith(sortPrefix)) {
|
|
588
|
+
url.searchParams.delete(searchParam[0]);
|
|
589
|
+
//console.log("url later: " + url);
|
|
590
|
+
}
|
|
591
|
+
}
|
|
592
|
+
|
|
571
593
|
for (const filter of this.filters) {
|
|
572
|
-
|
|
594
|
+
url = this.addHistoryParameter(
|
|
573
595
|
`f-${filter.Column}`,
|
|
574
596
|
filter.Value,
|
|
575
597
|
this.storage,
|
|
576
|
-
|
|
598
|
+
url,
|
|
577
599
|
false
|
|
578
600
|
);
|
|
579
601
|
}
|
|
580
602
|
|
|
581
|
-
this.clearHistoryParameters("s-");
|
|
582
603
|
for (const sort of this.sorting) {
|
|
583
|
-
|
|
604
|
+
url = this.addHistoryParameter(
|
|
584
605
|
`s-${sort.Column}`,
|
|
585
606
|
sort.Asc ? 1 : 0,
|
|
586
607
|
this.storage,
|
|
587
|
-
|
|
608
|
+
url,
|
|
588
609
|
false
|
|
589
610
|
);
|
|
590
611
|
}
|
|
591
|
-
this.replaceHistory(
|
|
612
|
+
this.replaceHistory(url);
|
|
592
613
|
}
|
|
614
|
+
this.comingFromPopState = false;
|
|
615
|
+
this.skipWatch = false;
|
|
593
616
|
|
|
594
617
|
if (!result || result.status !== 200) {
|
|
595
618
|
this.isLoading = false;
|
|
@@ -620,12 +643,18 @@ export default {
|
|
|
620
643
|
|
|
621
644
|
this.settings.currentPage = currentPage;
|
|
622
645
|
this.settings.itemPerPage = itemPerPage;
|
|
646
|
+
if (this.settings.currentPage <= 0) {
|
|
647
|
+
this.settings.currentPage = 1;
|
|
648
|
+
}
|
|
623
649
|
if (
|
|
624
650
|
this.settings.itemPerPage ===
|
|
625
651
|
(resultData.totalItemCount || resultData.TotalItemCount)
|
|
626
652
|
) {
|
|
627
653
|
this.settings.pageCount = 1;
|
|
628
654
|
}
|
|
655
|
+
if (this.settings.pageCount <= 0) {
|
|
656
|
+
this.settings.pageCount = 1;
|
|
657
|
+
}
|
|
629
658
|
if (this.settings.currentPage > this.settings.pageCount) {
|
|
630
659
|
this.settings.currentPage = this.settings.pageCount;
|
|
631
660
|
this.changePage(this.settings.currentPage);
|
|
@@ -642,14 +671,14 @@ export default {
|
|
|
642
671
|
changeItemPerPage(value) {
|
|
643
672
|
this.settings.itemPerPage = value;
|
|
644
673
|
this.addHistoryParameter("limit", value);
|
|
645
|
-
this.getValues();
|
|
674
|
+
this.getValues(false);
|
|
646
675
|
},
|
|
647
676
|
isLessThanTotalItemCount(val) {
|
|
648
677
|
return this.settings.totalItemCount > val;
|
|
649
678
|
},
|
|
650
679
|
/** */
|
|
651
680
|
refresh() {
|
|
652
|
-
this.getValues();
|
|
681
|
+
if (!this.comingFromPopState) this.getValues();
|
|
653
682
|
},
|
|
654
683
|
addFilter(word) {
|
|
655
684
|
if (!this.searchColumn) return;
|
|
@@ -665,6 +694,7 @@ export default {
|
|
|
665
694
|
);
|
|
666
695
|
},
|
|
667
696
|
searchColumnValue(column, value, limit = -1) {
|
|
697
|
+
if (this.skipWatch) return;
|
|
668
698
|
let filter = this.filters.find(x => x.Column === column);
|
|
669
699
|
|
|
670
700
|
if (filter && (!value || value.length < limit)) {
|
|
@@ -706,8 +736,7 @@ export default {
|
|
|
706
736
|
url.searchParams.delete(searchParam[0]);
|
|
707
737
|
}
|
|
708
738
|
}
|
|
709
|
-
|
|
710
|
-
return;
|
|
739
|
+
return url;
|
|
711
740
|
}
|
|
712
741
|
|
|
713
742
|
if (storage === "local") {
|
|
@@ -835,31 +864,24 @@ export default {
|
|
|
835
864
|
const parameters = this.getHistoryParameters("f-");
|
|
836
865
|
const trimName = this.getHistoryName("f-");
|
|
837
866
|
const names = Object.keys(parameters);
|
|
867
|
+
this.filters.splice(0, this.filters.length);
|
|
838
868
|
for (const paramName of names) {
|
|
839
869
|
const value = parameters[paramName];
|
|
840
870
|
const column = paramName.replace(trimName, "");
|
|
841
871
|
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
if (filter) {
|
|
848
|
-
filter.Value = value;
|
|
849
|
-
} else {
|
|
850
|
-
this.filters.push({
|
|
851
|
-
Column: column,
|
|
852
|
-
Value: value
|
|
853
|
-
});
|
|
854
|
-
}
|
|
872
|
+
if (value) {
|
|
873
|
+
this.filters.push({
|
|
874
|
+
Column: column,
|
|
875
|
+
Value: value
|
|
876
|
+
});
|
|
855
877
|
}
|
|
856
878
|
}
|
|
857
879
|
},
|
|
858
880
|
loadHistorySorting() {
|
|
859
|
-
const latestSorting = [...this.initialSorting];
|
|
860
881
|
const parameters = this.getHistoryParameters("s-");
|
|
861
882
|
const trimName = this.getHistoryName("s-");
|
|
862
883
|
const names = Object.keys(parameters);
|
|
884
|
+
this.sorting.splice(0, this.sorting.length);
|
|
863
885
|
for (const paramName of names) {
|
|
864
886
|
var paramValue = parameters[paramName];
|
|
865
887
|
let value = undefined;
|
|
@@ -867,25 +889,22 @@ export default {
|
|
|
867
889
|
else if (paramValue && paramValue === "0") value = false;
|
|
868
890
|
const column = paramName.replace(trimName, "");
|
|
869
891
|
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
sort.Value = value;
|
|
875
|
-
} else {
|
|
876
|
-
latestSorting.push({ Column: column, Asc: value });
|
|
877
|
-
}
|
|
878
|
-
}
|
|
879
|
-
}
|
|
880
|
-
this.sorting.length = 0;
|
|
881
|
-
for (const sort of latestSorting) {
|
|
882
|
-
this.sorting.push(sort);
|
|
892
|
+
this.sorting.push({
|
|
893
|
+
Column: column,
|
|
894
|
+
Asc: value
|
|
895
|
+
});
|
|
883
896
|
}
|
|
884
897
|
},
|
|
885
898
|
replaceHistory(state, storage = this.historyStorage) {
|
|
886
|
-
if (!state) return;
|
|
887
899
|
if (storage === "query") {
|
|
888
|
-
|
|
900
|
+
let url;
|
|
901
|
+
if (state) url = state;
|
|
902
|
+
else
|
|
903
|
+
url = new URL(
|
|
904
|
+
window.location.origin + window.location.pathname
|
|
905
|
+
);
|
|
906
|
+
//console.log("Pushing(3): " + url);
|
|
907
|
+
window.history.pushState({ url: url.href }, "", url.href);
|
|
889
908
|
return;
|
|
890
909
|
}
|
|
891
910
|
},
|
|
@@ -908,6 +927,7 @@ export default {
|
|
|
908
927
|
state = url;
|
|
909
928
|
return state;
|
|
910
929
|
}
|
|
930
|
+
//console.log("Pushing(2): " + url.href);
|
|
911
931
|
window.history.pushState({ url: url.href }, "", url.href);
|
|
912
932
|
return;
|
|
913
933
|
}
|
|
@@ -1002,6 +1022,7 @@ export default {
|
|
|
1002
1022
|
if (storage === "query") {
|
|
1003
1023
|
const url = new URL(window.location);
|
|
1004
1024
|
url.searchParams.delete(historyName);
|
|
1025
|
+
//console.log("Pushing(1): " + url);
|
|
1005
1026
|
window.history.pushState({}, "", url);
|
|
1006
1027
|
return;
|
|
1007
1028
|
}
|