Skip to content

Commit 9fd92cc

Browse files
Fix #5454: Group edits are immediately reflected in the user interface
(cherry picked from commit 65a9249)
1 parent 1f0d936 commit 9fd92cc

2 files changed

Lines changed: 25 additions & 0 deletions

File tree

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

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@ import { HttpClient } from '@angular/common/http';
33
import { CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
44
import {
55
ComponentFixture,
6+
fakeAsync,
67
TestBed,
8+
tick,
79
waitForAsync,
810
} from '@angular/core/testing';
911
import {
@@ -335,6 +337,19 @@ describe('GroupFormComponent', () => {
335337
component.ngOnInit();
336338
});
337339

340+
it('should update the form fields with the new values after successful edit', fakeAsync(() => {
341+
component.groupName.setValue('newGroupName');
342+
component.groupDescription.setValue(groupDescription);
343+
344+
component.onSubmit();
345+
tick();
346+
347+
expect(component.formGroup.value.groupName).toBe(expected2.name);
348+
expect(component.formGroup.value.groupDescription).toBe(
349+
expected2.firstMetadataValue('dc.description'),
350+
);
351+
}));
352+
338353
it('should edit with name and description operations', () => {
339354
component.groupName.setValue('newGroupName');
340355
component.onSubmit();

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

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -414,6 +414,16 @@ export class GroupFormComponent implements OnInit, OnDestroy {
414414
getFirstCompletedRemoteData(),
415415
).subscribe((rd: RemoteData<Group>) => {
416416
if (rd.hasSucceeded) {
417+
418+
const updatedGroup = rd.payload;
419+
420+
this.groupRegistryService.editGroup(updatedGroup);
421+
422+
this.formGroup.patchValue({
423+
groupName: updatedGroup.name,
424+
groupDescription: updatedGroup.firstMetadataValue('dc.description'),
425+
});
426+
417427
this.notificationsService.success(this.translateService.get(this.messagePrefix + '.notification.edited.success', { name: this.dsoNameService.getName(rd.payload) }));
418428
this.submitForm.emit(rd.payload);
419429
} else {

0 commit comments

Comments
 (0)