|
@@ -14,30 +14,67 @@ const reducerIteree = (res, field) => Object.assign(res, { [field.name]: field.v
|
|
|
const _extractFormGroupData = reduce(reducerIteree, {});
|
|
|
const extractFormGroupData = nonNestedFormMetaLevel => _extractFormGroupData(nonNestedFormMetaLevel);
|
|
|
|
|
|
-const fieldOne = new fmd.BasicField({
|
|
|
- name: 'fieldOne',
|
|
|
- type: 'Checkbutton',
|
|
|
- value: '123',
|
|
|
- label: 'Field One'
|
|
|
+
|
|
|
+
|
|
|
+const basicTextField = new fmd.BasicField({
|
|
|
+ name: 'basicTextField',
|
|
|
+ label: 'Field One',
|
|
|
+ placeholder: 'Type a value here',
|
|
|
+ class: ['red', 'bgPaleBlue'],
|
|
|
+ id: 'yoyo'
|
|
|
});
|
|
|
|
|
|
-const fieldTwo = new fmd.BasicField({
|
|
|
- name: 'fieldTwo',
|
|
|
+const checkButton = new fmd.BasicField({
|
|
|
+ name: 'checkButton',
|
|
|
type: 'Checkbutton',
|
|
|
value: '456',
|
|
|
});
|
|
|
|
|
|
-const fieldThree = new fmd.BasicField({
|
|
|
- name: 'fieldThree',
|
|
|
- value: 'C'
|
|
|
+const modifiers = ['Matches', 'Starts With', 'Contains'];
|
|
|
+const transformerFunctions: ValueTransformer = {
|
|
|
+ inputFn: val => {
|
|
|
+ let modifier = 'Starts With';
|
|
|
+ if (/^%.*?%$/.test(val)) {
|
|
|
+ modifier = 'Contains'
|
|
|
+ } else if (/^[^%].*?[^%]$/.test(val)) {
|
|
|
+ modifier = 'Matches'
|
|
|
+ } else if (/^%.*/.test(val)) {
|
|
|
+ modifier = 'Starts With';
|
|
|
+ }
|
|
|
+ const transformedVal = val.replace(/%/g, '').trim();
|
|
|
+ return { modifier: modifier, value: transformedVal };
|
|
|
+ },
|
|
|
+ outputFn: (mod, val) => {
|
|
|
+ let transformedValue;
|
|
|
+ switch(mod) {
|
|
|
+ case 'Starts With':
|
|
|
+ transformedValue = `%${val}`;
|
|
|
+ break;
|
|
|
+ case 'Contains':
|
|
|
+ transformedValue = `%${val}%`;
|
|
|
+ break;
|
|
|
+ case 'Matches':
|
|
|
+ default:
|
|
|
+ transformedValue = val;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ return transformedValue;
|
|
|
+ }
|
|
|
+};
|
|
|
+const dropDownModifiedInput = new fmd.DropdownModifiedInputField({
|
|
|
+ name: 'dropDownModifiedInput',
|
|
|
+ value: 'lovely',
|
|
|
+ modifiers,
|
|
|
+ transform: transformerFunctions
|
|
|
});
|
|
|
|
|
|
const formMetaDataObj = {
|
|
|
- fieldOne,
|
|
|
- fieldTwo,
|
|
|
- fieldThree
|
|
|
+ basicTextField,
|
|
|
+ checkButton,
|
|
|
+ dropDownModifiedInput
|
|
|
};
|
|
|
|
|
|
+
|
|
|
|
|
|
@Component({
|
|
|
selector: 'app-root',
|
|
@@ -48,40 +85,6 @@ export class AppComponent implements OnInit {
|
|
|
|
|
|
form: FormGroup;
|
|
|
|
|
|
- modifiers = ['Starts With', 'Contains', 'Matches'];
|
|
|
- transformerFunctions: ValueTransformer = {
|
|
|
- inputFn: val => {
|
|
|
- let modifier = 'Starts With';
|
|
|
- if (/^%.*?%$/.test(val)) {
|
|
|
- modifier = 'Contains'
|
|
|
- } else if (/^[^%].*?[^%]$/.test(val)) {
|
|
|
- modifier = 'Matches'
|
|
|
- } else if (/^%.*/.test(val)) {
|
|
|
- modifier = 'Starts With';
|
|
|
- }
|
|
|
- const transformedVal = val.replace(/%/g, '').trim();
|
|
|
- return { modifier: modifier, value: transformedVal };
|
|
|
- },
|
|
|
- outputFn: (mod, val) => {
|
|
|
- let transformedValue;
|
|
|
- switch(mod) {
|
|
|
- case 'Starts With':
|
|
|
- transformedValue = `%${val}`;
|
|
|
- break;
|
|
|
- case 'Contains':
|
|
|
- transformedValue = `%${val}%`;
|
|
|
- break;
|
|
|
- case 'Matches':
|
|
|
- default:
|
|
|
- transformedValue = val;
|
|
|
- break;
|
|
|
- }
|
|
|
- return transformedValue;
|
|
|
- }
|
|
|
- };
|
|
|
-
|
|
|
- labels = ['Feature One', 'Allowed', 'Protected'];
|
|
|
-
|
|
|
formMetaDataObj = formMetaDataObj;
|
|
|
|
|
|
@ViewChild('testTemplate', { read: TemplateRef })
|
|
@@ -94,13 +97,6 @@ export class AppComponent implements OnInit {
|
|
|
|
|
|
ngOnInit() {
|
|
|
this.form = this.fb.group({
|
|
|
- testVal: '%lovely%',
|
|
|
- testCheckbutton: true,
|
|
|
- testCheckbuttonGroup: this.fb.group({
|
|
|
- feature1: true,
|
|
|
- feature1Allowed: true,
|
|
|
- feature1Password: false
|
|
|
- }),
|
|
|
dynaformtest: this.fb.group(extractFormGroupData(formMetaDataObj))
|
|
|
});
|
|
|
}
|