From 4ab3040954e3ad737a17a3152375fa04e9afcba3 Mon Sep 17 00:00:00 2001 From: Mykyta Maliarchuk <84377976+nikita-web-ua@users.noreply.github.com> Date: Mon, 16 Dec 2024 12:58:42 +0100 Subject: [PATCH] [ACS-8824] The user cannot edit node properties after failing... (#10420) * [ACS-8824] The user cannot edit node properties after failing to change node name with special characters * [ACS-8824] fix formatting --- .../content-metadata.component.spec.ts | 21 +++++++++++++++++++ .../content-metadata.component.ts | 1 + .../services/basic-properties.service.ts | 2 +- 3 files changed, 23 insertions(+), 1 deletion(-) diff --git a/lib/content-services/src/lib/content-metadata/components/content-metadata/content-metadata.component.spec.ts b/lib/content-services/src/lib/content-metadata/components/content-metadata/content-metadata.component.spec.ts index 83811229f69..fe504f2257e 100644 --- a/lib/content-services/src/lib/content-metadata/components/content-metadata/content-metadata.component.spec.ts +++ b/lib/content-services/src/lib/content-metadata/components/content-metadata/content-metadata.component.spec.ts @@ -389,6 +389,27 @@ describe('ContentMetadataComponent', () => { flush(); })); + it('should revert changes on unsuccessful save', fakeAsync(() => { + component.readOnly = false; + const property = { key: 'properties.property-key', value: 'original-value' } as CardViewBaseItemModel; + spyOn(nodesApiService, 'updateNode').and.returnValue(throwError(new Error('error message'))); + spyOn(component, 'revertChanges').and.callThrough(); + updateService.update(property, 'new-value'); + tick(600); + + fixture.detectChanges(); + toggleEditModeForGeneralInfo(); + tick(100); + clickOnGeneralInfoSave(); + tick(100); + + expect(component.revertChanges).toHaveBeenCalled(); + expect(component.changedProperties).toEqual({}); + expect(component.hasMetadataChanged).toBeFalse(); + discardPeriodicTasks(); + flush(); + })); + it('should open the confirm dialog when content type is changed', fakeAsync(() => { component.readOnly = false; const property = { key: 'nodeType', value: 'ft:sbiruli' } as CardViewBaseItemModel; diff --git a/lib/content-services/src/lib/content-metadata/components/content-metadata/content-metadata.component.ts b/lib/content-services/src/lib/content-metadata/components/content-metadata/content-metadata.component.ts index 89976e71a0a..c3acb82a0b7 100644 --- a/lib/content-services/src/lib/content-metadata/components/content-metadata/content-metadata.component.ts +++ b/lib/content-services/src/lib/content-metadata/components/content-metadata/content-metadata.component.ts @@ -409,6 +409,7 @@ export class ContentMetadataComponent implements OnChanges, OnInit { this.cardViewContentUpdateService.updateElement(this.targetProperty); this.handleUpdateError(err); this._saving = false; + this.revertChanges(); this.loadProperties(this.node); return of(null); }) diff --git a/lib/content-services/src/lib/content-metadata/services/basic-properties.service.ts b/lib/content-services/src/lib/content-metadata/services/basic-properties.service.ts index 5530fef7d8e..74fd9686a28 100644 --- a/lib/content-services/src/lib/content-metadata/services/basic-properties.service.ts +++ b/lib/content-services/src/lib/content-metadata/services/basic-properties.service.ts @@ -45,7 +45,7 @@ export class BasicPropertiesService { key: 'properties.cm:name', editable: true, validators: [ - new CardViewItemMatchValidator('[\\/\\*\\\\"\\\\]') + new CardViewItemMatchValidator('[\\/\\*\\\\"\\\\:]') ] }), new CardViewTextItemModel({