aboutsummaryrefslogtreecommitdiffstats
path: root/catalog-ui/src/app/ng2/pages/properties-assignment/property-creator
diff options
context:
space:
mode:
authoraribeiro <anderson.ribeiro@est.tech>2021-07-15 09:18:37 +0100
committeraribeiro <anderson.ribeiro@est.tech>2021-08-06 17:22:20 +0100
commit47bcc63a9daff1f310125fed006f27c93656fa83 (patch)
tree3c61670b039c0e63d14880f909e6047d54776492 /catalog-ui/src/app/ng2/pages/properties-assignment/property-creator
parent0ed125f98ae8ea9e80c855a640c328654660d081 (diff)
Retrieve data types based on component model
Issue-ID: SDC-3660 Signed-off-by: aribeiro <anderson.ribeiro@est.tech> Change-Id: I09c533eb39277532b29e581e4dd57e9df952e8e6
Diffstat (limited to 'catalog-ui/src/app/ng2/pages/properties-assignment/property-creator')
-rw-r--r--catalog-ui/src/app/ng2/pages/properties-assignment/property-creator/property-creator.component.ts55
1 files changed, 29 insertions, 26 deletions
diff --git a/catalog-ui/src/app/ng2/pages/properties-assignment/property-creator/property-creator.component.ts b/catalog-ui/src/app/ng2/pages/properties-assignment/property-creator/property-creator.component.ts
index 8167caa959..57c9f97387 100644
--- a/catalog-ui/src/app/ng2/pages/properties-assignment/property-creator/property-creator.component.ts
+++ b/catalog-ui/src/app/ng2/pages/properties-assignment/property-creator/property-creator.component.ts
@@ -7,6 +7,7 @@ import { PROPERTY_DATA } from 'app/utils';
import * as _ from 'lodash';
import { PROPERTY_TYPES } from '../../../../utils';
import {Validation} from "../../../../view-models/workspace/tabs/general/general-view-model";
+import {WorkspaceService} from "../../workspace/workspace.service";
@Component({
selector: 'property-creator',
@@ -23,14 +24,38 @@ export class PropertyCreatorComponent {
dataTypes: DataTypesMap;
isLoading: boolean;
- constructor(protected dataTypeService: DataTypeService) {}
+ constructor(protected dataTypeService: DataTypeService, private workspaceService: WorkspaceService) {
+ this.filterDataTypesByModel(this.workspaceService.metadata.model);
+ }
+
+ checkFormValidForSubmit() {
+ const showSchema: boolean = this.showSchema();
+ const isSchemaValid: boolean = (showSchema && !this.propertyModel.schema.property.type) ? false : true;
+ if (!showSchema) {
+ this.propertyModel.schema.property.type = '';
+ }
+ return this.propertyModel.name && this.propertyModel.type && isSchemaValid;
+ }
+
+ showSchema(): boolean {
+ return [PROPERTY_TYPES.LIST, PROPERTY_TYPES.MAP].indexOf(this.propertyModel.type) > -1;
+ }
+
+ onSchemaTypeChange(): void {
+ if (this.propertyModel.type === PROPERTY_TYPES.MAP) {
+ this.propertyModel.value = JSON.stringify({'': null});
+ } else if (this.propertyModel.type === PROPERTY_TYPES.LIST) {
+ this.propertyModel.value = JSON.stringify([]);
+ }
+ }
- ngOnInit() {
+ public filterDataTypesByModel = (modelName: string) => {
+ this.dataTypes = new DataTypesMap(null);
+ this.dataTypes = this.dataTypeService.getDataTypeByModel(modelName);
this.propertyModel = new PropertyBEModel();
this.propertyModel.type = '';
this.propertyModel.schema.property.type = '';
const types: string[] = PROPERTY_DATA.TYPES; // All types - simple type + map + list
- this.dataTypes = this.dataTypeService.getAllDataTypes(); // Get all data types in service
const nonPrimitiveTypes: string[] = _.filter(Object.keys(this.dataTypes), (type: string) => {
return types.indexOf(type) === -1;
});
@@ -43,35 +68,13 @@ export class PropertyCreatorComponent {
);
const nonPrimitiveTypesValues = _.map(nonPrimitiveTypes,
(type: string) => new DropdownValue(type,
- type.replace('org.openecomp.datatypes.heat.', ''))
+ type.replace('org.openecomp.datatypes.heat.', ''))
)
.sort((a, b) => a.label.localeCompare(b.label));
this.typesProperties = _.concat(this.typesProperties, nonPrimitiveTypesValues);
this.typesSchemaProperties = _.concat(typesSimpleProperties, nonPrimitiveTypesValues);
this.typesProperties.unshift(new DropdownValue('', 'Select Type...'));
this.typesSchemaProperties.unshift(new DropdownValue('', 'Select Schema Type...'));
-
- }
-
- checkFormValidForSubmit() {
- const showSchema: boolean = this.showSchema();
- const isSchemaValid: boolean = (showSchema && !this.propertyModel.schema.property.type) ? false : true;
- if (!showSchema) {
- this.propertyModel.schema.property.type = '';
- }
- return this.propertyModel.name && this.propertyModel.type && isSchemaValid;
- }
-
- showSchema(): boolean {
- return [PROPERTY_TYPES.LIST, PROPERTY_TYPES.MAP].indexOf(this.propertyModel.type) > -1;
- }
-
- onSchemaTypeChange(): void {
- if (this.propertyModel.type === PROPERTY_TYPES.MAP) {
- this.propertyModel.value = JSON.stringify({'': null});
- } else if (this.propertyModel.type === PROPERTY_TYPES.LIST) {
- this.propertyModel.value = JSON.stringify([]);
- }
}
}