EasyFormViewer-DEMO.html 9.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319
  1. <!DOCTYPE html>
  2. <html lang="en" ng-app="app">
  3. <head>
  4. <title>Easy form generator (Easy Form Viewer)</title>
  5. <meta charset="utf-8">
  6. <meta http-equiv="X-UA-Compatible" content="IE=edge">
  7. <meta name="viewport" content="width=device-width, initial-scale=1">
  8. <!-- head dep. : all css -->
  9. <link href="../bootstrap/dist/css/bootstrap.min.css" rel="stylesheet">
  10. <link href="../bootswatch/paper/bootstrap.min.css" rel="stylesheet">
  11. <link href="../font-awesome/css/font-awesome.min.css" rel="stylesheet">
  12. <link href="../animate.css/animate.min.css" rel="stylesheet">
  13. <!--textAngular css is broken since 1.4.4-->
  14. <!--<link href='../textAngular/dist/textAngular.css' rel='stylesheet'> -->
  15. <!--use own to avoid bad surprise-->
  16. <link href='../easy-form-generator/dist/css/eda.textAngular.min.css' rel='stylesheet'>
  17. <link href='../nya-bootstrap-select/dist/css/nya-bs-select.min.css' rel='stylesheet' >
  18. <link href="../easy-form-generator/dist/css/eda.easyFormViewer.min.css" rel="stylesheet">
  19. <head>
  20. <body ng-controller="demoController as demoCtrl">
  21. <!-- Easy form viewer -->
  22. <eda-easy-form-viewer
  23. eda-easy-form-viewer-data-model="demoCtrl.dataModel"
  24. eda-easy-form-viewer-easy-form-generator-fields-model="demoCtrl.fieldsModel"
  25. eda-easy-form-viewer-submit-button-text="demoCtrl.submitButtonText"
  26. eda-easy-form-viewer-cancel-button-text="demoCtrl.cancelButtonText"
  27. eda-easy-form-viewer-submit-form-event="demoCtrl.submitFormEvent(dataModelSubmitted)"
  28. eda-easy-form-viewer-cancel-form-event="demoCtrl.cancelFormEvent()">
  29. </eda-easy-form-viewer>
  30. <!-- at the end of the body : all js -->
  31. <script type="text/javascript" src="../angular/angular.min.js"></script>
  32. <!-- YOUR APPLICATION WILL REPLACE THIS : -->
  33. <script type="text/javascript">
  34. (function(angular){
  35. 'use strict';
  36. angular
  37. .module('app', ['eda.easyFormViewer'])
  38. .controller('demoController', demoController);
  39. demoController.$inject = ['$timeout'];
  40. function demoController($timeout){
  41. var demoCtrl = this;
  42. demoCtrl.fieldsModel = testACompleteForm();
  43. demoCtrl.dataModel = {};
  44. demoCtrl.submitButtonText = 'Submit this form';
  45. demoCtrl.cancelButtonText = 'Cancel all';
  46. demoCtrl.submitFormEvent = submitFormEvent;
  47. demoCtrl.cancelFormEvent = cancelFormEvent;
  48. function submitFormEvent(dataModelSubmitted){
  49. console.info('Submit event : you can manage this event in your controller');
  50. console.dir( {'dataModelSubmitted' : dataModelSubmitted} );
  51. }
  52. function cancelFormEvent(){
  53. console.info('Cancel event : you can manage this event in your controller');
  54. }
  55. /**
  56. * an easy form generator model as demo
  57. *
  58. * here as a demo, it could be retrieved from a database
  59. */
  60. function testACompleteForm(){
  61. var _testACompleteForm = [
  62. {
  63. "line": 1,
  64. "activeColumn": 1,
  65. "columns": [
  66. {
  67. "numColumn": 1,
  68. "exist": true,
  69. "control": {
  70. "type": "header",
  71. "key": "header-1441426238190",
  72. "selectedControl": "Header",
  73. "subtype": "",
  74. "templateOptions": {
  75. "label": "",
  76. "required": false,
  77. "description": "EasyFormViewer : Loaded Form",
  78. "placeholder": "",
  79. "options": []
  80. },
  81. "formlyExpressionProperties": {},
  82. "formlyValidators": {},
  83. "formlyValidation": {},
  84. "edited": true
  85. }
  86. }
  87. ]
  88. },
  89. {
  90. "line": -1,
  91. "activeColumn": 1,
  92. "columns": [
  93. {
  94. "numColumn": 1,
  95. "exist": true,
  96. "control": {
  97. "type": "input",
  98. "key": "input-1441426278314",
  99. "selectedControl": "TextInput",
  100. "subtype": "",
  101. "templateOptions": {
  102. "label": "text input",
  103. "required": true,
  104. "description": "text input",
  105. "placeholder": "text input",
  106. "options": []
  107. },
  108. "formlyExpressionProperties": {},
  109. "formlyValidators": {},
  110. "formlyValidation": {
  111. "messages": {}
  112. },
  113. "edited": true
  114. }
  115. },
  116. {
  117. "numColumn": 2,
  118. "exist": true,
  119. "control": {
  120. "type": "input",
  121. "key": "input-1441426295927",
  122. "selectedControl": "Password",
  123. "subtype": "password",
  124. "templateOptions": {
  125. "label": "password",
  126. "required": true,
  127. "description": "password",
  128. "placeholder": "password",
  129. "options": []
  130. },
  131. "formlyExpressionProperties": {},
  132. "formlyValidators": {},
  133. "formlyValidation": {
  134. "messages": {}
  135. },
  136. "edited": true
  137. }
  138. },
  139. {
  140. "numColumn": 3,
  141. "exist": true,
  142. "control": {
  143. "type": "input",
  144. "key": "input-1441426313388",
  145. "selectedControl": "Email",
  146. "subtype": "email",
  147. "templateOptions": {
  148. "label": "email",
  149. "required": true,
  150. "description": "email",
  151. "placeholder": "email",
  152. "options": []
  153. },
  154. "formlyExpressionProperties": {},
  155. "formlyValidators": {
  156. "emailShape": {
  157. "message": "$viewValue + ' is not a valid email'"
  158. }
  159. },
  160. "formlyValidation": {
  161. "messages": {}
  162. },
  163. "edited": true
  164. }
  165. }
  166. ]
  167. },
  168. {
  169. "line": -1,
  170. "activeColumn": 1,
  171. "columns": [
  172. {
  173. "numColumn": 1,
  174. "exist": true,
  175. "control": {
  176. "type": "datepicker",
  177. "key": "datepicker-1441426325143",
  178. "selectedControl": "Date",
  179. "subtype": "",
  180. "templateOptions": {
  181. "label": "date",
  182. "required": true,
  183. "description": "date",
  184. "placeholder": "",
  185. "options": [],
  186. "datepickerPopup": "dd-MMMM-yyyy"
  187. },
  188. "formlyExpressionProperties": {},
  189. "formlyValidators": {},
  190. "formlyValidation": {
  191. "messages": {}
  192. },
  193. "edited": true
  194. }
  195. },
  196. {
  197. "numColumn": 2,
  198. "exist": true,
  199. "control": {
  200. "type": "basicSelect",
  201. "key": "basicSelect-1441426346817",
  202. "selectedControl": "BasicSelect",
  203. "subtype": "",
  204. "templateOptions": {
  205. "label": "",
  206. "required": false,
  207. "description": "",
  208. "placeholder": "",
  209. "options": [
  210. {
  211. "name": "opt1",
  212. "value": 0,
  213. "group": ""
  214. },
  215. {
  216. "name": "opt2",
  217. "value": 1,
  218. "group": ""
  219. },
  220. {
  221. "name": "opt3",
  222. "value": 2,
  223. "group": ""
  224. }
  225. ]
  226. },
  227. "formlyExpressionProperties": {},
  228. "formlyValidators": {},
  229. "formlyValidation": {
  230. "messages": {}
  231. },
  232. "edited": true
  233. }
  234. }
  235. ]
  236. },
  237. {
  238. "line": -1,
  239. "activeColumn": 1,
  240. "columns": [
  241. {
  242. "numColumn": 1,
  243. "exist": true,
  244. "control": {
  245. "type": "richEditor",
  246. "key": "richEditor-1441426365355",
  247. "selectedControl": "RichTextEditor",
  248. "subtype": "",
  249. "templateOptions": {
  250. "label": "",
  251. "required": false,
  252. "description": "",
  253. "placeholder": "",
  254. "options": []
  255. },
  256. "formlyExpressionProperties": {},
  257. "formlyValidators": {},
  258. "formlyValidation": {
  259. "messages": {}
  260. },
  261. "edited": true
  262. }
  263. }
  264. ]
  265. }
  266. ]
  267. return _testACompleteForm;
  268. }
  269. }
  270. })(angular);
  271. </script>
  272. <script type="text/javascript" src="../jquery/dist/jquery.min.js"></script>
  273. <script type="text/javascript" src="../bootstrap/dist/js/bootstrap.min.js"></script>
  274. <script type="text/javascript" src="../angular-bootstrap/ui-bootstrap-tpls.min.js"></script>
  275. <script type="text/javascript" src="../easy-form-generator/dist/js/eda.easyFormViewer.min.js"></script>
  276. <script type="text/javascript" src='../textAngular/dist/textAngular-rangy.min.js'></script>
  277. <script type="text/javascript" src='../textAngular/dist/textAngular-sanitize.min.js'></script>
  278. <script type="text/javascript" src='../textAngular/dist/textAngular.min.js'></script>
  279. <script type="text/javascript" src='../lodash/lodash.min.js'></script>
  280. <script type="text/javascript" src="../angular-animate/angular-animate.min.js"></script>
  281. <script type="text/javascript" src="../angularjs-toaster/toaster.min.js"></script>
  282. <script type="text/javascript" src="../nya-bootstrap-select/dist/js/nya-bs-select.min.js"></script>
  283. <script type="text/javascript" src="../api-check/dist/api-check.min.js"></script>
  284. <script type="text/javascript" src="../angular-formly/dist/formly.min.js"></script>
  285. <script type="text/javascript" src="../angular-formly-templates-bootstrap/dist/angular-formly-templates-bootstrap.min.js"></script>
  286. </body>
  287. </html>