simpler activation/suspension of holds for staff
authorphasefx <phasefx@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Fri, 4 Apr 2008 04:32:19 +0000 (04:32 +0000)
committerphasefx <phasefx@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Fri, 4 Apr 2008 04:32:19 +0000 (04:32 +0000)
git-svn-id: svn://svn.open-ils.org/ILS/branches/rel_1_2@9218 dcc99617-32d9-48b4-a31d-7c20da2025e4

Open-ILS/xul/staff_client/server/patron/holds.js
Open-ILS/xul/staff_client/server/patron/holds.xul
Open-ILS/xul/staff_client/server/patron/holds_overlay.xul

index fda7fbf..9ef912d 100644 (file)
@@ -243,7 +243,8 @@ patron.holds.prototype = {
                                                obj.controller.view.cmd_holds_edit_email_notify.setAttribute('disabled','false');
                                                obj.controller.view.cmd_holds_edit_selection_depth.setAttribute('disabled','false');
                                                obj.controller.view.cmd_holds_edit_thaw_date.setAttribute('disabled','false');
-                                               obj.controller.view.cmd_holds_edit_freeze.setAttribute('disabled','false');
+                                               obj.controller.view.cmd_holds_activate.setAttribute('disabled','false');
+                                               obj.controller.view.cmd_holds_suspend.setAttribute('disabled','false');
                                                obj.controller.view.cmd_show_notifications.setAttribute('disabled','false');
                                                obj.controller.view.cmd_holds_retarget.setAttribute('disabled','false');
                                                obj.controller.view.cmd_holds_cancel.setAttribute('disabled','false');
@@ -259,7 +260,8 @@ patron.holds.prototype = {
                                                obj.controller.view.cmd_holds_edit_email_notify.setAttribute('disabled','true');
                                                obj.controller.view.cmd_holds_edit_selection_depth.setAttribute('disabled','true');
                                                obj.controller.view.cmd_holds_edit_thaw_date.setAttribute('disabled','true');
-                                               obj.controller.view.cmd_holds_edit_freeze.setAttribute('disabled','true');
+                                               obj.controller.view.cmd_holds_activate.setAttribute('disabled','true');
+                                               obj.controller.view.cmd_holds_suspend.setAttribute('disabled','true');
                                                obj.controller.view.cmd_show_notifications.setAttribute('disabled','true');
                                                obj.controller.view.cmd_holds_retarget.setAttribute('disabled','true');
                                                obj.controller.view.cmd_holds_cancel.setAttribute('disabled','true');
@@ -578,53 +580,90 @@ patron.holds.prototype = {
                                                        }
                                                }
                                        ],
-                                       'cmd_holds_edit_freeze' : [
+                    'cmd_holds_suspend' : [
                                                ['command'],
                                                function() {
                                                        try {
-                                                               var xml = '<vbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" flex="1" style="overflow: vertical">';
-                                                               xml += '<description>Activate or suspend these holds?</description>';
-                                                               xml += '<hbox><button value="freeze" label="Suspend" accesskey="F" name="fancy_submit"/>';
-                                                               xml += '<button value="unfreeze" label="Activate" accesskey="U" name="fancy_submit"/></hbox>';
-                                                               xml += '</vbox>';
-                                                               var bot_xml = '<hbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" flex="1" style="overflow: vertical">';
-                                                               bot_xml += '<spacer flex="1"/><button label="Cancel" accesskey="C" name="fancy_cancel"/></hbox>';
-                                                               netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect UniversalBrowserWrite');
-                                                               //obj.data.temp_mid = xml; obj.data.stash('temp_mid');
-                                                               //obj.data.temp_bot = bot_xml; obj.data.stash('temp_bot');
-                                                               JSAN.use('util.window'); var win = new util.window();
-                                                               var fancy_prompt_data = win.open(
-                                                                       urls.XUL_FANCY_PROMPT,
-                                                                       //+ '?xml_in_stash=temp_mid'
-                                                                       //+ '&bottom_xml_in_stash=temp_bot'
-                                                                       //+ '&title=' + window.escape('Set Email Notification for Holds'),
-                                                                       'fancy_prompt', 'chrome,resizable,modal',
-                                                                       { 'xml' : xml, 'bottom_xml' : bot_xml, 'title' : 'Activate/Suspend Hold' }
-                                                               );
-                                                               if (fancy_prompt_data.fancy_status == 'incomplete') { return; }
-                                                               var freeze = fancy_prompt_data.fancy_submit == 'freeze' ? get_db_true() : get_db_false();
-                                                               var msg = 'Are you sure you would like to ' + ( get_bool( freeze ) ? 'freeze' : 'un-freeze' ) + ' hold' + ( obj.retrieve_ids.length > 1 ? 's ' : ' ') + util.functional.map_list( obj.retrieve_ids, function(o){return o.id;}).join(', ') + '?';
-                                                               var r = obj.error.yns_alert(msg,'Modifying Holds','Yes','No',null,'Check here to confirm this message');
+                                var hold_list = util.functional.map_list( obj.retrieve_ids, function(o){return o.id;}).join(', '); 
+                                                               var r = obj.error.yns_alert(
+                                    obj.retrieve_ids.length > 1 ?
+                                    'Are you sure you would like to suspend holds ' + hold_list + '?' :
+                                    'Are you sure you would like to suspend hold ' + hold_list + '?',
+                                    'Modifying Holds',
+                                    'Yes',
+                                    'No',
+                                    null,
+                                    'Check here to confirm this message.'
+                                );
                                                                if (r == 0) {
+                                    var already_suspended = [];
                                                                        for (var i = 0; i < obj.retrieve_ids.length; i++) {
                                                                                var hold = obj.holds_map[ obj.retrieve_ids[i].id ];
-                                                                               hold.frozen(  freeze ); 
-                                                                               if ( ! get_bool( freeze ) ) {
-                                                                                       hold.thaw_date( null );
-                                                                               }
+                                        if ( get_bool( hold.frozen() ) ) {
+                                            already_suspended.push( hold.id() );
+                                            continue; 
+                                        }
+                                                                               hold.frozen('t'); 
+                                                                               hold.thaw_date(null);
                                                                                hold.ischanged('1');
                                         hold = obj.flatten_copy(hold);
                                                                                var robj = obj.network.simple_request('FM_AHR_UPDATE',[ ses(), hold ]);
                                                                                if (typeof robj.ilsevent != 'undefined') throw(robj);
                                                                        }
+                                    if (already_suspended.length == 1) {
+                                        alert( 'Hold ' + already_suspended[0] + ' is already suspended.' );
+                                    } else if (already_suspended.length > 1) {
+                                        alert( 'Holds ' + already_suspended.join(', ') + ' are already suspended.' );
+                                    }
                                                                        obj.retrieve(true);
                                                                }
                                                        } catch(E) {
-                                                               obj.error.standard_unexpected_error_alert('Holds not likely modified.',E);
+                                                               obj.error.standard_unexpected_error_alert('Holds not likely suspended.',E);
+                                                       }
+                                               }
+                                       ],
+                    'cmd_holds_activate' : [
+                                               ['command'],
+                                               function() {
+                                                       try {
+                                var hold_list = util.functional.map_list( obj.retrieve_ids, function(o){return o.id;}).join(', '); 
+                                                               var r = obj.error.yns_alert(
+                                    obj.retrieve_ids.length > 1 ?
+                                    'Are you sure you would like to activate holds ' + hold_list + '?' :
+                                    'Are you sure you would like to activate hold ' + hold_list + '?',
+                                    'Modifying Holds',
+                                    'Yes',
+                                    'No',
+                                    null,
+                                    'Check here to confirm this message.'
+                                );
+                                                               if (r == 0) {
+                                    var already_activated = [];
+                                                                       for (var i = 0; i < obj.retrieve_ids.length; i++) {
+                                                                               var hold = obj.holds_map[ obj.retrieve_ids[i].id ];
+                                        if ( ! get_bool( hold.frozen() ) ) {
+                                            already_activated.push( hold.id() );
+                                            continue; 
+                                        }
+                                                                               hold.frozen('f'); 
+                                                                               hold.thaw_date(null);
+                                                                               hold.ischanged('1');
+                                        hold = obj.flatten_copy(hold);
+                                                                               var robj = obj.network.simple_request('FM_AHR_UPDATE',[ ses(), hold ]);
+                                                                               if (typeof robj.ilsevent != 'undefined') throw(robj);
+                                                                       }
+                                    if (already_activated.length == 1) {
+                                        alert( 'Hold ' + already_activated[0] + ' is already activated.' );
+                                    } else if (already_activated.length > 1) {
+                                        alert( 'Holds ' + already_activated.join(', ') + ' are already activated.' );
+                                    }
+                                                                       obj.retrieve(true);
+                                                               }
+                                                       } catch(E) {
+                                                               obj.error.standard_unexpected_error_alert('Holds not likely activated.',E);
                                                        }
                                                }
                                        ],
-
                     'cmd_holds_edit_thaw_date' : [
                                                ['command'],
                                                function() {
@@ -823,7 +862,8 @@ patron.holds.prototype = {
                obj.controller.view.cmd_holds_edit_email_notify.setAttribute('disabled','true');
                obj.controller.view.cmd_holds_edit_selection_depth.setAttribute('disabled','true');
                obj.controller.view.cmd_holds_edit_thaw_date.setAttribute('disabled','true');
-               obj.controller.view.cmd_holds_edit_freeze.setAttribute('disabled','true');
+        obj.controller.view.cmd_holds_activate.setAttribute('disabled','true');
+        obj.controller.view.cmd_holds_suspend.setAttribute('disabled','true');
                obj.controller.view.cmd_show_notifications.setAttribute('disabled','true');
                obj.controller.view.cmd_holds_retarget.setAttribute('disabled','true');
                obj.controller.view.cmd_holds_cancel.setAttribute('disabled','true');
index bf561dd..1285683 100644 (file)
@@ -82,7 +82,8 @@
                <command id="cmd_holds_edit_phone_notify" />
                <command id="cmd_holds_edit_email_notify" />
                <command id="cmd_holds_edit_thaw_date" />
-               <command id="cmd_holds_edit_freeze" />
+               <command id="cmd_holds_activate" />
+               <command id="cmd_holds_suspend" />
                <command id="cmd_holds_edit_selection_depth" disabled="true" hidden="true"/>
                <command id="cmd_broken" disabled="true" hidden="true"/>
                <command id="cmd_holds_retarget"/>
index 02c89c8..cca39fc 100644 (file)
@@ -22,8 +22,9 @@
                <menuitem label="Edit Pickup Library" command="cmd_holds_edit_pickup_lib" accesskey="L"/>
                <menuitem label="Edit Phone Notification" command="cmd_holds_edit_phone_notify" accesskey="P"/>
                <menuitem label="Set Email Notification" command="cmd_holds_edit_email_notify" accesskey="E"/>
-               <menuitem label="Set Activation Date" command="cmd_holds_edit_thaw_date" accesskey="T"/>
-               <menuitem label="Activate/Suspend Hold" command="cmd_holds_edit_freeze" accesskey="F"/>
+               <menuitem label="Edit Activation Date" command="cmd_holds_edit_thaw_date" accesskey="D"/>
+               <menuitem label="Activate Hold" command="cmd_holds_activate" accesskey="A"/>
+               <menuitem label="Suspend Hold" command="cmd_holds_suspend" accesskey="S"/>
                <!--
                <menuitem label="Edit Hold Range" command="cmd_holds_edit_selection_depth" accesskey="R"/>
                <menuitem label="Edit Hold Focus" command="cmd_broken" accesskey="F"/>
@@ -73,8 +74,9 @@
                                <menuitem label="Edit Pickup Library" command="cmd_holds_edit_pickup_lib" accesskey="L"/>
                                <menuitem label="Edit Phone Notification" command="cmd_holds_edit_phone_notify" accesskey="P"/>
                                <menuitem label="Set Email Notification" command="cmd_holds_edit_email_notify" accesskey="E" />
-                <menuitem label="Set Activation Date" command="cmd_holds_edit_thaw_date" accesskey="T"/>
-                <menuitem label="Activate/Suspend Hold" command="cmd_holds_edit_freeze" accesskey="F"/>
+                <menuitem label="Edit Activation Date" command="cmd_holds_edit_thaw_date" accesskey="T"/>
+                <menuitem label="Activate Hold" command="cmd_holds_activate" accesskey="A"/>
+                <menuitem label="Suspend Hold" command="cmd_holds_suspend" accesskey="S"/>
                                <!--
                                <menuitem label="Edit Hold Range" command="cmd_holds_edit_selection_depth" accesskey="R" />
                                <menuitem label="Edit Hold Focus" command="cmd_broken" accesskey="F" />