bring class, prefix, and suffix to the Volume Editor, and some i18n to the volume...
authorJason Etheridge <jason@esilibrary.com>
Mon, 21 Mar 2011 08:56:06 +0000 (04:56 -0400)
committerJason Etheridge <jason@esilibrary.com>
Mon, 21 Mar 2011 08:56:06 +0000 (04:56 -0400)
Open-ILS/web/opac/locale/en-US/lang.dtd
Open-ILS/xul/staff_client/server/cat/volume_copy_creator.xul
Open-ILS/xul/staff_client/server/cat/volume_editor.js
Open-ILS/xul/staff_client/server/cat/volume_editor.xul

index 8f7bc2b..e2438e9 100644 (file)
 <!ENTITY staff.cat.volume_copy_creator.print_labels.accesskey "P">
 <!ENTITY staff.cat.volume_copy_creator.library_label.value "Library">
 <!ENTITY staff.cat.volume_copy_creator.num_of_volumes_label.value "# of volumes">
+<!ENTITY staff.cat.volume_copy_creator.batch_bar "BATCH">
+<!ENTITY staff.cat.volume_copy_creator.batch_bar.call_number.classification "Classification:">
+<!ENTITY staff.cat.volume_copy_creator.batch_bar.call_number.prefix "Prefix:">
+<!ENTITY staff.cat.volume_copy_creator.batch_bar.call_number.label.label "Label:">
+<!ENTITY staff.cat.volume_copy_creator.batch_bar.call_number.label.accesskey "L">
+<!ENTITY staff.cat.volume_copy_creator.batch_bar.call_number.suffix "Suffix:">
 <!ENTITY staff.cat.volume_editor.title "Volumes">
 <!ENTITY staff.cat.volume_editor.caption.label "Volume Editor">
 <!ENTITY staff.cat.volume_editor.modify.label "Modify">
 <!ENTITY staff.cat.volume_editor.cancel.accesskey "C">
 <!ENTITY staff.cat.volume_editor.automerge.label "Auto-Merge on Volume Collision">
 <!ENTITY staff.cat.volume_editor.automerge.accesskey "A">
+<!ENTITY staff.cat.volume_editor.owning_lib "Owning lib">
+<!ENTITY staff.cat.volume_editor.classification "Classification">
+<!ENTITY staff.cat.volume_editor.prefix "Prefix">
+<!ENTITY staff.cat.volume_editor.label "Label">
+<!ENTITY staff.cat.volume_editor.suffix "Suffix">
 <!ENTITY staff.cat.z3950.marc_import.label "MARC Import via Z39.50">
 <!ENTITY staff.cat.z3950.marc_import.accesskey "I">
 <!ENTITY staff.cat.z3950.service_credentials.label "Service and Credentials">
index 88559f3..80f8634 100644 (file)
     <vbox id="main" oils_persist="height" flex="1">
         <hbox flex="0">
             <hbox id="batch_bar">
-                <label value="BATCH"/>
-                <label value="Classification:"/>
+                <label value="&staff.cat.volume_copy_creator.batch_bar;"/>
+                <label value="&staff.cat.volume_copy_creator.batch_bar.call_number.classification;"/>
                 <hbox id="batch_class"/>
-                <label value="Prefix:"/>
+                <label value="&staff.cat.volume_copy_creator.batch_bar.call_number.prefix;"/>
                 <hbox id="batch_prefix"/>
-                <label value="Label:" accesskey="L" control="marc_cn_menulist"/>
+                <label value="&staff.cat.volume_copy_creator.batch_bar.call_number.label.label;"
+                    accesskey="&staff.cat.volume_copy_creator.batch_bar.call_number.label.accesskey;" control="marc_cn_menulist"/>
                 <hbox id="marc_cn"/>
-                <label value="Suffix:"/>
+                <label value="&staff.cat.volume_copy_creator.batch_bar.call_number.suffix;"/>
                 <hbox id="batch_suffix"/>
                 <hbox id="batch_button_box"/>
             </hbox>
index 37ec1c8..92aeb21 100644 (file)
@@ -10,6 +10,7 @@ function my_init() {
         g.error.sdump('D_TRACE','my_init() for cat/volume_editor.xul');
 
         JSAN.use('OpenILS.data'); g.data = new OpenILS.data(); g.data.init({'via':'stash'});
+        JSAN.use('util.network'); g.network = new util.network();
 
         JSAN.use('util.functional');
 
@@ -23,8 +24,11 @@ function my_init() {
         for (var i = 0; i < g.volumes.length; i++) {
             var row = document.createElement('row'); rows.appendChild(row);
             var lib_label = document.createElement('label'); row.appendChild(lib_label);
-            var tb = document.createElement('textbox'); row.appendChild(tb);
-            if (!first_tb) { first_tb = tb; }
+            var class_ml = g.render_class_menu(i); row.appendChild(class_ml);
+            var prefix_ml = g.render_prefix_menu(i); row.appendChild(prefix_ml);
+            var label_tb = document.createElement('textbox'); row.appendChild(label_tb);
+            var suffix_ml = g.render_suffix_menu(i); row.appendChild(suffix_ml);
+            if (!first_tb) { first_tb = label_tb; }
 
             var lib_id = g.volumes[i].owning_lib();
             var last_lib_seen;
@@ -34,8 +38,8 @@ function my_init() {
                 last_lib_seen = lib_id;
             }
 
-            tb.setAttribute('value',g.volumes[i].label());
-            tb.setAttribute('onchange','try { var v = g.volumes['+i+']; v.ischanged("1"); v.label( this.value ); } catch(E) { alert(E); }');
+            label_tb.setAttribute('value',g.volumes[i].label());
+            label_tb.setAttribute('onchange','try { var v = g.volumes['+i+']; v.ischanged("1"); v.label( this.value ); } catch(E) { alert(E); }');
         }
 
         first_tb.select(); first_tb.focus();
@@ -62,4 +66,152 @@ g.stash_and_close = function() {
     }
 }
 
+g.render_class_menu = function(vol_idx) {
+    var ml = util.widgets.make_menulist(
+        util.functional.map_list(
+            g.data.list.acnc,
+            function(o) {
+                return [ o.name(), o.id() ];
+            }
+        ),
+        typeof g.volumes[vol_idx].label_class() == 'object'
+            ? g.volumes[vol_idx].label_class().id()
+            : g.volumes[vol_idx].label_class()
+    );
+    ml.addEventListener(
+        'command',
+        function(ev) {
+            g.volumes[vol_idx].ischanged(1);
+            g.volumes[vol_idx].label_class(ml.value);
+        },
+        false
+    );
+    return ml;
+}
+
+g.render_prefix_menu = function(vol_idx) {
+    var org = typeof g.volumes[vol_idx].owning_lib() == 'object'
+        ? g.volumes[vol_idx].owning_lib()
+        : g.data.hash.aou[ g.volumes[vol_idx].owning_lib() ];
+    var menulist = document.createElement('menulist');
+        var menupopup = document.createElement('menupopup');
+        menulist.appendChild(menupopup);
+        var org_list = []; // order from top of consortium to owning lib
+        while(org) {
+            org_list.unshift(org.id());
+            org = org.parent_ou();
+            if (org && typeof org != 'object') {
+                org = g.data.hash.aou[ org ];
+            }
+        }
+        for (var i = 0; i < org_list.length; i++) {
+            g.render_prefix_menu_items(menupopup,org_list[i]);
+        }
+        menulist.setAttribute('value',
+            typeof g.volumes[vol_idx].prefix() == 'object'
+                ? g.volumes[vol_idx].prefix().id()
+                : g.volumes[vol_idx].prefix()
+        );
+
+    menulist.addEventListener(
+        'command',
+        function() {
+            g.volumes[vol_idx].ischanged(1);
+            g.volumes[vol_idx].prefix(menulist.value);
+        },
+        false
+    );
+    return menulist;
+}
+
+g.render_prefix_menu_items = function(menupopup,ou_id) {
+    if (typeof g.data.list['acnp_for_lib_'+ou_id] == 'undefined') {
+        g.data.list['acnp_for_lib_'+ou_id] = g.network.simple_request(
+            'FM_ACNP_RETRIEVE_VIA_PCRUD',
+            [ ses(), {"owning_lib":{"=":ou_id}}, {"order_by":{"acnp":"label_sortkey"}} ]
+        );
+        g.data.stash('list');
+    }
+    for (var i = 0; i < g.data.list['acnp_for_lib_'+ou_id].length; i++) {
+        var my_acnp = g.data.list['acnp_for_lib_'+ou_id][i];
+        var menuitem = document.createElement('menuitem');
+        menupopup.appendChild(menuitem);
+            menuitem.setAttribute(
+                'label',
+                my_acnp.id() == -1 ? '' :
+                $('catStrings').getFormattedString(
+                    'staff.cat.volume_copy_creator.call_number_prefix.menuitem_label',
+                    [
+                        my_acnp.label(),
+                        g.data.hash.aou[ ou_id ].shortname()
+                    ]
+                )
+            );
+            menuitem.setAttribute('value',my_acnp.id());
+    }
+}
+
+
+g.render_suffix_menu = function(vol_idx) {
+    var org = typeof g.volumes[vol_idx].owning_lib() == 'object'
+        ? g.volumes[vol_idx].owning_lib()
+        : g.data.hash.aou[ g.volumes[vol_idx].owning_lib() ];
+    var menulist = document.createElement('menulist');
+        var menupopup = document.createElement('menupopup');
+        menulist.appendChild(menupopup);
+        var org_list = []; // order from top of consortium to owning lib
+        while(org) {
+            org_list.unshift(org.id());
+            org = org.parent_ou();
+            if (org && typeof org != 'object') {
+                org = g.data.hash.aou[ org ];
+            }
+        }
+        for (var i = 0; i < org_list.length; i++) {
+            g.render_suffix_menu_items(menupopup,org_list[i]);
+        }
+        menulist.setAttribute('value',
+            typeof g.volumes[vol_idx].suffix() == 'object'
+                ? g.volumes[vol_idx].suffix().id()
+                : g.volumes[vol_idx].suffix()
+        );
+
+    menulist.addEventListener(
+        'command',
+        function() {
+            g.volumes[vol_idx].ischanged(1);
+            g.volumes[vol_idx].suffix(menulist.value);
+        },
+        false
+    );
+    return menulist;
+}
+
+g.render_suffix_menu_items = function(menupopup,ou_id) {
+    if (typeof g.data.list['acns_for_lib_'+ou_id] == 'undefined') {
+        g.data.list['acns_for_lib_'+ou_id] = g.network.simple_request(
+            'FM_ACNS_RETRIEVE_VIA_PCRUD',
+            [ ses(), {"owning_lib":{"=":ou_id}}, {"order_by":{"acns":"label_sortkey"}} ]
+        );
+        g.data.stash('list');
+    }
+    for (var i = 0; i < g.data.list['acns_for_lib_'+ou_id].length; i++) {
+        var my_acns = g.data.list['acns_for_lib_'+ou_id][i];
+        var menuitem = document.createElement('menuitem');
+        menupopup.appendChild(menuitem);
+            menuitem.setAttribute(
+                'label',
+                my_acns.id() == -1 ? '' :
+                $('catStrings').getFormattedString(
+                    'staff.cat.volume_copy_creator.call_number_suffix.menuitem_label',
+                    [
+                        my_acns.label(),
+                        g.data.hash.aou[ ou_id ].shortname()
+                    ]
+                )
+            );
+            menuitem.setAttribute('value',my_acns.id());
+    }
+}
+
 
index 4ea3423..5a4e5c6 100644 (file)
@@ -19,7 +19,7 @@
 
 <window id="cat_volume_editor_win" 
     onload="try { my_init(); font_helper(); persist_helper(); } catch(E) { alert(E); }"
-    title="&staff.cat.volume_editor.title;" height="400" width="300" oils_persist="height width"
+    title="&staff.cat.volume_editor.title;" height="800" width="300" oils_persist="height width"
     xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
 
     <!-- ///////////////////////////////////////////////////////////////////////////////////////////////////////////// -->
             <checkbox id="auto_merge" label="&staff.cat.volume_editor.automerge.label;" accesskey="&staff.cat.volume_editor.automerge.accesskey;" oils_persist="checked"/>
         </hbox>
         <grid flex="1">
-            <columns> <column /> <column /> <column flex="1"/> </columns>
-            <rows id="rows" />
+            <columns>
+                <column />
+                <column />
+                <column />
+                <column flex="1"/>
+                <column />
+            </columns>
+            <rows id="rows">
+                <row>
+                    <label value="&staff.cat.volume_editor.owning_lib;" class="header"/>
+                    <label value="&staff.cat.volume_editor.classification;" class="header"/>
+                    <label value="&staff.cat.volume_editor.prefix;" class="header"/>
+                    <label value="&staff.cat.volume_editor.label;" class="header"/>
+                    <label value="&staff.cat.volume_editor.suffix;" class="header"/>
+                </row>
+            </rows>
         </grid>
     </groupbox>