[open-ils-commits] r13728 - in trunk/Open-ILS: web/opac/locale/en-US xul/staff_client/chrome/content/main 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
Fri Jul 24 13:14:23 EDT 2009


Author: phasefx
Date: 2009-07-24 13:14:19 -0400 (Fri, 24 Jul 2009)
New Revision: 13728

Added:
   trunk/Open-ILS/xul/staff_client/server/patron/edit_standing_penalty.js
   trunk/Open-ILS/xul/staff_client/server/patron/edit_standing_penalty.xul
   trunk/Open-ILS/xul/staff_client/server/patron/new_standing_penalty.js
   trunk/Open-ILS/xul/staff_client/server/patron/new_standing_penalty.xul
Modified:
   trunk/Open-ILS/web/opac/locale/en-US/lang.dtd
   trunk/Open-ILS/xul/staff_client/chrome/content/main/constants.js
   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
   trunk/Open-ILS/xul/staff_client/server/patron/util.js
Log:
Reworking of the "Messages" interface in the patron display for manipulating standing penalties.  Not yet complete, but functional.  

TODO:
Need to add a field for staff initials if a specific OU setting is present, and need to add a section and some methods for "archived" messages.  Also need to change how penalties are expressed in the summary sidebar.  Also need thought on 
how/whether/when this will replace the existing Notes infrastructure, since it can do the same thing but better.  

NOTES:
Experimenting with xul toolbar/toolbox; there's a beep when you use the hot key for the Actions menu that this might be the cause of.  Also, we're actually using the Dojo openils.PermaCrud code for 
modifying existing penalties.  Exciting :)



Modified: trunk/Open-ILS/web/opac/locale/en-US/lang.dtd
===================================================================
--- trunk/Open-ILS/web/opac/locale/en-US/lang.dtd	2009-07-24 16:32:49 UTC (rev 13727)
+++ trunk/Open-ILS/web/opac/locale/en-US/lang.dtd	2009-07-24 17:14:19 UTC (rev 13728)
@@ -1217,15 +1217,41 @@
 <!ENTITY staff.patron_display.standing.label 'Standing:'>
 <!ENTITY staff.patron_display.status.caption 'Status'>
 <!ENTITY staff.patron_display_interface_label "Patron">
-<!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.caption "Staff-Generated 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 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.apply.label "Apply Standing Penalty/Message">
+<!ENTITY staff.patron_display.penalty.menu.apply.accesskey "S">
+<!ENTITY staff.patron_display.penalty.menu.actions.remove.label "Remove Penalty/Message">
 <!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_display.penalty.menu.actions.edit.label "Modify Penalty/Message">
+<!ENTITY staff.patron_display.penalty.menu.actions.edit.accesskey "M">
+<!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">
+<!ENTITY staff.patron_display.apply_penalty_dialog.radio_btn.note.label "Note">
+<!ENTITY staff.patron_display.apply_penalty_dialog.radio_btn.note.accesskey "N">
+<!ENTITY staff.patron_display.apply_penalty_dialog.radio_btn.alert.label "Alert">
+<!ENTITY staff.patron_display.apply_penalty_dialog.radio_btn.alert.accesskey "t">
+<!ENTITY staff.patron_display.apply_penalty_dialog.radio_btn.block.label "Block">
+<!ENTITY staff.patron_display.apply_penalty_dialog.radio_btn.block.accesskey "k">
+<!ENTITY staff.patron_display.apply_penalty_dialog.cancel_btn.label "Cancel">
+<!ENTITY staff.patron_display.apply_penalty_dialog.cancel_btn.accesskey "C">
+<!ENTITY staff.patron_display.apply_penalty_dialog.apply_btn.label "Apply">
+<!ENTITY staff.patron_display.apply_penalty_dialog.apply_btn.accesskey "A">
+<!ENTITY staff.patron_display.edit_penalty_dialog.title "Modify Standing Penalty/Message">
+<!ENTITY staff.patron_display.edit_penalty_dialog.header "Modify Standing Penalty/Message">
+<!ENTITY staff.patron_display.edit_penalty_dialog.description "Notes, Alerts, Blocks">
+<!ENTITY staff.patron_display.edit_penalty_dialog.radio_btn.note.label "Note">
+<!ENTITY staff.patron_display.edit_penalty_dialog.radio_btn.note.accesskey "N">
+<!ENTITY staff.patron_display.edit_penalty_dialog.radio_btn.alert.label "Alert">
+<!ENTITY staff.patron_display.edit_penalty_dialog.radio_btn.alert.accesskey "t">
+<!ENTITY staff.patron_display.edit_penalty_dialog.radio_btn.block.label "Block">
+<!ENTITY staff.patron_display.edit_penalty_dialog.radio_btn.block.accesskey "k">
+<!ENTITY staff.patron_display.edit_penalty_dialog.cancel_btn.label "Cancel">
+<!ENTITY staff.patron_display.edit_penalty_dialog.cancel_btn.accesskey "C">
+<!ENTITY staff.patron_display.edit_penalty_dialog.apply_btn.label "Modify">
+<!ENTITY staff.patron_display.edit_penalty_dialog.apply_btn.accesskey "M">
 <!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/chrome/content/main/constants.js
===================================================================
--- trunk/Open-ILS/xul/staff_client/chrome/content/main/constants.js	2009-07-24 16:32:49 UTC (rev 13727)
+++ trunk/Open-ILS/xul/staff_client/chrome/content/main/constants.js	2009-07-24 17:14:19 UTC (rev 13728)
@@ -35,6 +35,9 @@
 }
 
 const api = {
+    'PCRUD_XACT_BEGIN' : { 'app' : 'open-ils.pcrud', 'method' : 'open-ils.pcrud.transaction.begin' },
+    'PCRUD_XACT_COMMIT' : { 'app' : 'open-ils.pcrud', 'method' : 'open-ils.pcrud.transaction.commit' },
+    'PCRUD_XACT_ROLLBACK' : { 'app' : 'open-ils.pcrud', 'method' : 'open-ils.pcrud.transaction.rollback' },
 	'TEST_SECURE' : { 'app' : 'open-ils.actor', 'method' : 'opensrf.system.time' },
 	'TEST_UNSECURE' : { 'app' : 'open-ils.actor', 'method' : 'opensrf.system.time', 'secure' : false },
 	'AUTH_INIT' : { 'app' : 'open-ils.auth', 'method' : 'open-ils.auth.authenticate.init' },
@@ -154,6 +157,7 @@
 	'FM_AUS_UPDATE' : { 'app' : 'open-ils.actor', 'method' : 'open-ils.actor.patron.settings.update' },
 	'FM_AUSP_APPLY' : { 'app' : 'open-ils.actor', 'method' : 'open-ils.actor.user.penalty.apply' },
 	'FM_AUSP_REMOVE' : { 'app' : 'open-ils.actor', 'method' : 'open-ils.actor.user.penalty.remove' },
+    'FM_AUSP_PCRUD_UPDATE' : { 'app' : 'open-ils.pcrud', 'method' : 'open-ils.pcrud.update.ausp', 'secure' : false },
 	'FM_AUSP_UPDATE_NOTE' : { 'app' : 'open-ils.actor', 'method' : 'open-ils.actor.user.penalty.note.update' },
 	'FM_BRE_RETRIEVE_VIA_ID' : { 'app' : 'open-ils.cat', 'method' : 'open-ils.cat.biblio.record.metadata.retrieve', 'secure' : false },
 	'FM_BRE_RETRIEVE_VIA_ID.authoritative' : { 'app' : 'open-ils.cat', 'method' : 'open-ils.cat.biblio.record.metadata.retrieve.authoritative', 'secure' : false },
@@ -334,6 +338,8 @@
 	'XUL_SPINE_LABEL' : '/xul/server/cat/spine_labels.xul',
 	'XUL_STANDALONE' : 'chrome://open_ils_staff_client/content/circ/offline.xul',
 	'XUL_STANDING_PENALTIES' : '/xul/server/patron/standing_penalties.xul',
+	'XUL_NEW_STANDING_PENALTY' : '/xul/server/patron/new_standing_penalty.xul',
+	'XUL_EDIT_STANDING_PENALTY' : '/xul/server/patron/edit_standing_penalty.xul',
 	'XUL_STAT_CAT_EDIT' : '/xul/server/admin/stat_cat_editor.xhtml',
 	'XUL_SURVEY_WIZARD' : 'chrome://open_ils_staff_client/content/admin/survey_wizard.xul',
 	'XUL_USER_BUCKETS' : '/xul/server/patron/user_buckets.xul',

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-24 16:32:49 UTC (rev 13727)
+++ trunk/Open-ILS/xul/staff_client/server/locale/en-US/patron.properties	2009-07-24 17:14:19 UTC (rev 13728)
@@ -245,14 +245,9 @@
 staff.patron.summary.expires_on=Expires on
 staff.patron.summary.standing_penalty.remove=Remove
 staff.patron.summary.standing_penalty.none=No Blocks/Penalties
-staff.patron.standing_penalty.note_prompt=Enter note to go with penalties:
-staff.patron.standing_penalty.note_title=Apply Penalty
 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.note_prompt.title=Edit Block/Standing Penalty Note
-staff.patron.standing_penalty.note_prompt.singular=Enter note for selected block/standing penalty:
-staff.patron.standing_penalty.note_prompt.plural=Enter note for selected blocks/standing penalties:
 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

Added: trunk/Open-ILS/xul/staff_client/server/patron/edit_standing_penalty.js
===================================================================
--- trunk/Open-ILS/xul/staff_client/server/patron/edit_standing_penalty.js	                        (rev 0)
+++ trunk/Open-ILS/xul/staff_client/server/patron/edit_standing_penalty.js	2009-07-24 17:14:19 UTC (rev 13728)
@@ -0,0 +1,124 @@
+var data; var error; 
+
+function default_focus() { document.getElementById('note_tb').focus(); } // parent interfaces often call this
+
+function edit_penalty_init() {
+    try {
+
+        commonStrings = document.getElementById('commonStrings');
+        patronStrings = document.getElementById('patronStrings');
+
+        if (typeof JSAN == 'undefined') {
+            throw(
+                commonStrings.getString('common.jsan.missing')
+            );
+        }
+
+        JSAN.errorLevel = "die"; // none, warn, or die
+        JSAN.addRepository('..');
+
+		JSAN.use('OpenILS.data'); data = new OpenILS.data(); data.stash_retrieve();
+
+        JSAN.use('util.error'); error = new util.error();
+        JSAN.use('util.widgets');
+
+        build_penalty_menu();
+
+        /* set widget values */
+        document.getElementById('csp_menupopup').setAttribute('value',xul_param('id',{'modal_xulG':true}));
+        if (xul_param('id',{'modal_xulG':true})==21) { // SILENT_NOTE
+            document.getElementById('note_btn').checked = true;
+        } else if (xul_param('id',{'modal_xulG':true})==20) { // ALERT_NOTE
+            document.getElementById('alert_btn').checked = true;
+        } else if (xul_param('id',{'modal_xulG':true})==25) { // STAFF_CHR
+            document.getElementById('block_btn').checked = true;
+        } else {
+            var nl = document.getElementById('csp_menupopup').getElementsByAttribute('value',xul_param('id',{'modal_xulG':true}));
+            if (nl.length > 0) {
+                document.getElementById('csp_menulist').setAttribute('label', nl[0].getAttribute('label'));
+            } else {
+                document.getElementById('csp_menulist').setAttribute('label', '???');
+            }
+        }
+
+        /* set widget behavior */
+        document.getElementById('csp_menulist').addEventListener(
+            'command',
+            function() {
+                document.getElementById('note_btn').checked = false;
+                document.getElementById('alert_btn').checked = false;
+                document.getElementById('block_btn').checked = false;
+            },
+            false
+        );
+        document.getElementById('note_btn').addEventListener(
+            'command', 
+            function() { 
+                document.getElementById('csp_menulist').setAttribute('label',''); 
+                document.getElementById('csp_menupopup').setAttribute('value','21'); // SILENT_NOTE
+            }, 
+            false
+        );
+        document.getElementById('alert_btn').addEventListener(
+            'command', 
+            function() { 
+                document.getElementById('csp_menulist').setAttribute('label',''); 
+                document.getElementById('csp_menupopup').setAttribute('value','20'); // ALERT_NOTE
+            }, 
+            false
+        );
+        document.getElementById('block_btn').addEventListener(
+            'command', 
+            function() { 
+                document.getElementById('csp_menulist').setAttribute('label',''); 
+                document.getElementById('csp_menupopup').setAttribute('value','25'); // STAFF_CHR
+            }, 
+            false
+        );
+        document.getElementById('cancel_btn').addEventListener(
+            'command', function() { window.close(); }, false
+        );
+        document.getElementById('apply_btn').addEventListener(
+            'command', 
+            function() {
+                update_modal_xulG(
+                    {
+                        'id' : document.getElementById('csp_menupopup').getAttribute('value'),
+                        'note' : document.getElementById('note_tb').value,
+                        'modify' : 1
+                    }
+                )
+                window.close();
+            }, 
+            false
+        );
+        default_focus();
+
+    } catch(E) {
+        var err_prefix = 'standing_penalties.js -> penalty_init() : ';
+        if (error) error.standard_unexpected_error_alert(err_prefix,E); else alert(err_prefix + E);
+    }
+
+}
+
+function build_penalty_menu() {
+    try {
+
+        var csp_menupopup = document.getElementById('csp_menupopup');
+        util.widgets.remove_children(csp_menupopup);
+        for (var i = 0; i < data.list.csp.length; i++) {
+            if (data.list.csp[i].id() > 100) {
+                var menuitem = document.createElement('menuitem'); csp_menupopup.appendChild(menuitem);
+                menuitem.setAttribute('label',data.list.csp[i].label());
+                menuitem.setAttribute('value',data.list.csp[i].id());
+                menuitem.setAttribute('id','csp_'+data.list.csp[i].id());
+                menuitem.setAttribute('oncommand',"var p = this.parentNode; p.parentNode.setAttribute('label',this.getAttribute('label')); p.setAttribute('value'," + data.list.csp[i].id() + ")");
+            }
+        }
+
+    } catch(E) {
+        var err_prefix = 'edit_standing_penalty.js -> build_penalty_menu() : ';
+        if (error) error.standard_unexpected_error_alert(err_prefix,E); else alert(err_prefix + E);
+    }
+}
+

Added: trunk/Open-ILS/xul/staff_client/server/patron/edit_standing_penalty.xul
===================================================================
--- trunk/Open-ILS/xul/staff_client/server/patron/edit_standing_penalty.xul	                        (rev 0)
+++ trunk/Open-ILS/xul/staff_client/server/patron/edit_standing_penalty.xul	2009-07-24 17:14:19 UTC (rev 13728)
@@ -0,0 +1,66 @@
+<?xml version="1.0"?>
+<!-- Application: Evergreen Staff Client -->
+<!-- Dialog: Edit Standing Penalty to Patron -->
+
+<!-- ///////////////////////////////////////////////////////////////////////////////////////////////////////////// -->
+<!-- PRESENTATION -->
+<?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
+<?xml-stylesheet href="chrome://open_ils_staff_client/skin/global.css" type="text/css"?>
+<?xml-stylesheet href="/xul/server/skin/global.css" type="text/css"?>
+
+<!-- ///////////////////////////////////////////////////////////////////////////////////////////////////////////// -->
+<!-- LOCALIZATION -->
+<!DOCTYPE window PUBLIC "" ""[
+	<!--#include virtual="/opac/locale/${locale}/lang.dtd"-->
+]>
+
+<!-- ///////////////////////////////////////////////////////////////////////////////////////////////////////////// -->
+<!-- OVERLAYS -->
+<?xul-overlay href="/xul/server/OpenILS/util_overlay.xul"?>
+
+<window id="edit_penalty_win" 
+    onload="try { edit_penalty_init(); font_helper(); } catch(E) { alert(E); }"
+	xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
+    title="&staff.patron_display.edit_penalty_dialog.title;">
+
+	<!-- ///////////////////////////////////////////////////////////////////////////////////////////////////////////// -->
+	<!-- BEHAVIOR -->
+	<script type="text/javascript">var myPackageDir = 'open_ils_staff_client'; var IAMXUL = true;</script>
+	<scripts id="openils_util_scripts"/>
+
+	<script type="text/javascript" src="/xul/server/main/JSAN.js"/>
+	<script type="text/javascript" src="edit_standing_penalty.js"/>
+
+	<messagecatalog id="patronStrings" src="/xul/server/locale/<!--#echo var='locale'-->/patron.properties" />
+
+	<!-- ///////////////////////////////////////////////////////////////////////////////////////////////////////////// -->
+	<!-- CONTENT -->
+    <dialogheader title="&staff.patron_display.edit_penalty_dialog.header;" description="&staff.patron_display.edit_penalty_dialog.description;" />
+    <toolbox flex="1">
+        <toolbar>
+            <toolbarbutton id="note_btn" 
+                type="radio" group="radio" style="-moz-user-focus: normal" 
+                label="&staff.patron_display.edit_penalty_dialog.radio_btn.note.label;" accesskey="&staff.patron_display.edit_penalty_dialog.radio_btn.note.accesskey;" 
+                checked="true"/>
+            <toolbarbutton id="alert_btn" 
+                type="radio" group="radio" style="-moz-user-focus: normal" 
+                label="&staff.patron_display.edit_penalty_dialog.radio_btn.alert.label;" accesskey="&staff.patron_display.edit_penalty_dialog.radio_btn.alert.accesskey;" />
+            <toolbarbutton id="block_btn" 
+                type="radio" group="radio" style="-moz-user-focus: normal" 
+                label="&staff.patron_display.edit_penalty_dialog.radio_btn.block.label;" accesskey="&staff.patron_display.edit_penalty_dialog.radio_btn.block.accesskey;" />
+            <toolbarspring/>
+            <toolbaritem>
+                <menulist id="csp_menulist" label="">
+                    <menupopup id="csp_menupopup" />
+                </menulist>
+            </toolbaritem>
+        </toolbar>
+    </toolbox>
+    <textbox id="note_tb" multiline="true" />
+    <hbox>
+        <spacer flex="1"/>
+        <button id="cancel_btn" label="&staff.patron_display.edit_penalty_dialog.cancel_btn.label;" accesskey="&staff.patron_display.edit_penalty_dialog.cancel_btn.accesskey;" />
+        <button id="apply_btn" label="&staff.patron_display.edit_penalty_dialog.apply_btn.label;" accesskey="&staff.patron_display.edit_penalty_dialog.apply_btn.label;" />
+    </hbox>
+</window>
+

Added: trunk/Open-ILS/xul/staff_client/server/patron/new_standing_penalty.js
===================================================================
--- trunk/Open-ILS/xul/staff_client/server/patron/new_standing_penalty.js	                        (rev 0)
+++ trunk/Open-ILS/xul/staff_client/server/patron/new_standing_penalty.js	2009-07-24 17:14:19 UTC (rev 13728)
@@ -0,0 +1,108 @@
+var data; var error; 
+
+function default_focus() { document.getElementById('note_tb').focus(); } // parent interfaces often call this
+
+function new_penalty_init() {
+    try {
+
+        commonStrings = document.getElementById('commonStrings');
+        patronStrings = document.getElementById('patronStrings');
+
+        if (typeof JSAN == 'undefined') {
+            throw(
+                commonStrings.getString('common.jsan.missing')
+            );
+        }
+
+        JSAN.errorLevel = "die"; // none, warn, or die
+        JSAN.addRepository('..');
+
+		JSAN.use('OpenILS.data'); data = new OpenILS.data(); data.stash_retrieve();
+
+        JSAN.use('util.error'); error = new util.error();
+        JSAN.use('util.widgets');
+
+        build_penalty_menu();
+
+        /* set widget behavior */
+        document.getElementById('csp_menulist').addEventListener(
+            'command',
+            function() {
+                document.getElementById('note_btn').checked = false;
+                document.getElementById('alert_btn').checked = false;
+                document.getElementById('block_btn').checked = false;
+            },
+            false
+        );
+        document.getElementById('note_btn').addEventListener(
+            'command', 
+            function() { 
+                document.getElementById('csp_menulist').setAttribute('label',''); 
+                document.getElementById('csp_menupopup').setAttribute('value','21'); // SILENT_NOTE
+            }, 
+            false
+        );
+        document.getElementById('alert_btn').addEventListener(
+            'command', 
+            function() { 
+                document.getElementById('csp_menulist').setAttribute('label',''); 
+                document.getElementById('csp_menupopup').setAttribute('value','20'); // ALERT_NOTE
+            }, 
+            false
+        );
+        document.getElementById('block_btn').addEventListener(
+            'command', 
+            function() { 
+                document.getElementById('csp_menulist').setAttribute('label',''); 
+                document.getElementById('csp_menupopup').setAttribute('value','25'); // STAFF_CHR
+            }, 
+            false
+        );
+        document.getElementById('cancel_btn').addEventListener(
+            'command', function() { window.close(); }, false
+        );
+        document.getElementById('apply_btn').addEventListener(
+            'command', 
+            function() {
+                update_modal_xulG(
+                    {
+                        'id' : document.getElementById('csp_menupopup').getAttribute('value'),
+                        'note' : document.getElementById('note_tb').value,
+                        'modify' : 1
+                    }
+                )
+                window.close();
+            }, 
+            false
+        );
+
+        default_focus();
+
+    } catch(E) {
+        var err_prefix = 'standing_penalties.js -> penalty_init() : ';
+        if (error) error.standard_unexpected_error_alert(err_prefix,E); else alert(err_prefix + E);
+    }
+
+}
+
+function build_penalty_menu() {
+    try {
+
+        var csp_menupopup = document.getElementById('csp_menupopup');
+        util.widgets.remove_children(csp_menupopup);
+        for (var i = 0; i < data.list.csp.length; i++) {
+            if (data.list.csp[i].id() > 100) {
+                var menuitem = document.createElement('menuitem'); csp_menupopup.appendChild(menuitem);
+                menuitem.setAttribute('label',data.list.csp[i].label());
+                menuitem.setAttribute('value',data.list.csp[i].id());
+                menuitem.setAttribute('id','csp_'+data.list.csp[i].id());
+                menuitem.setAttribute('oncommand',"var p = this.parentNode; p.parentNode.setAttribute('label',this.getAttribute('label')); p.setAttribute('value'," + data.list.csp[i].id() + ")");
+            }
+        }
+
+    } catch(E) {
+        var err_prefix = 'new_standing_penalty.js -> build_penalty_menu() : ';
+        if (error) error.standard_unexpected_error_alert(err_prefix,E); else alert(err_prefix + E);
+    }
+}
+

Added: trunk/Open-ILS/xul/staff_client/server/patron/new_standing_penalty.xul
===================================================================
--- trunk/Open-ILS/xul/staff_client/server/patron/new_standing_penalty.xul	                        (rev 0)
+++ trunk/Open-ILS/xul/staff_client/server/patron/new_standing_penalty.xul	2009-07-24 17:14:19 UTC (rev 13728)
@@ -0,0 +1,66 @@
+<?xml version="1.0"?>
+<!-- Application: Evergreen Staff Client -->
+<!-- Dialog: Apply Standing Penalty to Patron -->
+
+<!-- ///////////////////////////////////////////////////////////////////////////////////////////////////////////// -->
+<!-- PRESENTATION -->
+<?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
+<?xml-stylesheet href="chrome://open_ils_staff_client/skin/global.css" type="text/css"?>
+<?xml-stylesheet href="/xul/server/skin/global.css" type="text/css"?>
+
+<!-- ///////////////////////////////////////////////////////////////////////////////////////////////////////////// -->
+<!-- LOCALIZATION -->
+<!DOCTYPE window PUBLIC "" ""[
+	<!--#include virtual="/opac/locale/${locale}/lang.dtd"-->
+]>
+
+<!-- ///////////////////////////////////////////////////////////////////////////////////////////////////////////// -->
+<!-- OVERLAYS -->
+<?xul-overlay href="/xul/server/OpenILS/util_overlay.xul"?>
+
+<window id="new_penalty_win" 
+    onload="try { new_penalty_init(); font_helper(); } catch(E) { alert(E); }"
+	xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
+    title="&staff.patron_display.apply_penalty_dialog.title;">
+
+	<!-- ///////////////////////////////////////////////////////////////////////////////////////////////////////////// -->
+	<!-- BEHAVIOR -->
+	<script type="text/javascript">var myPackageDir = 'open_ils_staff_client'; var IAMXUL = true;</script>
+	<scripts id="openils_util_scripts"/>
+
+	<script type="text/javascript" src="/xul/server/main/JSAN.js"/>
+	<script type="text/javascript" src="new_standing_penalty.js"/>
+
+	<messagecatalog id="patronStrings" src="/xul/server/locale/<!--#echo var='locale'-->/patron.properties" />
+
+	<!-- ///////////////////////////////////////////////////////////////////////////////////////////////////////////// -->
+	<!-- CONTENT -->
+    <dialogheader title="&staff.patron_display.apply_penalty_dialog.header;" description="&staff.patron_display.apply_penalty_dialog.description;" />
+    <toolbox flex="1">
+        <toolbar>
+            <toolbarbutton id="note_btn" 
+                type="radio" group="radio" style="-moz-user-focus: normal" 
+                label="&staff.patron_display.apply_penalty_dialog.radio_btn.note.label;" accesskey="&staff.patron_display.apply_penalty_dialog.radio_btn.note.accesskey;" 
+                checked="true"/>
+            <toolbarbutton id="alert_btn" 
+                type="radio" group="radio" style="-moz-user-focus: normal" 
+                label="&staff.patron_display.apply_penalty_dialog.radio_btn.alert.label;" accesskey="&staff.patron_display.apply_penalty_dialog.radio_btn.alert.accesskey;" />
+            <toolbarbutton id="block_btn" 
+                type="radio" group="radio" style="-moz-user-focus: normal" 
+                label="&staff.patron_display.apply_penalty_dialog.radio_btn.block.label;" accesskey="&staff.patron_display.apply_penalty_dialog.radio_btn.block.accesskey;" />
+            <toolbarspring/>
+            <toolbaritem>
+                <menulist id="csp_menulist" label="">
+                    <menupopup id="csp_menupopup" value="21"/> <!-- default SILENT_NOTE -->
+                </menulist>
+            </toolbaritem>
+        </toolbar>
+    </toolbox>
+    <textbox id="note_tb" multiline="true" />
+    <hbox>
+        <spacer flex="1"/>
+        <button id="cancel_btn" label="&staff.patron_display.apply_penalty_dialog.cancel_btn.label;" accesskey="&staff.patron_display.apply_penalty_dialog.cancel_btn.accesskey;" />
+        <button id="apply_btn" label="&staff.patron_display.apply_penalty_dialog.apply_btn.label;" accesskey="&staff.patron_display.apply_penalty_dialog.apply_btn.label;" />
+    </hbox>
+</window>
+

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-24 16:32:49 UTC (rev 13727)
+++ trunk/Open-ILS/xul/staff_client/server/patron/standing_penalties.js	2009-07-24 17:14:19 UTC (rev 13728)
@@ -1,7 +1,10 @@
 var list; var data; var error; var net; var rows;
 
+function default_focus() { document.getElementById('apply_btn').focus(); } // parent interfaces often call this
+
 function penalty_init() {
     try {
+        netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect"); 
 
         commonStrings = document.getElementById('commonStrings');
         patronStrings = document.getElementById('patronStrings');
@@ -26,10 +29,11 @@
         JSAN.use('util.widgets');
 
         init_list();
-        build_penalty_menu();
+        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);
         populate_list();
+        default_focus();
 
     } catch(E) {
         var err_prefix = 'standing_penalties.js -> penalty_init() : ';
@@ -67,8 +71,10 @@
     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');
     }
 }
 
@@ -96,58 +102,37 @@
     }
 }
 
-function build_penalty_menu() {
+function handle_apply_penalty(ev) {
     try {
+        netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect"); 
+        JSAN.use('util.window');
+        var win = new util.window();
+        var my_xulG = win.open(
+            urls.XUL_NEW_STANDING_PENALTY,
+            'new_standing_penalty',
+            'chrome,resizable,modal',
+            {}
+        );
 
-        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.setAttribute('id','csp_'+data.list.csp[i].id());
-                menuitem.addEventListener(
-                    'command',
-                    handle_menuitem,
-                    false
-                );
-            }
-        }
+        if (!my_xulG.id) { alert('cancelled'); return 0; }
 
-    } catch(E) {
-        var err_prefix = 'standing_penalties.js -> build_penalty_menu() : ';
-        if (error) error.standard_unexpected_error_alert(err_prefix,E); else alert(err_prefix + E);
-    }
-}
-
-function handle_menuitem(ev) {
-    try {
-
-        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 penalty = new ausp();
         penalty.usr( xulG.patron.id() );
         penalty.isnew( 1 );
-        penalty.standing_penalty( id );
+        penalty.standing_penalty( my_xulG.id );
         penalty.org_unit( ses('ws_ou') );
-        penalty.note( note );
+        penalty.note( my_xulG.note );
         net.simple_request(
             'FM_AUSP_APPLY', 
             [ ses(), penalty ],
-            generate_request_handler_for_penalty_apply( penalty, id )
+            generate_request_handler_for_penalty_apply( penalty, my_xulG.id )
         );
 
         document.getElementById('progress').hidden = false;
 
     } catch(E) {
-        var err_prefix = 'standing_penalties.js -> handle_menuitem() : ';
+        alert('error: ' + E);
+        var err_prefix = 'standing_penalties.js -> handle_apply_penalty() : ';
         if (error) error.standard_unexpected_error_alert(err_prefix,E); else alert(err_prefix + E);
     }
 }
@@ -187,7 +172,7 @@
         }
     };
 }
-        
+ 
 function handle_remove_penalty(ev) {
     try {
 
@@ -244,37 +229,60 @@
 function handle_edit_penalty(ev) {
     try {
 
+        netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect"); 
+        JSAN.use('util.window');
+        var win = new util.window();
+
         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 note = window.prompt(
-                patronStrings.getString( 'staff.patron.standing_penalty.note_prompt.' + (ids.length == 1 ? 'singular' : 'plural') ),
-                '',
-                patronStrings.getString( 'staff.patron.standing_penalty.note_prompt.title' )
-            );
-            if (note == null) { return; } /* cancel */
             for (var i = 0; i < ids.length; i++) {
                 var penalty = util.functional.find_list( xulG.patron.standing_penalties(), function(o) { return o.id() == ids[i]; } );
-                penalty.note( note ); /* this is for rendering, and propogates by reference to the object associated with the row in the GUI */
-            } 
-            document.getElementById('progress').hidden = false;
-            net.simple_request( 
-                'FM_AUSP_UPDATE_NOTE', [ ses(), ids, note ],
-                function(reqObj) {
-                    var req = reqObj.getResultObject();
-                    if (typeof req.ilsevent != 'undefined' || String(req) != '1') {
-                        error.standard_unexpected_error_alert(patronStrings.getString('staff.patron.standing_penalty.update_error'),req);
-                    } else {
-                        for (var i = 0; i < ids.length; i++) {
-                            list.refresh_row( rows[ ids[i] ] );
+                alert('penalty = ' + js2JSON(penalty));
+                var my_xulG = win.open(
+                    urls.XUL_EDIT_STANDING_PENALTY,
+                    'new_standing_penalty',
+                    'chrome,resizable,modal',
+                    { 
+                        'id' : typeof penalty.standing_penalty() == 'object' ? penalty.standing_penalty().id() : penalty.standing_penalty(), 
+                        'note' : penalty.note() 
+                    }
+                );
+                if (my_xulG.modify) {
+                    document.getElementById('progress').hidden = false;
+                    penalty.note( my_xulG.note ); /* this is for rendering, and propogates by reference to the object associated with the row in the GUI */
+                    penalty.standing_penalty( my_xulG.id );
+                    penalty.ischanged( 1 );
+                    dojo.require('openils.PermaCrud');
+                    var pcrud = new openils.PermaCrud( { authtoken :ses() });
+                    pcrud.apply( penalty, {
+                        timeout : 10, // makes it synchronous
+                        onerror : function(r) {
+                            try {
+                                document.getElementById('progress').hidden = true;
+                                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);
+                            }
+                        },
+                        oncomplete : function(r) {
+                            try {
+                                var res = openils.Util.readResponse(r,true);
+                                list.refresh_row( rows[ ids[i] ] );
+                                document.getElementById('progress').hidden = true;
+                            } catch(E) {
+                                alert(E);
+                            }
                         }
-                    }
-                    if (xulG && typeof xulG.refresh == 'function') {
-                        xulG.refresh();
-                    }
-                    document.getElementById('progress').hidden = true;
+                    });
                 }
-            );
+            } 
+            /*
+            if (xulG && typeof xulG.refresh == 'function') {
+                xulG.refresh();
+            }
+            */
         }
 
     } catch(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-24 16:32:49 UTC (rev 13727)
+++ trunk/Open-ILS/xul/staff_client/server/patron/standing_penalties.xul	2009-07-24 17:14:19 UTC (rev 13728)
@@ -33,8 +33,12 @@
 
 	<commandset id="penalty_cmds">
 		<command id="cmd_apply_penalty" />
-		<command id="cmd_remove_penalty" />
-		<command id="cmd_edit_penalty" />
+		<command id="cmd_remove_penalty" disabled="true"/>
+		<command id="cmd_edit_penalty" disabled="true"/>
+		<command id="cmd_show_all" />
+		<command id="cmd_show_note" />
+		<command id="cmd_show_alert" />
+		<command id="cmd_show_block" />
 	</commandset>
 
 	<!-- ///////////////////////////////////////////////////////////////////////////////////////////////////////////// -->
@@ -43,23 +47,39 @@
 		<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>
+                <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>
+                        <toolbarseparator />
+                        <!--
+                        <toolbarbutton command="cmd_show_all" label="All" accesskey="A" type="radio" group="radio" style="-moz-user-focus: normal" checked="true"/>
+                        <toolbarbutton command="cmd_show_note" label="Note" accesskey="N" type="radio" group="radio" style="-moz-user-focus: normal"/>
+                        <toolbarbutton command="cmd_show_alert" label="Alert" accesskey="t" type="radio" group="radio" style="-moz-user-focus: normal"/>
+                        <toolbarbutton command="cmd_show_block" label="Block" accesskey="k" type="radio" group="radio" style="-moz-user-focus: normal"/>
+                        <toolbarseparator />
+                        -->
+                        <toolbarspring />
+                        <toolbaritem>
+                            <progressmeter id="progress" flex="1" hidden="true" mode="undetermined"/>
+                        </toolbaritem>
+                        <toolbarbutton 
+                            label="&staff.patron_display.penalty.menu.actions.label;" 
+                            accesskey="&staff.patron_display.penalty.menu.actions.accesskey;" 
+                            type="menu" style="-moz-user-focus: normal" 
+                            oncommand="this.focus(); this.firstChild.showPopup()">
+                            <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>
+                        </toolbarbutton>
+                    </toolbar>
+                </toolbox>
             </hbox>
         </vbox>
         <tree id="ausp_list" flex="1" enableColumnDrag="true" context="ausp_actions"/>

Modified: trunk/Open-ILS/xul/staff_client/server/patron/util.js
===================================================================
--- trunk/Open-ILS/xul/staff_client/server/patron/util.js	2009-07-24 16:32:49 UTC (rev 13727)
+++ trunk/Open-ILS/xul/staff_client/server/patron/util.js	2009-07-24 17:14:19 UTC (rev 13728)
@@ -272,7 +272,7 @@
 		},
 		{
 			'persist' : 'hidden width ordinal', 'id' : 'csp_name', 'label' : commonStrings.getString('staff.csp_name_label'), 'flex' : 1,
-			'primary' : false, 'hidden' : false, 'render' : function(my) { return my.csp.name(); }
+			'primary' : false, 'hidden' : true, 'render' : function(my) { return my.csp.name(); }
 		},
 		{
 			'persist' : 'hidden width ordinal', 'id' : 'csp_label', 'label' : commonStrings.getString('staff.csp_label_label'), 'flex' : 1,



More information about the open-ils-commits mailing list