private string GetFieldDefaultValue(FormGroupControlModel field) { switch (GetTypeName(field.TypeReference)) { case "string": return("\"\""); case "boolean": return("false"); default: return(field.TypeReference.IsCollection ? "[]" : "null"); } }
public string GetPathFromMapping(string prefix, FormGroupControlModel field) { var path = prefix + string.Join(".", field.InternalElement.MappedElement.Path.Select(x => x.Name.ToCamelCase())); if (field.InternalElement.IsMapped && field.TypeReference.Element.SpecializationTypeId == FormGroupDefinitionModel.SpecializationTypeId) { if (field.TypeReference.IsCollection) { path += $".map(x => new {GetTypeName(field).RemoveSuffix("[]")}(x))"; } else { path = $"new {GetTypeName(field)}({path})"; } } if (GetTypeName(field) == "Date") { return($"new Date({path})"); } return(path); }
private string GetFormFieldType(FormGroupControlModel field) { return(field.TypeReference.IsCollection && field.TypeReference.Element.SpecializationTypeId != TypeDefinitionModel.SpecializationTypeId ? "FormArray" : "FormControl"); }