|
@@ -5,38 +5,38 @@
|
|
|
********************************************************************************************************************* */
|
|
|
|
|
|
import { ValidatorFn, AsyncValidatorFn } from '@angular/forms';
|
|
|
-import { ValueTransformer } from './../components/fields/dropdown-modified-input/dropdown-modified-input.component';
|
|
|
+import { ValueTransformer } from './../interfaces';
|
|
|
|
|
|
// ---------------------------------------------------------------------------------------------------------------------
|
|
|
// Types & Interfaces
|
|
|
|
|
|
-type Option = {
|
|
|
- label: string,
|
|
|
- value: string
|
|
|
+interface Option {
|
|
|
+ label: string;
|
|
|
+ value: string;
|
|
|
}
|
|
|
|
|
|
interface BasicFieldMetaData {
|
|
|
- name: string // The FormControl name
|
|
|
- origin?: 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?: string // The field value - defaults to empty string if not supplied
|
|
|
- placeholder?: string // Optional placeholder text
|
|
|
- class?: string | Array<string> // CSS classes to apply
|
|
|
- id?: string // CSS id to apply
|
|
|
- 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
|
|
|
+ origin?: 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?: string; // The field value - defaults to empty string if not supplied
|
|
|
+ placeholder?: string; // Optional placeholder text
|
|
|
+ class?: string | Array<string>; // CSS classes to apply
|
|
|
+ id?: string; // CSS id to apply
|
|
|
+ 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
|
|
|
}
|
|
|
|
|
|
interface OptionsFieldMetaData extends BasicFieldMetaData {
|
|
|
- options: Option[] // Array of Options - for select, radio-button-group and other 'multiple-choice' types
|
|
|
+ options: Option[]; // Array of Options - for select, radio-button-group and other 'multiple-choice' types
|
|
|
}
|
|
|
|
|
|
interface DropdownModifiedInputFieldMetaData extends BasicFieldMetaData {
|
|
|
- modifiers: string[]
|
|
|
- transform: ValueTransformer
|
|
|
+ modifiers: string[];
|
|
|
+ transform: ValueTransformer;
|
|
|
}
|
|
|
|
|
|
interface TimePickerFieldMetaData extends BasicFieldMetaData {
|
|
@@ -130,7 +130,7 @@ for (field in model) {
|
|
|
Object.assign(modeledMeta, new BasicField(field)); // Defaults to basic text field
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
|
|
|
(2) Apprach 2: Meta-data fully specified (not lazily-generated), so loop through metadata genetating field models.
|
|
|
metaspec may be hard-coded (for now) or loaded from server and cached, as part of app boostraping
|