118
118
</TableCell >
119
119
<TableCell >
120
120
<PkpButton
121
- v-if =" store.invitationPayload.userGroupsToAdd.length > 1"
121
+ v-if ="
122
+ store.invitationPayload.userGroupsToAdd.length > 1 ||
123
+ hasUserGroupsValue()
124
+ "
122
125
:is-warnable =" true"
123
126
@click =" removeInvitedUserGroup(index)"
124
127
>
@@ -169,6 +172,7 @@ const allUserGroupsToAdd = computed(
169
172
() => store .invitationPayload .userGroupsToAdd ,
170
173
);
171
174
updateWithSelectedUserGroups (props .userGroups );
175
+ hasUserGroupsValue ();
172
176
173
177
/**
174
178
* update selected user group
@@ -182,6 +186,7 @@ function updateUserGroup(index, fieldName, newValue) {
182
186
userGroupsUpdate[index][fieldName] = newValue;
183
187
store .updatePayload (' userGroupsToAdd' , userGroupsUpdate, false );
184
188
updateWithSelectedUserGroups (props .userGroups );
189
+ hasUserGroupsValue ();
185
190
}
186
191
187
192
const availableUserGroups = computed (() => {
@@ -192,6 +197,19 @@ const availableUserGroups = computed(() => {
192
197
});
193
198
});
194
199
200
+ /**
201
+ * check user groups array and show
202
+ * remove role button only for clear the fields
203
+ */
204
+ function hasUserGroupsValue () {
205
+ if (store .invitationPayload .userGroupsToAdd [0 ]) {
206
+ Object .values (store .invitationPayload .userGroupsToAdd [0 ]).some (
207
+ (value ) => value !== null ,
208
+ );
209
+ }
210
+ return false ;
211
+ }
212
+
195
213
/**
196
214
* add user groups to the invitation payload
197
215
*/
@@ -245,6 +263,13 @@ function removeUserGroup(userGroup, index) {
245
263
*/
246
264
function removeInvitedUserGroup (index ) {
247
265
const userGroupsUpdate = [... store .invitationPayload .userGroupsToAdd ];
266
+ if (hasUserGroupsValue && userGroupsUpdate .length === 1 ) {
267
+ userGroupsUpdate .push ({
268
+ userGroupId: null ,
269
+ dateStart: null ,
270
+ masthead: null ,
271
+ });
272
+ }
248
273
userGroupsUpdate .splice (index, 1 );
249
274
store .updatePayload (' userGroupsToAdd' , userGroupsUpdate, false );
250
275
updateWithSelectedUserGroups (props .userGroups );
0 commit comments