diff options
-rw-r--r-- | bitbake/lib/toaster/toastergui/templates/filtersnippet.html | 3 | ||||
-rw-r--r-- | bitbake/lib/toaster/toastergui/templatetags/projecttags.py | 11 |
2 files changed, 13 insertions, 1 deletions
diff --git a/bitbake/lib/toaster/toastergui/templates/filtersnippet.html b/bitbake/lib/toaster/toastergui/templates/filtersnippet.html index d4a4f328ce..4626ffecae 100644 --- a/bitbake/lib/toaster/toastergui/templates/filtersnippet.html +++ b/bitbake/lib/toaster/toastergui/templates/filtersnippet.html @@ -1,3 +1,4 @@ +{% load projecttags %} <!-- '{{f.class}}' filter --> <form id="filter_{{f.class}}" class="modal hide fade" tabindex="-1" role="dialog" aria-hidden="true"> <input type="hidden" name="search" value="{{request.GET.search}}"/> @@ -8,7 +9,7 @@ <div class="modal-body"> <p>{{f.label}}</p> <label class="radio"> - <input type="radio" name="filter" value=""> All {{objectname}} + <input type="radio" name="filter" {%if request.GET.filter%}{{f.options|check_filter_status:request.GET.filter}} {%else%} checked {%endif%} value=""> All {{objectname}} </label> {% for option in f.options %} <label class="radio"> diff --git a/bitbake/lib/toaster/toastergui/templatetags/projecttags.py b/bitbake/lib/toaster/toastergui/templatetags/projecttags.py index 042d6927c5..7e2c8e98fa 100644 --- a/bitbake/lib/toaster/toastergui/templatetags/projecttags.py +++ b/bitbake/lib/toaster/toastergui/templatetags/projecttags.py @@ -114,3 +114,14 @@ def filtered_filesizeformat(value): def filtered_packagespec(value): """Strip off empty version and revision""" return re.sub(r'(--$)', '', value) + +@register.filter +def check_filter_status(options, filter): + """Check if the active filter is among the available options, and return 'checked' + if filter is not active. + Used in FilterDialog to select the first radio button if the filter is not active. + """ + for option in options: + if filter == option[1]: + return "" + return "checked" |