-
-
Notifications
You must be signed in to change notification settings - Fork 31.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixed #27471 -- Made admin's filter choices collapsable.
- Loading branch information
1 parent
37602e4
commit 27aa703
Showing
7 changed files
with
116 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
/** | ||
* Persist changelist filters state (collapsed/expanded). | ||
*/ | ||
'use strict'; | ||
{ | ||
// Init filters. | ||
let filters = JSON.parse(sessionStorage.getItem('django.admin.filtersState')); | ||
|
||
if (!filters) { | ||
filters = {}; | ||
} | ||
|
||
Object.entries(filters).forEach(([key, value]) => { | ||
const detailElement = document.querySelector(`[data-filter-title='${key}']`); | ||
|
||
// Check if the filter is present, it could be from other view. | ||
if (detailElement) { | ||
value ? detailElement.setAttribute('open', '') : detailElement.removeAttribute('open'); | ||
} | ||
}); | ||
|
||
// Save filter state when clicks. | ||
const details = document.querySelectorAll('details'); | ||
details.forEach(detail => { | ||
detail.addEventListener('toggle', event => { | ||
filters[`${event.target.dataset.filterTitle}`] = detail.open; | ||
sessionStorage.setItem('django.admin.filtersState', JSON.stringify(filters)); | ||
}); | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,12 @@ | ||
{% load i18n %} | ||
<h3>{% blocktranslate with filter_title=title %} By {{ filter_title }} {% endblocktranslate %}</h3> | ||
<ul> | ||
{% for choice in choices %} | ||
<details data-filter-title="{{ title }}" open> | ||
<summary> | ||
{% blocktranslate with filter_title=title %} By {{ filter_title }} {% endblocktranslate %} | ||
</summary> | ||
<ul> | ||
{% for choice in choices %} | ||
<li{% if choice.selected %} class="selected"{% endif %}> | ||
<a href="{{ choice.query_string|iriencode }}">{{ choice.display }}</a></li> | ||
{% endfor %} | ||
</ul> | ||
{% endfor %} | ||
</ul> | ||
</details> |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters