LP#1526185 Disable second toast on permfail
authorKyle Huckins <khuckins@catalystdevworks.com>
Wed, 28 Dec 2016 20:15:25 +0000 (12:15 -0800)
committerKathy Lussier <klussier@masslnc.org>
Mon, 6 Mar 2017 03:42:55 +0000 (22:42 -0500)
Supress extra toast after inputting valid credentials after
permission failure.

Signed-off-by: Kyle Huckins <khuckins@catalystdevworks.com>
Signed-off-by: Bill Erickson <berickxx@gmail.com>
Signed-off-by: Kathy Lussier <klussier@masslnc.org>
Open-ILS/src/templates/staff/base_js.tt2
Open-ILS/web/js/ui/default/staff/services/navbar.js
Open-ILS/web/js/ui/default/staff/services/op_change.js

index d75c3c5..1054c05 100644 (file)
@@ -85,6 +85,8 @@
     s.OP_CHANGE_FAILURE = "[% l('Operator Change Failed') %]";
     s.OP_CHANGE_TITLE = "[% l('Operator Change') %]";
     s.OP_CHANGE_PERM_MESSAGE = "[% l('Another staff member with the above permission may authorize this specific action.  Please notify your library administrator if you need this permission.  If you feel you have received this exception in error, please inform your friendly Evergreen developers or helpdesk staff of the above permission.') %]";
+    s.PERM_OP_CHANGE_SUCCESS = "[% l('Permission Override Login Succeeded') %]";
+    s.PERM_OP_CHANGE_FAILURE = "[% l('Permission Override Login Failed') %]";
   }]);
 </script>
 
index e70d926..ec00a9a 100644 (file)
@@ -82,8 +82,8 @@ angular.module('egCoreMod')
                 }
 
                 $scope.changeOperator = function() {
-                    egOpChange.changeOperator(true).then(function() {
-                        $scope.op_changed = true;
+                    egOpChange.changeOperator().then(function() {
+                        $scope.op_changed = egCore.auth.OCtoken() ? true : false;
                         $scope.username = egCore.auth.user().usrname();
                     });
                 }
index 94d6690..e7bf1aa 100644 (file)
@@ -15,17 +15,18 @@ function($uibModal, $interpolate, $rootScope, $q, egAuth, egStrings, egNet, ngTo
 
     // Returns a promise resolved upon successful op-change.
     // Rejected otherwise.
-    service.changeOperator = function(showTypes, permEvt) {
+    service.changeOperator = function(permEvt) {
         return $uibModal.open({
             templateUrl: './share/t_opchange',
             controller:
                 ['$scope', '$uibModalInstance', function($scope, $uibModalInstance) {
                 $scope.args = {username : '', password : '', type : 'temp'};
-                $scope.displayTypeField = showTypes;
                 $scope.title = egStrings.OP_CHANGE_TITLE;
                 if (permEvt) {
                     $scope.title = permEvt.desc + ": " + permEvt.ilsperm;
                     $scope.message = egStrings.OP_CHANGE_PERM_MESSAGE;
+                } else {
+                    $scope.displayTypeField = true;
                 }
                 $scope.focus = true;
                 $scope.ok = function() { $uibModalInstance.close($scope.args) }
@@ -40,26 +41,34 @@ function($uibModal, $interpolate, $rootScope, $q, egAuth, egStrings, egNet, ngTo
             return egAuth.opChange(args).then(
                 function() {
                     console.debug('op-change succeeded');
-                    ngToast.create(egStrings.OP_CHANGE_SUCCESS);
+                    if (permEvt) {
+                        ngToast.create(egStrings.PERM_OP_CHANGE_SUCCESS);
+                    } else {
+                        ngToast.create(egStrings.OP_CHANGE_SUCCESS);
+                    }
                 },
                 function() {
                     console.debug('op-change failed');
-                    ngToast.warning(egStrings.OP_CHANGE_FAILURE);
+                    if (permEvt) {
+                        ngToast.warning(egStrings.PERM_OP_CHANGE_FAILURE);
+                    } else {
+                        ngToast.warning(egStrings.OP_CHANGE_FAILURE);
+                    }
                 }
             );
         });
     }
 
     // Returns a promise resolved on successful op-change undo.
-    service.changeOperatorUndo = function() {
+    service.changeOperatorUndo = function(hideToast) {
         return egAuth.opChangeUndo().then(
             function() {
                 console.debug('op-change undo succeeded');
-                ngToast.create(egStrings.OP_CHANGE_SUCCESS);
+                if (!hideToast) ngToast.create(egStrings.OP_CHANGE_SUCCESS);
             },
             function() {
                 console.debug('op-change undo failed');
-                ngToast.warning(egStrings.OP_CHANGE_FAILURE);
+                if (!hideToast) ngToast.warning(egStrings.OP_CHANGE_FAILURE);
             }
         );
     }
@@ -76,7 +85,7 @@ function($uibModal, $interpolate, $rootScope, $q, egAuth, egStrings, egNet, ngTo
     egNet.handlePermFailure = function(request) {
         console.debug("perm override required for "+request.method);
 
-        return service.changeOperator(false, request.evt).then(function() {
+        return service.changeOperator(request.evt).then(function() {
 
             return egNet.requestWithParamList(
                 request.service,
@@ -88,7 +97,7 @@ function($uibModal, $interpolate, $rootScope, $q, egAuth, egStrings, egNet, ngTo
             )['finally'](function() {
                 // always undo the operator change after a perm override.
                 console.debug("clearing op-change after perm override redo");
-                service.changeOperatorUndo();
+                service.changeOperatorUndo(true);
             });
         });
     }