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

View File

@@ -350,6 +350,8 @@
"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.notification.created.success": "Successfully created Group \"{{name}}\"",