From 592105d1d5fe6c7eb9ea2ddcae92b1b5d5b9db85 Mon Sep 17 00:00:00 2001 From: dbs Date: Tue, 19 Jan 2010 03:14:06 +0000 Subject: [PATCH] Give sites the ability to easily display due dates and times in the OPAC under "copy details" We add two new variables to copy_details.js: * showDueDate - this needs to be set to a non-false value to display the due date in the OPAC * showDueTime - this needs to be set to a non-false value to display the due time in the OPAC, along with the due date. If showDueDate is false, then the value of this variable is ignored. git-svn-id: svn://svn.open-ils.org/ILS/trunk@15336 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- .../web/opac/skin/default/js/copy_details.js | 25 ++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/Open-ILS/web/opac/skin/default/js/copy_details.js b/Open-ILS/web/opac/skin/default/js/copy_details.js index 762b13ee18..94adfd1f79 100644 --- a/Open-ILS/web/opac/skin/default/js/copy_details.js +++ b/Open-ILS/web/opac/skin/default/js/copy_details.js @@ -2,8 +2,15 @@ var cpdTemplate; var cpdCounter = 0; var cpdNodes = {}; +/* showDueDate will show the due date in the OPAC */ +var showDueDate = false; +/* showDueTime will show the due time (hours and minutes) in the OPAC; + if showDueDate is false, then showDueTime has no effect +*/ +var showDueTime = false; + function cpdBuild( contextTbody, contextRow, record, callnumber, orgid, depth, copy_location ) { -var i = cpdCheckExisting(contextRow); + var i = cpdCheckExisting(contextRow); if(i) return i; var counter = cpdCounter++; @@ -25,6 +32,9 @@ var i = cpdCheckExisting(contextRow); unHideMe($n(templateRow, 'age_protect_label')); unHideMe($n(templateRow, 'create_date_label')); unHideMe($n(templateRow, 'holdable_label')); + } + + if (isXUL() || showDueDate) { unHideMe($n(templateRow, 'due_date_label')); } @@ -177,6 +187,9 @@ function cpdDrawCopies(r) { unHideMe($n(copyrow, 'age_protect_value')); unHideMe($n(copyrow, 'create_date_value')); unHideMe($n(copyrow, 'copy_holdable_td')); + } + + if(isXUL() || showDueDate) { unHideMe($n(copyrow, 'copy_due_date_td')); } @@ -236,15 +249,21 @@ function cpdDrawCopy(r) { } else { $n(row, 'copy_is_holdable').appendChild(text(no)); } + } + if (isXUL() || showDueDate) { var circ; if( copy.circulations() ) { circ = copy.circulations()[0]; if( circ ) { - $n(row, 'copy_due_date').appendChild(text(circ.due_date().replace(/[T ].*/,''))); + var due_time = dojo.date.stamp.fromISOString(circ.due_date()); + if( showDueTime ) { + $n(row, 'copy_due_date').appendChild(text(dojo.date.locale.format(due_time, {"formatLength": "medium"}))); + } else { + $n(row, 'copy_due_date').appendChild(text(dojo.date.locale.format(due_time, {"selector": "date", "formatLength": "medium"}))); + } } } - } r.args.copy = copy; -- 2.43.2