From 2f74a4ac81f228bdb0bf0f509e9c0ef296d28d82 Mon Sep 17 00:00:00 2001 From: aribeiro Date: Tue, 17 Nov 2020 10:52:41 +0000 Subject: Fix import VFC with attributes Fix import VFC with default attribute value Fix Update, create and delete attribute action Make attribute definition tosca compliant Issue-ID: SDC-3381 Signed-off-by: aribeiro Change-Id: Ibbd36b105b8c86d1e750f3b6d55752d63fe6530e --- .../attributes/attribute-modal.component.html | 24 +++++++--------------- .../attributes/attribute-modal.component.ts | 16 ++++++--------- .../attributes/attributes-modal.component.spec.ts | 20 +++++------------- .../workspace/attributes/attributes.component.html | 4 ++-- 4 files changed, 20 insertions(+), 44 deletions(-) (limited to 'catalog-ui/src/app/ng2') diff --git a/catalog-ui/src/app/ng2/pages/workspace/attributes/attribute-modal.component.html b/catalog-ui/src/app/ng2/pages/workspace/attributes/attribute-modal.component.html index bd30a469e0..094045e8b4 100644 --- a/catalog-ui/src/app/ng2/pages/workspace/attributes/attribute-modal.component.html +++ b/catalog-ui/src/app/ng2/pages/workspace/attributes/attribute-modal.component.html @@ -48,19 +48,19 @@
- - + @@ -71,7 +71,7 @@
@@ -88,17 +88,7 @@
- - - -
- \ No newline at end of file + diff --git a/catalog-ui/src/app/ng2/pages/workspace/attributes/attribute-modal.component.ts b/catalog-ui/src/app/ng2/pages/workspace/attributes/attribute-modal.component.ts index c703869ad2..b0a7651809 100644 --- a/catalog-ui/src/app/ng2/pages/workspace/attributes/attribute-modal.component.ts +++ b/catalog-ui/src/app/ng2/pages/workspace/attributes/attribute-modal.component.ts @@ -15,7 +15,7 @@ import { AttributeOptions } from './attributes-options'; }) export class AttributeModalComponent implements OnInit { - @ViewChild('defaultValue') validatedInput: InputComponent; + @ViewChild('_default') validatedInput: InputComponent; public readonly types = AttributeOptions.types; // integer, string, boolean etc. @@ -44,13 +44,9 @@ export class AttributeModalComponent implements OnInit { this.revalidateDefaultValue(); } - onHiddenCheckboxClicked(event: boolean) { - this.attributeToEdit.hidden = event; - } - onTypeSelected(selectedElement: IDropDownOption) { if (this.attributeToEdit.type !== selectedElement.value && selectedElement.value === 'boolean') { - this.attributeToEdit.defaultValue = ''; // Clean old value in case we choose change type to boolean + this.attributeToEdit._default = ''; // Clean old value in case we choose change type to boolean } this.attributeToEdit.type = selectedElement.value; this.revalidateDefaultValue(); @@ -58,7 +54,7 @@ export class AttributeModalComponent implements OnInit { onBooleanDefaultValueSelected(selectedElement: IDropDownOption) { if (this.attributeToEdit.type === 'boolean') { - this.attributeToEdit.defaultValue = selectedElement.value; + this.attributeToEdit._default = selectedElement.value; } } @@ -92,8 +88,8 @@ export class AttributeModalComponent implements OnInit { } public isMapUnique = () => { - if (this.attributeToEdit && this.attributeToEdit.type === 'map' && this.attributeToEdit.defaultValue) { - return ValidationUtils.validateUniqueKeys(this.attributeToEdit.defaultValue); + if (this.attributeToEdit && this.attributeToEdit.type === 'map' && this.attributeToEdit._default) { + return ValidationUtils.validateUniqueKeys(this.attributeToEdit._default); } return true; } @@ -102,7 +98,7 @@ export class AttributeModalComponent implements OnInit { this.setDefaultValuePattern(this.attributeToEdit.type); setTimeout(() => { if (this.validatedInput) { - this.validatedInput.onKeyPress(this.attributeToEdit.defaultValue); + this.validatedInput.onKeyPress(this.attributeToEdit._default); } }, 250); } diff --git a/catalog-ui/src/app/ng2/pages/workspace/attributes/attributes-modal.component.spec.ts b/catalog-ui/src/app/ng2/pages/workspace/attributes/attributes-modal.component.spec.ts index 99aa140dd1..2eed2311bb 100644 --- a/catalog-ui/src/app/ng2/pages/workspace/attributes/attributes-modal.component.spec.ts +++ b/catalog-ui/src/app/ng2/pages/workspace/attributes/attributes-modal.component.spec.ts @@ -56,28 +56,18 @@ describe('attributes modal component', () => { }) ); - it('test that when hidden is clicked, hidden attribute is set', async () => { - fixture.componentInstance.attributeToEdit = new AttributeModel(); - const hidden = fixture.componentInstance.attributeToEdit.hidden; - fixture.componentInstance.ngOnInit(); - - expect(hidden).toBe(false); - fixture.componentInstance.onHiddenCheckboxClicked(true); - expect(fixture.componentInstance.attributeToEdit.hidden).toBe(true); - }); - it('test that when type is set to boolean default value is cleared', async () => { const component = fixture.componentInstance; component.attributeToEdit = new AttributeModel(); component.ngOnInit(); component.onTypeSelected({ value : 'string', label : 'string'}); - component.attributeToEdit.defaultValue = 'some_value'; + component.attributeToEdit._default = 'some_value'; component.onTypeSelected({ value : 'boolean', label : 'boolean'}); - expect(component.attributeToEdit.defaultValue).toBe(''); + expect(component.attributeToEdit._default).toBe(''); component.onBooleanDefaultValueSelected({ value : 'true', label : 'true'}); - expect(component.attributeToEdit.defaultValue).toBe('true'); + expect(component.attributeToEdit._default).toBe('true'); }); it('test that when certain type is selected, the correct regex pattern is chosen', async () => { @@ -120,9 +110,9 @@ describe('attributes modal component', () => { expect(component.isMapUnique()).toBe(true); // map is not selected so return true by default component.onTypeSelected({ value : 'map', label : 'map'}); component.onEntrySchemaTypeSelected({ value : 'boolean', label : 'boolean' }); - component.attributeToEdit.defaultValue = '"1":true,"2":false'; + component.attributeToEdit._default = '"1":true,"2":false'; expect(component.isMapUnique()).toBe(true); - component.attributeToEdit.defaultValue = '"1":true,"1":false'; + component.attributeToEdit._default = '"1":true,"1":false'; expect(component.isMapUnique()).toBe(false); }); }); diff --git a/catalog-ui/src/app/ng2/pages/workspace/attributes/attributes.component.html b/catalog-ui/src/app/ng2/pages/workspace/attributes/attributes.component.html index 00a7a5cec0..6d50bbe11b 100644 --- a/catalog-ui/src/app/ng2/pages/workspace/attributes/attributes.component.html +++ b/catalog-ui/src/app/ng2/pages/workspace/attributes/attributes.component.html @@ -66,7 +66,7 @@ - {{row.defaultValue}} + {{row._default}} @@ -90,4 +90,4 @@ - \ No newline at end of file + -- cgit 1.2.3-korg