Skip to content

Commit c651a51

Browse files
authored
Merge pull request DSpace#5461 from guillermo-escire/feature/5454
Fix DSpace#5454: Group edits are immediately reflected in the user interface
2 parents 6fd8c17 + 65a9249 commit c651a51

File tree

2 files changed

+25
-0
lines changed

2 files changed

+25
-0
lines changed

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 {
@@ -344,6 +346,19 @@ describe('GroupFormComponent', () => {
344346
component.ngOnInit();
345347
});
346348

349+
it('should update the form fields with the new values after successful edit', fakeAsync(() => {
350+
component.groupName.setValue('newGroupName');
351+
component.groupDescription.setValue(groupDescription);
352+
353+
component.onSubmit();
354+
tick();
355+
356+
expect(component.formGroup.value.groupName).toBe(expected2.name);
357+
expect(component.formGroup.value.groupDescription).toBe(
358+
expected2.firstMetadataValue('dc.description'),
359+
);
360+
}));
361+
347362
it('should edit with name and description operations', () => {
348363
component.groupName.setValue('newGroupName');
349364
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
@@ -416,6 +416,16 @@ export class GroupFormComponent implements OnInit, OnDestroy {
416416
getFirstCompletedRemoteData(),
417417
).subscribe((rd: RemoteData<Group>) => {
418418
if (rd.hasSucceeded) {
419+
420+
const updatedGroup = rd.payload;
421+
422+
this.groupRegistryService.editGroup(updatedGroup);
423+
424+
this.formGroup.patchValue({
425+
groupName: updatedGroup.name,
426+
groupDescription: updatedGroup.firstMetadataValue('dc.description'),
427+
});
428+
419429
this.notificationsService.success(this.translateService.get(this.messagePrefix + '.notification.edited.success', { name: this.dsoNameService.getName(rd.payload) }));
420430
this.submitForm.emit(rd.payload);
421431
} else {

0 commit comments

Comments
 (0)