- };
-
- link = (scope:IDataTypeFieldsStructureScope, element:any, $attr:any) => {
- scope.propertyNameValidationPattern = this.PropertyNameValidationPattern;
-
- scope.$watchCollection('[typeName,fieldsPrefixName]', (newData:any):void => {
- this.rerender(scope);
- });
-
-
- scope.expandAndCollapse = ():void => {
- if (!scope.expanded) {
- this.initDataOnScope(scope, $attr);
- scope.expanded = true;
- }
- scope.expand = !scope.expand;
- };
-
- scope.getValidationPattern = (type:string):RegExp => {
- return this.ValidationUtils.getValidationPattern(type);
- };
-
- scope.validateIntRange = (value:string):boolean => {
- return !value || this.ValidationUtils.validateIntRange(value);
- };
-
- scope.onValueChange = (propertyName:string, type:string,):void => {
- scope.valueObjRef[propertyName] = !angular.isUndefined(scope.valueObjRef[propertyName]) ? scope.valueObjRef[propertyName] : scope.currentTypeDefaultValue[propertyName];
- if (scope.valueObjRef[propertyName] && type != 'string') {
- scope.valueObjRef[propertyName] = JSON.parse(scope.valueObjRef[propertyName]);
- }
- };
-
- scope.inputOnValueChange = (property:any) => {
- if (property.constraints){
- // this.constraints = property.constraints[0].validValues;
- }
-
- let value = !scope.parentFormObj[scope.fieldsPrefixName + property.name].$error.pattern
- && ('integer' == property.type && scope.parentFormObj[scope.fieldsPrefixName + property.name].$setValidity('pattern', scope.validateIntRange(scope.valueObjRef[property.name]))
- || scope.onValueChange(property.name, (property.simpleType || property.type)));
- return value;
- }
- };
-
- public static factory = (DataTypesService:DataTypesService,
- PropertyNameValidationPattern:RegExp,
- ValidationUtils:ValidationUtils)=> {
- return new DataTypeFieldsStructureDirective(DataTypesService, PropertyNameValidationPattern, ValidationUtils);
- };