Skip to content

Commit a65c0f2

Browse files
committed
Add schemaform
1 parent c41b717 commit a65c0f2

6 files changed

Lines changed: 86 additions & 1 deletion

File tree

bower.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,8 @@
3434
"angular-loading-bar": "0.6.0",
3535
"Faker": "2.1.2",
3636
"angular-mocks": "1.3.12",
37-
"angular-scenario": "1.3.12"
37+
"angular-scenario": "1.3.12",
38+
"angular-schema-form": "~0.8.3"
3839
},
3940
"devDependencies": {
4041
"angular-mocks": "1.3",

client/app/js/app.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ angular.module('loopbackApp', [
3232
'toasty',
3333
'autofields',
3434
'gettext',
35+
'schemaForm',
3536
'com.module.core',
3637
'com.module.about',
3738
'com.module.events',

client/app/modules/sandbox/config/sandbox.routes.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,12 @@ angular.module('com.module.sandbox')
1414
$state.go('app.sandbox.autofields');
1515
}
1616
})
17+
.state('app.sandbox.schemaform', {
18+
url: '/schemaform',
19+
templateUrl: 'modules/sandbox/views/schemaform.html',
20+
controller: 'SandboxSchemaformCtrl',
21+
controllerAs: 'ctrl'
22+
})
1723
.state('app.sandbox.forms', {
1824
url: '/forms',
1925
templateUrl: 'modules/sandbox/views/forms.html',

client/app/modules/sandbox/controllers/sandbox.ctrl.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@ angular.module('com.module.sandbox')
1313
}, {
1414
name: 'Dashboard',
1515
sref: '.dashboard'
16+
}, {
17+
name: 'Schemaform',
18+
sref: '.schemaform'
1619
}, {
1720
name: 'Forms',
1821
sref: '.forms'
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
'use strict';
2+
angular.module('com.module.sandbox')
3+
.controller('SandboxSchemaformCtrl', function (CoreService) {
4+
5+
this.model = {};
6+
7+
this.schema = {
8+
type: 'object',
9+
title: 'Comment',
10+
properties: {
11+
name: {
12+
title: 'Name',
13+
type: 'string'
14+
},
15+
email: {
16+
title: 'Email',
17+
type: 'string',
18+
pattern: '^\\S+@\\S+$'
19+
},
20+
comment: {
21+
title: 'Comment',
22+
type: 'string'
23+
}
24+
},
25+
required: ['name', 'email', 'comment']
26+
}
27+
;
28+
29+
this.form = [
30+
'name',
31+
'email',
32+
{
33+
key: 'comment',
34+
type: 'textarea',
35+
placeholder: 'Make a comment'
36+
},
37+
{
38+
type: 'submit',
39+
title: 'OK'
40+
}
41+
];
42+
43+
this.onSubmit = function () {
44+
CoreService.alertSuccess('Good job!', 'Well done, ' + this.model.name);
45+
};
46+
});
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<div class="row">
2+
<div class="col-md-6">
3+
<div class="box box-primary">
4+
<div class="box-header">
5+
<h3 class="box-title"></h3>
6+
</div>
7+
<div class="box-body">
8+
<form id="demoForm"
9+
sf-schema="ctrl.schema"
10+
sf-form="ctrl.form"
11+
sf-model="ctrl.model"
12+
ng-submit="ctrl.onSubmit(demoForm)">
13+
</form>
14+
</div>
15+
</div>
16+
</div>
17+
<div class="col-md-6">
18+
<div class="box box-primary">
19+
<div class="box-header">
20+
<h3 class="box-title"></h3>
21+
</div>
22+
<div class="box-body">
23+
<pre>{{ctrl.model|json}}</pre>
24+
</div>
25+
</div>
26+
</div>
27+
</div>
28+

0 commit comments

Comments
 (0)