append other URL query params when navigating in ui-table
This commit is contained in:
@@ -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
|
||||
{
|
||||
|
||||
@@ -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;
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user