From 175ce3bf5c161b29576e3b568a9a3065972c3a08 Mon Sep 17 00:00:00 2001 From: steven choi Date: Fri, 6 Oct 2023 13:34:13 +1100 Subject: [PATCH] #700 make sure only access option has changed --- .../controllers/UserAccessController.js | 34 +++++++++---------- grails-app/views/opus/_editAccessControl.gsp | 2 +- 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/grails-app/assets/javascripts/profileEditor/controllers/UserAccessController.js b/grails-app/assets/javascripts/profileEditor/controllers/UserAccessController.js index 1b1161b3..fb5a5f2d 100644 --- a/grails-app/assets/javascripts/profileEditor/controllers/UserAccessController.js +++ b/grails-app/assets/javascripts/profileEditor/controllers/UserAccessController.js @@ -80,21 +80,23 @@ profileEditor.controller('UserAccessController', function (messageService, util, }); }; - self.privateModeChanged = function(form) { + self.privateModeChanged = function(form, isOptionChanged) { if (self.opus.privateCollection) { self.roles.push(userRole); } else { - var hasRole_USER = self.users.find(it=>it.role === 'ROLE_USER') - if (hasRole_USER) { - self.users = self.users.filter(it => it.role !== 'ROLE_USER') - var data = {privateCollection: self.opus.privateCollection, authorities: self.users}; - var promise = profileService.updateUsers(self.opusId, data); - promise.then(function () { - form.$setPristine(); - messageService.success("User access has been successfully updated."); - }, function () { - messageService.alert("An error has occurred while updating user access."); - }); + if (isOptionChanged) { + var hasRole_USER = self.users.find(it => it.role === 'ROLE_USER') + if (hasRole_USER) { + self.users = self.users.filter(it => it.role !== 'ROLE_USER') + var data = {privateCollection: self.opus.privateCollection, authorities: self.users}; + var promise = profileService.updateUsers(self.opusId, data); + promise.then(function () { + form.$setPristine(); + messageService.success("User access has been successfully updated."); + }, function () { + messageService.alert("An error has occurred while updating user access."); + }); + } } self.roles.splice(4, 1) } @@ -124,10 +126,10 @@ profileEditor.controller('UserAccessController', function (messageService, util, } self.reset = function (form) { - loadOpus(form, true); + loadOpus(form); }; - function loadOpus(form, isReset) { + function loadOpus(form) { if (!self.opusId) { return; } @@ -143,9 +145,7 @@ profileEditor.controller('UserAccessController', function (messageService, util, popupateUserDetails(user); }); - if (isReset) { - self.privateModeChanged(form); - } + self.privateModeChanged(); if (form) { form.$setPristine(); diff --git a/grails-app/views/opus/_editAccessControl.gsp b/grails-app/views/opus/_editAccessControl.gsp index c3a50c83..1439483f 100644 --- a/grails-app/views/opus/_editAccessControl.gsp +++ b/grails-app/views/opus/_editAccessControl.gsp @@ -21,7 +21,7 @@