From cf1723791fea91fa90c0b6c52e2ae5e1b7c91a00 Mon Sep 17 00:00:00 2001 From: Freddy Montes Date: Thu, 16 Aug 2018 11:31:13 -0600 Subject: [PATCH] dotCMS/core#14999 UI feedback when delete a field without permission (#772) --- .../edit/content-types-edit.component.spec.ts | 20 +++++++++++++++++++ .../edit/content-types-edit.component.ts | 2 ++ 2 files changed, 22 insertions(+) diff --git a/src/app/portlets/content-types/edit/content-types-edit.component.spec.ts b/src/app/portlets/content-types/edit/content-types-edit.component.spec.ts index febc96db8b..b8858f3b88 100644 --- a/src/app/portlets/content-types/edit/content-types-edit.component.spec.ts +++ b/src/app/portlets/content-types/edit/content-types-edit.component.spec.ts @@ -465,6 +465,26 @@ describe('ContentTypesEditComponent edit mode', () => { expect(comp.fields).toEqual(fieldsReturnByServer); }); + it('should handle remove field error', () => { + spyOn(dotHttpErrorManagerService, 'handle').and.callThrough(); + const fieldService = fixture.debugElement.injector.get(FieldService); + spyOn(fieldService, 'deleteFields').and.returnValue(Observable.throw(mockResponseView(403))); + + const contentTypeFieldsDropZone = de.query(By.css('dot-content-type-fields-drop-zone')); + + const fieldToRemove = { + name: 'field 3', + id: '3', + clazz: 'com.dotcms.contenttype.model.field.ImmutableColumnField', + sortOrder: 3 + }; + + // when: the saveFields event is tiggered in content-type-fields-drop-zone + contentTypeFieldsDropZone.componentInstance.removeFields.emit(fieldToRemove); + + expect(dotHttpErrorManagerService.handle).toHaveBeenCalledTimes(1); + }); + describe('update', () => { let contentTypeForm: DebugElement; diff --git a/src/app/portlets/content-types/edit/content-types-edit.component.ts b/src/app/portlets/content-types/edit/content-types-edit.component.ts index c0a1518695..8a24f0bcb6 100644 --- a/src/app/portlets/content-types/edit/content-types-edit.component.ts +++ b/src/app/portlets/content-types/edit/content-types-edit.component.ts @@ -151,6 +151,8 @@ export class ContentTypesEditComponent implements OnInit { .pluck('fields') .subscribe((fields: ContentTypeField[]) => { this.fields = fields; + }, (err: ResponseView) => { + this.dotHttpErrorManagerService.handle(err).subscribe((() => {})); }); }