Clean up and refine serial note support, part 3
authorDan Wells <dbw2@calvin.edu>
Tue, 17 Apr 2012 20:48:43 +0000 (16:48 -0400)
committerDan Wells <dbw2@calvin.edu>
Tue, 17 Apr 2012 22:15:04 +0000 (18:15 -0400)
Add needed menu entries for invoking the serial notes editor from
the list in the Items tab.

Signed-off-by: Dan Wells <dbw2@calvin.edu>
Open-ILS/web/opac/locale/en-US/lang.dtd
Open-ILS/xul/staff_client/server/locale/en-US/serial.properties
Open-ILS/xul/staff_client/server/serial/manage_items.js
Open-ILS/xul/staff_client/server/serial/manage_items.xul
Open-ILS/xul/staff_client/server/serial/notes.xul
Open-ILS/xul/staff_client/server/serial/serctrl_main.xul

index e9385dd..fd3e752 100644 (file)
 <!ENTITY staff.serial.manage_dists.actions.cmd_add_sstr.label "Add Stream">
 <!ENTITY staff.serial.manage_dists.actions.cmd_delete_sstr.label "Delete Stream">
 <!ENTITY staff.serial.manage_items.actions.cmd_edit_items.label "Edit Item Attributes">
-<!ENTITY staff.serial.manage_items.actions.cmd_edit_items.access_key "E">
+<!ENTITY staff.serial.manage_items.actions.cmd_edit_items.accesskey "E">
 <!ENTITY staff.serial.manage_items.actions.cmd_delete_items.label "Delete Items">
-<!ENTITY staff.serial.manage_items.actions.cmd_delete_items.access_key "D">
+<!ENTITY staff.serial.manage_items.actions.cmd_delete_items.accesskey "D">
 <!ENTITY staff.serial.manage_items.actions.cmd_reset_items.label "Reset Items to Expected">
+<!ENTITY staff.serial.manage_items.actions.cmd_view_sdist_notes.label "View Dist. Notes">
+<!ENTITY staff.serial.manage_items.actions.cmd_view_sdist_notes.accesskey "T">
+<!ENTITY staff.serial.manage_items.actions.cmd_view_sitem_notes.label "View Item Notes">
+<!ENTITY staff.serial.manage_items.actions.cmd_view_sitem_notes.accesskey "I">
+<!ENTITY staff.serial.manage_items.actions.cmd_view_ssub_notes.label "View Sub. Notes">
+<!ENTITY staff.serial.manage_items.actions.cmd_view_ssub_notes.accesskey "S">
 <!ENTITY staff.serial.manage_items.workarea_showing "Showing: ">
 <!ENTITY staff.serial.manage_items.workarea_current_unit "Current Working Unit: ">
 <!ENTITY staff.serial.manage_items.workarea_recently_received "Recently Received">
index 30f348f..917dd68 100644 (file)
@@ -66,6 +66,7 @@ staff.serial.manage_dists.delete_sstr.title=Delete Streams?
 staff.serial.manage_dists.delete_sstr.override=Override Delete Failure? Doing so will delete all attached items as well!
 staff.serial.manage_items.subscriber.label=Subscriber
 staff.serial.manage_items.holder.label=Holder
+staff.serial.manage_items.notes_column.label=Notes (Item/Dist/Sub)
 staff.serial.manage_subs.add.error=error adding object in manage_subs.js:
 staff.serial.manage_subs.delete.error=error deleting object in manage_subs.js:
 staff.serial.manage_subs.delete_scap.confirm=Are you sure you would like to delete this caption and pattern?
index acaae8c..5e5e449 100644 (file)
@@ -524,7 +524,36 @@ serial.manage_items.prototype = {
                             }
                         }
                     ],
-
+                    'cmd_view_sitem_notes' : [
+                        ['command'],
+                        function() {
+                            try {
+                                obj.view_notes('sitem');
+                            } catch(E) {
+                                obj.error.standard_unexpected_error_alert('cmd_view_sitem_notes failed!',E);
+                            }
+                        }
+                    ],
+                    'cmd_view_sdist_notes' : [
+                        ['command'],
+                        function() {
+                            try {
+                                obj.view_notes('sdist');
+                            } catch(E) {
+                                obj.error.standard_unexpected_error_alert('cmd_view_sdist_notes failed!',E);
+                            }
+                        }
+                    ],
+                    'cmd_view_ssub_notes' : [
+                        ['command'],
+                        function() {
+                            try {
+                                obj.view_notes('ssub');
+                            } catch(E) {
+                                obj.error.standard_unexpected_error_alert('cmd_view_ssub_notes failed!',E);
+                            }
+                        }
+                    ],
                     'cmd_items_print' : [ ['command'], function() { obj.items_print(obj.selected_list); } ],
                                        'cmd_items_export' : [ ['command'], function() { obj.items_export(obj.selected_list); } ],
                                        'cmd_refresh_list' : [ ['command'], function() { obj.retrieve_ssubs_and_sdists(); obj.refresh_list('main'); obj.refresh_list('workarea'); } ]
@@ -935,6 +964,66 @@ serial.manage_items.prototype = {
             obj.refresh_list('main');
             obj.refresh_list('workarea');
         }
+    },
+
+    'view_notes' : function(type) {
+        var obj = this;
+
+        if (!obj.retrieve_ids || obj.retrieve_ids.length == 0) return;
+
+        var object_id_fn;
+        var function_type;
+        var object_type;
+        var constructor;
+
+        switch(type) {
+            case 'sitem':
+                object_id_fn = function(item) { return item.id() };
+                title_fn = function(item) { return fieldmapper.IDL.fmclasses.sitem.field_map.id.label + ' ' + item.id() };
+                function_type = 'SIN';
+                object_type = 'item';
+                constructor = sin;
+                break;
+            case 'sdist':
+                object_id_fn = function(item) { return item.stream().distribution() };
+                title_fn = function(item) {
+                    var sdist_id = object_id_fn(item);
+                    return obj.sdist_map[sdist_id].label()
+                        + ' -- ' + obj.sdist_map[sdist_id].holding_lib().shortname()
+                        + ' (' + fieldmapper.IDL.fmclasses.sdist.field_map.id.label + ' ' + sdist_id + ')'
+                };
+                function_type = 'SDISTN';
+                object_type = 'distribution';
+                constructor = sdistn;
+                break;
+            case 'ssub':
+                object_id_fn = function(item) { return item.issuance().subscription().id() };
+                title_fn = function(item) {
+                    var ssub_id = object_id_fn(item);
+                    return obj.ssub_map[ssub_id].owning_lib().shortname()
+                        + ' (' + fieldmapper.IDL.fmclasses.ssub.field_map.id.label + ' ' + ssub_id + ')'
+                };
+                function_type = 'SSUBN';
+                object_type = 'subscription';
+                constructor = ssubn;
+                break;
+            default:
+                return;
+        }
+
+        var seen_ids = {};
+        for (var i = 0; i < obj.retrieve_ids.length; i++) {
+            var item = obj.list_sitem_map[obj.retrieve_ids[i].sitem_id];
+            var obj_id = object_id_fn(item);
+            if (seen_ids[obj_id]) continue;
+            JSAN.use('util.window'); var win = new util.window();
+            win.open(
+                urls.XUL_SERIAL_NOTES,
+                '','chrome,resizable,modal',
+                { 'object_id' : obj_id, 'function_type' : function_type, 'object_type' : object_type, 'constructor' : constructor, 'title' : $('serialStrings').getString('staff.serial.'+type+'_editor.notes') + ' -- ' + title_fn(item) }
+            );
+            seen_ids[obj_id] = 1;
+        }
     }
 }
 
@@ -1018,11 +1107,11 @@ function item_columns(modify,params) {
         },
         {
             'id' : 'notes',
-            'label' : 'Notes',
+            'label' : $('serialStrings').getString('staff.serial.manage_items.notes_column.label'),
             'flex' : 1,
             'primary' : false,
             'hidden' : false,
-            'render' : function(my) { return my.sitem.notes().length; },
+            'render' : function(my) { return my.sitem.notes().length + ' / ' + my.parent_obj.sdist_map[my.sitem.stream().distribution()].notes().length + ' / ' + my.parent_obj.ssub_map[my.sitem.issuance().subscription().id()].notes().length; },
             'persist' : 'hidden width ordinal'
         },
         {
index c5bedca..b8f8115 100644 (file)
@@ -43,6 +43,9 @@ vim:noet:sw=4:ts=4:
             <menuitem command="cmd_edit_items" label="&staff.serial.manage_items.actions.cmd_edit_items.label;" accesskey="&staff.serial.manage_items.actions.cmd_edit_items.accesskey;"/>
             <menuitem command="cmd_reset_items" label="&staff.serial.manage_items.actions.cmd_reset_items.label;" />
             <menuitem command="cmd_delete_items" label="&staff.serial.manage_items.actions.cmd_delete_items.label;" accesskey="&staff.serial.manage_items.actions.cmd_delete_items.accesskey;"/>
+            <menuitem command="cmd_view_sitem_notes" label="&staff.serial.manage_items.actions.cmd_view_sitem_notes.label;" accesskey="&staff.serial.manage_items.actions.cmd_view_sitem_notes.accesskey;"/>
+            <menuitem command="cmd_view_sdist_notes" label="&staff.serial.manage_items.actions.cmd_view_sdist_notes.label;" accesskey="&staff.serial.manage_items.actions.cmd_view_sdist_notes.accesskey;"/>
+            <menuitem command="cmd_view_ssub_notes" label="&staff.serial.manage_items.actions.cmd_view_ssub_notes.label;" accesskey="&staff.serial.manage_items.actions.cmd_view_ssub_notes.accesskey;"/>
         </popup>
     </popupset>
     <tabpanel id="serial_manage_items" orient="vertical" flex="1">
@@ -67,6 +70,9 @@ vim:noet:sw=4:ts=4:
                         <menuitem command="cmd_edit_items" label="&staff.serial.manage_items.actions.cmd_edit_items.label;" accesskey="&staff.serial.manage_items.actions.cmd_edit_items.accesskey;"/>
                         <menuitem command="cmd_reset_items" label="&staff.serial.manage_items.actions.cmd_reset_items.label;" />
                         <menuitem command="cmd_delete_items" label="&staff.serial.manage_items.actions.cmd_delete_items.label;" accesskey="&staff.serial.manage_items.actions.cmd_delete_items.accesskey;"/>
+                        <menuitem command="cmd_view_sitem_notes" label="&staff.serial.manage_items.actions.cmd_view_sitem_notes.label;" accesskey="&staff.serial.manage_items.actions.cmd_view_sitem_notes.accesskey;"/>
+                        <menuitem command="cmd_view_sdist_notes" label="&staff.serial.manage_items.actions.cmd_view_sdist_notes.label;" accesskey="&staff.serial.manage_items.actions.cmd_view_sdist_notes.accesskey;"/>
+                        <menuitem command="cmd_view_ssub_notes" label="&staff.serial.manage_items.actions.cmd_view_ssub_notes.label;" accesskey="&staff.serial.manage_items.actions.cmd_view_ssub_notes.accesskey;"/>
                         <menuseparator/>
                         <menuitem command="cmd_refresh_list" label="&staff.cat.copy_browser.holdings_maintenance.cmd_refresh_list.label;" accesskey="&staff.cat.copy_browser.holdings_maintenance.cmd_refresh_list.accesskey;"/>
                         <menuitem command="save_columns" label="&staff.cat.copy_browser.holdings_maintenance.save_columns.label;"/>
index 2009de6..3866802 100644 (file)
                                g.function_type = xul_param('function_type',{'modal_xulG':true});
                                g.constructor = xul_param('constructor',{'modal_xulG':true});
 
+                               var window_title = xul_param('title',{'modal_xulG':true});
+                               if (window_title) {
+                                       try { document.title = window_title; } catch(E) {}
+                               }
+
                                refresh();
 
                        } catch(E) {
index 4448794..cde4abe 100644 (file)
@@ -83,6 +83,9 @@ vim:noet:sw=4:ts=4:
         <command id="cmd_transfer_sdists"/>
         <command id="cmd_transfer_sstrs"/>
         <command id="cmd_transfer_subscription"/>
+        <command id="cmd_view_sdist_notes"/>
+        <command id="cmd_view_sitem_notes"/>
+        <command id="cmd_view_ssub_notes"/>
                <command id="save_columns" />
                <command id="sel_clip" />
                <command id="sel_mark_items_damaged" />