@mongoosejs/studio 0.0.4 → 0.0.5
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.
|
@@ -25,7 +25,8 @@ module.exports = app => app.component('models', {
|
|
|
25
25
|
searchText: '',
|
|
26
26
|
shouldShowExportModal: false,
|
|
27
27
|
shouldExport: {},
|
|
28
|
-
sortBy: {}
|
|
28
|
+
sortBy: {},
|
|
29
|
+
query: {}
|
|
29
30
|
}),
|
|
30
31
|
created() {
|
|
31
32
|
this.currentModel = this.model;
|
|
@@ -35,11 +36,18 @@ module.exports = app => app.component('models', {
|
|
|
35
36
|
if (this.currentModel == null && this.models.length > 0) {
|
|
36
37
|
this.currentModel = this.models[0];
|
|
37
38
|
}
|
|
39
|
+
this.query = Object.assign({}, this.$route.query); // important that this is here before the if statements
|
|
38
40
|
if (this.$route.query?.search) {
|
|
39
41
|
this.searchText = this.$route.query.search;
|
|
40
42
|
this.filter = eval(`(${this.$route.query.search})`);
|
|
41
43
|
this.filter = EJSON.stringify(this.filter);
|
|
42
44
|
}
|
|
45
|
+
if (this.$route.query?.sort) {
|
|
46
|
+
const sort = eval(`(${this.$route.query.sort})`);
|
|
47
|
+
const path = Object.keys(sort)[0];
|
|
48
|
+
const num = Object.values(sort)[0];
|
|
49
|
+
this.sortDocs(num, path);
|
|
50
|
+
}
|
|
43
51
|
|
|
44
52
|
if (this.currentModel != null) {
|
|
45
53
|
await this.getDocuments();
|
|
@@ -52,12 +60,16 @@ module.exports = app => app.component('models', {
|
|
|
52
60
|
let sorted = false;
|
|
53
61
|
if (this.sortBy[path] == num) {
|
|
54
62
|
sorted = true;
|
|
63
|
+
delete this.query.sort;
|
|
64
|
+
this.$router.push({ query: this.query });
|
|
55
65
|
}
|
|
56
66
|
for (const key in this.sortBy) {
|
|
57
67
|
delete this.sortBy[key];
|
|
58
68
|
}
|
|
59
69
|
if (!sorted) {
|
|
60
70
|
this.sortBy[path] = num;
|
|
71
|
+
this.query.sort = `{${path}:${num}}`
|
|
72
|
+
this.$router.push({ query: this.query });
|
|
61
73
|
}
|
|
62
74
|
await this.getDocuments();
|
|
63
75
|
},
|
|
@@ -65,10 +77,12 @@ module.exports = app => app.component('models', {
|
|
|
65
77
|
if (this.searchText && Object.keys(this.searchText).length) {
|
|
66
78
|
this.filter = eval(`(${this.searchText})`);
|
|
67
79
|
this.filter = EJSON.stringify(this.filter);
|
|
68
|
-
this
|
|
80
|
+
this.query.search = this.searchText;
|
|
81
|
+
this.$router.push({ path: this.$route.path, query: this.query })
|
|
69
82
|
} else {
|
|
70
83
|
this.filter = {};
|
|
71
|
-
|
|
84
|
+
delete this.query.search;
|
|
85
|
+
this.$router.push({ path: this.$route.path, query: this.query });
|
|
72
86
|
}
|
|
73
87
|
await this.getDocuments();
|
|
74
88
|
},
|