[CST-4058] Show the name of the community/collection in "Edit group" page

This commit is contained in:
Davide Negretti
2021-08-17 17:08:07 +02:00
parent 1bb98119f5
commit 5c070428d3
2 changed files with 33 additions and 7 deletions

View File

@@ -65,6 +65,7 @@ export class GroupFormComponent implements OnInit, OnDestroy {
* Dynamic models for the inputs of form * Dynamic models for the inputs of form
*/ */
groupName: DynamicInputModel; groupName: DynamicInputModel;
groupCommunity: DynamicInputModel;
groupDescription: DynamicTextAreaModel; groupDescription: DynamicTextAreaModel;
/** /**
@@ -160,8 +161,9 @@ export class GroupFormComponent implements OnInit, OnDestroy {
); );
observableCombineLatest( observableCombineLatest(
this.translateService.get(`${this.messagePrefix}.groupName`), this.translateService.get(`${this.messagePrefix}.groupName`),
this.translateService.get(`${this.messagePrefix}.groupCommunity`),
this.translateService.get(`${this.messagePrefix}.groupDescription`) this.translateService.get(`${this.messagePrefix}.groupDescription`)
).subscribe(([groupName, groupDescription]) => { ).subscribe(([groupName, groupCommunity, groupDescription]) => {
this.groupName = new DynamicInputModel({ this.groupName = new DynamicInputModel({
id: 'groupName', id: 'groupName',
label: groupName, label: groupName,
@@ -171,6 +173,13 @@ export class GroupFormComponent implements OnInit, OnDestroy {
}, },
required: true, required: true,
}); });
this.groupCommunity = new DynamicInputModel({
id: 'groupCommunity',
label: groupCommunity,
name: 'groupCommunity',
required: false,
readOnly: true,
});
this.groupDescription = new DynamicTextAreaModel({ this.groupDescription = new DynamicTextAreaModel({
id: 'groupDescription', id: 'groupDescription',
label: groupDescription, label: groupDescription,
@@ -179,6 +188,7 @@ export class GroupFormComponent implements OnInit, OnDestroy {
}); });
this.formModel = [ this.formModel = [
this.groupName, this.groupName,
this.groupCommunity,
this.groupDescription, this.groupDescription,
]; ];
this.formGroup = this.formBuilderService.createFormGroup(this.formModel); this.formGroup = this.formBuilderService.createFormGroup(this.formModel);
@@ -189,13 +199,27 @@ export class GroupFormComponent implements OnInit, OnDestroy {
).subscribe(([activeGroup, canEdit]) => { ).subscribe(([activeGroup, canEdit]) => {
if (activeGroup != null) { if (activeGroup != null) {
this.groupBeingEdited = activeGroup; this.groupBeingEdited = activeGroup;
this.getLinkedDSO(activeGroup).subscribe((res) => {
if (res?.payload?.name) {
this.formGroup.patchValue({
groupName: activeGroup != null ? activeGroup.name : '',
groupCommunity: res?.payload?.name ?? '',
groupDescription: activeGroup != null ? activeGroup.firstMetadataValue('dc.description') : '',
});
} else {
this.formModel = [
this.groupName,
this.groupDescription,
];
this.formGroup.patchValue({ this.formGroup.patchValue({
groupName: activeGroup != null ? activeGroup.name : '', groupName: activeGroup != null ? activeGroup.name : '',
groupDescription: activeGroup != null ? activeGroup.firstMetadataValue('dc.description') : '', groupDescription: activeGroup != null ? activeGroup.firstMetadataValue('dc.description') : '',
}); });
}
if (!canEdit || activeGroup.permanent) { if (!canEdit || activeGroup.permanent) {
this.formGroup.disable(); this.formGroup.disable();
} }
});
} }
}) })
); );

View File

@@ -350,6 +350,8 @@
"admin.access-control.groups.form.groupName": "Group name", "admin.access-control.groups.form.groupName": "Group name",
"admin.access-control.groups.form.groupCommunity": "Community or Collection",
"admin.access-control.groups.form.groupDescription": "Description", "admin.access-control.groups.form.groupDescription": "Description",
"admin.access-control.groups.form.notification.created.success": "Successfully created Group \"{{name}}\"", "admin.access-control.groups.form.notification.created.success": "Successfully created Group \"{{name}}\"",