append other URL query params when navigating in ui-table

This commit is contained in:
2022-04-29 11:26:33 +02:00
parent 984a663647
commit 7980627209
2 changed files with 16 additions and 5 deletions
@@ -271,10 +271,8 @@
{
if (!this.listConfig.noQueryString)
{
//const query = Qs.stringify(this.listConfig.paramsToQuery(this.query));
//const path = this.$route.href.split('?')[0] + (query ? '?' + query : '');
//history.replaceState({}, null, path);
this.$router.replace({ path: this.$route.path, params: this.$route.params, query: this.listConfig.paramsToQuery(this.query) })
const query = this.listConfig.paramsToQuery(this.query, true);
this.$router.replace({ path: this.$route.path, params: this.$route.params, query })
}
else
{
+14 -1
View File
@@ -84,9 +84,10 @@ class List implements ZeroSchema
/**
* Converts the list parameters (like page, search, filter, ...) to a vue router query
*/
paramsToQuery = params =>
paramsToQuery = (params: any, mergeWithUrlQuery: boolean = false) =>
{
let values: any = {};
let reserved = ['page', 'by', 'desc', 'search', 'filter', 'orderBy', 'isDescending'];
if (params.page !== this.query.page)
{
@@ -106,6 +107,18 @@ class List implements ZeroSchema
values.filter = params.filter.id;
}
if (mergeWithUrlQuery)
{
var urlParams = new URLSearchParams(location.search);
urlParams.forEach((value, key) =>
{
if (reserved.indexOf(key) < 0)
{
values[key] = value;
}
});
}
return values;
};