forked from MacKentoch/easyFormGenerator
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index_StepWay_As_Module.html
426 lines (381 loc) · 13.4 KB
/
index_StepWay_As_Module.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
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
<!DOCTYPE html>
<html lang="en" ng-app="appDemo">
<head>
<title>Easy form generator</title>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="description" content="create amazing forms without coding : form editor based on angular formly">
<meta name="author" content="Erwan Datin (MacKentoch)">
<!-- IMPORTANT : angular js lib (here for better result with ng-cloak) -->
<script type="text/javascript" src="./public/lib/js/angular.min.js"></script>
<!-- Bootstrap core CSS -->
<link href="./public/lib/css/bootstrap.min.css" rel="stylesheet">
<!-- font-awesome -->
<link href="./public/lib/css/font-awesome.min.css" rel="stylesheet">
<!-- animate -->
<link href="./public/lib/css/animate.min.css" rel="stylesheet">
<!-- textAngular -->
<link rel='stylesheet' href='./public/lib/css/textAngular.min.css'>
<!-- taoster angular -->
<link rel='stylesheet' href='./public/lib/css/toaster.min.css'>
<!-- nya select bootstrap -->
<link rel='stylesheet' href='./public/lib/css/nya-bs-select.min.css'>
<!-- Custom styles for this template -->
<link href="./public/css/eda.stepway.css" rel="stylesheet">
<!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
<!--[if lt IE 9]>
<script src="./public/lib/html5shiv/dist/html5shiv.min.js"></script>
<script src="./public/lib/respondJS/dest/respond.min.js"></script>
<![endif]-->
</head>
<!-- NOTE : ng-cloak here is not optimal solution : better to use it only where it is needed (I just take a shortcut as this an example not a production sample) -->
<body ng-controller="demoController as demoCtrl" ng-cloak>
<div>
<!-- navigation : just decoration it is not easy form generator
=============================================================-->
<header id="pageHeader" >
<div class="navbar navbar-default navbar-fixed-top">
<div class="container">
<div class="navbar-header">
<a class="navbar-brand" href="#">Easy form generator</a>
<button class="navbar-toggle" type="button" data-toggle="collapse" data-target="#navbar-main">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
</div>
<div class="navbar-collapse collapse" id="navbar-main">
<ul class="nav navbar-nav">
</ul>
<ul class="nav navbar-nav navbar-right">
<li><a class="socialIcon" target="_blank" href="https://github.com/MacKentoch"><span class="text-center"><i class="fa fa-github"></i></span></a></li>
<li><a class="socialIcon" target="_blank" href="https://twitter.com/erwan_datin"><span class="text-center"><i class="fa fa-twitter"></i></span></a></li>
</ul>
</div>
</div>
</div>
</header>
<!-- Easy Form Generator (here step way) is now a ridiculous small html :
=============================================================-->
<eda-step-way-easy-form-gen
eda-easy-form-generator-model="demoCtrl.easyFormGeneratorModel"
eda-save-form-event="demoCtrl.saveForm(edaEasyFormGeneratorModel)">
</eda-step-way-easy-form-gen>
</div>
<script type="text/javascript">
//demo purpose : here should be your app
//just inject easy form generator and bind properties
//then,
(function(){
'use strict';
angular
.module('appDemo', [
'eda.easyformGen.stepway' //injects easy form generator-step way
])
.controller('demoController', demoController);
demoController.$inject = ['$timeout'];
function demoController($timeout){
var demoCtrl = this;
demoCtrl.easyFormGeneratorModel = {};
demoCtrl.saveForm = saveForm;
//demo purpose only :
//in 3 seconds a new form will be bound to easy form generator :
timedModelChanged();
/**
* when click on save form, will call your save form function :
*/
function saveForm(easyFormGeneratorModel){
console.info('-> from here : you can save models to database (your controller)');
console.dir({
'What is it?' : 'this log shows you easy form returned model on save event',
'easyFormGeneratorModel' : easyFormGeneratorModel
});
/**
*
* MORE DETAILS ON 'easyFormGeneratorModel'
* ----------------------------------------
*
* easy form generator model properties:
*
* - formName : {string} (at save step you name your form)
* - btnSubmitText : {string} (if 'Submit' does not suits to you change submit button name)
* - btnCancelText : {string} (if 'Cancel' does not suits to you change cancel button name)
* - edaFieldsModel : {array} - easy form generator model that describe form
* - edaFieldsModelStringified : {string} - exactly same as edaFieldsModel it is just stringified
* - formlyFieldsModel : {object} - easy form generator model translate by itself 'edaFieldsModel' to 'angular formly fields model' -> usefull is you just need a formly directive
* - dataModel : {object} - this object is filled when filling form.
*/
}
/**
* to simulate server async load of a form model (3 seconds is eternity I hope your server won't take so much time)
*
* easy form generator will render it when timer done
*/
function timedModelChanged(){
$timeout(function(){
demoCtrl
.easyFormGeneratorModel
.formName = 'DemoForm';
demoCtrl
.easyFormGeneratorModel
.edaFieldsModel = testACompleteForm();
demoCtrl
.easyFormGeneratorModel
.btnSubmitText = 'I Confirm';
demoCtrl
.easyFormGeneratorModel
.btnCancelText = 'I give up';
console.info('timeout model change');
console.dir(demoCtrl.easyFormGeneratorModel);
}, 3000);
}
/**
* an easy form generator model as demo
*
* here as a demo, it could be retrieved from a database
*/
function testACompleteForm(){
var _testACompleteForm = [
{
"line": 1,
"activeColumn": 1,
"columns": [
{
"numColumn": 1,
"exist": true,
"control": {
"type": "header",
"key": "header-1441426238190",
"selectedControl": "Header",
"subtype": "",
"templateOptions": {
"label": "",
"required": false,
"description": "Anther Loaded Form",
"placeholder": "",
"options": []
},
"formlyExpressionProperties": {},
"formlyValidators": {},
"formlyValidation": {},
"edited": true
}
}
]
},
{
"line": -1,
"activeColumn": 1,
"columns": [
{
"numColumn": 1,
"exist": true,
"control": {
"type": "input",
"key": "input-1441426278314",
"selectedControl": "TextInput",
"subtype": "",
"templateOptions": {
"label": "text input",
"required": true,
"description": "text input",
"placeholder": "text input",
"options": []
},
"formlyExpressionProperties": {},
"formlyValidators": {},
"formlyValidation": {
"messages": {}
},
"edited": true
}
},
{
"numColumn": 2,
"exist": true,
"control": {
"type": "input",
"key": "input-1441426295927",
"selectedControl": "Password",
"subtype": "password",
"templateOptions": {
"label": "password",
"required": true,
"description": "password",
"placeholder": "password",
"options": []
},
"formlyExpressionProperties": {},
"formlyValidators": {},
"formlyValidation": {
"messages": {}
},
"edited": true
}
},
{
"numColumn": 3,
"exist": true,
"control": {
"type": "input",
"key": "input-1441426313388",
"selectedControl": "Email",
"subtype": "email",
"templateOptions": {
"label": "email",
"required": true,
"description": "email",
"placeholder": "email",
"options": []
},
"formlyExpressionProperties": {},
"formlyValidators": {
"emailShape": {
"message": "$viewValue + ' is not a valid email'"
}
},
"formlyValidation": {
"messages": {}
},
"edited": true
}
}
]
},
{
"line": -1,
"activeColumn": 1,
"columns": [
{
"numColumn": 1,
"exist": true,
"control": {
"type": "datepicker",
"key": "datepicker-1441426325143",
"selectedControl": "Date",
"subtype": "",
"templateOptions": {
"label": "date",
"required": true,
"description": "date",
"placeholder": "",
"options": [],
"datepickerPopup": "dd-MMMM-yyyy"
},
"formlyExpressionProperties": {},
"formlyValidators": {},
"formlyValidation": {
"messages": {}
},
"edited": true
}
},
{
"numColumn": 2,
"exist": true,
"control": {
"type": "basicSelect",
"key": "basicSelect-1441426346817",
"selectedControl": "BasicSelect",
"subtype": "",
"templateOptions": {
"label": "",
"required": false,
"description": "",
"placeholder": "",
"options": [
{
"name": "opt1",
"value": 0,
"group": ""
},
{
"name": "opt2",
"value": 1,
"group": ""
},
{
"name": "opt3",
"value": 2,
"group": ""
}
]
},
"formlyExpressionProperties": {},
"formlyValidators": {},
"formlyValidation": {
"messages": {}
},
"edited": true
}
}
]
},
{
"line": -1,
"activeColumn": 1,
"columns": [
{
"numColumn": 1,
"exist": true,
"control": {
"type": "richEditor",
"key": "richEditor-1441426365355",
"selectedControl": "RichTextEditor",
"subtype": "",
"templateOptions": {
"label": "",
"required": false,
"description": "",
"placeholder": "",
"options": []
},
"formlyExpressionProperties": {},
"formlyValidators": {},
"formlyValidation": {
"messages": {}
},
"edited": true
}
}
]
}
]
return _testACompleteForm;
}
}
})();
</script>
<!-- footer : declare JS dependencies
=============================================================-->
<footer id="pageFooter">
<!-- jquery framework : top 1 priority -->
<script type="text/javascript" src="./public/lib/js/jquery.min.js"></script>
<!-- bootstrap framework scripts -->
<script type="text/javascript" src="./public/lib/js/bootstrap.min.js"></script>
<!-- angular ui bootstrap -->
<script type="text/javascript" src="./public/lib/js/ui-bootstrap-tpls.min.js"></script>
<!-- angular app all concatenated here (app, controllers directives, containers ...) -->
<script type="text/javascript" src="./public/js/eda.stepway.js"></script>
<!-- textAngular Includes -->
<script src='./public/lib/js/textAngular-rangy.min.js'></script>
<script src='./public/lib/js/textAngular-sanitize.min.js'></script>
<script src='./public/lib/js/textAngular.min.js'></script>
<!-- lodash -->
<script src='./public/lib/js/lodash.min.js'></script>
<!-- angular animate -->
<script type="text/javascript" src="./public/lib/js/angular-animate.min.js"></script>
<!-- angular toaster -->
<script type="text/javascript" src="./public/lib/js/toaster.min.js"></script>
<!-- nya select bootstrap -->
<script type="text/javascript" src="./public/lib/js/nya-bs-select.min.js"></script>
<!-- api-check = formly needed : IMPORTANT : always before formly -->
<script type="text/javascript" src="./public/lib/js/api-check.min.js"></script>
<!-- angular formly -->
<script type="text/javascript" src="./public/lib/js/formly.min.js"></script>
<!-- angular formly template bootstrap -->
<script type="text/javascript" src="./public/lib/js/angular-formly-templates-bootstrap.min.js"></script>
</footer>
</body>
</html>