Keep query state in URL
This commit is contained in:
parent
258571a064
commit
dc74e78d4b
@ -53,6 +53,7 @@ export default {
|
|||||||
gridColumnApi: null,
|
gridColumnApi: null,
|
||||||
comboBoxOptions: {},
|
comboBoxOptions: {},
|
||||||
es: null,
|
es: null,
|
||||||
|
initialFilter: null,
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
@ -70,10 +71,11 @@ export default {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
created() {
|
created() {
|
||||||
// TODO: monitor actual URL.
|
let queryParams = new URLSearchParams(window.location.search);
|
||||||
this.setFilterQuery({
|
queryParams = Object.fromEntries(queryParams);
|
||||||
'initial': 'true'
|
this.initialFilter = queryParams
|
||||||
})
|
queryParams['initial'] = true
|
||||||
|
this.setFilterQuery(queryParams)
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
...mapActions({
|
...mapActions({
|
||||||
@ -94,6 +96,11 @@ export default {
|
|||||||
es.addEventListener("timeout", (e) => this.handleReceiveTimeout(e))
|
es.addEventListener("timeout", (e) => this.handleReceiveTimeout(e))
|
||||||
this.es = es
|
this.es = es
|
||||||
}
|
}
|
||||||
|
url.searchParams.delete('initial')
|
||||||
|
if (url.searchParams.get('streaming') === 'false') {
|
||||||
|
url.searchParams.delete('streaming')
|
||||||
|
}
|
||||||
|
window.history.replaceState({}, '', `${location.pathname}?${url.searchParams.toString()}`);
|
||||||
},
|
},
|
||||||
onGridReady(params) {
|
onGridReady(params) {
|
||||||
this.gridApi = params.api;
|
this.gridApi = params.api;
|
||||||
@ -104,6 +111,16 @@ export default {
|
|||||||
sort: 'desc'
|
sort: 'desc'
|
||||||
}]
|
}]
|
||||||
});
|
});
|
||||||
|
|
||||||
|
for (let k in this.initialFilter) {
|
||||||
|
let filterInstance = params.api.getFilterInstance(k);
|
||||||
|
if (filterInstance) {
|
||||||
|
filterInstance.updateFilter(this.initialFilter[k]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
params.api.onFilterChanged();
|
||||||
|
this.initialFilter = null
|
||||||
|
|
||||||
this.gridApi.addGlobalListener((type, event) => {
|
this.gridApi.addGlobalListener((type, event) => {
|
||||||
if (type === 'filterChanged') {
|
if (type === 'filterChanged') {
|
||||||
let changedColumn = event.columns[0] ? (event.columns[0].colId) : null
|
let changedColumn = event.columns[0] ? (event.columns[0].colId) : null
|
||||||
|
Loading…
Reference in New Issue
Block a user