diff --git a/README.md b/README.md
index 6ef2117..08f92a6 100644
--- a/README.md
+++ b/README.md
@@ -1,17 +1,70 @@
-# Json Schema Form Builder
+# Schema Form Builder
+A simple form builder that generates a schema and form based on the [angular schema form](http://schemaform.io) package.
+
+<<<<<<< HEAD
+=======
(branch for directive development)
Quickly generate your your schema form using this GUI builder.
+>>>>>>> refs/remotes/origin/directive
# Roadmap
- Complete support of all elements based on schema-form
+<<<<<<< HEAD
+- Support for editing existing Schemas & Forms
- Provide source definition for different platforms
- 100% test coverage
+<<<<<<< HEAD
+=======
+<<<<<<< HEAD
# Demo
There is a live demo at http://ralphowino.github.io/schema-form-builder
+=======
+>>>>>>> refs/remotes/origin/directive
+
+
+#Basic Usage
+
+**This is what using the Schema Form Builder should look like:**
+First, expose your (exinsting) schema and form to the $scope.
+
+```javascript
+angular.module('myModule', ['schemaFormBuilder'])
+ .controller('FormBuilderController', function($scope) {
+ // JSON Schema
+ // add an existing schema to edit it
+ // or leave blank to create a new form
+ $scope.schema = {};
+
+ // Schema Form Defintion
+ // add an existing form definition for editing
+ // or leave blank to create a new form
+ $scope.form = [];
+
+
+});
+```
+
+Then load them into the Schema Form Builder using the `sfbSchema` and `sfbForm` directives.
+
+```html
+
+
+
+```
+
+<<<<<<< HEAD
+=======
+>>>>>>> refs/remotes/origin/master
+>>>>>>> refs/remotes/origin/directive
# Simply need a html form?
-To generate vanilla/bootstrap/material forms check out ralphowino.github.com/form-builder
+To generate vanilla/bootstrap/material forms checkout ralphowino.github.com/form-builder
+=======
+- Generate vanilla/bootstrap/material forms
+
+Built By: [ralphowino.com](http://ralphowino.com)
+>>>>>>> parent of 81af0ee... update builder
diff --git a/app/app-controller.es6 b/app/app-controller.es6
new file mode 100644
index 0000000..d7e24cc
--- /dev/null
+++ b/app/app-controller.es6
@@ -0,0 +1,82 @@
+angular.module('schemaFormBuilderApp').controller('FormBuilderController',function ($scope) {
+ // JSON Schema
+ // add an existing schema to edit it
+ // or leave blank to create a new form
+ $scope.schema = {};
+
+ // Schema Form Defintion
+ // add an existing form definition for editing
+ // or leave blank to create a new form
+ $scope.form = [];
+
+
+ $scope.$watch(function () {
+ return $scope.schema;
+ }, function (update) {
+ window.console.log("schema udpated");
+ //window.console.log("Schema Update: " + JSON.stringify(update));
+ //window.console.log("Form Update: " + JSON.stringify($scope.form));
+ }, true);
+
+ $scope.newForm = function () {
+ $scope.model = {
+ fields: []
+ };
+ }
+
+ $scope.model = {
+ type: 'schema-form',
+ fields: [
+ {
+ type: 'text',
+ key: 'first_name',
+ title: 'First name',
+ open: false
+ },
+ {
+ type: 'text',
+ key: 'last_name',
+ title: 'Last name',
+ open: false
+ },
+ {
+ type: 'email',
+ key: 'email',
+ title: 'Email',
+ open: false,
+ showAdvance: true,
+ fieldAddonRight:''
+ },
+ {
+ type: 'date',
+ key: 'dob',
+ title: 'Date of Birth',
+ open: false
+ },
+ {
+ type: 'dropdown',
+ key: 'marital-status',
+ title: 'Marital Status',
+ open: false
+ },
+ {
+ type: 'date-time',
+ key: 'check-in',
+ title: 'Check In',
+ open: false
+ },
+ {
+ type: 'date-time',
+ key: 'check-out',
+ title: 'Check Out',
+ open: false
+ },
+ {
+ type: 'textarea',
+ key: 'bio',
+ title: 'Biography',
+ open: false
+ }
+ ]
+ };
+});
\ No newline at end of file
diff --git a/app/app-module.es6 b/app/app-module.es6
index 09bd985..dada330 100644
--- a/app/app-module.es6
+++ b/app/app-module.es6
@@ -2,13 +2,13 @@
'use strict';
/* @ngdoc object
- * @name schemaFormBuilder
+ * @name schemaFormBuilderApp
* @description
*
*/
angular
- .module('schemaFormBuilder', [
- 'builder',
+ .module('schemaFormBuilderApp', [
+ 'schemaFormBuilder',
'ui.bootstrap'
]);
}());
diff --git a/app/app-routes.es6 b/app/app-routes.es6
deleted file mode 100644
index ecfb3d7..0000000
--- a/app/app-routes.es6
+++ /dev/null
@@ -1,11 +0,0 @@
-(function () {
- 'use strict';
-
- angular
- .module('schemaFormBuilder')
- .config(config);
-
- function config($urlRouterProvider) {
- $urlRouterProvider.otherwise('/builder');
- }
-}());
diff --git a/app/builder/builder-directive.es6 b/app/builder/builder-directive.es6
new file mode 100644
index 0000000..28dcc74
--- /dev/null
+++ b/app/builder/builder-directive.es6
@@ -0,0 +1,321 @@
+(function () {
+ 'use strict';
+
+ angular.module('schemaFormBuilder').directive('sfbSchema',['Converter', function(Converter){
+ return {
+ restrict: 'A',
+ scope: {
+ sfbSchema: '=sfbSchema',
+ sfbForm: '=sfbForm',
+ builderModel: '=sfbModel'
+ },
+ templateUrl: 'builder/builder.tpl.html',
+ link: function (scope, element, attrs) {
+
+ var vm = scope;
+
+ // sample form
+ scope.sampleForm = scope.builderModel;
+
+ // describing properties of each form field
+ scope.builderSchema = {
+ type: 'object',
+ title: 'Comment',
+ properties: {
+ name: {
+ type: 'string'
+ },
+ fields: {
+ type: 'array',
+ title: 'Fields',
+ items: {
+ type: 'object',
+ properties: {
+ open: {
+ type: 'boolean',
+ 'default': true
+ },
+ type: {
+ title: 'Type',
+ type: 'string',
+ 'enum': ['text', 'textarea', 'number', 'email', 'password', 'dropdown', 'radios', 'radios-inline', 'radiobuttons', 'checkbox', 'checkboxes', 'boolean', 'date', 'time', 'date-time', 'button', 'submit', 'reset', 'help', 'template']
+ },
+ key: {
+ title: 'Key',
+ type: 'string',
+ description: 'Unique identifier'
+ },
+ title: {
+ condition: 'model.notitle',
+ title: 'Title',
+ type: 'string'
+ },
+ notitle: {
+ type: 'boolean',
+ title: 'Don\'t show title'
+ },
+ description: {
+ title: 'Description',
+ type: 'string'
+ },
+ validationMessage: {
+ title: 'Validation Message',
+ description: 'A custom validation error message. It can be a string, an object with error codes as key and messages as values or a custom message function',
+ type: 'string'
+ },
+ onChange: {
+ title: 'onChange',
+ description: 'onChange event handler, expression or function. For expression, modelValue and form are both available. For a function, they will be passed as parameters in that order',
+ type: 'string'
+ },
+ feedback: {
+ title: 'Feedback Icon',
+ description: 'Inline feedback icons. To turn off just set feedback to false. If set to a string that string is evaluated by a ngClass in the decorators scope. If not set att all the default value is { "glyphicon": true, "glyphicon-ok": hasSuccess(), "glyphicon-remove": hasError() }',
+ type: 'string'
+ },
+ disableSuccessState: {
+ type: 'boolean',
+ title: 'Disable Success State',
+ 'default': false
+ },
+ disableErrorState: {
+ type: 'boolean',
+ title: 'Disable Error State',
+ 'default': false
+ },
+ placeholder: {
+ title: 'Placeholder',
+ description: 'Placeholder on inputs and textarea',
+ type: 'string'
+ },
+ ngModelOptions: {
+ title: 'ng-Model Options',
+ description: 'Passed along to ng-model-options',
+ type: 'string'
+ },
+ readonly: {
+ type: 'boolean',
+ title: 'Readonly',
+ 'default': false
+ },
+ htmlClass: {
+ title: 'Class',
+ description: 'CSS Class(es) to be added to the container div e.g. : \'street foobar\'',
+ type: 'string'
+ },
+ destroyStrategy: {
+ title: 'Destroy Strategy',
+ description: 'One of null, empty , remove, or retain. Changes model on $destroy event. default is remove.',
+ type: 'string'
+ },
+ copyValueTo: {
+ title: 'Copy Value To',
+ description: 'Copy values to these schema keys e.g [\'address.street\']. The receiving fields can be shown, but the intent for them is to be hidden.',
+ type: 'string'
+ },
+ fieldHtmlClass: {
+ title: 'Field Class',
+ description: 'CSS Class(es) to be added to field input (or similar)',
+ type: 'string'
+ },
+ labelHtmlClass: {
+ title: 'Label Class',
+ description: 'CSS Class(es) to be added to the label of the field (or similar)',
+ type: 'string'
+ },
+ condition: {
+ title: 'Condition',
+ description: 'Show or hide field depending on an angular expression e.g \'model.age < 18\'. The expression has access to model, modelValue, arrayIndex. The condition need not reference a model value it could be anything on scope.',
+ type: 'string'
+ },
+ fieldAddonLeft: {
+ title: 'Field Addon - Left',
+ description: 'Add html code to left of input field. For reference check bootstrap input groups.',
+ type: 'string'
+ },
+ fieldAddonRight: {
+ title: 'Field Addon - Right',
+ description: 'Add html code to right of input field. For reference check bootstrap input groups.',
+ type: 'string'
+ },
+ onClick: {
+ title: 'onClick',
+ description: 'Function to call when a button/submit is clicked',
+ type: 'string'
+ },
+ showAdvanced: {
+ title: 'Show advance options',
+ type: 'boolean'
+ }
+ },
+ required: ['key']
+ }
+ }
+ },
+ required: ['name']
+ };
+
+ // holding properties of each form field
+ scope.model = {};
+
+ // describing the layout of the builder fields
+ scope.builderForm = [{
+ type: 'section',
+ htmlClass: 'my-field row',
+ items: [{
+ type: 'section',
+ htmlClass: 'col-sm-6',
+ items: [{
+ type: 'help',
+ helpvalue: '