From 1bd9dd270f2a004fca52128f7cab7489c0b6399b Mon Sep 17 00:00:00 2001 From: Mike Rylander Date: Wed, 11 Sep 2019 14:46:44 -0400 Subject: [PATCH] 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 Signed-off-by: Jane Sandberg --- .../templates/staff/circ/patron/reg_actions.tt2 | 6 ++++++ .../web/js/ui/default/staff/circ/patron/regctl.js | 15 +++++++++++++-- Open-ILS/web/js/ui/default/staff/offline.js | 8 ++++++++ 3 files changed, 27 insertions(+), 2 deletions(-) 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') %] +
+ [% l('Editing your own account is disallowed') %] +
+
+ [% l('Editing users in this group is disallowed') %] +
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 6320a92c9e..718be6f76b 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 @@ -2008,13 +2008,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 @@ -2022,6 +2026,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; -- 2.43.2