From: Bill Erickson Date: Fri, 28 Oct 2016 14:56:26 +0000 (-0400) Subject: Angular selfcheck WIP X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=27c36340bf79a4381c7b49f26bb36cef6e0c83bf;p=working%2FEvergreen.git Angular selfcheck WIP Signed-off-by: Bill Erickson --- diff --git a/Open-ILS/src/sql/Pg/upgrade/XXXX.data.selfcheck-settings.sql b/Open-ILS/src/sql/Pg/upgrade/XXXX.data.selfcheck-settings.sql new file mode 100644 index 0000000000..0040d6d524 --- /dev/null +++ b/Open-ILS/src/sql/Pg/upgrade/XXXX.data.selfcheck-settings.sql @@ -0,0 +1,20 @@ + +BEGIN; +-- SELECT evergreen.upgrade_deps_block_check('XXXX', :eg_version); + +INSERT INTO config.org_unit_setting_type (name, grp, label, description, datatype) + VALUES ( + 'circ.selfcheck.hide_negatve_fines', 'self', + oils_i18n_gettext( + 'circ.selfcheck.hide_negatve_fines', + 'Selfcheck: Hide Negative Fine Transactions', + 'coust', 'label'), + oils_i18n_gettext( + 'circ.selfcheck.hide_negatve_fines', + 'Avoid displaying transactions with a negative balance in the ' || + 'patron fines list in selfcheck', + 'coust', 'description'), + 'bool' + ); + +COMMIT; diff --git a/Open-ILS/src/templates/staff/circ/selfcheck/index.tt2 b/Open-ILS/src/templates/staff/circ/selfcheck/index.tt2 index e6b1bce089..67704112ae 100644 --- a/Open-ILS/src/templates/staff/circ/selfcheck/index.tt2 +++ b/Open-ILS/src/templates/staff/circ/selfcheck/index.tt2 @@ -63,13 +63,15 @@ angular.module('egCoreMod').run(['egStrings', function(s) {
[% l('Holds') %] -
[% l('You have [_1] item(s) ready for pickup', '{{counts("ready_hold")}}') %]
-
[% l('You have [_1] total holds', '{{counts("total_hold")}}') %]
+
[% l('You have [_1] item(s) ready for pickup.', '{{counts("ready_hold")}}') %]
+
[% l('You have [_1] total holds.', '{{counts("total_hold")}}') %]
[% l('Fines') %] +
[% l('Total fines on this account: [_1]', + '{{counts("total_owed") | currency}}') %]
diff --git a/Open-ILS/web/js/ui/default/staff/circ/selfcheck/app.js b/Open-ILS/web/js/ui/default/staff/circ/selfcheck/app.js index 64ac90d617..7dd85af500 100644 --- a/Open-ILS/web/js/ui/default/staff/circ/selfcheck/app.js +++ b/Open-ILS/web/js/ui/default/staff/circ/selfcheck/app.js @@ -34,14 +34,17 @@ angular.module('egSelfCheckApp', return egCore.org.settings([ 'opac.barcode_regex', 'circ.selfcheck.patron_login_timeout', - 'circ.selfcheck.auto_override_checkout_events', + 'circ.selfcheck.auto_override_checkout_events', // TODO 'circ.selfcheck.patron_password_required', - 'circ.checkout_auto_renew_age', - 'circ.selfcheck.workstation_required', - 'circ.selfcheck.alert.popup', - 'circ.selfcheck.alert.sound', - 'credit.payments.allow', - 'circ.selfcheck.block_checkout_on_copy_status' + 'circ.checkout_auto_renew_age', // TODO + // TODO: Document workstations universally required + // 'circ.selfcheck.workstation_required', + 'circ.selfcheck.alert.popup', // TODO + 'circ.selfcheck.alert.sound', // TODO + 'credit.payments.allow', // TODO + // TODO: should hiding negative fines affect the "total owed" display? + 'circ.selfcheck.hide_negatve_fines', + 'circ.selfcheck.block_checkout_on_copy_status' // TODO ]).then(function(settings) { egCore.env.aous = settings; }); @@ -111,9 +114,25 @@ function($q , $timeout , $window , $location , $timeout , egCore , egConfirmDial total_circ_count : 0, ready_hold_count : 0, total_hold_count : 0, + total_owed_count : 0 }; - service.get_counts = function() { + // patron_id is set in cases where the patron has not yet been fetched. + service.set_user_stats = function(patron_id) { + if (!patron_id) patron_id = service.patron.id(); + return egCore.net.request( + 'open-ils.actor', + 'open-ils.actor.user.opac.vital_stats.authoritative', + egCore.auth.token(), patron_id + ).then( + function(stats) { + service.ready_hold_count = Number(stats.holds.ready); + service.total_hold_count = Number(stats.holds.total); + service.total_owed_count = Number(stats.fines.balance_owed); + service.total_circ_count = Number(stats.checkouts.overdue) + + Number(stats.checkouts.out); + } + ); } // called with each path load @@ -137,16 +156,18 @@ function($q , $timeout , $window , $location , $timeout , egCore , egConfirmDial // If the patron choses no action from the above dialog, // force a logout after the configured amount of time. + var timeout = egCore.env.aous['circ.selfcheck.patron_login_timeout']; service.login_warning_timer = $timeout( service.logout_patron, service.login_timeout_warning ); } service.start_login_timer = function() { + var timeout = egCore.env.aous['circ.selfcheck.patron_login_timeout']; + if (timeout) service.login_timeout = timeout; service.login_timer = $timeout( service.show_timeout_warning, service.login_timeout ); - console.debug('starting patron login timer'); } service.reset_login_timer = function() { @@ -159,10 +180,8 @@ function($q , $timeout , $window , $location , $timeout , egCore , egConfirmDial service.login_warning_timer = null; } service.start_login_timer(); - console.debug('reset patron login timer'); } - service.fetch_patron = function(username, barcode) { var evt; @@ -177,6 +196,10 @@ function($q , $timeout , $window , $location , $timeout , egCore , egConfirmDial return $q.reject(evt); } + // Retrieve user stats in parallel with user retrieval. + // No need to inspect the response. + service.set_user_stats(patron_id); + return egCore.net.request( 'open-ils.actor', 'open-ils.actor.user.fleshed.retrieve.authoritative', @@ -188,6 +211,17 @@ function($q , $timeout , $window , $location , $timeout , egCore , egConfirmDial return $q.reject(evt); } + if (barcode) { + // Confirm the patron was retrieved with an active card. + var card = patron.cards().filter( + function(c) { return c.barcode() == barcode })[0]; + + if (card && card.active() == 'f') { + console.warn("Patron used inactive card: " + barcode); + return $q.reject(); + } + } + service.patron = patron; service.start_login_timer(); }); @@ -363,6 +397,14 @@ function($scope, $q, $location , egCore, scSvc) { } ); } + + if ($location.search().username) { + // Allow passing the username via the URL for testing purposes. + // This only works when circ.selfcheck.patron_password_required + // is false/unset. + $scope.login({username : $location.search().username}); + } + }]) .controller('CheckoutCtrl', @@ -405,9 +447,9 @@ function($scope, $q, $location , egCore, scSvc) { $scope.xacts = []; scSvc.get_fines().then(function(xacts) { - console.log('here with ' + xacts.length) $scope.xacts = xacts; }); }]) +