@monoui/vuejs 1.1.21 → 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 +8 -8
- package/package.json +2 -1
- package/src/components/Table/Table.vue +65 -53
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",
|
|
@@ -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,34 +572,47 @@ export default {
|
|
|
565
572
|
itemPerPage
|
|
566
573
|
);
|
|
567
574
|
|
|
568
|
-
if (addHistory) {
|
|
569
|
-
|
|
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
|
+
}
|
|
570
586
|
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
587
|
+
if (searchParam[0].startsWith(sortPrefix)) {
|
|
588
|
+
url.searchParams.delete(searchParam[0]);
|
|
589
|
+
//console.log("url later: " + url);
|
|
590
|
+
}
|
|
591
|
+
}
|
|
574
592
|
|
|
575
593
|
for (const filter of this.filters) {
|
|
576
|
-
|
|
594
|
+
url = this.addHistoryParameter(
|
|
577
595
|
`f-${filter.Column}`,
|
|
578
596
|
filter.Value,
|
|
579
597
|
this.storage,
|
|
580
|
-
|
|
598
|
+
url,
|
|
581
599
|
false
|
|
582
600
|
);
|
|
583
601
|
}
|
|
584
602
|
|
|
585
603
|
for (const sort of this.sorting) {
|
|
586
|
-
|
|
604
|
+
url = this.addHistoryParameter(
|
|
587
605
|
`s-${sort.Column}`,
|
|
588
606
|
sort.Asc ? 1 : 0,
|
|
589
607
|
this.storage,
|
|
590
|
-
|
|
608
|
+
url,
|
|
591
609
|
false
|
|
592
610
|
);
|
|
593
611
|
}
|
|
594
|
-
this.replaceHistory(
|
|
612
|
+
this.replaceHistory(url);
|
|
595
613
|
}
|
|
614
|
+
this.comingFromPopState = false;
|
|
615
|
+
this.skipWatch = false;
|
|
596
616
|
|
|
597
617
|
if (!result || result.status !== 200) {
|
|
598
618
|
this.isLoading = false;
|
|
@@ -652,7 +672,7 @@ export default {
|
|
|
652
672
|
},
|
|
653
673
|
/** */
|
|
654
674
|
refresh() {
|
|
655
|
-
this.getValues();
|
|
675
|
+
if (!this.comingFromPopState) this.getValues();
|
|
656
676
|
},
|
|
657
677
|
addFilter(word) {
|
|
658
678
|
if (!this.searchColumn) return;
|
|
@@ -668,6 +688,7 @@ export default {
|
|
|
668
688
|
);
|
|
669
689
|
},
|
|
670
690
|
searchColumnValue(column, value, limit = -1) {
|
|
691
|
+
if (this.skipWatch) return;
|
|
671
692
|
let filter = this.filters.find(x => x.Column === column);
|
|
672
693
|
|
|
673
694
|
if (filter && (!value || value.length < limit)) {
|
|
@@ -709,8 +730,7 @@ export default {
|
|
|
709
730
|
url.searchParams.delete(searchParam[0]);
|
|
710
731
|
}
|
|
711
732
|
}
|
|
712
|
-
|
|
713
|
-
return;
|
|
733
|
+
return url;
|
|
714
734
|
}
|
|
715
735
|
|
|
716
736
|
if (storage === "local") {
|
|
@@ -838,31 +858,24 @@ export default {
|
|
|
838
858
|
const parameters = this.getHistoryParameters("f-");
|
|
839
859
|
const trimName = this.getHistoryName("f-");
|
|
840
860
|
const names = Object.keys(parameters);
|
|
861
|
+
this.filters.splice(0, this.filters.length);
|
|
841
862
|
for (const paramName of names) {
|
|
842
863
|
const value = parameters[paramName];
|
|
843
864
|
const column = paramName.replace(trimName, "");
|
|
844
865
|
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
if (filter) {
|
|
851
|
-
filter.Value = value;
|
|
852
|
-
} else {
|
|
853
|
-
this.filters.push({
|
|
854
|
-
Column: column,
|
|
855
|
-
Value: value
|
|
856
|
-
});
|
|
857
|
-
}
|
|
866
|
+
if (value) {
|
|
867
|
+
this.filters.push({
|
|
868
|
+
Column: column,
|
|
869
|
+
Value: value
|
|
870
|
+
});
|
|
858
871
|
}
|
|
859
872
|
}
|
|
860
873
|
},
|
|
861
874
|
loadHistorySorting() {
|
|
862
|
-
const latestSorting = [...this.initialSorting];
|
|
863
875
|
const parameters = this.getHistoryParameters("s-");
|
|
864
876
|
const trimName = this.getHistoryName("s-");
|
|
865
877
|
const names = Object.keys(parameters);
|
|
878
|
+
this.sorting.splice(0, this.sorting.length);
|
|
866
879
|
for (const paramName of names) {
|
|
867
880
|
var paramValue = parameters[paramName];
|
|
868
881
|
let value = undefined;
|
|
@@ -870,25 +883,22 @@ export default {
|
|
|
870
883
|
else if (paramValue && paramValue === "0") value = false;
|
|
871
884
|
const column = paramName.replace(trimName, "");
|
|
872
885
|
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
sort.Value = value;
|
|
878
|
-
} else {
|
|
879
|
-
latestSorting.push({ Column: column, Asc: value });
|
|
880
|
-
}
|
|
881
|
-
}
|
|
882
|
-
}
|
|
883
|
-
this.sorting.length = 0;
|
|
884
|
-
for (const sort of latestSorting) {
|
|
885
|
-
this.sorting.push(sort);
|
|
886
|
+
this.sorting.push({
|
|
887
|
+
Column: column,
|
|
888
|
+
Asc: value
|
|
889
|
+
});
|
|
886
890
|
}
|
|
887
891
|
},
|
|
888
892
|
replaceHistory(state, storage = this.historyStorage) {
|
|
889
|
-
if (!state) return;
|
|
890
893
|
if (storage === "query") {
|
|
891
|
-
|
|
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);
|
|
892
902
|
return;
|
|
893
903
|
}
|
|
894
904
|
},
|
|
@@ -911,6 +921,7 @@ export default {
|
|
|
911
921
|
state = url;
|
|
912
922
|
return state;
|
|
913
923
|
}
|
|
924
|
+
//console.log("Pushing(2): " + url.href);
|
|
914
925
|
window.history.pushState({ url: url.href }, "", url.href);
|
|
915
926
|
return;
|
|
916
927
|
}
|
|
@@ -1005,6 +1016,7 @@ export default {
|
|
|
1005
1016
|
if (storage === "query") {
|
|
1006
1017
|
const url = new URL(window.location);
|
|
1007
1018
|
url.searchParams.delete(historyName);
|
|
1019
|
+
//console.log("Pushing(1): " + url);
|
|
1008
1020
|
window.history.pushState({}, "", url);
|
|
1009
1021
|
return;
|
|
1010
1022
|
}
|