[groups/epeople admin pages] hide add epeople/groups on new group page, redirect after group creation to add them

This commit is contained in:
Marie Verdonck
2020-04-06 14:55:36 +02:00
parent cc402a0a02
commit 2ecc1ca7fd
4 changed files with 35 additions and 11 deletions

View File

@@ -20,8 +20,8 @@
(submitForm)="onSubmit()">
</ds-form>
<ds-members-list [messagePrefix]="messagePrefix + '.members-list'"></ds-members-list>
<ds-subgroups-list [messagePrefix]="messagePrefix + '.subgroups-list'"></ds-subgroups-list>
<ds-members-list *ngIf="groupBeingEdited != null" [messagePrefix]="messagePrefix + '.members-list'"></ds-members-list>
<ds-subgroups-list *ngIf="groupBeingEdited != null" [messagePrefix]="messagePrefix + '.subgroups-list'"></ds-subgroups-list>
<div>
<button [routerLink]="[this.groupDataService.getGroupRegistryRouterLink()]"

View File

@@ -84,6 +84,11 @@ export class GroupFormComponent implements OnInit, OnDestroy {
*/
subs: Subscription[] = [];
/**
* Group currently being edited
*/
groupBeingEdited: Group;
constructor(public groupDataService: GroupDataService,
private ePersonDataService: EPersonDataService,
private formBuilderService: FormBuilderService,
@@ -123,6 +128,7 @@ export class GroupFormComponent implements OnInit, OnDestroy {
this.formGroup = this.formBuilderService.createFormGroup(this.formModel);
this.subs.push(this.groupDataService.getActiveGroup().subscribe((activeGroup: Group) => {
if (activeGroup != null) {
this.groupBeingEdited = activeGroup;
this.formGroup.patchValue({
groupName: activeGroup != null ? activeGroup.name : '',
groupDescription: activeGroup != null ? activeGroup.firstMetadataValue('dc.description') : '',
@@ -185,7 +191,9 @@ export class GroupFormComponent implements OnInit, OnDestroy {
this.submitForm.emit(groupToCreate);
const resp: any = restResponse;
if (isNotEmpty(resp.resourceSelfLinks)) {
this.setActiveGroupWithLink(resp.resourceSelfLinks[0]);
const groupSelfLink = resp.resourceSelfLinks[0];
this.setActiveGroupWithLink(groupSelfLink);
this.router.navigateByUrl(this.groupDataService.getGroupEditPageRouterLinkWithID(this.groupDataService.getUUIDFromString(groupSelfLink)));
}
} else {
this.notificationsService.error(this.translateService.get(this.messagePrefix + '.notification.created.failure', { name: groupToCreate.name }));

View File

@@ -149,11 +149,6 @@ export class GroupsRegistryComponent implements OnInit {
* @param groupName
*/
getOptionalComColFromName(groupName: string): string {
let optionalComColName = '';
const uuidMatches = groupName.match(/[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}/g);
if (uuidMatches != null) {
optionalComColName = uuidMatches[0];
}
return optionalComColName;
return this.groupService.getUUIDFromString(groupName);
}
}

View File

@@ -277,7 +277,7 @@ export class GroupDataService extends DataService<Group> {
this.editGroup(newGroup)
}
});
return '/admin/access-control/groups/' + newGroup.id;
return this.getGroupEditPageRouterLinkWithID(newGroup.id)
}
/**
@@ -285,7 +285,28 @@ export class GroupDataService extends DataService<Group> {
* @param group Group we want edit page for
*/
public getGroupEditPageRouterLink(group: Group): string {
return '/admin/access-control/groups/' + group.id;
return this.getGroupEditPageRouterLinkWithID(group.id);
}
/**
* Get Edit page of group
* @param groupID Group ID we want edit page for
*/
public getGroupEditPageRouterLinkWithID(groupId: string): string {
return '/admin/access-control/groups/' + groupId;
}
/**
* Extract optional UUID from a string
* @param stringWithUUID String with possible UUID
*/
public getUUIDFromString(stringWithUUID: string): string {
let foundUUID = '';
const uuidMatches = stringWithUUID.match(/[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}/g);
if (uuidMatches != null) {
foundUUID = uuidMatches[0];
}
return foundUUID;
}
}