blob: 2178319e0b3f9460342925c48f89dd22704f72a6 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
|
import { SchemaPropertyGroupModel, SchemaProperty } from '../aschema-property';
import { DerivedPropertyType, PropertyBEModel } from '../../models';
import { PROPERTY_TYPES } from 'app/utils';
import { UUID } from "angular2-uuid";
export class DerivedFEProperty extends PropertyBEModel {
valueObj: any;
parentName: string;
propertiesName: string; //"network_assignments#ipv4_subnet#use_ipv4 = parentPath + name
derivedDataType: DerivedPropertyType;
isDeclared: boolean;
isSelected: boolean;
isDisabled: boolean;
hidden: boolean;
isChildOfListOrMap: boolean;
canBeDeclared: boolean;
mapKey: string;
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 + '#' + 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 + '#' + 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();
}
}
export class DerivedFEPropertyMap {
[parentPath: string]: Array<DerivedFEProperty>;
}
|