Documented xosForm
diff --git a/views/ngXosLib/xosHelpers/src/services/rest/Instances.js b/views/ngXosLib/xosHelpers/src/services/rest/Instances.js
index 2e74f33..57e5537 100644
--- a/views/ngXosLib/xosHelpers/src/services/rest/Instances.js
+++ b/views/ngXosLib/xosHelpers/src/services/rest/Instances.js
@@ -5,9 +5,9 @@
/**
* @ngdoc service
* @name xos.helpers.Instances
- * @description Angular resource to fetch /api/core/instances/
+ * @description Angular resource to fetch /api/core/instances/:instance_id/
**/
.service('Instances', function($resource){
- return $resource('/api/core/instances/');
+ return $resource('/api/core/instances/:instance_id/', { instance_id: '@id' });
})
})();
\ No newline at end of file
diff --git a/views/ngXosLib/xosHelpers/src/services/rest/Users.js b/views/ngXosLib/xosHelpers/src/services/rest/Users.js
index deb18a4..cb93866 100644
--- a/views/ngXosLib/xosHelpers/src/services/rest/Users.js
+++ b/views/ngXosLib/xosHelpers/src/services/rest/Users.js
@@ -5,9 +5,9 @@
/**
* @ngdoc service
* @name xos.helpers.Users
- * @description Angular resource to fetch /api/core/users/
+ * @description Angular resource to fetch /api/core/users/:user_id/
**/
.service('Users', function($resource){
- return $resource('/api/core/users/');
+ return $resource('/api/core/users/:user_id/', { user_id: '@id' });
})
})();
\ No newline at end of file
diff --git a/views/ngXosLib/xosHelpers/src/ui_components/dumbComponents/form/form.component.js b/views/ngXosLib/xosHelpers/src/ui_components/dumbComponents/form/form.component.js
index 521a0bb..5294229 100644
--- a/views/ngXosLib/xosHelpers/src/ui_components/dumbComponents/form/form.component.js
+++ b/views/ngXosLib/xosHelpers/src/ui_components/dumbComponents/form/form.component.js
@@ -15,7 +15,8 @@
* @ngdoc directive
* @name xos.uiComponents.directive:xosForm
* @restrict E
- * @description The xos-form directive
+ * @description The xos-form directive.
+ * This components have two usage, given a model it is able to autogenerate a form or it can be configured to create a custom form.
* @param {Object} config The configuration object
* ```
* {
@@ -29,18 +30,29 @@
},
class: 'success'
}
- * ]
+ * ],
+ * fields: {
+ * field_name: {
+ * label: 'Field Label',
+ * type: 'string' // options are: [date, boolean, number, email, string],
+ * validators: {
+ * minlength: number,
+ maxlength: number,
+ required: boolean,
+ min: number,
+ max: number
+ * }
+ * }
+ * }
* }
* ```
* @element ANY
* @scope
* @example
+
+ Autogenerated form
+
<example module="sampleForm">
- <file name="index.html">
- <div ng-controller="SampleCtrl as vm">
- <xos-form ng-model="vm.model" config="vm.config"></xos-form>
- </div>
- </file>
<file name="script.js">
angular.module('sampleForm', ['xos.uiComponents'])
.factory('_', function($window){
@@ -70,6 +82,69 @@
};
});
</file>
+ <file name="index.html">
+ <div ng-controller="SampleCtrl as vm">
+ <xos-form ng-model="vm.model" config="vm.config"></xos-form>
+ </div>
+ </file>
+ </example>
+
+ Configuration defined form
+
+ <example module="sampleForm1">
+ <file name="script.js">
+ angular.module('sampleForm1', ['xos.uiComponents'])
+ .factory('_', function($window){
+ return $window._;
+ })
+ .controller('SampleCtrl1', function(){
+ this.model = {
+ };
+
+ this.config = {
+ exclude: ['password', 'last_login'],
+ formName: 'sampleForm1',
+ actions: [
+ {
+ label: 'Save',
+ icon: 'ok', // refers to bootstraps glyphicon
+ cb: (user) => { // receive the model
+ console.log(user);
+ },
+ class: 'success'
+ }
+ ],
+ fields: {
+ first_name: {
+ type: 'string',
+ validators: {
+ required: true
+ }
+ },
+ last_name: {
+ label: 'Surname',
+ type: 'string',
+ validators: {
+ required: true,
+ minlength: 10
+ }
+ },
+ age: {
+ type: 'number',
+ validators: {
+ required: true,
+ min: 21
+ }
+ },
+ }
+ };
+ });
+ </file>
+ <file name="index.html">
+ <div ng-controller="SampleCtrl1 as vm">
+ <xos-form ng-model="vm.model" config="vm.config"></xos-form>
+ </div>
+ </file>
</example>
**/
diff --git a/views/ngXosLib/xosHelpers/src/ui_components/smartComponents/smartTable/smartTable.component.js b/views/ngXosLib/xosHelpers/src/ui_components/smartComponents/smartTable/smartTable.component.js
index 6ae25f7..5f2443b 100644
--- a/views/ngXosLib/xosHelpers/src/ui_components/smartComponents/smartTable/smartTable.component.js
+++ b/views/ngXosLib/xosHelpers/src/ui_components/smartComponents/smartTable/smartTable.component.js
@@ -14,6 +14,8 @@
/**
* @ngdoc directive
* @name xos.uiComponents.directive:xosSmartTable
+ * @link xos.uiComponents.directive:xosTable xosTable
+ * @link xos.uiComponents.directive:xosForm xosForm
* @restrict E
* @description The xos-table directive
* @param {Object} config The configuration for the component,