Skip to content

Commit acf996e

Browse files
committed
removed "form name" property, router dependency, property renaming
1 parent 99475b1 commit acf996e

File tree

7 files changed

+36
-87
lines changed

7 files changed

+36
-87
lines changed

app/app-controller.es6

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,20 @@ angular.module('schemaFormBuilderApp').controller('FormBuilderController',functi
1111

1212

1313
$scope.$watch(function () {
14-
return $scope.form;
14+
return $scope.schema;
1515
}, function (update) {
16-
window.console.log(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));
1719
}, true);
20+
21+
$scope.newForm = function () {
22+
$scope.model = {
23+
fields: []
24+
};
25+
}
1826

1927
$scope.model = {
20-
name: 'Sample Form',
2128
type: 'schema-form',
2229
fields: [
2330
{

app/app-routes.es6

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

app/builder/builder-directive.es6

Lines changed: 17 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,24 @@
11
(function () {
2-
'use strict';
3-
2+
'use strict';
43

54
angular.module('schemaFormBuilder').directive('sfbSchema',['Converter', function(Converter){
65
return {
76
restrict: 'A',
87
scope: {
9-
schema: '=sfbSchema',
10-
form: '=sfbForm',
11-
model: '=sfbModel'
8+
sfbSchema: '=sfbSchema',
9+
sfbForm: '=sfbForm',
10+
builderModel: '=sfbModel'
1211
},
13-
//template: '<h1>Test</h1>'
1412
templateUrl: 'builder/builder.tpl.html',
1513
link: function (scope, element, attrs) {
1614

1715
var vm = scope;
1816

1917
// sample form
20-
vm.sampleForm = scope.model;
21-
window.console.log(JSON.stringify(vm.sampleForm));
18+
scope.sampleForm = scope.builderModel;
2219

2320
// describing properties of each form field
24-
vm.schema = {
21+
scope.builderSchema = {
2522
type: 'object',
2623
title: 'Comment',
2724
properties: {
@@ -159,21 +156,10 @@
159156
};
160157

161158
// holding properties of each form field
162-
vm.model = {};
159+
scope.model = {};
163160

164161
// describing the layout of the builder fields
165-
vm.form = [{
166-
type: 'section',
167-
htmlClass: 'row main-info',
168-
items: [{
169-
key: 'name',
170-
htmlClass: 'col-sm-6',
171-
placeholder: 'name of the form',
172-
notitle: true,
173-
fieldHtmlClass: 'field-name',
174-
labelHtmlClass: 'field-name-label'
175-
}]
176-
}, {
162+
scope.builderForm = [{
177163
type: 'section',
178164
htmlClass: 'my-field row',
179165
items: [{
@@ -183,17 +169,6 @@
183169
type: 'help',
184170
helpvalue: '<h4>My Fields:</h4>'
185171
}]
186-
}, {
187-
type: 'section',
188-
htmlClass: 'col-sm-6',
189-
items: [{
190-
type: 'button',
191-
onClick: function onClick() {
192-
vm.instructionsVisible = true;
193-
},
194-
style: 'btn-success btn-sm pull-right',
195-
title: 'Generate Schema'
196-
}]
197172
}]
198173
}, {
199174
key: 'fields',
@@ -319,27 +294,20 @@
319294
}];
320295

321296
// the resulting schema and form definitions
322-
vm.output = { schema: {}, form: [] };
323-
324-
vm.newForm = function () {
325-
vm.model = {
326-
fields: []
327-
};
328-
console.log(vm.model);
329-
};
330-
331-
if (!vm.model.name) {
332-
vm.model = vm.sampleForm;
333-
}
297+
scope.output = { schema: {}, form: [] };
334298

335299
function generateOutput(update) {
336-
vm.output = Converter.generateFields(update);
337-
console.log(vm.output);
338-
vm.display = angular.copy(vm.output);
300+
scope.output = Converter.generateFields(update);
301+
//console.log(JSON.stringify(scope.output));
302+
scope.sfbSchema = angular.copy(scope.output.schema);
303+
console.log("sfbSchema: " + JSON.stringify(scope.sfbSchema));
304+
scope.sfbForm = angular.copy(scope.output.form);
305+
console.log("sfbForm: " + JSON.stringify(scope.sfbForm));
306+
window.console.log("generate output");
339307
}
340308

341309
scope.$watch(function () {
342-
return vm.model;
310+
return scope.builderModel;
343311
}, function (update) {
344312
generateOutput(update);
345313
}, true);

app/builder/builder-module.es6

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
.module('schemaFormBuilder', [
1111
'schemaForm',
1212
'ui.bootstrap',
13-
'ui.router',
1413
'ui.sortable'
1514
]);
1615

app/builder/builder.tpl.html

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,14 @@
44
<div class="row">
55
<div class="col-sm-6 schemaFormBuilder">
66
<form name="builderForm">
7-
<div sf-schema="schema" sf-form="form" sf-model="model"
7+
<div sf-schema="builderSchema" sf-form="builderForm" sf-model="builderModel"
88
sf-options="{ formDefaults: { ngModelOptions: { updateOn: 'blur' } }}"></div>
99
</form>
10-
<a class="btn btn-sm btn-primary pull-right" ng-click="builder.newForm()">New Form</a>
1110
</div>
1211
<div class="col-sm-6 preview">
1312
<h4>preview</h4>
14-
<div sf-schema="display.schema" sf-form="display.form"
15-
sf-model="display.model"></div>
13+
<div sf-schema="sfbSchema" sf-form="sfbForm"
14+
sf-model="sfbModel"></div>
1615
</div>
1716
</div>
1817
</div>

app/index.html

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,11 @@
1313
<!-- endinject -->
1414
</head>
1515
<body>
16+
1617
<div ng-controller="FormBuilderController">
17-
<div sfb-schema="schema" sfb-form="form" sfb-model="model"></form>
18-
</div>
19-
18+
<a class="btn btn-sm btn-primary pull-right" ng-click="newForm()">New Form</a>
19+
<div sfb-schema="schema" sfb-form="form" sfb-model="model"></form>
20+
</div>
2021
</div>
2122

2223
<!-- bower:js -->

app/scss/builder.scss

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ body{
1515
text-transform: uppercase;
1616
}
1717
.schemaFormBuilder{
18-
height:calc(100vh - 80px);
18+
height:calc(100%);
1919
border-right:1px solid #ccc;
2020
overflow-y:auto;
2121
.my-field{
@@ -99,27 +99,13 @@ body{
9999
}
100100
.preview{
101101
background: #eee;
102-
height:calc(100vh - 80px);
102+
height:calc(100%);
103103
overflow-y:auto;
104104
input, textarea{
105105
background:none;
106106
}
107107
}
108108
}
109-
.instructions{
110-
display:none;
111-
width:100%;
112-
height:calc(100vh - 80px);
113-
background:#eee;
114-
position: absolute;
115-
top:80px;
116-
left:0;
117-
overflow-y:auto;
118-
z-index:2;
119-
}
120-
.instructions.visible{
121-
display: block;
122-
}
123109
}
124110

125111
.hide-label{

0 commit comments

Comments
 (0)