mirror of
https://github.com/louislam/uptime-kuma.git
synced 2024-11-23 14:54:05 +00:00
Use default value to remove unused filters from query params
This commit is contained in:
parent
177363ac60
commit
dfb1b97780
2 changed files with 11 additions and 8 deletions
|
@ -164,7 +164,7 @@ export default {
|
|||
*/
|
||||
filterState() {
|
||||
// Since query params are always strings, convert them to the correct type
|
||||
let status = this.$route.query["status"] || null;
|
||||
let status = this.$route.query["status"] || [];
|
||||
if (status) {
|
||||
if (!Array.isArray(status)) {
|
||||
status = [ status ];
|
||||
|
@ -172,14 +172,14 @@ export default {
|
|||
status = status.map(Number);
|
||||
}
|
||||
// Casting to boolean does not work here as Boolean("false") === true
|
||||
let active = this.$route.query["active"] || null;
|
||||
let active = this.$route.query["active"] || [];
|
||||
if (active) {
|
||||
if (!Array.isArray(active)) {
|
||||
active = [ active ];
|
||||
}
|
||||
active = active.map(val => val === "true");
|
||||
}
|
||||
let tags = this.$route.query["tags"] || null;
|
||||
let tags = this.$route.query["tags"] || [];
|
||||
if (tags) {
|
||||
if (!Array.isArray(tags)) {
|
||||
tags = [ tags ];
|
||||
|
@ -198,11 +198,14 @@ export default {
|
|||
return this.$route.query.searchText || "";
|
||||
},
|
||||
set(value) {
|
||||
this.$router.replace({
|
||||
query: {
|
||||
...this.$route.query,
|
||||
searchText: value,
|
||||
let newQuery = { ...this.$route.query };
|
||||
if (value === "") {
|
||||
delete newQuery.searchText;
|
||||
} else {
|
||||
newQuery.searchText = value;
|
||||
}
|
||||
this.$router.replace({
|
||||
query: newQuery,
|
||||
});
|
||||
}
|
||||
},
|
||||
|
|
|
@ -242,7 +242,7 @@ export default {
|
|||
},
|
||||
clearFilters() {
|
||||
this.$emit("updateFilter", {
|
||||
status: null,
|
||||
status: [],
|
||||
});
|
||||
},
|
||||
getExistingTags() {
|
||||
|
|
Loading…
Reference in a new issue