apply new penalty
authorphasefx <phasefx@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Wed, 7 Jan 2009 17:35:13 +0000 (17:35 +0000)
committerphasefx <phasefx@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Wed, 7 Jan 2009 17:35:13 +0000 (17:35 +0000)
git-svn-id: svn://svn.open-ils.org/ILS/trunk@11756 dcc99617-32d9-48b4-a31d-7c20da2025e4

Open-ILS/web/opac/locale/en-US/lang.dtd
Open-ILS/xul/staff_client/server/patron/standing_penalties.js
Open-ILS/xul/staff_client/server/patron/standing_penalties.xul

index 2735d6b..f8767ac 100644 (file)
 <!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'>
index d48ce32..afc500a 100644 (file)
@@ -17,9 +17,9 @@ function penalty_init() {
 
         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,49 +55,61 @@ function penalty_init() {
             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;
                             }
-                        }; 
-                    }
+                        );
+
+                        document.getElementById('progress').hidden = false;
+                    },
+                    false
+                );
+            }
+        }
 
-                    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('cmd_remove_penalty').addEventListener(
             'command',
index 37a81be..17751b5 100644 (file)
@@ -34,6 +34,7 @@
        <commandset id="penalty_cmds">
                <command id="cmd_apply_penalty" />
                <command id="cmd_remove_penalty" />
+               <command id="cmd_edit_penalty" />
        </commandset>
 
        <!-- ///////////////////////////////////////////////////////////////////////////////////////////////////////////// -->
                <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>