From: Mike Rylander <mrylander@gmail.com>
Date: Wed, 11 Sep 2019 18:46:44 +0000 (-0400)
Subject: LP#1842940: Alert when editing is disallowed
X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=8734da6411fe129fdcba8018ec77e0ffe213c20c;p=evergreen%2Fequinox.git

LP#1842940: Alert when editing is disallowed

Provide functions that checks the permissions required to edit ones
own account, or accounts in groups based on group application
permissions, and alert the user if and why they can't edit an account.

Signed-off-by: Mike Rylander <mrylander@gmail.com>
Signed-off-by: Jane Sandberg <sandbej@linnbenton.edu>
---

diff --git a/Open-ILS/src/templates/staff/circ/patron/reg_actions.tt2 b/Open-ILS/src/templates/staff/circ/patron/reg_actions.tt2
index 76414f9468..72969fc350 100644
--- a/Open-ILS/src/templates/staff/circ/patron/reg_actions.tt2
+++ b/Open-ILS/src/templates/staff/circ/patron/reg_actions.tt2
@@ -36,5 +36,11 @@
       ng-disabled="edit_passthru.hide_save_actions()"
       ng_click="edit_passthru.save({clone:true})">[% l('Save & Clone') %]</button>
   </span>
+  <div class="alert alert-warning" ng-show="edit_passthru.self_edit_disallowed()">
+    [% l('Editing your own account is disallowed') %]
+  </div>
+  <div class="alert alert-warning" ng-show="edit_passthru.group_edit_disallowed()">
+    [% l('Editing users in this group is disallowed') %]
+  </div>
 </div>
 
diff --git a/Open-ILS/web/js/ui/default/staff/circ/patron/regctl.js b/Open-ILS/web/js/ui/default/staff/circ/patron/regctl.js
index 885df71bc9..5949658912 100644
--- a/Open-ILS/web/js/ui/default/staff/circ/patron/regctl.js
+++ b/Open-ILS/web/js/ui/default/staff/circ/patron/regctl.js
@@ -2066,13 +2066,17 @@ function($scope , $routeParams , $q , $uibModal , $window , egCore ,
         return !egCore.org.CanHaveVolumes(org_id);
     }
 
-    // Returns true if the Save and Save & Clone buttons should be disabled.
-    $scope.edit_passthru.hide_save_actions = function() {
+    // Returns true if attempting to edit self, but perms don't allow
+    $scope.edit_passthru.self_edit_disallowed = function() {
         if ($scope.patron.id
             && $scope.patron.id == egCore.auth.user().id()
             && !$scope.perms.EDIT_SELF_IN_CLIENT
         ) return true;
+        return false;
+    }
 
+    // Returns true if attempting to edit a user without appropriate group application perms
+    $scope.edit_passthru.group_edit_disallowed = function() {
         if ( $scope.patron.profile
              && patronRegSvc
                 .edit_profiles
@@ -2080,6 +2084,13 @@ function($scope , $routeParams , $q , $uibModal , $window , egCore ,
                     return $scope.patron.profile.id() == p.id();
                 }).length == 0
         ) return true;
+        return false;
+    }
+
+    // Returns true if the Save and Save & Clone buttons should be disabled.
+    $scope.edit_passthru.hide_save_actions = function() {
+        if ($scope.edit_passthru.self_edit_disallowed()) return true;
+        if ($scope.edit_passthru.group_edit_disallowed()) return true;
 
         return $scope.patron.isnew ?
             !$scope.perms.CREATE_USER : 
diff --git a/Open-ILS/web/js/ui/default/staff/offline.js b/Open-ILS/web/js/ui/default/staff/offline.js
index 7d80de6d5f..2a3f820c58 100644
--- a/Open-ILS/web/js/ui/default/staff/offline.js
+++ b/Open-ILS/web/js/ui/default/staff/offline.js
@@ -2090,6 +2090,14 @@ function($scope , $routeParams , $q , $uibModal , $window , egCore ,
         );
     }
 
+    $scope.edit_passthru.self_edit_disallowed = function() {
+        return false;
+    }
+
+    $scope.edit_passthru.group_edit_disallowed = function() {
+        return false;
+    }
+
     // Returns true if the Save and Save & Clone buttons should be disabled.
     $scope.edit_passthru.hide_save_actions = function() {
         return false;