Preserve URL hash when redirecting in grid "reset to defaults"
This commit is contained in:
parent
625982d639
commit
62aa0c5965
|
@ -542,7 +542,16 @@
|
||||||
|
|
||||||
resetView() {
|
resetView() {
|
||||||
this.loading = true
|
this.loading = true
|
||||||
location.href = '?reset-to-default-filters=true'
|
|
||||||
|
// use current url proper, plus reset param
|
||||||
|
let url = '?reset-to-default-filters=true'
|
||||||
|
|
||||||
|
// add current hash, to preserve that in redirect
|
||||||
|
if (location.hash) {
|
||||||
|
url += '&hash=' + location.hash.slice(1)
|
||||||
|
}
|
||||||
|
|
||||||
|
location.href = url
|
||||||
},
|
},
|
||||||
|
|
||||||
addFilter(filter_key) {
|
addFilter(filter_key) {
|
||||||
|
|
|
@ -329,7 +329,11 @@ class MasterView(View):
|
||||||
# If user just refreshed the page with a reset instruction, issue a
|
# If user just refreshed the page with a reset instruction, issue a
|
||||||
# redirect in order to clear out the query string.
|
# redirect in order to clear out the query string.
|
||||||
if self.request.GET.get('reset-to-default-filters') == 'true':
|
if self.request.GET.get('reset-to-default-filters') == 'true':
|
||||||
return self.redirect(self.request.current_route_url(_query=None))
|
kw = {'_query': None}
|
||||||
|
hash_ = self.request.GET.get('hash')
|
||||||
|
if hash_:
|
||||||
|
kw['_anchor'] = hash_
|
||||||
|
return self.redirect(self.request.current_route_url(**kw))
|
||||||
|
|
||||||
# Stash some grid stats, for possible use when generating URLs.
|
# Stash some grid stats, for possible use when generating URLs.
|
||||||
if grid.pageable and hasattr(grid, 'pager'):
|
if grid.pageable and hasattr(grid, 'pager'):
|
||||||
|
@ -1126,7 +1130,11 @@ class MasterView(View):
|
||||||
# If user just refreshed the page with a reset instruction, issue a
|
# If user just refreshed the page with a reset instruction, issue a
|
||||||
# redirect in order to clear out the query string.
|
# redirect in order to clear out the query string.
|
||||||
if self.request.GET.get('reset-to-default-filters') == 'true':
|
if self.request.GET.get('reset-to-default-filters') == 'true':
|
||||||
return self.redirect(self.request.current_route_url(_query=None))
|
kw = {'_query': None}
|
||||||
|
hash_ = self.request.GET.get('hash')
|
||||||
|
if hash_:
|
||||||
|
kw['_anchor'] = hash_
|
||||||
|
return self.redirect(self.request.current_route_url(**kw))
|
||||||
|
|
||||||
# return grid only, if partial page was requested
|
# return grid only, if partial page was requested
|
||||||
if self.request.params.get('partial'):
|
if self.request.params.get('partial'):
|
||||||
|
|
Loading…
Reference in a new issue