|
@@ -7,20 +7,12 @@
|
|
|
import { ValidatorFn, AsyncValidatorFn } from '@angular/forms';
|
|
|
import { ValueTransformer } from './../interfaces';
|
|
|
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-interface Option {
|
|
|
- label: string;
|
|
|
- value: string;
|
|
|
-}
|
|
|
-
|
|
|
-interface BasicFieldMetaData {
|
|
|
+interface SimpleFieldMetaData {
|
|
|
name: string;
|
|
|
origin?: string;
|
|
|
type?: string;
|
|
|
label?: string;
|
|
|
- value?: string;
|
|
|
+ value?: any;
|
|
|
placeholder?: string;
|
|
|
class?: string | Array<string>;
|
|
|
id?: string;
|
|
@@ -30,37 +22,42 @@ interface BasicFieldMetaData {
|
|
|
valFailureMsgs?: StringMap;
|
|
|
}
|
|
|
|
|
|
-interface OptionsFieldMetaData extends BasicFieldMetaData {
|
|
|
- options: Option[];
|
|
|
+interface Option {
|
|
|
+ label: string;
|
|
|
+ value: string;
|
|
|
}
|
|
|
|
|
|
-interface DropdownModifiedInputFieldMetaData extends BasicFieldMetaData {
|
|
|
+interface OptionsFieldMetaData extends SimpleFieldMetaData {
|
|
|
+ options: Option[];
|
|
|
+}
|
|
|
+interface DropdownModifiedInputFieldMetaData extends SimpleFieldMetaData {
|
|
|
modifiers: string[];
|
|
|
transform: ValueTransformer;
|
|
|
}
|
|
|
|
|
|
-interface TimePickerFieldMetaData extends BasicFieldMetaData {
|
|
|
+interface TimePickerFieldMetaData extends SimpleFieldMetaData {
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
+
|
|
|
+
|
|
|
|
|
|
-class BasicField
|
|
|
-{
|
|
|
- type: string = 'Basicinput';
|
|
|
+class SimpleField {
|
|
|
+ type = 'text';
|
|
|
name: string;
|
|
|
origin?: string;
|
|
|
label?: string;
|
|
|
- value: string = '';
|
|
|
- placeholder: string = '';
|
|
|
+ value;
|
|
|
+ placeholder = '';
|
|
|
class?: string | Array<string>;
|
|
|
isDisabled?: boolean;
|
|
|
validators: Array<ValidatorFn> = [];
|
|
|
asyncValidators: Array<AsyncValidatorFn> = [];
|
|
|
valFailureMsgs: StringMap = {};
|
|
|
|
|
|
- constructor(meta: BasicFieldMetaData) {
|
|
|
+ constructor(meta: SimpleFieldMetaData) {
|
|
|
Object.assign(this, meta);
|
|
|
if (!this.origin) {
|
|
|
|
|
@@ -74,18 +71,50 @@ class BasicField
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-class OptionsField extends BasicField
|
|
|
-{
|
|
|
- type: string = 'OptionsField';
|
|
|
+class OptionsField extends SimpleField {
|
|
|
options: Option[];
|
|
|
constructor(meta: OptionsFieldMetaData) {
|
|
|
super(meta);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-class DropdownModifiedInputField extends BasicField
|
|
|
-{
|
|
|
- type: string = 'DropdownModifiedInput';
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+class TextField extends SimpleField {
|
|
|
+ type = 'Text';
|
|
|
+}
|
|
|
+
|
|
|
+class TextareaField extends SimpleField {
|
|
|
+ type = 'Textarea';
|
|
|
+}
|
|
|
+
|
|
|
+class PasswordField extends SimpleField {
|
|
|
+ type = 'Password';
|
|
|
+}
|
|
|
+
|
|
|
+class SelectField extends OptionsField {
|
|
|
+ type = 'Select';
|
|
|
+}
|
|
|
+
|
|
|
+class RadioField extends OptionsField {
|
|
|
+ type = 'Radio';
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+class CheckbuttonField extends SimpleField {
|
|
|
+ type = 'Checkbutton';
|
|
|
+}
|
|
|
+
|
|
|
+class CheckbuttonGroup extends SimpleField {
|
|
|
+ value: (string | boolean)[];
|
|
|
+ type = 'CheckbuttonGroup';
|
|
|
+}
|
|
|
+
|
|
|
+class DropdownModifiedInputField extends SimpleField {
|
|
|
+ type = 'DropdownModifiedInput';
|
|
|
modifiers: string[];
|
|
|
transform: ValueTransformer;
|
|
|
constructor(meta: DropdownModifiedInputFieldMetaData) {
|
|
@@ -93,18 +122,25 @@ class DropdownModifiedInputField extends BasicField
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-class TimePickerField extends BasicField
|
|
|
-{
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+class TimePickerField extends SimpleField {
|
|
|
|
|
|
constructor(meta: TimePickerFieldMetaData) {
|
|
|
super(meta);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+
|
|
|
|
|
|
|
|
|
|
|
|
-export { BasicField, OptionsField, DropdownModifiedInputField, TimePickerField };
|
|
|
+export {
|
|
|
+ TextField, TextareaField, PasswordField, SelectField, RadioField,
|
|
|
+ CheckbuttonField, CheckbuttonGroup, DropdownModifiedInputField, TimePickerField
|
|
|
+};
|
|
|
|
|
|
|
|
|
|
|
@@ -127,7 +163,7 @@ for (field in model) {
|
|
|
if (field in overrides) {
|
|
|
Object.assign(modeledMeta, FieldFactory(model, overrides[field]));
|
|
|
} else {
|
|
|
- Object.assign(modeledMeta, new BasicField(field));
|
|
|
+ Object.assign(modeledMeta, new SimpleField(field));
|
|
|
}
|
|
|
}
|
|
|
|