Z39 Batch : Z Index Conify
authorBill Erickson <berick@esilibrary.com>
Mon, 25 Feb 2013 15:37:11 +0000 (10:37 -0500)
committerBill Erickson <berick@esilibrary.com>
Mon, 25 Feb 2013 15:37:11 +0000 (10:37 -0500)
Signed-off-by: Bill Erickson <berick@esilibrary.com>
Open-ILS/src/templates/conify/global/config/z3950_index_field_map.tt2 [new file with mode: 0644]

diff --git a/Open-ILS/src/templates/conify/global/config/z3950_index_field_map.tt2 b/Open-ILS/src/templates/conify/global/config/z3950_index_field_map.tt2
new file mode 100644 (file)
index 0000000..a180feb
--- /dev/null
@@ -0,0 +1,111 @@
+[% WRAPPER base.tt2 %]
+[% ctx.page_title = l('Z39.50 Index Field Maps') %]
+
+<div dojoType="dijit.layout.ContentPane" layoutAlign="client">
+
+    <div dojoType="dijit.layout.ContentPane" 
+            layoutAlign="top" class='oils-header-panel'>
+
+        <div>[% l('Z39.50 Attributes for [_1]', source_code) | html %]</div>
+        <div>
+            <button dojoType='dijit.form.Button' 
+                onClick='zGrid.showCreateDialog()'>
+                [% l('New') %]
+            </button>
+            <button dojoType='dijit.form.Button' 
+                onClick='zGrid.deleteSelected()'>
+                [% l('Delete Selected') %]
+            </button>
+        </div>
+    </div>
+
+    <br/>
+
+    <table
+        id="zGrid"
+        jsid="zGrid"
+        dojoType="openils.widget.FlattenerGrid"
+        columnPersistKey='"conify.config.z3950_index_field_map"'
+        autoHeight="true"
+        editOnEnter="true"
+        editStyle="pane"
+        showLoadFilter="true"
+        fmClass="'czifm'"
+        defaultSort="['label']"
+        query="{'id': {'!=' : null}}">
+        <thead>
+            <tr>
+                <th field="label" fpath="label" ffilter="true"/>
+                <th field="metabib_field_label" fpath="metabib_field.label" 
+                    ffilter="true" name="[% l('Metabib Field') %]"/>
+                <th field="record_attr_label" fpath="record_attr.label" 
+                    ffilter="true" name="[% l('Record Attribute') %]"/>
+                <th field="z3950_attr_label" fpath="z3950_attr.label" 
+                    ffilter="true" name="[% l('Z39.50 Attribute') %]"/>
+                <th field="z3950_attr_type" fpath="z3950_attr_type" 
+                    ffilter="true"/>
+            </tr>
+        </thead>
+    </table>
+</div>
+
+<script>
+    dojo.require('dijit.form.Button');
+    dojo.require('dojo.data.ItemFileReadStore');
+    dojo.require('dijit.form.FilteringSelect');
+    dojo.require('openils.widget.FlattenerGrid');
+    dojo.require('openils.PermaCrud');
+    dojo.require('openils.Util');
+
+    dojo.addOnLoad(function() {
+
+        zGrid.overrideWidgetArgs.z3950_attr = {
+            labelFormat : ['${0} : ${1}', 'source', 'label']
+        }
+
+        // fetch all of the z39 attrs and create an attr type
+        // selector from the distinct set of z39 attr names
+        new openils.PermaCrud().retrieveAll('cza', {
+            oncomplete : function(r) {
+                var attrs = openils.Util.readResponse(r);
+                var names = [];
+                var seen = {};
+
+                dojo.forEach(attrs, function(attr) {
+                    var name = attr.name();
+                    if (seen[name]) return;
+                    names.push({name : name});
+                    seen[name] = 1;
+                });
+
+                var store = new dojo.data.ItemFileReadStore({ 
+                    data : {
+                        identifier : 'name', 
+                        label : 'name', 
+                        items : names
+                    }
+                });  
+
+                zGrid.overrideEditWidgets.z3950_attr_type = 
+                    new dijit.form.FilteringSelect({
+                        searchAttr : 'name',
+                        valueAttr : 'name',
+                        labelAttr : 'name',
+                        store : store
+                    });
+
+                // when the edit pane is rendered, update the value of our
+                // custom widget to match that of the row being edited
+                zGrid.onEditPane = function(pane) {
+                    zGrid.overrideEditWidgets.z3950_attr_type.attr(
+                        'value', pane.fmObject.z3950_attr_type() || ''
+                    );
+                }
+            }
+        });
+    });
+
+</script>
+
+[% END %]
+