forked from dhallsim/angular-form-generator
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
197 lines (182 loc) · 6.9 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
<!DOCTYPE html>
<html lang="en" ng-app="formGeneratorApp">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<head>
<title>Form Generator Test</title>
<link href="http://netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap.min.css" rel="stylesheet">
<link href="demo/css/app.css" rel="stylesheet">
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.1/jquery.min.js"></script>
<script src="http://netdna.bootstrapcdn.com/bootstrap/3.0.0/js/bootstrap.min.js"></script>
<script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.0.7/angular.min.js"></script>
<script src="demo/js/app.js"></script>
<script src="demo/js/controllers.js"></script>
<script src="src/angular-form-generator.js"></script>
</head>
<body ng-controller="indexCtrl">
<div class="container" style="margin-top: 20px;">
<div class="row">
<div class="col-lg-4">
<h1>Form Fields</h1>
<button class="btn btn-default" ng-click="newField()">New Field</button>
<div ng-show="editingField">
<form>
<div class="form-group">
<label>Label</label>
<input type="text" ng-model="currentField.label.name" class="form-control"/>
<div>
<label>Wrap Field?</label>
<input type="checkbox" ng-model="currentField.label.wrapField"/>
</div>
<label>Label Classes (separate by commas)</label>
<textarea ng-model="currentLabelClasses" ng-change="addLabelClasses()" class="form-control"></textarea>
</div>
<div class="form-group">
<label>Field Type</label>
<select ng-change="addFieldType()" ng-model="currentFieldType" ng-options="field.name for field in fieldTypes" class="form-control"></select>
</div>
<div class="form-group">
<label>Model Property (ng-model to bind back to)</label>
<input type="text" ng-model="currentFieldModel" ng-change="addFieldModel()" class="form-control">
</div>
<div class="form-group">
<label>Required</label>
<input type="checkbox" ng-model="currentField.required"/>
</div>
<div class="form-group" ng-show="showFieldPlaceholder()">
<label>Placeholder Text</label>
<input type="text" ng-model="currentField.placeholder" class="form-control"/>
</div>
<div class="form-group">
<label>Group ID</label>
<input type="number" ng-model="currentField.group" class="form-control"/>
</div>
<div class="form-group">
<label>Field Classes (separate by commas)</label>
<textarea ng-model="currentFieldClasses" ng-change="addFieldClasses()" class="form-control"></textarea>
</div>
<div class="form-group" ng-show="showFieldOptions()">
<h4>Options</h4>
<button class="btn btn-default" ng-click="newFieldOption()">Add Option</button>
<div ng-show="editingFieldOption">
<form>
<div class="form-group">
<label>Option Label</label>
<input type="text" ng-model="currentFieldOption.label.name" class="form-control"/>
<div>
<label>Wrap Option?</label>
<input type="checkbox" ng-model="currentFieldOption.label.wrapField"/>
</div>
<label>Option Label Classes (separate by commas)</label>
<textarea ng-model="currentFieldOptionLabelClasses" ng-change="addOptionLabelClasses()" class="form-control"></textarea>
</div>
<div class="form-group">
<label>Option Value</label>
<input type="text" ng-model="currentFieldOption.value" class="form-control"/>
</div>
<div class="form-group">
<label>Option Group ID</label>
<input type="number" min="0" ng-model="currentFieldOption.group" class="form-control"/>
</div>
</form>
</div>
</div>
</form>
<div ng-hide="currentField.options.length == 0">
<h4>Current Field Options<h4>
<table class="table table-bordered">
<thead>
<th>Label</th>
<th>Value</th>
<th>Actions</th>
</thead>
<tbody>
<tr ng-repeat="option in currentField.options">
<td>{{option.label.name}}</td>
<td>{{option.value}}</td>
<td>
<button type="button" class="btn btn-primary btn-xs" ng-click="editFieldOption(option)">Edit</button>
<button type="button" class="btn btn-danger btn-xs" ng-click="deleteFieldOption(option)">Delete</button>
</td>
</tr>
</tbody>
</table>
</div>
</div>
<div ng-hide="myForm.fields.length == 0">
<h4>Current Form Fields<h4>
<table class="table table-bordered">
<thead>
<th>Label</th>
<th>Type</th>
<th>Actions</th>
</thead>
<tbody>
<tr ng-repeat="field in myForm.fields">
<td>{{field.label.name}}</td>
<td>{{field.type}}</td>
<td>
<button type="button" class="btn btn-primary btn-xs" ng-click="editField(field)">Edit</button>
<button type="button" class="btn btn-danger btn-xs" ng-click="deleteField(field)">Delete</button>
</td>
</tr>
</tbody>
</table>
</div>
</div>
<div class="col-lg-4">
<h1>Form Properties</h1>
<form>
<div class="form-group">
<label>Form Classes (separate by commas)</label>
<textarea ng-model="currentFormClasses" ng-change="addFormClasses()" class="form-control"></textarea>
</div>
</form>
<h1>Form Groups</h1>
<button type="button" class="btn btn-default" ng-click="newGroup()">Add Group</button>
<div ng-show="editingGroup">
<form>
<div class="form-group">
<label>ID (integer to be referenced by field's group property)</label>
<input type="number" ng-model="currentGroup.id" min="0" class="form-control"/>
</div>
<div class="form-group">
<label>Name</label>
<input type="text" ng-model="currentGroup.name" class="form-control"/>
</div>
<div class="form-group">
<label>Group Classes (separate by commas)</label>
<textarea ng-model="currentGroupClasses" ng-change="addGroupClasses()" class="form-control"></textarea>
</div>
</form>
</div>
<div ng-hide="myForm.groups.length == 0">
<h4>Current Form Groups<h4>
<table class="table table-bordered">
<thead>
<th>Name</th>
<th>ID</th>
<th>Actions</th>
</thead>
<tbody>
<tr ng-repeat="group in myForm.groups">
<td>{{group.name}}</td>
<td>{{group.id}}</td>
<td>
<button type="button" class="btn btn-primary btn-xs" ng-click="editGroup(group)">Edit</button>
<button type="button" class="btn btn-danger btn-xs" ng-click="deleteGroup(group)">Delete</button>
</td>
</tr>
</tbody>
</table>
</div>
</div>
<div class="col-lg-4">
<h1>Resulting Form</h1>
<div form-generator form="myForm"></div>
<h1>Form Model</h1>
<pre>{{myFormModel | json}}</pre>
</div>
</div>
</div>
</body>
</html>