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

svn at svn.open-ils.org svn at svn.open-ils.org
Wed Jul 29 07:48:19 EDT 2009


Author: phasefx
Date: 2009-07-29 07:48:18 -0400 (Wed, 29 Jul 2009)
New Revision: 13776

Modified:
   trunk/Open-ILS/web/opac/locale/en-US/lang.dtd
   trunk/Open-ILS/xul/staff_client/server/locale/en-US/patron.properties
   trunk/Open-ILS/xul/staff_client/server/patron/standing_penalties.js
   trunk/Open-ILS/xul/staff_client/server/patron/standing_penalties.xul
Log:
Interface for archived penalties.  I frikkin love streaming results.  Pulled down and rendered 80 archived penalties in 3 seconds on a vmware image.



Modified: trunk/Open-ILS/web/opac/locale/en-US/lang.dtd
===================================================================
--- trunk/Open-ILS/web/opac/locale/en-US/lang.dtd	2009-07-29 09:31:15 UTC (rev 13775)
+++ trunk/Open-ILS/web/opac/locale/en-US/lang.dtd	2009-07-29 11:48:18 UTC (rev 13776)
@@ -1218,6 +1218,7 @@
 <!ENTITY staff.patron_display.status.caption 'Status'>
 <!ENTITY staff.patron_display_interface_label "Patron">
 <!ENTITY staff.patron_display.penalty.caption "Staff-Generated Penalties/Messages">
+<!ENTITY staff.patron_display.archived_penalty.caption "Archived Penalties/Messages">
 <!ENTITY staff.patron_display.penalty.menu.actions.label "Actions for these Penalties/Messages">
 <!ENTITY staff.patron_display.penalty.menu.actions.accesskey "P">
 <!ENTITY staff.patron_display.penalty.menu.apply.label "Apply Standing Penalty/Message">
@@ -1256,6 +1257,12 @@
 <!ENTITY staff.patron_display.edit_penalty_dialog.apply_btn.accesskey "M">
 <!ENTITY staff.patron_display.edit_penalty_dialog.initials_entry.label "Initials">
 <!ENTITY staff.patron_display.edit_penalty_dialog.initials_entry.accesskey "I">
+<!ENTITY staff.patron_display.archived_penalty.start_date.label "Start Date:">
+<!ENTITY staff.patron_display.archived_penalty.start_date.accesskey "">
+<!ENTITY staff.patron_display.archived_penalty.end_date.label "End Date:">
+<!ENTITY staff.patron_display.archived_penalty.end_date.accesskey "">
+<!ENTITY staff.patron_display.archived_penalty.retrieve.label "Retrieve Archived Penalties">
+<!ENTITY staff.patron_display.archived_penalty.retrieve.accesskey "R">
 <!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/locale/en-US/patron.properties
===================================================================
--- trunk/Open-ILS/xul/staff_client/server/locale/en-US/patron.properties	2009-07-29 09:31:15 UTC (rev 13775)
+++ trunk/Open-ILS/xul/staff_client/server/locale/en-US/patron.properties	2009-07-29 11:48:18 UTC (rev 13776)
@@ -248,6 +248,7 @@
 staff.patron.standing_penalty.apply_error=Error applying %1$s block/standing penalty.
 staff.patron.standing_penalty.remove_error=Error removing %1$s block/standing penalty.
 staff.patron.standing_penalty.update_error=Error updating block/standing penalty.
+staff.patron.standing_penalty.retrieve_error=Error retrieving block/standing penalty.
 staff.patron.ue.uEditInit.session_no_defined=User session is not defined
 staff.patron.ue.uEditSaveuser.error_creating_note=Error creating patron guardian or parent note
 staff.patron.ue.uEditShowSearch.search=Search would be:\n%1$s

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 09:31:15 UTC (rev 13775)
+++ trunk/Open-ILS/xul/staff_client/server/patron/standing_penalties.js	2009-07-29 11:48:18 UTC (rev 13776)
@@ -1,4 +1,4 @@
-var list; var data; var error; var net; var rows;
+var list; var archived_list; var data; var error; var net; var rows; var archived_rows;
 
 function default_focus() { document.getElementById('apply_btn').focus(); } // parent interfaces often call this
 
@@ -29,9 +29,12 @@
         JSAN.use('util.widgets');
 
         init_list();
+        init_archived_list();
+        document.getElementById('date1').year = document.getElementById('date1').year - 1;
         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_retrieve_archived_penalties').addEventListener('command', handle_retrieve_archived_penalties, false);
         populate_list();
         default_focus();
 
@@ -50,7 +53,7 @@
                 'columns' : patron.util.ausp_columns({}),
                 'map_row_to_columns' : patron.util.std_map_row_to_columns(),
                 'retrieve_row' : retrieve_row,
-                'on_select' : handle_selection
+                'on_select' : generate_handle_selection(list)
             } 
         );
 
@@ -60,22 +63,46 @@
     }
 }
 
+function init_archived_list() {
+    try {
+
+        archived_list = new util.list( 'archived_ausp_list' );
+        archived_list.init( 
+            {
+                'columns' : patron.util.ausp_columns({}),
+                'map_row_to_columns' : patron.util.std_map_row_to_columns(),
+                'retrieve_row' : retrieve_row, // We're getting fleshed objects for now, but if we move to just ausp.id's, then we'll need to put a per-id fetcher in here
+                'on_select' : generate_handle_selection(archived_list)
+            } 
+        );
+
+    } catch(E) {
+        var err_prefix = 'standing_penalties.js -> init_archived_list() : ';
+        if (error) error.standard_unexpected_error_alert(err_prefix,E); else alert(err_prefix + E);
+    }
+}
+
+
 function retrieve_row (params) { // callback function for fleshing rows in a list
     params.row_node.setAttribute('retrieve_id',params.row.my.ausp.id()); 
     params.on_retrieve(params.row); 
     return params.row; 
 }
 
-function handle_selection (ev) { // handler for list row selection event
-    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('cmd_remove_penalty').setAttribute('disabled','false');
-        document.getElementById('cmd_edit_penalty').setAttribute('disabled','false');
-    } else {
-        document.getElementById('cmd_remove_penalty').setAttribute('disabled','true');
-        document.getElementById('cmd_edit_penalty').setAttribute('disabled','true');
-    }
+function generate_handle_selection(which_list) {
+    return function (ev) { // handler for list row selection event
+        var sel = which_list.retrieve_selection();
+        var ids = util.functional.map_list( sel, function(o) { return JSON2js( o.getAttribute('retrieve_id') ); } );
+        if (which_list == list) { // top list
+            if (ids.length > 0) {
+                document.getElementById('cmd_remove_penalty').setAttribute('disabled','false');
+                document.getElementById('cmd_edit_penalty').setAttribute('disabled','false');
+            } else {
+                document.getElementById('cmd_remove_penalty').setAttribute('disabled','true');
+                document.getElementById('cmd_edit_penalty').setAttribute('disabled','true');
+            }
+        }
+    };
 }
 
 function populate_list() {
@@ -114,7 +141,7 @@
             {}
         );
 
-        if (!my_xulG.id) { alert('cancelled'); return 0; }
+        if (!my_xulG.id) { return 0; }
 
         var penalty = new ausp();
         penalty.usr( xulG.patron.id() );
@@ -296,3 +323,60 @@
         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;
+        archived_list.clear(); archived_rows = {};
+        JSAN.use('util.date');
+        dojo.require('openils.PermaCrud');
+        var pcrud = new openils.PermaCrud( { authtoken :ses() });
+        pcrud.search(
+            'ausp',
+            {
+                usr : xulG.patron.id(),
+                stop_date : {
+                    'between' : [ 
+                        document.getElementById('date1').value, 
+                        document.getElementById('date2').value == util.date.formatted_date(new Date(),'%F') ? 'now' : document.getElementById('date2').value
+                    ]
+                }
+            },
+            {
+                async : true,
+                streaming : true,
+                onerror : function(r) {
+                    try {
+                        var res = openils.Util.readResponse(r,true);
+                        error.standard_unexpected_error_alert(patronStrings.getString('staff.patron.standing_penalty.retrieve_error'),res);
+                    } catch(E) {
+                        error.standard_unexpected_error_alert(patronStrings.getString('staff.patron.standing_penalty.retrieve_error'),r);
+                    }
+                },
+                oncomplete : function() {
+                    document.getElementById('archived_progress').hidden = true;
+                },
+                onresponse : function(r) {
+                    try {
+                        var my_ausp = openils.Util.readResponse(r);
+                        var row_params = {
+                            'row' : {
+                                'my' : {
+                                    'ausp' : my_ausp,
+                                    'csp' : my_ausp.standing_penalty(),
+                                    'au' : xulG.patron,
+                                }
+                            }
+                        };
+                        archived_rows[ my_ausp.id() ] = archived_list.append( row_params );
+                    } catch(E) {
+                        error.standard_unexpected_error_alert(patronStrings.getString('staff.patron.standing_penalty.retrieve_error'),E);
+                    }
+                }
+            }
+        );
+    } catch(E) {
+        var err_prefix = 'standing_penalties.js -> handle_retrieve_archived_penalties() : ';
+        if (error) error.standard_unexpected_error_alert(err_prefix,E); else alert(err_prefix + E);
+    }
+}

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 09:31:15 UTC (rev 13775)
+++ trunk/Open-ILS/xul/staff_client/server/patron/standing_penalties.xul	2009-07-29 11:48:18 UTC (rev 13776)
@@ -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_retrieve_archived_penalties" />
 		<command id="cmd_show_all" />
 		<command id="cmd_show_note" />
 		<command id="cmd_show_alert" />
@@ -49,13 +50,11 @@
             <hbox flex="1">
                 <toolbox flex="1">
                     <toolbar>
-                        <toolbaritem> <!-- why not a toolbarbutton?  I like the way this looks better -->
-                            <button id="apply_btn" 
-                                command="cmd_apply_penalty" 
-                                label="&staff.patron_display.penalty.menu.apply.label;" 
-                                accesskey="&staff.patron_display.penalty.menu.apply.accesskey;" 
-                                style="-moz-user-focus: normal" />
-                        </toolbaritem>
+                        <toolbarbutton id="apply_btn" 
+                            command="cmd_apply_penalty" 
+                            label="&staff.patron_display.penalty.menu.apply.label;" 
+                            accesskey="&staff.patron_display.penalty.menu.apply.accesskey;" 
+                            style="-moz-user-focus: normal" />
                         <toolbarseparator />
                         <!--
                         <toolbarbutton command="cmd_show_all" label="All" accesskey="A" type="radio" group="radio" style="-moz-user-focus: normal" checked="true"/>
@@ -82,8 +81,34 @@
                 </toolbox>
             </hbox>
         </vbox>
-        <tree id="ausp_list" flex="1" enableColumnDrag="true" context="ausp_actions"/>
+        <tree id="ausp_list" flex="1" enableColumnDrag="true" context="ausp_actions" />
 	</groupbox>
+    <splitter id="list_splitter" collapse="after" persist="state hidden"><grippy id="splitter_grippy"/></splitter>
+	<groupbox id="archived_penalty_groupbox" flex="1" class="my_overflow">
+		<caption id="penalty_caption" label="&staff.patron_display.archived_penalty.caption;"/>
+        <vbox flex="0">
+            <toolbox flex="1">
+                <toolbar>
+                    <toolbarspring/>
+                    <toolbaritem>
+                        <progressmeter id="archived_progress" flex="1" hidden="true" mode="undetermined"/>
+                    </toolbaritem>
+                    <toolbaritem>
+                        <label value="&staff.patron_display.archived_penalty.start_date.label;" accesskey="&staff.patron_display.archived_penalty.start_date.accesskey;" control="date1"/>
+                        <datepicker id="date1" type="popup" />
+                        <label value="&staff.patron_display.archived_penalty.end_date.label;" accesskey="&staff.patron_display.archived_penalty.end_date.accesskey;" control="date2"/>
+                        <datepicker id="date2" type="popup" />
+                    </toolbaritem>
+                    <toolbarbutton id="retrieve_btn" 
+                        label="&staff.patron_display.archived_penalty.retrieve.label;" 
+                        accesskey="&staff.patron_display.archived_penalty.retrieve.accesskey;" 
+                        command="cmd_retrieve_archived_penalties"
+                        style="-moz-user-focus: normal" />
+                </toolbar>
+            </toolbox>
+        </vbox>
+        <tree id="archived_ausp_list" flex="1" enableColumnDrag="true" />
+	</groupbox>
 
     <popupset id="csp_popupset">
         <popup id="ausp_actions" position="at_pointer">



More information about the open-ils-commits mailing list