Skip to content

Commit 535f5fb

Browse files
FrancescoMolinarovins01-4science
authored andcommitted
Merged in task/main-glam/GLAM-1102 (pull request DSpace#3332)
[GLAM-1102] improve check on group editability Approved-by: Andrea Barbasso
2 parents 545a29e + 653b414 commit 535f5fb

File tree

1 file changed

+21
-6
lines changed

1 file changed

+21
-6
lines changed

src/app/access-control/group-registry/group-form/group-form.component.ts

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import {
33
NgIf,
44
} from '@angular/common';
55
import {
6+
AfterViewInit,
67
ChangeDetectorRef,
78
Component,
89
EventEmitter,
@@ -104,7 +105,7 @@ import { ValidateGroupExists } from './validators/group-exists.validator';
104105
/**
105106
* A form used for creating and editing groups
106107
*/
107-
export class GroupFormComponent implements OnInit, OnDestroy {
108+
export class GroupFormComponent implements OnInit, OnDestroy, AfterViewInit {
108109

109110
messagePrefix = 'admin.access-control.groups.form';
110111

@@ -230,6 +231,25 @@ export class GroupFormComponent implements OnInit, OnDestroy {
230231
this.initialisePage();
231232
}
232233

234+
ngAfterViewInit() {
235+
this.subs.push(
236+
observableCombineLatest([
237+
this.activeGroup$,
238+
this.canEdit$,
239+
]).subscribe(([activeGroup, canEdit]) => {
240+
if (!activeGroup) {
241+
return;
242+
}
243+
244+
if (canEdit && !activeGroup.permanent) {
245+
this.formGroup.enable();
246+
} else {
247+
this.formGroup.disable();
248+
}
249+
}),
250+
);
251+
}
252+
233253
initialisePage() {
234254
const groupNameModel = new DynamicInputModel({
235255
id: 'groupName',
@@ -301,11 +321,6 @@ export class GroupFormComponent implements OnInit, OnDestroy {
301321
groupDescription: activeGroup.firstMetadataValue('dc.description'),
302322
});
303323
}
304-
if (!canEdit || activeGroup.permanent) {
305-
this.formGroup.disable();
306-
} else {
307-
this.formGroup.enable();
308-
}
309324
}
310325
}),
311326
);

0 commit comments

Comments
 (0)