Skip to content

Commit be91456

Browse files
authored
Merge pull request #6 from ThomasPe/directive
Refactored as a directive
2 parents db99b7c + 3bedd5f commit be91456

25 files changed

+580
-264
lines changed

README.md

Lines changed: 55 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,70 @@
1-
# Json Schema Form Builder
1+
# Schema Form Builder
22

3+
A simple form builder that generates a schema and form based on the [angular schema form](http://schemaform.io) package.
4+
5+
<<<<<<< HEAD
6+
=======
37
(branch for directive development)
48

59
Quickly generate your your schema form using this GUI builder.
10+
>>>>>>> refs/remotes/origin/directive
611
712
# Roadmap
813

914
- Complete support of all elements based on schema-form
15+
<<<<<<< HEAD
16+
- Support for editing existing Schemas & Forms
1017
- Provide source definition for different platforms
1118
- 100% test coverage
1219

20+
<<<<<<< HEAD
21+
=======
22+
<<<<<<< HEAD
1323
# Demo
1424
There is a live demo at http://ralphowino.github.io/schema-form-builder
25+
=======
26+
>>>>>>> refs/remotes/origin/directive
27+
28+
29+
#Basic Usage
30+
31+
**This is what using the Schema Form Builder should look like:**
32+
First, expose your (exinsting) schema and form to the $scope.
33+
34+
```javascript
35+
angular.module('myModule', ['schemaFormBuilder'])
36+
.controller('FormBuilderController', function($scope) {
37+
// JSON Schema
38+
// add an existing schema to edit it
39+
// or leave blank to create a new form
40+
$scope.schema = {};
41+
42+
// Schema Form Defintion
43+
// add an existing form definition for editing
44+
// or leave blank to create a new form
45+
$scope.form = [];
46+
47+
48+
});
49+
```
50+
51+
Then load them into the Schema Form Builder using the `sfbSchema` and `sfbForm` directives.
52+
53+
```html
54+
<div ng-controller="FormBuilderController">
55+
<div sfb-schema="schema" sfb-form="form"></form>
56+
</div>
57+
```
58+
59+
<<<<<<< HEAD
60+
=======
61+
>>>>>>> refs/remotes/origin/master
62+
>>>>>>> refs/remotes/origin/directive
1563
1664
# Simply need a html form?
17-
To generate vanilla/bootstrap/material forms check out ralphowino.github.com/form-builder
65+
To generate vanilla/bootstrap/material forms checkout ralphowino.github.com/form-builder
66+
=======
67+
- Generate vanilla/bootstrap/material forms
68+
69+
Built By: [ralphowino.com](http://ralphowino.com)
70+
>>>>>>> parent of 81af0ee... update builder

app/app-controller.es6

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
angular.module('schemaFormBuilderApp').controller('FormBuilderController',function ($scope) {
2+
// JSON Schema
3+
// add an existing schema to edit it
4+
// or leave blank to create a new form
5+
$scope.schema = {};
6+
7+
// Schema Form Defintion
8+
// add an existing form definition for editing
9+
// or leave blank to create a new form
10+
$scope.form = [];
11+
12+
13+
$scope.$watch(function () {
14+
return $scope.schema;
15+
}, function (update) {
16+
window.console.log("schema udpated");
17+
//window.console.log("Schema Update: " + JSON.stringify(update));
18+
//window.console.log("Form Update: " + JSON.stringify($scope.form));
19+
}, true);
20+
21+
$scope.newForm = function () {
22+
$scope.model = {
23+
fields: []
24+
};
25+
}
26+
27+
$scope.model = {
28+
type: 'schema-form',
29+
fields: [
30+
{
31+
type: 'text',
32+
key: 'first_name',
33+
title: 'First name',
34+
open: false
35+
},
36+
{
37+
type: 'text',
38+
key: 'last_name',
39+
title: 'Last name',
40+
open: false
41+
},
42+
{
43+
type: 'email',
44+
key: 'email',
45+
title: 'Email',
46+
open: false,
47+
showAdvance: true,
48+
fieldAddonRight:'<i class="glyphicon glyphicon-envelope"></i>'
49+
},
50+
{
51+
type: 'date',
52+
key: 'dob',
53+
title: 'Date of Birth',
54+
open: false
55+
},
56+
{
57+
type: 'dropdown',
58+
key: 'marital-status',
59+
title: 'Marital Status',
60+
open: false
61+
},
62+
{
63+
type: 'date-time',
64+
key: 'check-in',
65+
title: 'Check In',
66+
open: false
67+
},
68+
{
69+
type: 'date-time',
70+
key: 'check-out',
71+
title: 'Check Out',
72+
open: false
73+
},
74+
{
75+
type: 'textarea',
76+
key: 'bio',
77+
title: 'Biography',
78+
open: false
79+
}
80+
]
81+
};
82+
});

app/app-module.es6

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@
22
'use strict';
33

44
/* @ngdoc object
5-
* @name schemaFormBuilder
5+
* @name schemaFormBuilderApp
66
* @description
77
*
88
*/
99
angular
10-
.module('schemaFormBuilder', [
11-
'builder',
10+
.module('schemaFormBuilderApp', [
11+
'schemaFormBuilder',
1212
'ui.bootstrap'
1313
]);
1414
}());

app/app-routes.es6

Lines changed: 0 additions & 11 deletions
This file was deleted.

0 commit comments

Comments
 (0)