From 2519e9188ff3e825f2897f105e5acdac76ae837d Mon Sep 17 00:00:00 2001 From: phasefx Date: Thu, 15 Jul 2010 21:34:16 +0000 Subject: [PATCH] more configuration options for date/timepicker dialog, and use that dialog with staff editing of hold thaw date and expire time git-svn-id: svn://svn.open-ils.org/ILS/trunk@16950 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- .../staff_client/chrome/content/util/timestamp.js | 11 +++ .../server/locale/en-US/circ.properties | 16 ++-- Open-ILS/xul/staff_client/server/patron/holds.js | 85 +++++++++------------- 3 files changed, 53 insertions(+), 59 deletions(-) diff --git a/Open-ILS/xul/staff_client/chrome/content/util/timestamp.js b/Open-ILS/xul/staff_client/chrome/content/util/timestamp.js index 825dc9471..0c0a8ab7d 100644 --- a/Open-ILS/xul/staff_client/chrome/content/util/timestamp.js +++ b/Open-ILS/xul/staff_client/chrome/content/util/timestamp.js @@ -23,6 +23,17 @@ function timestamp_init() { JSAN.use('util.date'); $('datepicker').value = xul_param('default_date',{'modal_xulG':true}) || util.date.formatted_date(new Date(),'%F'); + if (xul_param('default_time',{'modal_xulG':true})) { + $('timepicker').value = xul_param('default_time',{'modal_xulG':true}); + } + if (xul_param('time_readonly',{'modal_xulG':true})) { + $('timepicker').readonly = true; // This isn't working correctly with xulrunner 1.9.2 + $('timepicker').disabled = true; // So, poor man's kludge + } + if (xul_param('date_readonly',{'modal_xulG':true})) { + $('datepicker').readonly = true; // This isn't working correctly with xulrunner 1.9.2 + $('datepicker').disabled = true; // So, poor man's kludge + } 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})); } diff --git a/Open-ILS/xul/staff_client/server/locale/en-US/circ.properties b/Open-ILS/xul/staff_client/server/locale/en-US/circ.properties index b046070ff..21626ee51 100644 --- a/Open-ILS/xul/staff_client/server/locale/en-US/circ.properties +++ b/Open-ILS/xul/staff_client/server/locale/en-US/circ.properties @@ -420,23 +420,19 @@ staff.circ.holds.activate.prompt=Are you sure you would like to activate hold %1 staff.circ.holds.activate.prompt.plural=Are you sure you would like to activate holds %1$s? staff.circ.holds.suspend.prompt=Are you sure you would like to suspend hold %1$s? staff.circ.holds.suspend.prompt.plural=Are you sure you would like to suspend holds %1$s? -staff.circ.holds.activation_date.prompt=Please enter an Activation Date (or leave blank to unset) for hold %1$s. This will also Suspend the hold. -staff.circ.holds.activation_date.prompt.plural=Please enter an Activation Date (or leave blank to unset) for holds %1$s. This will also Suspend the holds. -staff.circ.holds.activation_date.too_early.error=Activation Date needs to be either unset or set to fall on a future date. -staff.circ.holds.activation_date.invalid_date=Invalid Date +staff.circ.holds.activation_date.prompt=Please enter an Activation Date (or choose Remove to unset) for hold %1$s. This will also Suspend the hold. +staff.circ.holds.activation_date.prompt.plural=Please enter an Activation Date (or choose Remove to unset) for holds %1$s. This will also Suspend the holds. +staff.circ.holds.activation_date.dialog.description=Activation Date staff.circ.holds.request_date.prompt=Please enter a new Request Date for hold %1$s. WARNING: This effectively reorders the holds queue. staff.circ.holds.request_date.prompt.plural=Please enter a new Request Date for holds %1$s. WARNING: This effectively reorders the holds queue. staff.circ.holds.request_date.dialog.description=Request Date -staff.circ.holds.request_date.invalid_date=Invalid Date -staff.circ.holds.expire_time.prompt=Please enter an Expiration Date (or leave blank to unset) for hold %1$s. -staff.circ.holds.expire_time.prompt.plural=Please enter an Expiration Date (or leave blank to unset) for holds %1$s. -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.expire_time.prompt=Please enter an Expiration Date (or choose Remove to unset) for hold %1$s. +staff.circ.holds.expire_time.prompt.plural=Please enter an Expiration Date (or choose Remove to unset) for holds %1$s. +staff.circ.holds.expire_time.dialog.description=Expiration Date 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 staff.circ.holds.modifying_holds.yes=Yes diff --git a/Open-ILS/xul/staff_client/server/patron/holds.js b/Open-ILS/xul/staff_client/server/patron/holds.js index 519e17abd..cfae61efb 100644 --- a/Open-ILS/xul/staff_client/server/patron/holds.js +++ b/Open-ILS/xul/staff_client/server/patron/holds.js @@ -756,39 +756,32 @@ patron.holds.prototype = { ['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.activation_date.invalid_date')); } - if (util.date.check_past('YYYY-MM-DD',value) || util.date.formatted_date(new Date(),'%F') == value ) { - throw(document.getElementById('circStrings').getString('staff.circ.holds.activation_date.too_early.error')); - } - 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.activation_date.prompt',[hold_list.join(', ')]); var msg_plural = document.getElementById('circStrings').getFormattedString('staff.circ.holds.activation_date.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 thaw_date; var invalid = true; - while(invalid) { - thaw_date = window.prompt(msg,value,title); - if (thaw_date) { - invalid = ! check_date(thaw_date); - } else { - invalid = false; + var desc = document.getElementById('circStrings').getString('staff.circ.holds.activation_date.dialog.description'); + + JSAN.use('util.window'); var win = new util.window(); + var my_xulG = win.open( + urls.XUL_TIMESTAMP_DIALOG, 'edit_thaw_date', 'chrome,resizable,modal', + { + 'title' : title, + 'description' : desc, + 'msg' : msg, + 'allow_unset' : true, + 'disallow_future_dates' : false, + 'disallow_past_dates' : true, + 'disallow_today' : true, + 'default_time' : '00:00:00', + 'time_readonly' : false } - } - if (thaw_date || thaw_date == '') { + ); + if (my_xulG.complete) { circ.util.batch_hold_update( hold_list, - { 'frozen' : 't', 'thaw_date' : thaw_date == '' ? null : util.date.formatted_date(thaw_date,'%{iso8601}') }, + { 'frozen' : 't', 'thaw_date' : my_xulG.timestamp }, { 'progressmeter' : progressmeter, 'oncomplete' : function() { obj.clear_and_retrieve(true); } } ); } @@ -801,39 +794,33 @@ patron.holds.prototype = { ['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.expire_time.invalid_date')); } - if (util.date.check_past('YYYY-MM-DD',value) || util.date.formatted_date(new Date(),'%F') == value ) { - throw(document.getElementById('circStrings').getString('staff.circ.holds.expire_time.too_early.error')); - } - 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.expire_time.prompt',[hold_list.join(', ')]); var msg_plural = document.getElementById('circStrings').getFormattedString('staff.circ.holds.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 expire_time; var invalid = true; - while(invalid) { - expire_time = window.prompt(msg,value,title); - if (expire_time) { - invalid = ! check_date(expire_time); - } else { - invalid = false; + var desc = document.getElementById('circStrings').getString('staff.circ.holds.expire_time.dialog.description'); + + JSAN.use('util.window'); var win = new util.window(); + var my_xulG = win.open( + urls.XUL_TIMESTAMP_DIALOG, 'edit_expire_time', 'chrome,resizable,modal', + { + 'title' : title, + 'description' : desc, + 'msg' : msg, + 'allow_unset' : true, + 'disallow_future_dates' : false, + 'disallow_past_dates' : true, + 'disallow_today' : true, + 'default_time' : '00:00:00', + 'time_readonly' : false } - } - if (expire_time || expire_time == '') { + ); + if (my_xulG.complete) { circ.util.batch_hold_update( hold_list, - { 'expire_time' : expire_time == '' ? null : util.date.formatted_date(expire_time,'%{iso8601}') }, + { 'expire_time' : my_xulG.timestamp }, { 'progressmeter' : progressmeter, 'oncomplete' : function() { obj.clear_and_retrieve(true); } } ); } -- 2.11.0