bitbake: toaster: Select a radio button by default in Filter Dialog
authorRavi Chintakunta <ravi.chintakunta@timesys.com>
Thu, 6 Feb 2014 03:54:46 +0000 (22:54 -0500)
committerRichard Purdie <richard.purdie@linuxfoundation.org>
Mon, 17 Feb 2014 15:38:53 +0000 (15:38 +0000)
If none of the filter options in the filter dialog are active,
then select the first radio button.

(Bitbake rev: 8aa63143cc446227c69f64688b314c65b74604d8)

Signed-off-by: Ravi Chintakunta <ravi.chintakunta@timesys.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
bitbake/lib/toaster/toastergui/templates/filtersnippet.html
bitbake/lib/toaster/toastergui/templatetags/projecttags.py

index d4a4f32..4626ffe 100644 (file)
@@ -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">
index 042d692..7e2c8e9 100644 (file)
@@ -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"