LP#1716962 - honor In-House Use: num of uses threshold setting
authorCesar Velez <Cesar.Velez@equinoxinitiative.org>
Wed, 27 Sep 2017 17:16:04 +0000 (18:16 +0100)
committerMike Rylander <mrylander@gmail.com>
Mon, 16 Oct 2017 19:28:04 +0000 (15:28 -0400)
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 <cesar.velez@equinoxinitiative.org>

Signed-off-by: Mike Rylander <mrylander@gmail.com>

Open-ILS/src/templates/staff/base_js.tt2
Open-ILS/src/templates/staff/circ/in_house_use/index.tt2
Open-ILS/web/js/ui/default/staff/circ/in_house_use/app.js

index 5d93fbe..324e452 100644 (file)
@@ -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?') %]";
   }]);
 </script>
 
index 254d804..0e3ab44 100644 (file)
@@ -28,7 +28,7 @@
         </label>
         <input type="number" min="1" max="{{countMax}}"
           class="form-control" focus-me="useFocus"
-           id="in-house-num-uses" ng-model="args.num_uses"/>
+           id="in-house-num-uses" ng-model="args.num_uses" ng-change="onNumUsesChanged()" />
       </div>
     </div>
 
index dab5420..69427d1 100644 (file)
@@ -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 = {