aboutsummaryrefslogtreecommitdiffstats
path: root/catalog-ui/src/app/models/properties-inputs/derived-fe-property.ts
diff options
context:
space:
mode:
Diffstat (limited to 'catalog-ui/src/app/models/properties-inputs/derived-fe-property.ts')
-rw-r--r--catalog-ui/src/app/models/properties-inputs/derived-fe-property.ts75
1 files changed, 27 insertions, 48 deletions
diff --git a/catalog-ui/src/app/models/properties-inputs/derived-fe-property.ts b/catalog-ui/src/app/models/properties-inputs/derived-fe-property.ts
index 1d79353453..f7117e456c 100644
--- a/catalog-ui/src/app/models/properties-inputs/derived-fe-property.ts
+++ b/catalog-ui/src/app/models/properties-inputs/derived-fe-property.ts
@@ -1,15 +1,11 @@
import { SchemaPropertyGroupModel, SchemaProperty } from '../aschema-property';
-import { PROPERTY_DATA, PROPERTY_TYPES} from 'app/utils';
-import { PropertyBEModel } from '../../models';
+import { DerivedPropertyType, PropertyBEModel } from '../../models';
+import { PROPERTY_TYPES } from 'app/utils';
+import { UUID } from "angular2-uuid";
-export enum DerivedPropertyType {
- SIMPLE,
- LIST,
- MAP,
- COMPLEX //other datatype, list of non-simple, or map of non-simple
-}
export class DerivedFEProperty extends PropertyBEModel {
+ valueObj: any;
parentName: string;
propertiesName: string; //"network_assignments#ipv4_subnet#use_ipv4 = parentPath + name
derivedDataType: DerivedPropertyType;
@@ -17,56 +13,39 @@ export class DerivedFEProperty extends PropertyBEModel {
isSelected: boolean;
isDisabled: boolean;
isChildOfListOrMap: boolean;
+ canBeDeclared: boolean;
+ mapKey: string;
- constructor(property: PropertyBEModel, parentName?: string)
- constructor(name: string, parentName: string, type: string, value: string, isChildOfListOrMap?:boolean, schema?: SchemaPropertyGroupModel);
- constructor(nameOrPropertyObj?: string | PropertyBEModel, parentName?: string, type?: string, value?: string, isChildOfListOrMap?: boolean, schema?: SchemaPropertyGroupModel) {
-
- super(typeof nameOrPropertyObj === 'string' ? null : nameOrPropertyObj);
-
- if (typeof nameOrPropertyObj !== 'string') { //constructor #1
+ constructor(property: PropertyBEModel, parentName?: string, createChildOfListOrMap?: boolean, key?:string, value?:any) {
+ if (!createChildOfListOrMap) { //creating a standard derived prop
+ super(property);
this.parentName = parentName ? parentName : null;
- this.propertiesName = (parentName) ? parentName + '#' + nameOrPropertyObj.name : nameOrPropertyObj.name;
- } else { //constructor #2
- this.name = nameOrPropertyObj;
- this.type = type;
+ this.propertiesName = (parentName) ? parentName + '#' + property.name : property.name;
+ this.canBeDeclared = true; //defaults to true
+ } else { //creating a direct child of list or map (ie. Item that can be deleted, with UUID instead of name)
+ super(null);
+ this.isChildOfListOrMap = true;
+ this.canBeDeclared = false;
+ this.name = UUID.UUID();
this.parentName = parentName;
- this.propertiesName = parentName + '#' + nameOrPropertyObj;
- this.value = value;
- if (schema) {
- this.schema = new SchemaPropertyGroupModel(new SchemaProperty(schema.property));
+ this.propertiesName = parentName + '#' + this.name;
+
+
+ if (property.type == PROPERTY_TYPES.LIST) {
+ this.mapKey = property.schema.property.type.split('.').pop();
+ this.type = property.schema.property.type;
+ } else { //map
+ this.mapKey = key || "";
+ this.type = property.type;
}
+ this.valueObj = (this.type == PROPERTY_TYPES.JSON && typeof value == 'object') ? JSON.stringify(value) : value;
+ this.schema = new SchemaPropertyGroupModel(new SchemaProperty(property.schema.property));
}
this.derivedDataType = this.getDerivedPropertyType();
- this.isChildOfListOrMap = (isChildOfListOrMap) ? isChildOfListOrMap : false;
}
-
- public getDerivedPropertyType = () => {
- if (PROPERTY_DATA.SIMPLE_TYPES.indexOf(this.type) > -1) {
- return DerivedPropertyType.SIMPLE;
- } else if (this.type == PROPERTY_TYPES.LIST) {
- return DerivedPropertyType.LIST;
- } else if (this.type == PROPERTY_TYPES.MAP) {
- return DerivedPropertyType.MAP;
- } else {
- return DerivedPropertyType.COMPLEX;
- }
- }
}
export class DerivedFEPropertyMap {
[parentPath: string]: Array<DerivedFEProperty>;
}
-
-
-// isDataType: boolean;
-
-
-// canAdd: boolean;
-// canCollapse: boolean;
-// canBeDeclared: boolean;
-
-// derivedValue: string;
-// derivedValueType: string;
-// propertiesName: string; \ No newline at end of file