Arpit Agarwal | 4397874 | 2016-08-09 15:38:25 -0700 | [diff] [blame] | 1 | 'use strict';
|
| 2 |
|
| 3 | angular.module('ngXosLib')
|
| 4 | .component('formTest', {
|
| 5 | restrict: 'E',
|
| 6 | bindings: {},
|
| 7 | bindToController: true,
|
| 8 | controllerAs: 'vm',
|
| 9 | templateUrl: 'templates/form.dev.html',
|
| 10 | controller: function () {
|
| 11 | this.model = {
|
| 12 | first_name: 'Jhon',
|
| 13 | last_name: 'Doe',
|
| 14 | },
|
| 15 | this.config = {
|
| 16 | exclude: ['password', 'last_login'],
|
| 17 | formName: 'sampleForm',
|
| 18 | actions: [
|
| 19 | {
|
| 20 | label: 'Save',
|
| 21 | icon: 'ok', // refers to bootstraps glyphicon
|
| 22 | cb: (user) => { // receive the model
|
| 23 | console.log(user);
|
| 24 | },
|
| 25 | class: 'success'
|
| 26 | }
|
| 27 | ],
|
| 28 | fields: {
|
| 29 | first_name: {
|
| 30 | type: 'string',
|
| 31 | validators: {
|
| 32 | required: true
|
| 33 | }
|
| 34 | },
|
| 35 | last_name: {
|
| 36 | label: 'Surname',
|
| 37 | type: 'string',
|
| 38 | validators: {
|
| 39 | required: true,
|
| 40 | minlength: 10
|
| 41 | }
|
| 42 | },
|
Matteo Scandolo | e57712f | 2016-09-21 15:27:36 -0700 | [diff] [blame] | 43 | select: {
|
| 44 | label: 'select',
|
| 45 | type: 'select',
|
| 46 | options: [
|
| 47 | {id: 1, label: 'a'},
|
| 48 | {id: 2, label: 'b'}
|
| 49 | ]
|
| 50 | },
|
Arpit Agarwal | 4397874 | 2016-08-09 15:38:25 -0700 | [diff] [blame] | 51 | details_field: {
|
| 52 | label: 'Empty Object Field',
|
| 53 | type: 'object',
|
| 54 | properties: {
|
| 55 | foo: {
|
| 56 | label: 'FooLabel:',
|
| 57 | type: 'string',
|
| 58 | validators: {
|
| 59 | required: true
|
| 60 | }
|
| 61 | },
|
| 62 | bar: {
|
| 63 | type: 'number'
|
| 64 | }
|
| 65 | }
|
| 66 | }
|
| 67 | }
|
| 68 | }
|
| 69 | }
|
| 70 | }) |