[open-ils-commits] r14779 - in trunk/Open-ILS: web/opac/locale/en-US xul/staff_client/chrome/content/main xul/staff_client/chrome/content/util 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 Nov 4 17:05:03 EST 2009
Author: phasefx
Date: 2009-11-04 17:04:57 -0500 (Wed, 04 Nov 2009)
New Revision: 14779
Added:
trunk/Open-ILS/xul/staff_client/chrome/content/util/timestamp.js
trunk/Open-ILS/xul/staff_client/chrome/content/util/timestamp.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/circ.properties
trunk/Open-ILS/xul/staff_client/server/locale/en-US/common.properties
trunk/Open-ILS/xul/staff_client/server/patron/holds.js
Log:
Generic date/timestamp dialog and a change to Shelf Expire Time as an example of how to use it. Need to start plugging it into places like Edit Due Date, etc
Modified: trunk/Open-ILS/web/opac/locale/en-US/lang.dtd
===================================================================
--- trunk/Open-ILS/web/opac/locale/en-US/lang.dtd 2009-11-04 21:52:55 UTC (rev 14778)
+++ trunk/Open-ILS/web/opac/locale/en-US/lang.dtd 2009-11-04 22:04:57 UTC (rev 14779)
@@ -2958,3 +2958,14 @@
<!ENTITY staff.circ.alternate_copy_summary.Total_Circs___Current_Year.label "Total Circs - Current Year">
<!ENTITY staff.circ.alternate_copy_summary.Total_Circs.label "Total Circs">
<!ENTITY staff.circ.alternate_copy_summary.Total_Circs___Prev_Year.label "Total Circs - Prev Year">
+<!ENTITY staff.util.timestamp_dialog.title "Select Date or Timestamp:">
+<!ENTITY staff.util.timestamp_dialog.date.label "Date:">
+<!ENTITY staff.util.timestamp_dialog.date.accesskey "D">
+<!ENTITY staff.util.timestamp_dialog.cancel_btn.label "Cancel">
+<!ENTITY staff.util.timestamp_dialog.cancel_btn.accesskey "C">
+<!ENTITY staff.util.timestamp_dialog.remove_btn.label "Remove">
+<!ENTITY staff.util.timestamp_dialog.remove_btn.accesskey "R">
+<!ENTITY staff.util.timestamp_dialog.apply_btn.label "Apply">
+<!ENTITY staff.util.timestamp_dialog.apply_btn.accesskey "A">
+
+
Modified: trunk/Open-ILS/xul/staff_client/chrome/content/main/constants.js
===================================================================
--- trunk/Open-ILS/xul/staff_client/chrome/content/main/constants.js 2009-11-04 21:52:55 UTC (rev 14778)
+++ trunk/Open-ILS/xul/staff_client/chrome/content/main/constants.js 2009-11-04 22:04:57 UTC (rev 14779)
@@ -361,6 +361,7 @@
'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_TIMESTAMP_DIALOG' : '/xul/server/util/timestamp.xul',
'XUL_USER_BUCKETS' : '/xul/server/patron/user_buckets.xul',
'XUL_VERIFY_CREDENTIALS' : '/xul/server/main/verify_credentials.xul',
'XUL_VOLUME_BUCKETS' : '/xul/server/cat/volume_buckets.xul',
Added: trunk/Open-ILS/xul/staff_client/chrome/content/util/timestamp.js
===================================================================
--- trunk/Open-ILS/xul/staff_client/chrome/content/util/timestamp.js (rev 0)
+++ trunk/Open-ILS/xul/staff_client/chrome/content/util/timestamp.js 2009-11-04 22:04:57 UTC (rev 14779)
@@ -0,0 +1,136 @@
+var data; var error; var network; var sound;
+
+function $(id) { return document.getElementById(id); }
+
+function default_focus() { $('cancel_btn').focus(); } // parent interfaces often call this
+
+function timestamp_init() {
+ try {
+
+ commonStrings = $('commonStrings');
+
+ if (typeof JSAN == 'undefined') {
+ throw(
+ commonStrings.getString('common.jsan.missing')
+ );
+ }
+
+ JSAN.errorLevel = "die"; // none, warn, or die
+ JSAN.addRepository('..');
+
+ JSAN.use('util.error'); error = new util.error();
+ JSAN.use('util.sound'); sound = new util.sound();
+ JSAN.use('util.date');
+
+ $('datepicker').value = xul_param('default_date',{'modal_xulG':true}) || util.date.formatted_date(new Date(),'%F');
+
+ if (xul_param('title',{'modal_xulG':true})) { $('dialogheader').setAttribute('title',xul_param('title',{'modal_xulG':true})); }
+ if (xul_param('description',{'modal_xulG':true})) { $('dialogheader').setAttribute('description',xul_param('description',{'modal_xulG':true})); }
+
+ var x = $('msg_area');
+ if (x && xul_param('msg',{'modal_xulG':true})) {
+ var d = document.createElement('description');
+ var t = document.createTextNode( xul_param('msg',{'modal_xulG':true}) );
+ x.appendChild( d );
+ d.appendChild( t );
+ }
+
+ if (xul_param('allow_unset',{'modal_xulG':true})) { $('remove_btn').hidden = false; }
+
+ /* set widget behavior */
+ $('cancel_btn').addEventListener(
+ 'command', function() { window.close(); }, false
+ );
+ $('apply_btn').addEventListener(
+ 'command',
+ gen_handle_apply(),
+ false
+ );
+ $('remove_btn').addEventListener(
+ 'command',
+ gen_handle_apply({'remove':true}),
+ false
+ );
+
+ $('datepicker').addEventListener(
+ 'change',
+ function(ev) {
+ try {
+ var check = check_date( ev.target.value );
+ if ( ! check.allowed ) { throw( check.reason ); }
+ $('apply_btn').disabled = false;
+ } catch(E) {
+ JSAN.use('util.sound'); var sound = new util.sound(); sound.bad();
+ var x = $('err_msg');
+ if (x) {
+ x.setAttribute('value', check.reason);
+ }
+ $('apply_btn').disabled = true;
+ }
+ dump('util.timestamp.js:date: ' + E + '\n');
+ },
+ false
+ );
+
+ default_focus();
+
+ } catch(E) {
+ var err_prefix = 'timestamp.js -> timestamp_init() : ';
+ if (error) error.standard_unexpected_error_alert(err_prefix,E); else alert(err_prefix + E);
+ }
+}
+
+function check_date(value) {
+ if (xul_param('disallow_future_dates',{'modal_xulG':true})) {
+ if ( ev.target.dateValue > new Date() ) { return { 'allowed' : false, 'reason' : $('commonStrings').getString('staff.util.timestamp_dialog.future_date_disallowed') }; }
+ }
+ if (xul_param('disallow_past_dates',{'modal_xulG':true})) {
+ if ( util.date.check_past('YYYY-MM-DD', ev.target.value) ) { return { 'allowed' : false, 'reason' : $('commonStrings').getString('staff.util.timestamp_dialog.past_date_disallowed') }; }
+ }
+ if (xul_param('disallow_today',{'modal_xulG':true})) {
+ if ( util.date.formatted_date(new Date(),'%F') == value) { return { 'allowed' : false, 'reason' : $('commonStrings').getString('staff.util.timestamp_dialog.today_disallowed') }; }
+ }
+ return { 'allowed' : true };
+}
+
+function gen_handle_apply(params) {
+ return function handle_apply(ev) {
+ try {
+
+ if (!params) { params = {}; }
+ if (params.remove) {
+ update_modal_xulG(
+ {
+ 'timestamp' : null,
+ 'complete' : 1
+ }
+ )
+ window.close();
+ } else {
+
+ var dp = $('datepicker');
+ var tp = $('timepicker');
+
+ var check = check_date( dp.value );
+ if ( ! check.allowed ) { alert( check.reason ); $('apply_btn').disabled = true; return; }
+
+ var tp_date = tp.dateValue;
+ var dp_date = dp.dateValue;
+ tp_date.setFullYear( dp_date.getFullYear() );
+ tp_date.setMonth( dp_date.getMonth() );
+ tp_date.setDate( dp_date.getDate() );
+
+ update_modal_xulG(
+ {
+ 'timestamp' : util.date.formatted_date(tp_date,'%{iso8601}'),
+ 'complete' : 1
+ }
+ )
+ window.close();
+ }
+
+ } catch(E) {
+ alert('Error in backdate.js, handle_apply(): ' + E);
+ }
+ };
+}
Added: trunk/Open-ILS/xul/staff_client/chrome/content/util/timestamp.xul
===================================================================
--- trunk/Open-ILS/xul/staff_client/chrome/content/util/timestamp.xul (rev 0)
+++ trunk/Open-ILS/xul/staff_client/chrome/content/util/timestamp.xul 2009-11-04 22:04:57 UTC (rev 14779)
@@ -0,0 +1,49 @@
+<?xml version="1.0"?>
+<!-- Application: Evergreen Staff Client -->
+<!-- Dialog: Generic Date/Time selector -->
+
+<!-- ///////////////////////////////////////////////////////////////////////////////////////////////////////////// -->
+<!-- PRESENTATION -->
+<?xml-stylesheet href="chrome://global/skin/" 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="timestamp_win"
+ onload="try { timestamp_init(); font_helper(); persist_helper(); } catch(E) { alert(E); }"
+ xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
+ oils_persist="height width"
+ title="&staff.util.timestamp_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="timestamp.js"/>
+
+ <!-- ///////////////////////////////////////////////////////////////////////////////////////////////////////////// -->
+ <!-- CONTENT -->
+ <dialogheader id="dialogheader" title="" description="" />
+ <vbox class="my_overflow" id="msg_area" flex="1"/>
+ <label id="err_msg" />
+ <hbox>
+ <label id="date_label" value="&staff.util.timestamp_dialog.date.label;" control="datepicker" accesskey="&staff.util.timestamp_dialog.date.accesskey;"/>
+ <datepicker id="datepicker" type="popup" context="clipboard"/>
+ <timepicker id="timepicker" type="popup" context="clipboard"/>
+ <spacer flex="1"/>
+ <button id="cancel_btn" label="&staff.util.timestamp_dialog.cancel_btn.label;" accesskey="&staff.util.timestamp_dialog.cancel_btn.accesskey;" />
+ <button id="remove_btn" label="&staff.util.timestamp_dialog.remove_btn.label;" accesskey="&staff.util.timestamp_dialog.remove_btn.accesskey;" hidden="true" />
+ <button id="apply_btn" label="&staff.util.timestamp_dialog.apply_btn.label;" accesskey="&staff.util.timestamp_dialog.apply_btn.accesskey;" />
+ </hbox>
+</window>
+
Modified: trunk/Open-ILS/xul/staff_client/server/locale/en-US/circ.properties
===================================================================
--- trunk/Open-ILS/xul/staff_client/server/locale/en-US/circ.properties 2009-11-04 21:52:55 UTC (rev 14778)
+++ trunk/Open-ILS/xul/staff_client/server/locale/en-US/circ.properties 2009-11-04 22:04:57 UTC (rev 14779)
@@ -389,8 +389,9 @@
staff.circ.holds.expire_time.too_early.error=Expiration Date needs to be either unset or set to fall on a future date.
staff.circ.holds.expire_time.invalid_date=Invalid Date
-staff.circ.holds.shelf_expire_time.prompt=Please enter a Shelf Expiration Date (or leave blank to unset) for hold %1$s.
-staff.circ.holds.shelf_expire_time.prompt.plural=Please enter a Shelf Expiration Date (or leave blank to unset) for holds %1$s.
+staff.circ.holds.shelf_expire_time.prompt=Please enter a Shelf Expiration Date for hold %1$s.
+staff.circ.holds.shelf_expire_time.prompt.plural=Please enter a Shelf Expiration Date for holds %1$s.
+staff.circ.holds.shelf_expire_time.dialog.description=Shelf Expire Time
staff.circ.holds.shelf_expire_time.invalid_date=Invalid Date
staff.circ.holds.modifying_holds=Modifying Holds
Modified: trunk/Open-ILS/xul/staff_client/server/locale/en-US/common.properties
===================================================================
--- trunk/Open-ILS/xul/staff_client/server/locale/en-US/common.properties 2009-11-04 21:52:55 UTC (rev 14778)
+++ trunk/Open-ILS/xul/staff_client/server/locale/en-US/common.properties 2009-11-04 22:04:57 UTC (rev 14779)
@@ -184,3 +184,7 @@
staff.main.gen_offline_widgets.registration.override=Override Registration Failure?
staff.main.gen_offline_widgets.registration.error=Workstation Registration error (%1$s)
staff.main.gen_offline_widgets.registration.success=Registration successful
+staff.util.timestamp_dialog.future_date_disallowed=Future dates disallowed.
+staff.util.timestamp_dialog.past_date_disallowed=Past dates disallowed.
+staff.util.timestamp_dialog.today_disallowed=Today disallowed.
+
Modified: trunk/Open-ILS/xul/staff_client/server/patron/holds.js
===================================================================
--- trunk/Open-ILS/xul/staff_client/server/patron/holds.js 2009-11-04 21:52:55 UTC (rev 14778)
+++ trunk/Open-ILS/xul/staff_client/server/patron/holds.js 2009-11-04 22:04:57 UTC (rev 14779)
@@ -837,36 +837,30 @@
['command'],
function() {
try {
- JSAN.use('util.date');
- function check_date(value) {
- try {
- if (! util.date.check('YYYY-MM-DD',value) ) { throw(document.getElementById('circStrings').getString('staff.circ.holds.shelf_expire_time.invalid_date')); }
- return true;
- } catch(E) {
- alert(E);
- return false;
- }
- }
-
var hold_list = util.functional.map_list(obj.retrieve_ids, function(o){return o.id;});
var msg_singular = document.getElementById('circStrings').getFormattedString('staff.circ.holds.shelf_expire_time.prompt',[hold_list.join(', ')]);
var msg_plural = document.getElementById('circStrings').getFormattedString('staff.circ.holds.shelf_expire_time.prompt.plural',[hold_list.join(', ')]);
var msg = obj.retrieve_ids.length > 1 ? msg_plural : msg_singular;
- var value = 'YYYY-MM-DD';
var title = document.getElementById('circStrings').getString('staff.circ.holds.modifying_holds');
- var shelf_expire_time; var invalid = true;
- while(invalid) {
- shelf_expire_time = window.prompt(msg,value,title);
- if (shelf_expire_time) {
- invalid = ! check_date(shelf_expire_time);
- } else {
- invalid = false;
+ var desc = document.getElementById('circStrings').getString('staff.circ.holds.shelf_expire_time.dialog.description');
+
+ JSAN.use('util.window'); var win = new util.window();
+ var my_xulG = win.open(
+ urls.XUL_TIMESTAMP_DIALOG, 'edit_shelf_expire_time', 'chrome,resizable,modal',
+ {
+ 'title' : title,
+ 'description' : desc,
+ 'msg' : msg,
+ 'allow_unset' : false,
+ 'disallow_future_dates' : false,
+ 'disallow_past_dates' : false,
+ 'disallow_today' : false
}
- }
- if (shelf_expire_time || shelf_expire_time == '') {
+ );
+ if (my_xulG.complete) {
circ.util.batch_hold_update(
hold_list,
- { 'shelf_expire_time' : shelf_expire_time == '' ? null : util.date.formatted_date(shelf_expire_time + ' 00:00:00','%{iso8601}') },
+ { 'shelf_expire_time' : my_xulG.timestamp },
{ 'progressmeter' : progressmeter, 'oncomplete' : function() { obj.clear_and_retrieve(true); } }
);
}
More information about the open-ils-commits
mailing list