TPAC filter group selector supports class / pos
authorBill Erickson <berick@esilibrary.com>
Wed, 23 May 2012 15:10:41 +0000 (11:10 -0400)
committerMike Rylander <mrylander@gmail.com>
Mon, 30 Jul 2012 19:05:03 +0000 (15:05 -0400)
* Sort filter group entry options by position
* Allow caller to pass in a class attribute for the filter group selector

Signed-off-by: Bill Erickson <berick@esilibrary.com>
Signed-off-by: Mike Rylander <mrylander@gmail.com>

Open-ILS/src/templates/opac/parts/filter_group_selector.tt2

index 3b8f730..7d72cde 100644 (file)
@@ -9,10 +9,11 @@
     END;
     name = name || "fg:" _ group.code;
     id = id || group.code _ "_selector";
+    class = class || '';
     values = values || CGI.param(name); 
 -%]
 
-<select id='[% id %]' name='[% name %]'[%
+<select id='[% id %]' class='[% class %]' name='[% name %]'[%
     multiple ? ' multiple="multiple"' : '';
     size ? (' size="' _ size _ '"') : ''; %]>
 [% IF none_ok %]
@@ -22,9 +23,9 @@
 # leverage TT's array.sort('<hashkey>') behavior
 sorter = [];
 FOR o IN group.entries;
-    sorter.push({id => o.id, label => o.query.label}); 
+    sorter.push({id => o.id, label => o.query.label, pos => o.pos}); 
 END;
-FOR o IN sorter.sort('label') %]
+FOR o IN sorter.sort('pos') %]
     <option value='[% o.id %]'[% values.grep(o.id).size ? ' selected="selected"' : '' %]>[% o.label | html %]</option>
 [%  END -%]
 </select>