Updated form.helpers service to support configuration of field object
diff --git a/views/ngXosLib/karma.conf.js b/views/ngXosLib/karma.conf.js
index 18c6f6f..9d880a0 100644
--- a/views/ngXosLib/karma.conf.js
+++ b/views/ngXosLib/karma.conf.js
@@ -94,7 +94,7 @@
// available browser launchers: https://npmjs.org/browse/keyword/karma-launcher
browsers: [
'PhantomJS',
- 'Chrome'
+ // 'Chrome'
],
diff --git a/views/ngXosLib/xosHelpers/spec/services/helpers/form.helpers.test.js b/views/ngXosLib/xosHelpers/spec/services/helpers/form.helpers.test.js
index 3c2405d..a126db5 100644
--- a/views/ngXosLib/xosHelpers/spec/services/helpers/form.helpers.test.js
+++ b/views/ngXosLib/xosHelpers/spec/services/helpers/form.helpers.test.js
@@ -229,6 +229,23 @@
options: [
{id: 1, label: 'something'}
]
+ },
+ object: {
+ label: 'Object Label',
+ type: 'object',
+ hint: 'Object Hint',
+ properties: {
+ foo: {
+ type: 'string',
+ label: 'FooLabel',
+ validators: {
+ required: true
+ }
+ },
+ bar: {
+ type: 'number'
+ }
+ }
}
};
@@ -277,6 +294,24 @@
options: [
{id: 1, label: 'something'}
]
+ },
+ object: {
+ label: 'Object Label:',
+ type: 'object',
+ hint: 'Object Hint',
+ validators: {},
+ properties: {
+ foo: {
+ type: 'string',
+ label: 'FooLabel',
+ validators: {
+ required: true
+ }
+ },
+ bar: {
+ type: 'number'
+ }
+ }
}
};
@@ -291,6 +326,7 @@
expect(res.created).toEqual(empty_formObject.created);
expect(res.custom).toEqual(empty_formObject.custom);
expect(res.select).toEqual(empty_formObject.select);
+ expect(res.object).toEqual(empty_formObject.object);
expect(res).toEqual(empty_formObject);
});
});
diff --git a/views/ngXosLib/xosHelpers/src/services/helpers/ui/form.helpers.js b/views/ngXosLib/xosHelpers/src/services/helpers/ui/form.helpers.js
index c312e6d..bc6a503 100644
--- a/views/ngXosLib/xosHelpers/src/services/helpers/ui/form.helpers.js
+++ b/views/ngXosLib/xosHelpers/src/services/helpers/ui/form.helpers.js
@@ -106,6 +106,9 @@
if(customField[f] && customField[f].options){
form[f].options = customField[f].options;
}
+ if(customField[f] && customField[f].properties){
+ form[f].properties = customField[f].properties;
+ }
if(form[f].type === 'date'){
model[f] = new Date(model[f]);
}
diff --git a/views/ngXosLib/xosHelpers/src/ui_components/dumbComponents/field/field.component.js b/views/ngXosLib/xosHelpers/src/ui_components/dumbComponents/field/field.component.js
index c361008..686dd38 100644
--- a/views/ngXosLib/xosHelpers/src/ui_components/dumbComponents/field/field.component.js
+++ b/views/ngXosLib/xosHelpers/src/ui_components/dumbComponents/field/field.component.js
@@ -152,8 +152,6 @@
},
template: `
<label ng-if="vm.field.type !== 'object'">{{vm.field.label}}</label>
- <!--<pre>{{vm.field.options | json}}</pre>-->
- <!--<pre>{{vm.ngModel | json}}</pre>-->
<input
ng-if="vm.field.type !== 'boolean' && vm.field.type !== 'object' && vm.field.type !== 'select'"
type="{{vm.field.type}}"
@@ -217,7 +215,7 @@
return RecursionHelper.compile(element);
},
controller: function($attrs, XosFormHelpers, LabelFormatter){
- // console.log('Field: ', this.name, this.field, this.ngModel);
+
if(!this.name){
throw new Error('[xosField] Please provide a field name');
}