From 8d1ddca365b817a2fa6031fa4b133bde571c7ba8 Mon Sep 17 00:00:00 2001 From: erickson Date: Wed, 18 Nov 2009 04:44:48 +0000 Subject: [PATCH] make circ info fetching synchronous to prevent race condition with scanning, added dummy data for testing, plugged in more stub functions, some css and layout fixes git-svn-id: svn://svn.open-ils.org/ILS/trunk@14947 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- Open-ILS/web/css/skin/default/selfcheck.css | 56 +++-- .../js/ui/default/circ/selfcheck/selfcheck.js | 197 +++++++++++------- .../default/circ/selfcheck/circ_page.tt2 | 20 -- .../default/circ/selfcheck/holds_page.tt2 | 22 ++ .../templates/default/circ/selfcheck/main.tt2 | 22 +- .../default/circ/selfcheck/summary.tt2 | 23 ++ 6 files changed, 215 insertions(+), 125 deletions(-) create mode 100644 Open-ILS/web/templates/default/circ/selfcheck/holds_page.tt2 create mode 100644 Open-ILS/web/templates/default/circ/selfcheck/summary.tt2 diff --git a/Open-ILS/web/css/skin/default/selfcheck.css b/Open-ILS/web/css/skin/default/selfcheck.css index a47dc6f016..bde1d81db5 100644 --- a/Open-ILS/web/css/skin/default/selfcheck.css +++ b/Open-ILS/web/css/skin/default/selfcheck.css @@ -1,9 +1,12 @@ +body { + font-family: Arial, Verdana; + font-size: 14px; +} + #oils-selfck-top-div { - width: 99%; - padding: 10px; - margin: 0px; - height: 180px; + padding: 20px; + margin: 2px; border: 1px solid #888; text-align: center; font-weight:bold; @@ -24,7 +27,7 @@ } #oils-selfck-bottom-div { - width: 100%; + width: 98%; padding: 10px; } @@ -39,28 +42,43 @@ } #oils-selfck-circ-table { - width: 100%; + width: 98%; + margin-top: 15px; +} + +#oils-selfck-circ-table td { + text-align: center; } #oils-selfck-circ-table thead { font-weight: bold; } -#oils-selfck-circ-table-div { +#oils-selfck-content-div { width: 70%; position: float; float: left; - border-right: 1px solid #888; } -#oils-selfck-circ-info-div { +#oils-selfck-summary-div { width: 28%; float: right; + border-left: 1px solid #888; +} + +#oils-selfck-info-nav { + margin: 15px 10px 15px 10px; + padding: 8px; + border-bottom: 1px dashed #888; +} + +#oils-selfck-info-nav span { + padding-right: 10px; } #oils-selfck-circ-info-div fieldset { - margin: 20px; - padding: 10px; + margin: 15px 10px 15px 10px; + padding: 8px; border: 2px dashed #888; -moz-border-radius: 3px; } @@ -69,13 +87,15 @@ font-weight: bold; } +#oils-selfck-circ-info-div div { + padding: 3px; +} +#oils-selfck-circ-tbody tr { + border-bottom: 1px solid #888; +} -/* -#oils-selfck-main-table {width: 100%} -#oils-selfck-main-table td { - padding: 5px; - border: 1px solid #888; +#oils-selfck-circ-tbody td { + padding:10px; } -#oils-selfck-main-table- td { -*/ + diff --git a/Open-ILS/web/js/ui/default/circ/selfcheck/selfcheck.js b/Open-ILS/web/js/ui/default/circ/selfcheck/selfcheck.js index 2405c55d86..4ac16d30c5 100644 --- a/Open-ILS/web/js/ui/default/circ/selfcheck/selfcheck.js +++ b/Open-ILS/web/js/ui/default/circ/selfcheck/selfcheck.js @@ -1,3 +1,5 @@ +dojo.require('dojo.date.locale'); +dojo.require('dojo.date.stamp'); dojo.require('openils.CGI'); dojo.require('openils.Util'); dojo.require('openils.User'); @@ -34,8 +36,28 @@ function SelfCheckManager() { // dict of org unit settings for "here" this.orgSettings = {}; + + + // Construct a mock checkout for debugging purposes + this.mockCheckout = { + payload : { + record : new fieldmapper.mvr(), + copy : new fieldmapper.acp(), + circ : new fieldmapper.circ() + } + }; + + this.mockCheckout.payload.record.title('Jazz improvisation for guitar'); + this.mockCheckout.payload.record.author('Wise, Les'); + this.mockCheckout.payload.record.isbn('0634033565'); + this.mockCheckout.payload.copy.barcode('123456789'); + this.mockCheckout.payload.circ.renewal_remaining(1); + this.mockCheckout.payload.circ.parent_circ(1); + this.mockCheckout.payload.circ.due_date('2012-12-21'); } + + /** * Fetch the org-unit settings, initialize the display, etc. */ @@ -46,9 +68,28 @@ SelfCheckManager.prototype.init = function() { this.authtoken = openils.User.authtoken; this.loadOrgSettings(); + // add onclick handlers for nav links + + var self = this; + dojo.connect( + dojo.byId('oils-selfck-hold-details-link'), + 'onclick', + function() { self.drawHoldsPage(); } + ); + + dojo.connect( + dojo.byId('oils-selfck-pay-fines-link'), + 'onclick', + function() { self.drawPayFinesPage(); } + ); + + if(this.cgi.param('patron')) { - // Patron barcode via cgi param. Mainly used for debugging. + + // Patron barcode via cgi param. Mainly used for debugging and + // only works if password is not required by policy this.loginPatron(this.cgi.param('patron')); + } else { this.drawLoginPage(); } @@ -224,106 +265,101 @@ SelfCheckManager.prototype.drawCircPage = function() { } ); - // items out summary - + // holds summary this.updateHoldsSummary(); + + // items out summary this.updateCircSummary(); + + // render mock checkouts for debugging? + if(this.cgi.param('mock-circ')) { + for(var i in [1,2,3]) + this.displayCheckout(this.mockCheckout); + } } SelfCheckManager.prototype.updateHoldsSummary = function(decrement) { - - var self = this; - var oncomplete = function() { - dojo.byId('oils-selfck-holds-total').innerHTML = - dojo.string.substitute( - localeStrings.TOTAL_HOLDS, - [self.holdsSummary.total] - ); - - dojo.byId('oils-selfck-holds-ready').innerHTML = - dojo.string.substitute( - localeStrings.HOLDS_READY_FOR_PICKUP, - [self.holdsSummary.ready] - ); - }; - if(!this.holdsSummary) { - fieldmapper.standardRequest( + var summary = fieldmapper.standardRequest( ['open-ils.circ', 'open-ils.circ.holds.user_summary'], - { async : true, - params : [this.authtoken, this.patron.id()], - oncomplete : function(r) { - var summary = openils.Util.readResponse(r); - self.holdsSummary = {}; - self.holdsSummary.ready = Number(summary['4']); - self.holdsSummary.total = 0; - for(var i in summary) - self.holdsSummary.total += Number(summary[i]); - oncomplete(); - } - } + {params : [this.authtoken, this.patron.id()]} ); - } else { - if(this.decrement) - this.holdsSummary.ready -= 1; - - oncomplete(); + this.holdsSummary = {}; + this.holdsSummary.ready = Number(summary['4']); + this.holdsSummary.total = 0; + + for(var i in summary) + this.holdsSummary.total += Number(summary[i]); } -} + if(this.decrement) + this.holdsSummary.ready -= 1; -SelfCheckManager.prototype.updateCircSummary = function(increment) { + dojo.byId('oils-selfck-holds-total').innerHTML = + dojo.string.substitute( + localeStrings.TOTAL_HOLDS, + [this.holdsSummary.total] + ); - var self = this; - var oncomplete = function() { - dojo.byId('oils-selfck-circ-account-total').innerHTML = - dojo.string.substitute( - localeStrings.TOTAL_ITEMS_ACCOUNT, - [self.circSummary.total] - ); - - dojo.byId('oils-selfck-circ-session-total').innerHTML = - dojo.string.substitute( - localeStrings.TOTAL_ITEMS_SESSION, - [self.circSummary.session] - ); - } + dojo.byId('oils-selfck-holds-ready').innerHTML = + dojo.string.substitute( + localeStrings.HOLDS_READY_FOR_PICKUP, + [this.holdsSummary.ready] + ); +} - if(this.circSummary) { - if(increment) { - // local checkout occurred. Add to the total and the session. - this.circSummary.total += 1; - this.circSummary.session += 1; - } +SelfCheckManager.prototype.updateCircSummary = function(increment) { - oncomplete(); + if(!this.circSummary) { - } else { - // fetch the circ summary for the patron var summary = fieldmapper.standardRequest( ['open-ils.actor', 'open-ils.actor.user.checked_out.count'], - { - async : true, - params : [this.authtoken, this.patron.id()], - oncomplete : function(r) { - var summary = openils.Util.readResponse(r); - self.circSummary = { - total : Number(summary.out) + Number(summary.overdue), - overdue : Number(summary.overdue), - session : 0 - } - oncomplete(); - } - } + {params : [this.authtoken, this.patron.id()]} ); + + this.circSummary = { + total : Number(summary.out) + Number(summary.overdue), + overdue : Number(summary.overdue), + session : 0 + }; } + + if(increment) { + // local checkout occurred. Add to the total and the session. + this.circSummary.total += 1; + this.circSummary.session += 1; + } + + dojo.byId('oils-selfck-circ-account-total').innerHTML = + dojo.string.substitute( + localeStrings.TOTAL_ITEMS_ACCOUNT, + [this.circSummary.total] + ); + + dojo.byId('oils-selfck-circ-session-total').innerHTML = + dojo.string.substitute( + localeStrings.TOTAL_ITEMS_SESSION, + [this.circSummary.session] + ); +} + + +SelfCheckManager.prototype.drawHoldsPage = function() { + + // TODO add option to hid scanBox + // this.updateScanBox(...) + + openils.Util.hide('oils-selfck-circ-page'); + openils.Util.hide('oils-selfck-payment-page'); + openils.Util.show('oils-selfck-holds-page'); } + /** * Check out a single item. If the item is already checked * out to the patron, redirect to renew() @@ -394,16 +430,19 @@ SelfCheckManager.prototype.displayCheckout = function(evt) { var circ = evt.payload.circ; var row = this.circTemplate.cloneNode(true); - /* if(record.isbn()) { - var pic = $n(template, 'jacket'); - pic.setAttribute('src', '/opac/ac/jacket/small/' + cleanISBN(record.isbn())); + this.byName(row, 'jacket').setAttribute('src', '/opac/extras/ac/jacket/small/' + record.isbn()); } - */ this.byName(row, 'barcode').innerHTML = copy.barcode(); this.byName(row, 'title').innerHTML = record.title(); this.byName(row, 'author').innerHTML = record.author(); + this.byName(row, 'remaining').innerHTML = circ.renewal_remaining(); + + var date = dojo.date.stamp.fromISOString(circ.due_date()); + this.byName(row, 'due_date').innerHTML = + dojo.date.locale.format(date, {selector : 'date'}); + this.circTbody.appendChild(row); } diff --git a/Open-ILS/web/templates/default/circ/selfcheck/circ_page.tt2 b/Open-ILS/web/templates/default/circ/selfcheck/circ_page.tt2 index 8c9c3ba887..8a9ea67b2b 100644 --- a/Open-ILS/web/templates/default/circ/selfcheck/circ_page.tt2 +++ b/Open-ILS/web/templates/default/circ/selfcheck/circ_page.tt2 @@ -27,23 +27,3 @@ - -
-
- Items Checked Out -
-
-
-
- Holds -
-
-
Hold Details
-
-
- Fines -
-
Pay fines
-
-
- diff --git a/Open-ILS/web/templates/default/circ/selfcheck/holds_page.tt2 b/Open-ILS/web/templates/default/circ/selfcheck/holds_page.tt2 new file mode 100644 index 0000000000..5be3a19e85 --- /dev/null +++ b/Open-ILS/web/templates/default/circ/selfcheck/holds_page.tt2 @@ -0,0 +1,22 @@ +
+ + + + + + + + + + + + + + + + + + + +
TitleAuthorStatusType
+
diff --git a/Open-ILS/web/templates/default/circ/selfcheck/main.tt2 b/Open-ILS/web/templates/default/circ/selfcheck/main.tt2 index abda7c2b88..14a7fb41fb 100644 --- a/Open-ILS/web/templates/default/circ/selfcheck/main.tt2 +++ b/Open-ILS/web/templates/default/circ/selfcheck/main.tt2 @@ -14,15 +14,21 @@
-