[UI] setUrlArgs should remove args when value == null.

This commit is contained in:
Fabio Manganiello 2023-12-16 18:58:31 +01:00
parent 065f7d74a5
commit 3bc27a505f
Signed by untrusted user: blacklight
GPG key ID: D90FBA7F76362774

View file

@ -22,10 +22,22 @@ export default {
}, },
setUrlArgs(args) { setUrlArgs(args) {
args = {...this.getUrlArgs(), ...args} const curArgs = this.getUrlArgs()
window.location.href = ( args = Object.entries(args)
`${window.location.pathname}#${this.parseUrlFragment()}?${this.fragmentFromArgs(args)}` .reduce((acc, [key, value]) => {
) if (value != null)
acc[key] = value
else if (curArgs[key] != null)
delete curArgs[key]
return acc
}, {})
args = {...curArgs, ...args}
let location = `${window.location.pathname}#${this.parseUrlFragment()}`
if (Object.keys(args).length)
location += `?${this.fragmentFromArgs(args)}`
window.location.href = location
}, },
fragmentFromArgs(args) { fragmentFromArgs(args) {