File tree Expand file tree Collapse file tree 3 files changed +23
-0
lines changed
Kitodo/src/main/java/org/kitodo/production/forms/user Expand file tree Collapse file tree 3 files changed +23
-0
lines changed Original file line number Diff line number Diff line change @@ -107,6 +107,10 @@ public String deleteFromClient() {
107107 for (Client client : this .userObject .getClients ()) {
108108 if (client .getId ().equals (clientId )) {
109109 this .userObject .getClients ().remove (client );
110+ if (Objects .nonNull (this .clients ) && !this .clients .contains (client )) {
111+ this .clients .add (client );
112+ this .clients .sort (Comparator .comparing (Client ::getName , String .CASE_INSENSITIVE_ORDER ));
113+ }
110114 if (client .equals (this .userObject .getDefaultClient ())) {
111115 this .userObject .setDefaultClient (null );
112116 }
@@ -137,6 +141,9 @@ public String addToClient() {
137141
138142 if (!this .userObject .getClients ().contains (client )) {
139143 this .userObject .getClients ().add (client );
144+ if (Objects .nonNull (this .clients )) {
145+ this .clients .remove (client );
146+ }
140147 }
141148 } catch (DAOException e ) {
142149 Helper .setErrorMessage (ERROR_DATABASE_READING ,
Original file line number Diff line number Diff line change 2424import org .apache .logging .log4j .LogManager ;
2525import org .apache .logging .log4j .Logger ;
2626import org .kitodo .data .database .beans .Project ;
27+ import org .kitodo .data .database .beans .Role ;
2728import org .kitodo .data .database .beans .User ;
2829import org .kitodo .data .database .exceptions .DAOException ;
2930import org .kitodo .production .enums .ObjectType ;
@@ -105,6 +106,10 @@ public String deleteFromProject() {
105106 for (Project project : this .userObject .getProjects ()) {
106107 if (project .getId ().equals (projectId )) {
107108 this .userObject .getProjects ().remove (project );
109+ if (Objects .nonNull (this .projects ) && !this .projects .contains (project )) {
110+ this .projects .add (project );
111+ this .projects .sort (Comparator .comparing (Project ::getTitle , String .CASE_INSENSITIVE_ORDER ));
112+ }
108113 break ;
109114 }
110115 }
@@ -132,6 +137,9 @@ public String addToProject() {
132137
133138 if (!this .userObject .getProjects ().contains (project )) {
134139 this .userObject .getProjects ().add (project );
140+ if (Objects .nonNull (this .projects )) {
141+ this .projects .remove (project );
142+ }
135143 }
136144 } catch (DAOException e ) {
137145 Helper .setErrorMessage (ERROR_DATABASE_READING ,
Original file line number Diff line number Diff line change 2323
2424import org .apache .logging .log4j .LogManager ;
2525import org .apache .logging .log4j .Logger ;
26+ import org .kitodo .data .database .beans .Client ;
2627import org .kitodo .data .database .beans .Role ;
2728import org .kitodo .data .database .beans .User ;
2829import org .kitodo .data .database .exceptions .DAOException ;
@@ -104,6 +105,10 @@ public String deleteFromRole() {
104105 for (Role role : this .userObject .getRoles ()) {
105106 if (role .getId ().equals (roleId )) {
106107 this .userObject .getRoles ().remove (role );
108+ if (Objects .nonNull (this .availableRoles ) && !this .availableRoles .contains (role )) {
109+ this .availableRoles .add (role );
110+ this .availableRoles .sort (Comparator .comparing (Role ::getTitle , String .CASE_INSENSITIVE_ORDER ));
111+ }
107112 break ;
108113 }
109114 }
@@ -131,6 +136,9 @@ public String addToRole() {
131136
132137 if (!this .userObject .getRoles ().contains (role )) {
133138 this .userObject .getRoles ().add (role );
139+ if (Objects .nonNull (this .availableRoles )) {
140+ this .availableRoles .remove (role );
141+ }
134142 }
135143 } catch (DAOException e ) {
136144 Helper .setErrorMessage (ERROR_DATABASE_READING ,
You can’t perform that action at this time.
0 commit comments