From: Bill Erickson Date: Tue, 17 Jun 2014 20:16:05 +0000 (-0400) Subject: more checkout / checkin event handling X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=bb3a23d0b2c5abd131959b8db344b3bf9a5111d7;p=working%2FEvergreen.git more checkout / checkin event handling Signed-off-by: Bill Erickson --- diff --git a/Open-ILS/src/templates/staff/circ/checkin/index.tt2 b/Open-ILS/src/templates/staff/circ/checkin/index.tt2 index 2432bd24e5..6bd7f1cd64 100644 --- a/Open-ILS/src/templates/staff/circ/checkin/index.tt2 +++ b/Open-ILS/src/templates/staff/circ/checkin/index.tt2 @@ -10,15 +10,8 @@ +[% INCLUDE 'staff/circ/share/circ_strings.tt2' %] - [% END %] diff --git a/Open-ILS/src/templates/staff/circ/patron/index.tt2 b/Open-ILS/src/templates/staff/circ/patron/index.tt2 index 2102e778f9..2cb6b7bb36 100644 --- a/Open-ILS/src/templates/staff/circ/patron/index.tt2 +++ b/Open-ILS/src/templates/staff/circ/patron/index.tt2 @@ -30,7 +30,6 @@ diff --git a/Open-ILS/web/js/ui/default/staff/circ/services/circ.js b/Open-ILS/web/js/ui/default/staff/circ/services/circ.js index 2ebebab2d2..3bf61eacf2 100644 --- a/Open-ILS/web/js/ui/default/staff/circ/services/circ.js +++ b/Open-ILS/web/js/ui/default/staff/circ/services/circ.js @@ -30,7 +30,7 @@ function($modal , $q , egCore , egAlertDialog , egConfirmDialog) { 'ITEM_RENTAL_FEE_REQUIRED', 'PATRON_EXCEEDS_LOST_COUNT', 'COPY_CIRC_NOT_ALLOWED', - 'COPY_NOT_AVAILABLE', // HM? + 'COPY_NOT_AVAILABLE', 'COPY_IS_REFERENCE', 'COPY_ALERT_MESSAGE', 'ITEM_ON_HOLDS_SHELF' @@ -147,13 +147,13 @@ function($modal , $q , egCore , egAlertDialog , egConfirmDialog) { switch(evt.textcode) { case 'COPY_NOT_AVAILABLE': return service.copy_not_avail_dialog(evt, params, options); + case 'COPY_ALERT_MESSAGE': + return service.copy_alert_dialog(evt, params, options, 'checkout'); default: return service.override_dialog(evt, params, options); } } - //TODO: copy_alert_dialog - service.handle_checkout_resp = function(evt, params, options) { var final_resp = {evt : evt, params : params, options : options}; @@ -184,10 +184,10 @@ function($modal , $q , egCore , egAlertDialog , egConfirmDialog) { case 'PATRON_ACCOUNT_EXPIRED': return service.exit_alert(egCore.strings[evt.textcode]); + /* stuff yet to consider PERM_FAILURE CIRC_CLAIMS_RETURNED - COPY_ALERT_MESSAGE */ default: @@ -372,6 +372,38 @@ function($modal , $q , egCore , egAlertDialog , egConfirmDialog) { ); } + // find the open transit for the given copy barcode; flesh the org + // units locally. + service.find_copy_transit = function(evt, params, options) { + + if (evt && evt.payload && (transit = evt.payload.transit)) { // not == + transit.source(egCore.org.get(transit.source())); + transit.dest(egCore.org.get(transit.dest())); + return $q.when(transit); + } + + return egCore.pcrud.search('atc', + { dest_recv_time : null}, + { flesh : 1, + flesh_fields : {atc : ['target_copy']}, + join : { + acp : { + filter : { + barcode : params.copy_barcode, + deleted : 'f' + } + } + }, + limit : 1, + order_by : {atc : 'source_send_time desc'}, + } + ).then(function(transit) { + transit.source(egCore.org.get(transit.source())); + transit.dest(egCore.org.get(transit.dest())); + return transit; + }); + } + service.copy_in_transit_dialog = function(evt, params, options) { return $modal.open({ templateUrl: './circ/share/t_copy_in_transit_dialog', @@ -385,26 +417,7 @@ function($modal , $q , egCore , egAlertDialog , egConfirmDialog) { resolve : { // fetch the conflicting open transit w/ fleshed copy transit : function() { - return egCore.pcrud.search('atc', - { dest_recv_time : null}, - { flesh : 1, - flesh_fields : {atc : ['target_copy']}, - join : { - acp : { - filter : { - barcode : params.copy_barcode, - deleted : 'f' - } - } - }, - limit : 1, - order_by : {atc : 'source_send_time desc'}, - } - ).then(function(transit) { - transit.source(egCore.org.get(transit.source())); - transit.dest(egCore.org.get(transit.dest())); - return transit; - }); + return service.find_copy_transit(evt, params, options); } } }).result.then( @@ -489,10 +502,11 @@ function($modal , $q , egCore , egAlertDialog , egConfirmDialog) { case 'SUCCESS': case 'NO_CHANGE': - // inform user if the item is on the local holds shelf if (copy.status() == 8 // on holds shelf && hold && hold.pickup_lib() == egCore.auth.user().ws_ou()) { + // inform user if the item is on the local holds shelf + return service.route_dialog( './circ/share/t_hold_shelf_dialog', evt, params, options @@ -502,41 +516,19 @@ function($modal , $q , egCore , egAlertDialog , egConfirmDialog) { return $q.when(final_resp); } - // show the route dialog case 'ROUTE_ITEM': return service.route_dialog( './circ/share/t_transit_dialog', evt, params, options ).then(function() { return final_resp }); - - // show the copy not found alert dialog case 'ASSET_COPY_NOT_FOUND': - // FIXME: where can we put strings that don't live within - // a specific page? return egAlertDialog.open( egCore.strings.UNCAT_ALERT_DIALOG, params) .result.then(function() {return final_resp}); case 'COPY_ALERT_MESSAGE': - // FIXME: where can we put strings that don't live within - // a specific page? - - return egConfirmDialog.open( - egCore.strings.COPY_ALERT_MSG_DIALOG_TITLE, - evt.payload, // payload == alert message text - { copy_barcode : params.copy_barcode, - ok : function() {}, - cancel : function() { - // TODO: do we return the final_resp so - // the user can display the copy even though - // the checkin did not take place? - } - } - ).result.then(function() { - options.override = true; - return service.checkin(params, options); - }); + return service.copy_alert_dialog(evt, params, options, 'checkin'); default: console.warn('unhandled checkin response : ' + evt.textcode); @@ -548,8 +540,8 @@ function($modal , $q , egCore , egAlertDialog , egConfirmDialog) { return $modal.open({ templateUrl: tmpl, controller: [ - '$scope', '$modalInstance', 'destAddr', 'holdUser', - function($scope, $modalInstance, destAddr, holdUser) { + '$scope','$modalInstance','destAddr','holdUser','transit', + function($scope , $modalInstance , destAddr , holdUser , transit) { // TODO: synchronize scope variables with print context vars. @@ -563,8 +555,6 @@ function($modal , $q , egCore , egAlertDialog , egConfirmDialog) { $scope.print = function() { $modalInstance.close(); - var transit = evt.payload.transit; - var print_context = { transit : egCore.idl.toHash(transit), title : evt.payload.record.title(), @@ -602,11 +592,29 @@ function($modal , $q , egCore , egAlertDialog , egConfirmDialog) { flesh_fields : {'au' : ['card']} } ); + }, + transit : function() { + return service.find_copy_transit(evt, params, options); } } }).result; } + // action == what action to take if the user confirms the alert + service.copy_alert_dialog = function(evt, params, options, action) { + return egConfirmDialog.open( + egCore.strings.COPY_ALERT_MSG_DIALOG_TITLE, + evt.payload, // payload == alert message text + { copy_barcode : params.copy_barcode, + ok : function() {}, + cancel : function() {} + } + ).result.then(function() { + options.override = true; + return service[action](params, options); + }); + } + // check the barcode. If it's no good, show the warning dialog // Resolves on success, rejected on error service.test_barcode = function(bc) { diff --git a/Open-ILS/web/js/ui/default/staff/services/idl.js b/Open-ILS/web/js/ui/default/staff/services/idl.js index 1fe712935d..5d4d5af3e5 100644 --- a/Open-ILS/web/js/ui/default/staff/services/idl.js +++ b/Open-ILS/web/js/ui/default/staff/services/idl.js @@ -74,6 +74,7 @@ angular.module('egCoreMod') * e.g. {"call_number.label" : "foo"} */ service.toHash = function(obj, flatten) { + if (!obj) return null; var hash = {}; angular.forEach( service.classes[obj.classname].fields,