Add "Simple" flag for selectors
authorThomas Berezansky <tsbere@mvlc.org>
Thu, 5 Apr 2012 19:39:40 +0000 (15:39 -0400)
committerThomas Berezansky <tsbere@mvlc.org>
Mon, 9 Apr 2012 01:14:28 +0000 (21:14 -0400)
This causes JSPac to ignore them and TPac to sort them above a divider.

Also fixes an issue where excessive escaping was being done on values. This
would break some values in the value map selectors.

Signed-off-by: Thomas Berezansky <tsbere@mvlc.org>
Signed-off-by: Ben Shum <bshum@biblio.org>

Open-ILS/examples/fm_IDL.xml
Open-ILS/src/sql/Pg/002.schema.config.sql
Open-ILS/src/sql/Pg/upgrade/XXXX.tpac_value_maps.sql
Open-ILS/src/templates/opac/parts/coded_value_selector.tt2
Open-ILS/web/opac/skin/default/js/adv_global.js

index c66eeaa..375f93f 100644 (file)
@@ -790,6 +790,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA
                        <field reporter:label="Description" name="description" reporter:datatype="text" oils_persist:i18n="true"/>
                        <field reporter:label="OPAC Visible" name="opac_visible" reporter:datatype="bool"/>
                        <field reporter:label="Search Label" name="search_label" reporter:datatype="text" oils_persist:i18n="true"/>
+            <field reporter:label="Is Simple Selector" name="is_simple" reporter:datatype="bool"/>
                </fields>
                <links>
                        <link field="ctype" reltype="has_a" key="name" map="" class="crad"/>
index af24ba4..e32fda3 100644 (file)
@@ -743,7 +743,8 @@ CREATE TABLE config.coded_value_map (
     value           TEXT    NOT NULL,
     description     TEXT,
     opac_visible    BOOL    NOT NULL DEFAULT TRUE, -- For TPac selectors
-    search_label    TEXT
+    search_label    TEXT,
+    is_simple       BOOL    NOT NULL DEFAULT FALSE
 );
 
 CREATE VIEW config.language_map AS SELECT code, value FROM config.coded_value_map WHERE ctype = 'item_lang';
index 4e409ec..6172f5e 100644 (file)
@@ -1,3 +1,4 @@
 ALTER TABLE config.coded_value_map
     ADD COLUMN opac_visible BOOL NOT NULL DEFAULT TRUE,
-    ADD COLUMN search_label TEXT;
+    ADD COLUMN search_label TEXT,
+    ADD COLUMN is_simple BOOL NOT NULL DEFAULT FALSE;
index acb464e..18bb4a4 100644 (file)
 [% END;
 # turn the list of objects into a list of hashes to 
 # leverage TT's array.sort('<hashkey>') behavior
+simple_sorter = [];
 sorter = [];
-FOR o IN all_values; 
-    sorter.push({code => o.code, value  => (o.search_label ? o.search_label : o.value)}); 
+FOR o IN all_values;
+    IF o.is_simple == 't';
+        simple_sorter.push({code => o.code, value => (o.search_label ? o.search_label : o.value)});
+    ELSE;
+        sorter.push({code => o.code, value  => (o.search_label ? o.search_label : o.value)}); 
+    END;
 END;
+FOR o IN simple_sorter.sort('value') %]
+    <option value='[% o.code | html | replace("'","&#39;") %]'[% values.grep('^' _ o.code _ '$').size ? ' selected="selected"' : '' %]>[% o.value | html %]</option>
+[%  END;
+IF simple_sorter.size && sorter.size %]
+    <option disabled='true'>-----</option>
+[%  END;
 FOR o IN sorter.sort('value') %]
-    <option value='[% o.code | uri %]'[% values.grep('^' _ o.code _ '$').size ? ' selected="selected"' : '' %]>[% o.value | html %]</option>
+    <option value='[% o.code | html | replace("'","&#39;") %]'[% values.grep('^' _ o.code _ '$').size ? ' selected="selected"' : '' %]>[% o.value | html %]</option>
 [%  END -%]
 </select>
 
index de29876..daf3e67 100644 (file)
@@ -16,7 +16,7 @@ function advgInit() {
 
     var ctypes = ["bib_level", "item_form", "item_type", "audience", "lit_form"];
 
-    var req = new Request('open-ils.fielder:open-ils.fielder.ccvm.atomic', {"cache":1,"query":{"ctype":ctypes, "opac_visible":"t"}});
+    var req = new Request('open-ils.fielder:open-ils.fielder.ccvm.atomic', {"cache":1,"query":{"ctype":ctypes, "opac_visible":"t", "is_simple":"f"}});
     req.callback(advDrawBibExtras);
     req.request.ctypes = ctypes;
     req.send();