[open-ils-commits] r13777 - in trunk/Open-ILS: web/opac/locale/en-US xul/staff_client/server/patron (phasefx)

svn at svn.open-ils.org svn at svn.open-ils.org
Wed Jul 29 08:23:08 EDT 2009


Author: phasefx
Date: 2009-07-29 08:23:07 -0400 (Wed, 29 Jul 2009)
New Revision: 13777

Modified:
   trunk/Open-ILS/web/opac/locale/en-US/lang.dtd
   trunk/Open-ILS/xul/staff_client/server/patron/standing_penalties.js
   trunk/Open-ILS/xul/staff_client/server/patron/standing_penalties.xul
Log:
action to archive selected penalties.  Progressmeter isn't working like I'd expect, though

Modified: trunk/Open-ILS/web/opac/locale/en-US/lang.dtd
===================================================================
--- trunk/Open-ILS/web/opac/locale/en-US/lang.dtd	2009-07-29 11:48:18 UTC (rev 13776)
+++ trunk/Open-ILS/web/opac/locale/en-US/lang.dtd	2009-07-29 12:23:07 UTC (rev 13777)
@@ -1227,6 +1227,8 @@
 <!ENTITY staff.patron_display.penalty.menu.actions.remove.accesskey "R">
 <!ENTITY staff.patron_display.penalty.menu.actions.edit.label "Modify Penalty/Message">
 <!ENTITY staff.patron_display.penalty.menu.actions.edit.accesskey "M">
+<!ENTITY staff.patron_display.penalty.menu.actions.archive.label "Archive Penalty/Message">
+<!ENTITY staff.patron_display.penalty.menu.actions.archive.accesskey "A">
 <!ENTITY staff.patron_display.apply_penalty_dialog.title "Apply Standing Penalty/Message">
 <!ENTITY staff.patron_display.apply_penalty_dialog.header "Apply Standing Penalty/Message">
 <!ENTITY staff.patron_display.apply_penalty_dialog.description "Notes, Alerts, Blocks">

Modified: trunk/Open-ILS/xul/staff_client/server/patron/standing_penalties.js
===================================================================
--- trunk/Open-ILS/xul/staff_client/server/patron/standing_penalties.js	2009-07-29 11:48:18 UTC (rev 13776)
+++ trunk/Open-ILS/xul/staff_client/server/patron/standing_penalties.js	2009-07-29 12:23:07 UTC (rev 13777)
@@ -34,6 +34,7 @@
         document.getElementById('cmd_apply_penalty').addEventListener('command', handle_apply_penalty, false);
         document.getElementById('cmd_remove_penalty').addEventListener('command', handle_remove_penalty, false);
         document.getElementById('cmd_edit_penalty').addEventListener('command', handle_edit_penalty, false);
+        document.getElementById('cmd_archive_penalty').addEventListener('command', handle_archive_penalty, false);
         document.getElementById('cmd_retrieve_archived_penalties').addEventListener('command', handle_retrieve_archived_penalties, false);
         populate_list();
         default_focus();
@@ -97,9 +98,11 @@
             if (ids.length > 0) {
                 document.getElementById('cmd_remove_penalty').setAttribute('disabled','false');
                 document.getElementById('cmd_edit_penalty').setAttribute('disabled','false');
+                document.getElementById('cmd_archive_penalty').setAttribute('disabled','false');
             } else {
                 document.getElementById('cmd_remove_penalty').setAttribute('disabled','true');
                 document.getElementById('cmd_edit_penalty').setAttribute('disabled','true');
+                document.getElementById('cmd_archive_penalty').setAttribute('disabled','true');
             }
         }
     };
@@ -299,6 +302,7 @@
                         oncomplete : function(r) {
                             try {
                                 var res = openils.Util.readResponse(r,true);
+                                /* FIXME - test for success */
                                 var row_params = rows[ ids[i] ];
                                 row_params.row.my.ausp = penalty;
                                 row_params.row.my.csp = penalty.standing_penalty();
@@ -324,6 +328,62 @@
     }
 }
 
+function handle_archive_penalty(ev) {
+    try {
+        var outstanding_requests = 0;
+        var sel = list.retrieve_selection();
+        var ids = util.functional.map_list( sel, function(o) { return JSON2js( o.getAttribute('retrieve_id') ); } );
+        if (ids.length > 0) {
+            document.getElementById('progress').hidden = false;
+            for (var i = 0; i < ids.length; i++) {
+                outstanding_requests++;
+                var penalty = util.functional.find_list( xulG.patron.standing_penalties(), function(o) { return o.id() == ids[i]; } );
+                penalty.ischanged( 1 );
+                penalty.stop_date( util.date.formatted_date(new Date(),'%F') );
+                dojo.require('openils.PermaCrud');
+                var pcrud = new openils.PermaCrud( { authtoken :ses() });
+                pcrud.apply( penalty, {
+                    onerror : function(r) {
+                        try {
+                            var res = openils.Util.readResponse(r,true);
+                            error.standard_unexpected_error_alert(patronStrings.getString('staff.patron.standing_penalty.update_error'),res);
+                        } catch(E) {
+                            alert(E);
+                        }
+                        if (--outstanding_requests==0) {
+                            document.getElementById('progress').hidden = true;
+                        }
+                    },
+                    oncomplete : function(r) {
+                        try {
+                            var res = openils.Util.readResponse(r,true);
+                            /* FIXME - test for success */
+                            var node = rows[ ids[i] ].my_node;
+                            var parentNode = node.parentNode;
+                            parentNode.removeChild( node );
+                            delete(rows[ ids[i] ]);
+                        } catch(E) {
+                            alert(E);
+                        }
+                        if (--outstanding_requests==0) {
+                            document.getElementById('progress').hidden = true;
+                        }
+                    }
+                });
+            } 
+            /*
+            if (xulG && typeof xulG.refresh == 'function') {
+                xulG.refresh();
+            }
+            */
+        }
+
+    } catch(E) {
+        var err_prefix = 'standing_penalties.js -> handle_archive_penalty() : ';
+        if (error) error.standard_unexpected_error_alert(err_prefix,E); else alert(err_prefix + E);
+    }
+}
+
 function handle_retrieve_archived_penalties() {
     try {
         document.getElementById('archived_progress').hidden = false;

Modified: trunk/Open-ILS/xul/staff_client/server/patron/standing_penalties.xul
===================================================================
--- trunk/Open-ILS/xul/staff_client/server/patron/standing_penalties.xul	2009-07-29 11:48:18 UTC (rev 13776)
+++ trunk/Open-ILS/xul/staff_client/server/patron/standing_penalties.xul	2009-07-29 12:23:07 UTC (rev 13777)
@@ -35,6 +35,7 @@
 		<command id="cmd_apply_penalty" />
 		<command id="cmd_remove_penalty" disabled="true"/>
 		<command id="cmd_edit_penalty" disabled="true"/>
+		<command id="cmd_archive_penalty" disabled="true"/>
 		<command id="cmd_retrieve_archived_penalties" />
 		<command id="cmd_show_all" />
 		<command id="cmd_show_note" />
@@ -75,6 +76,7 @@
                             <menupopup>
                                 <menuitem command="cmd_remove_penalty" label="&staff.patron_display.penalty.menu.actions.remove.label;" accesskey="&staff.patron-display.menu.actions.remove.accesskey;"/>
                                 <menuitem command="cmd_edit_penalty" label="&staff.patron_display.penalty.menu.actions.edit.label;" accesskey="&staff.patron-display.menu.actions.edit.accesskey;"/>
+                                <menuitem command="cmd_archive_penalty" label="&staff.patron_display.penalty.menu.actions.archive.label;" accesskey="&staff.patron-display.menu.actions.archive.accesskey;"/>
                             </menupopup>
                         </toolbarbutton>
                     </toolbar>
@@ -114,6 +116,7 @@
         <popup id="ausp_actions" position="at_pointer">
             <menuitem command="cmd_remove_penalty" label="&staff.patron_display.penalty.menu.actions.remove.label;" accesskey="&staff.patron-display.menu.actions.remove.accesskey;"/>
             <menuitem command="cmd_edit_penalty" label="&staff.patron_display.penalty.menu.actions.edit.label;" accesskey="&staff.patron-display.menu.actions.edit.accesskey;"/>
+            <menuitem command="cmd_archive_penalty" label="&staff.patron_display.penalty.menu.actions.archive.label;" accesskey="&staff.patron-display.menu.actions.archive.accesskey;"/>
         </popup>
     </popupset>
 



More information about the open-ils-commits mailing list