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

svn at svn.open-ils.org svn at svn.open-ils.org
Wed Jan 7 12:35:16 EST 2009


Author: phasefx
Date: 2009-01-07 12:35:13 -0500 (Wed, 07 Jan 2009)
New Revision: 11756

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:
apply new penalty

Modified: trunk/Open-ILS/web/opac/locale/en-US/lang.dtd
===================================================================
--- trunk/Open-ILS/web/opac/locale/en-US/lang.dtd	2009-01-07 08:16:38 UTC (rev 11755)
+++ trunk/Open-ILS/web/opac/locale/en-US/lang.dtd	2009-01-07 17:35:13 UTC (rev 11756)
@@ -1151,8 +1151,12 @@
 <!ENTITY staff.patron_display.penalty.caption "Staff-Generated Blocks / Standing Penalties">
 <!ENTITY staff.patron_display.penalty.menu.actions.label "Actions for these Penalties">
 <!ENTITY staff.patron_display.penalty.menu.actions.accesskey "P">
+<!ENTITY staff.patron_display.penalty.menu.apply.label "Apply New Penalty">
+<!ENTITY staff.patron_display.penalty.menu.apply.accesskey "N">
 <!ENTITY staff.patron_display.penalty.menu.actions.remove.label "Remove from Patron">
 <!ENTITY staff.patron_display.penalty.menu.actions.remove.accesskey "R">
+<!ENTITY staff.patron_display.penalty.menu.actions.edit.label "Edit Note">
+<!ENTITY staff.patron_display.penalty.menu.actions.edit.accesskey "E">
 <!ENTITY staff.patron_editor_interface_label "Patron Edit">
 <!ENTITY staff.patron_interface_label "Patron ">
 <!ENTITY staff.patron_navbar.bills 'Bills'>

Modified: trunk/Open-ILS/xul/staff_client/server/patron/standing_penalties.js
===================================================================
--- trunk/Open-ILS/xul/staff_client/server/patron/standing_penalties.js	2009-01-07 08:16:38 UTC (rev 11755)
+++ trunk/Open-ILS/xul/staff_client/server/patron/standing_penalties.js	2009-01-07 17:35:13 UTC (rev 11756)
@@ -17,9 +17,9 @@
 
         JSAN.use('util.error'); var error = new util.error();
         JSAN.use('util.network'); var net = new util.network();
-        JSAN.use('patron.util'); JSAN.use('util.list'); JSAN.use('util.functional');
+        JSAN.use('patron.util'); JSAN.use('util.list'); JSAN.use('util.functional'); JSAN.use('util.widgets');
 
-        var list = new util.list( 'csp_list' );
+        var list = new util.list( 'ausp_list' );
         list.init( 
             {
                 'columns' : patron.util.ausp_columns({}),
@@ -55,50 +55,62 @@
             rows[ xulG.patron.standing_penalties()[i].id() ] = list.append( row_params );
         };
 
-        document.getElementById('cmd_apply_penalty').addEventListener(
-            'command',
-            function() {
-                var sel = list.retrieve_selection();
-                var ids = util.functional.map_list( sel, function(o) { return JSON2js( o.getAttribute('retrieve_id') ); } );
-                if (ids.length > 0) {
+        var csp_list = document.getElementById('csp_list');
+        util.widgets.remove_children(csp_list);
+        for (var i = 0; i < data.list.csp.length; i++) {
+            if (data.list.csp[i].id() > 100) {
+                var menuitem = document.createElement('menuitem'); csp_list.appendChild(menuitem);
+                menuitem.setAttribute('label',data.list.csp[i].label());
+                menuitem.setAttribute('value',data.list.csp[i].id());
+                menuitem.addEventListener(
+                    'command',
+                    function(ev) {
+                        var id = ev.target.getAttribute('value');
 
-                    var note = window.prompt(patronStrings.getString('staff.patron.standing_penalty.note_prompt'),'',patronStrings.getString('staff.patron.standing_penalty.note_title'));
+                        var note = window.prompt(patronStrings.getString('staff.patron.standing_penalty.note_prompt'),'',patronStrings.getString('staff.patron.standing_penalty.note_title'));
 
-                    function gen_func(id) {
-                        return function() {
-                            var penalty = new ausp();
-                            penalty.usr( xulG.patron.id() );
-                            penalty.isnew( 1 );
-                            penalty.standing_penalty( id );
-                            penalty.org_unit( ses('ws_ou') );
-                            penalty.note( note );
-                            var req = net.simple_request( 'FM_AUSP_APPLY', [ ses(), penalty ] );
-                            if (typeof req.ilsevent != 'undefined') {
-                                error.standard_unexpected_error_alert(patronStrings.getFormattedString('staff.patron.standing_penalty.apply_error',[data.hash.csp[id].name()]),req);
+                        var penalty = new ausp();
+                        penalty.usr( xulG.patron.id() );
+                        penalty.isnew( 1 );
+                        penalty.standing_penalty( id );
+                        penalty.org_unit( ses('ws_ou') );
+                        penalty.note( note );
+                        net.simple_request(
+                            'FM_AUSP_APPLY', 
+                            [ ses(), penalty ],
+                            function(reqobj) {
+                                var req = reqobj.getResultObject();
+                                if (typeof req.ilsevent != 'undefined') {
+                                    error.standard_unexpected_error_alert(patronStrings.getFormattedString('staff.patron.standing_penalty.apply_error',[data.hash.csp[id].name()]),req);
+                                } else {
+                                    penalty.id(req);
+                                    xulG.patron.standing_penalties( xulG.patron.standing_penalties().concat( penalty ) );
+                                    var row_params = {
+                                        'row' : {
+                                            'my' : {
+                                                'ausp' : penalty,
+                                                'csp' : data.hash.csp[ penalty.standing_penalty() ],
+                                                'au' : xulG.patron,
+                                            }
+                                        }
+                                    };
+                                    rows[ req ] = list.append( row_params );
+                                }
+                                if (xulG && typeof xulG.refresh == 'function') {
+                                    xulG.refresh();
+                                }
+                                document.getElementById('progress').hidden = true;
                             }
-                        }; 
-                    }
+                        );
 
-                    var funcs = [];
-                    for (var i = 0; i < ids.length; i++) {
-                        funcs.push( gen_func(ids[i]) );
-                    } 
-                    funcs.push(
-                        function() {
-                            if (xulG && typeof xulG.refresh == 'function') {
-                                xulG.refresh();
-                            }
-                            document.getElementById('progress').hidden = true;
-                        }
-                    );
-                    document.getElementById('progress').hidden = false;
-                    JSAN.use('util.exec'); var exec = new util.exec();
-                    exec.chain(funcs);
-                }
-            },
-            false
-        );
+                        document.getElementById('progress').hidden = false;
+                    },
+                    false
+                );
+            }
+        }
 
+
         document.getElementById('cmd_remove_penalty').addEventListener(
             'command',
             function() {

Modified: trunk/Open-ILS/xul/staff_client/server/patron/standing_penalties.xul
===================================================================
--- trunk/Open-ILS/xul/staff_client/server/patron/standing_penalties.xul	2009-01-07 08:16:38 UTC (rev 11755)
+++ trunk/Open-ILS/xul/staff_client/server/patron/standing_penalties.xul	2009-01-07 17:35:13 UTC (rev 11756)
@@ -34,6 +34,7 @@
 	<commandset id="penalty_cmds">
 		<command id="cmd_apply_penalty" />
 		<command id="cmd_remove_penalty" />
+		<command id="cmd_edit_penalty" />
 	</commandset>
 
 	<!-- ///////////////////////////////////////////////////////////////////////////////////////////////////////////// -->
@@ -42,23 +43,32 @@
 		<caption id="penalty_caption" label="&staff.patron_display.penalty.caption;"/>
         <vbox flex="0">
             <hbox flex="1">
+                <menubar>
+                    <menu label="&staff.patron_display.penalty.menu.apply.label;" accesskey="&staff.patron_display.penalty.menu.apply.accesskey;">
+                        <menupopup id="csp_list">
+                        </menupopup>
+                    </menu>
+                </menubar>
+                <spacer flex="1"/>
                 <progressmeter id="progress" flex="1" hidden="true" mode="undetermined"/>
                 <spacer flex="1"/>
                 <menubar>
                     <menu label="&staff.patron_display.penalty.menu.actions.label;" accesskey="&staff.patron_display.penalty.menu.actions.accesskey;">
                         <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;"/>
                         </menupopup>
                     </menu>
                 </menubar>
             </hbox>
         </vbox>
-        <tree id="csp_list" flex="1" enableColumnDrag="true" context="csp_actions"/>
+        <tree id="ausp_list" flex="1" enableColumnDrag="true" context="ausp_actions"/>
 	</groupbox>
 
     <popupset id="csp_popupset">
-        <popup id="csp_actions" position="at_pointer">
+        <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;"/>
         </popup>
     </popupset>
 



More information about the open-ils-commits mailing list