From 3175bcc916c159282f93c630a15a9f334466ed9f Mon Sep 17 00:00:00 2001 From: Cesar Velez Date: Wed, 27 Sep 2017 18:16:04 +0100 Subject: [PATCH] LP#1716962 - honor In-House Use: num of uses threshold setting The 'ui.circ.in_house_use.entry_warn' library setting was not being taken into account nor any confirmation/warning modal being shown. This fix addresses that by watching the changes and if selected num_uses value exceeds setting value, displays egConfirm modal. Signed-off by: Cesar Velez Signed-off-by: Mike Rylander --- Open-ILS/src/templates/staff/base_js.tt2 | 1 + .../staff/circ/in_house_use/index.tt2 | 2 +- .../ui/default/staff/circ/in_house_use/app.js | 22 +++++++++++++++++-- 3 files changed, 22 insertions(+), 3 deletions(-) diff --git a/Open-ILS/src/templates/staff/base_js.tt2 b/Open-ILS/src/templates/staff/base_js.tt2 index 5d93fbe344..324e452932 100644 --- a/Open-ILS/src/templates/staff/base_js.tt2 +++ b/Open-ILS/src/templates/staff/base_js.tt2 @@ -186,6 +186,7 @@ UpUp.start({ s.CONFIRM_CLEAR_PENDING = "[% l('Clear pending transactions') %]"; s.CONFIRM_CLEAR_PENDING_BODY = "[% l('Are you certain you want to clear these pending offline transactions? This action is irreversible. Transactions cannot be recovered after clearing!') %]"; s.LOCATION_NAME_OU_QUALIFIED = "[% l('{{location_name}} ({{owning_lib_shortname}})') %]"; + s.CONFIRM_IN_HOUSE_NUM_USES_COUNT_TITLE = "[% l('Are you sure you want to record {{num_uses}} uses for this?') %]"; }]); diff --git a/Open-ILS/src/templates/staff/circ/in_house_use/index.tt2 b/Open-ILS/src/templates/staff/circ/in_house_use/index.tt2 index 254d8044ae..0e3ab44848 100644 --- a/Open-ILS/src/templates/staff/circ/in_house_use/index.tt2 +++ b/Open-ILS/src/templates/staff/circ/in_house_use/index.tt2 @@ -28,7 +28,7 @@ + id="in-house-num-uses" ng-model="args.num_uses" ng-change="onNumUsesChanged()" /> diff --git a/Open-ILS/web/js/ui/default/staff/circ/in_house_use/app.js b/Open-ILS/web/js/ui/default/staff/circ/in_house_use/app.js index dab5420211..69427d1d11 100644 --- a/Open-ILS/web/js/ui/default/staff/circ/in_house_use/app.js +++ b/Open-ILS/web/js/ui/default/staff/circ/in_house_use/app.js @@ -46,7 +46,7 @@ function($scope, egCore, egGridDataProvider , egConfirmDialog, egAlertDialog) }); $scope.useFocus = true; - $scope.args = {noncat_type : 'barcode', num_uses : 1}; + $scope.args = {noncat_type : 'barcode', num_uses : 1, needsCountWarnModal: false }; var checkouts = []; var provider = egGridDataProvider.instance({}); @@ -62,7 +62,25 @@ function($scope, egCore, egGridDataProvider , egConfirmDialog, egAlertDialog) return type ? type.name() : null; } - $scope.checkout = function(args) { + $scope.onNumUsesChanged = function(){ + $scope.args.needsCountWarnModal = countWarn < $scope.args.num_uses; + } + + $scope.checkout = function(args){ + if ($scope.args.needsCountWarnModal) { + // show modal to allow warning/confirmation + egConfirmDialog.open(egCore.strings.CONFIRM_IN_HOUSE_NUM_USES_COUNT_TITLE, '', + { num_uses: $scope.args.num_uses } + ).result.then(function(){ + $scope.args.needsCountWarnModal = false + $scope.checkoutStart(args) + }); + } else { + $scope.checkoutStart(args); + } + } + + $scope.checkoutStart = function(args) { $scope.copyNotFound = false; var coArgs = { -- 2.43.2