|
@@ -10,21 +10,22 @@ import { ValueTransformer } from '@modules/dynaform/interfaces';
|
|
|
import { standardModifiers, standardTransformer } from '@modules/dynaform/utils';
|
|
|
|
|
|
interface SimpleFieldMetaData {
|
|
|
- name: string; // The FormControl name
|
|
|
- source?: string; // Location in API-returned model - defaults to name
|
|
|
- type?: string; // The component type e.g. BasicInput, Checkbutton, Timepicker, etc
|
|
|
- label?: string; // The field label - defaults to unCamelCased name if not supplied
|
|
|
- value?: any; // The field value - defaults to empty string if not supplied
|
|
|
- default?: any; // Default value
|
|
|
- placeholder?: string; // Optional placeholder text
|
|
|
- class?: string | Array<string>; // CSS classes to apply
|
|
|
- id?: string; // CSS id to apply
|
|
|
- before?: string; // Ordering instruction - move before <name of another key in group>
|
|
|
- after?: string; // Ordering instruction - move after <name of another key in group>
|
|
|
- isDisabled?: boolean; // Whether field is initially disabled
|
|
|
- validators?: Array<ValidatorFn>; // Array of validator functions - following Angular FormControl API
|
|
|
- asyncValidators?: Array<AsyncValidatorFn>; // Array of async validator functions - following Angular FormControl API
|
|
|
- valFailureMsgs?: StringMap; // Validation failure messages - display appropriate message if validation fails
|
|
|
+ name: string; // The FormControl name
|
|
|
+ source?: string; // Location in API-returned model - defaults to name
|
|
|
+ type?: string; // The component type e.g. BasicInput, Checkbutton, Timepicker, etc
|
|
|
+ label?: string; // The field label - defaults to unCamelCased name if not supplied
|
|
|
+ value?: any; // The field value - defaults to empty string if not supplied
|
|
|
+ default?: any; // Default value
|
|
|
+ placeholder?: string; // Optional placeholder text
|
|
|
+ class?: string | string[]; // CSS classes to apply
|
|
|
+ id?: string; // CSS id to apply
|
|
|
+ before?: string; // Ordering instruction - move before <name of another key in group>
|
|
|
+ after?: string; // Ordering instruction - move after <name of another key in group>
|
|
|
+ isDisabled?: boolean; // Whether field is initially disabled
|
|
|
+ validators?: ValidatorFn[]; // Array of validator functions - following Angular FormControl API
|
|
|
+ asyncValidators?: AsyncValidatorFn[]; // Array of async validator functions - following Angular FormControl API
|
|
|
+ valFailureMsgs?: StringMap; // Validation failure messages - display appropriate message if validation fails
|
|
|
+ onChange?: (val) => {}; // Function to call when field's value changes
|
|
|
}
|
|
|
|
|
|
interface Option {
|
|
@@ -75,11 +76,11 @@ abstract class SimpleField {
|
|
|
value;
|
|
|
default = '';
|
|
|
placeholder = '';
|
|
|
- class?: string | Array<string>;
|
|
|
+ class?: string | string[];
|
|
|
id?: string;
|
|
|
isDisabled = false;
|
|
|
- validators: Array<ValidatorFn> = [];
|
|
|
- asyncValidators: Array<AsyncValidatorFn> = [];
|
|
|
+ validators: ValidatorFn[] = [];
|
|
|
+ asyncValidators: AsyncValidatorFn[] = [];
|
|
|
valFailureMsgs: StringMap = {};
|
|
|
|
|
|
constructor(meta: SimpleFieldMetaData) {
|
|
@@ -139,7 +140,6 @@ abstract class OptionsField extends SimpleField {
|
|
|
class TextField extends SimpleField {
|
|
|
type = 'Text';
|
|
|
link?: Link;
|
|
|
-
|
|
|
}
|
|
|
|
|
|
class TextareaField extends SimpleField {
|
|
@@ -215,7 +215,7 @@ class CheckbuttonGroup {
|
|
|
const groupMembers = groupmeta.meta;
|
|
|
this.meta = Object.entries(groupMembers)
|
|
|
.map( ([key, cb]) => [key, new CheckbuttonField(cb as SimpleFieldMetaData)] )
|
|
|
- .reduce((res, [key, cbf]) => { res[<string>key] = cbf; return res; }, {});
|
|
|
+ .reduce((res, [key, cbf]) => { res[key as string] = cbf; return res; }, {});
|
|
|
}
|
|
|
}
|
|
|
}
|