diff options
author | aribeiro <anderson.ribeiro@est.tech> | 2020-11-17 10:52:41 +0000 |
---|---|---|
committer | aribeiro <anderson.ribeiro@est.tech> | 2020-11-17 10:52:41 +0000 |
commit | 2f74a4ac81f228bdb0bf0f509e9c0ef296d28d82 (patch) | |
tree | 78a1a00ae007885085304aa835d0e6e4868bc8b3 /catalog-ui/src/app/ng2/pages/workspace | |
parent | ba9b67ace03cd9bf1e5f275c060824ce89599b88 (diff) |
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 <anderson.ribeiro@est.tech>
Change-Id: Ibbd36b105b8c86d1e750f3b6d55752d63fe6530e
Diffstat (limited to 'catalog-ui/src/app/ng2/pages/workspace')
4 files changed, 20 insertions, 44 deletions
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 @@ <!-- ATTRIBUTE DEFAULT VALUE TEXT - OPTIONAL --> <div *ngIf="attributeToEdit.type != 'boolean'"> <sdc-input - #defaultValue + #_default [required]="false" label="Default Value" - [(value)]="attributeToEdit.defaultValue" + [(value)]="attributeToEdit._default" [disabled]="false" - name="defaultValue" + name="_default" testId="defaultValue" [maxLength]="255" (valueChange)="defaultValueChanged()"> </sdc-input> - <sdc-validation [validateElement]="defaultValue" (validityChanged)="onValidityChange($event, 'defaultValue')"> - <sdc-regex-validator *ngIf="this.attributeToEdit.defaultValue && this.attributeToEdit.defaultValue.length > 0" message="{{ this.defaultValueErrorMessage }}" + <sdc-validation [validateElement]="_default" (validityChanged)="onValidityChange($event, 'default')"> + <sdc-regex-validator *ngIf="this.attributeToEdit._default && this.attributeToEdit._default.length > 0" message="{{ this.defaultValueErrorMessage }}" [pattern]="defaultValuePattern"></sdc-regex-validator> <sdc-custom-validator *ngIf="this.attributeToEdit.type == 'map' && this.attributeToEdit.schema.property.type" message="{{ 'PROPERTY_EDIT_MAP_UNIQUE_KEYS' | translate }}" [callback]="isMapUnique" [disabled]="false"></sdc-custom-validator> @@ -71,7 +71,7 @@ <div *ngIf="attributeToEdit.type == 'boolean'"> <sdc-dropdown [disabled]="false" label="Default Value" [required]="false" - [selectedOption]="toDropDownOption(this.attributeToEdit.defaultValue)" placeHolder="Choose Default Value" + [selectedOption]="toDropDownOption(this.attributeToEdit._default)" placeHolder="Choose Default Value" [options]="booleanValues" (changed)="onBooleanDefaultValueSelected($event)"> </sdc-dropdown> @@ -88,17 +88,7 @@ </sdc-validation> </sdc-dropdown> </div> - - <!-- ATTRIBUTE HIDDEN - OPTIONAL --> - <sdc-checkbox - label="Hidden" - [checked]="attributeToEdit.hidden" - [disabled]="false" - testId="hidden" - (checkedChange)="this.onHiddenCheckboxClicked($event)" - > - </sdc-checkbox> </div> </div> -</form>
\ No newline at end of file +</form> 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 @@ <ngx-datatable-column [resizeable]="false" name="Default Value" [flexGrow]="3"> <ng-template ngx-datatable-cell-template let-row="row"> - {{row.defaultValue}} + {{row._default}} </ng-template> </ngx-datatable-column> @@ -90,4 +90,4 @@ </ngx-datatable-column> </ngx-datatable> -</div>
\ No newline at end of file +</div> |