fe 1.0.0 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (402) hide show
  1. checksums.yaml +5 -5
  2. data/README.md +4 -4
  3. data/app/assets/config/fe/manifest.js +3 -0
  4. data/app/assets/config/manifest.js +3 -0
  5. data/app/assets/javascripts/application.js.erb +1 -1
  6. data/app/assets/javascripts/fe/admin.js +0 -1
  7. data/app/assets/javascripts/fe/fe.admin.js +2 -6
  8. data/app/assets/javascripts/fe/{fe.common.js → fe.common.js.erb} +14 -7
  9. data/app/assets/javascripts/fe/fe.public.js +1 -2
  10. data/app/assets/javascripts/fe/{fe.public.nojquery.js → fe.public.nojquery.js.erb} +152 -76
  11. data/app/assets/javascripts/fe/jquery.html5_upload.js +258 -0
  12. data/app/assets/stylesheets/fe/fe.screen.css.scss.erb +22 -1
  13. data/app/assets/stylesheets/fe/validation.css +5 -1
  14. data/app/controllers/{fe/concerns → concerns/fe}/admin/question_sheets_controller_concern.rb +15 -16
  15. data/app/controllers/concerns/fe/answer_pages_controller_concern.rb +131 -0
  16. data/app/controllers/{fe/concerns → concerns/fe}/answer_sheets_controller_concern.rb +14 -6
  17. data/app/controllers/{fe/concerns → concerns/fe}/application_controller_concern.rb +3 -3
  18. data/app/controllers/fe/admin/elements_controller.rb +46 -24
  19. data/app/controllers/fe/admin/email_templates_controller.rb +5 -5
  20. data/app/controllers/fe/admin/question_pages_controller.rb +8 -8
  21. data/app/controllers/fe/reference_pages_controller.rb +11 -11
  22. data/app/controllers/fe/reference_sheets_controller.rb +4 -4
  23. data/app/controllers/fe/references_controller.rb +19 -19
  24. data/app/controllers/fe/submit_pages_controller.rb +5 -5
  25. data/app/helpers/fe/answer_pages_helper.rb +1 -1
  26. data/app/helpers/fe/application_helper.rb +3 -3
  27. data/app/jobs/fe/update_reference_sheet_visibility_job.rb +11 -0
  28. data/app/mailers/fe/notifier.rb +4 -4
  29. data/app/models/answer_sheet.rb +1 -1
  30. data/app/models/application_record.rb +3 -0
  31. data/app/models/{fe/concerns → concerns/fe}/answer_concern.rb +2 -2
  32. data/app/models/{fe/concerns → concerns/fe}/answer_pages_presenter_concern.rb +6 -5
  33. data/app/models/concerns/fe/answer_sheet_concern.rb +125 -0
  34. data/app/models/{fe/concerns → concerns/fe}/choice_field_concern.rb +41 -23
  35. data/app/models/fe/address.rb +2 -2
  36. data/app/models/fe/answer.rb +1 -1
  37. data/app/models/fe/answer_sheet.rb +1 -1
  38. data/app/models/fe/answer_sheet_question_sheet.rb +2 -2
  39. data/app/models/fe/application.rb +14 -10
  40. data/app/models/fe/condition.rb +4 -4
  41. data/app/models/fe/date_field.rb +1 -1
  42. data/app/models/fe/element.rb +126 -44
  43. data/app/models/fe/email_address.rb +2 -2
  44. data/app/models/fe/email_template.rb +1 -1
  45. data/app/models/fe/page.rb +94 -19
  46. data/app/models/fe/page_element.rb +2 -2
  47. data/app/models/fe/paragraph.rb +1 -1
  48. data/app/models/fe/person.rb +5 -5
  49. data/app/models/fe/phone_number.rb +1 -1
  50. data/app/models/fe/question.rb +62 -38
  51. data/app/models/fe/question_grid.rb +15 -3
  52. data/app/models/fe/question_set.rb +53 -13
  53. data/app/models/fe/question_sheet.rb +49 -16
  54. data/app/models/fe/reference_question.rb +9 -3
  55. data/app/models/fe/reference_sheet.rb +102 -47
  56. data/app/models/fe/state_chooser.rb +2 -2
  57. data/app/models/fe/text_field.rb +2 -2
  58. data/app/models/fe/user.rb +1 -1
  59. data/app/models/staff.rb +6 -6
  60. data/app/views/fe/admin/elements/create.js.erb +3 -3
  61. data/app/views/fe/admin/elements/destroy.js.erb +1 -1
  62. data/app/views/fe/admin/elements/drop.js.erb +1 -1
  63. data/app/views/fe/admin/elements/duplicate.js.erb +1 -1
  64. data/app/views/fe/admin/elements/edit.js.erb +1 -1
  65. data/app/views/fe/admin/elements/error.js.erb +1 -1
  66. data/app/views/fe/admin/elements/new.js.erb +13 -6
  67. data/app/views/fe/admin/elements/update.js.erb +1 -1
  68. data/app/views/fe/admin/email_templates/_form.html.erb +3 -3
  69. data/app/views/fe/admin/email_templates/edit.html.erb +3 -3
  70. data/app/views/fe/admin/email_templates/index.html.erb +3 -3
  71. data/app/views/fe/admin/email_templates/new.html.erb +3 -3
  72. data/app/views/fe/admin/panels/_advanced_options.html.erb +8 -8
  73. data/app/views/fe/admin/panels/_common_boolean_fields.html.erb +1 -0
  74. data/app/views/fe/admin/panels/_common_boolean_fields_default.html.erb +11 -0
  75. data/app/views/fe/admin/panels/_common_fields.html.erb +2 -17
  76. data/app/views/fe/admin/panels/_condition.html.erb +1 -1
  77. data/app/views/fe/admin/panels/_insert.html.erb +25 -25
  78. data/app/views/fe/admin/panels/_nav_controls.html.erb +4 -4
  79. data/app/views/fe/admin/panels/_page.html.erb +1 -1
  80. data/app/views/fe/admin/panels/_pages_list.html.erb +3 -3
  81. data/app/views/fe/admin/panels/_prop_attachment_field.html.erb +2 -2
  82. data/app/views/fe/admin/panels/_prop_choice_field.html.erb +36 -17
  83. data/app/views/fe/admin/panels/_prop_date_field.html.erb +1 -1
  84. data/app/views/fe/admin/panels/_prop_element.html.erb +5 -5
  85. data/app/views/fe/admin/panels/_prop_page.html.erb +3 -3
  86. data/app/views/fe/admin/panels/_prop_paragraph.html.erb +8 -8
  87. data/app/views/fe/admin/panels/_prop_question_grid.html.erb +7 -2
  88. data/app/views/fe/admin/panels/_prop_question_grid_with_total.html.erb +2 -2
  89. data/app/views/fe/admin/panels/_prop_reference_question.html.erb +3 -3
  90. data/app/views/fe/admin/panels/_prop_section.html.erb +1 -1
  91. data/app/views/fe/admin/panels/_prop_sheet.html.erb +3 -3
  92. data/app/views/fe/admin/panels/_prop_text_field.html.erb +12 -12
  93. data/app/views/fe/admin/question_pages/_element.html.erb +7 -7
  94. data/app/views/fe/admin/question_pages/_element_show.html.erb +2 -2
  95. data/app/views/fe/admin/question_pages/_question_page.html.erb +4 -4
  96. data/app/views/fe/admin/question_pages/create.js.erb +3 -3
  97. data/app/views/fe/admin/question_pages/destroy.js.erb +3 -3
  98. data/app/views/fe/admin/question_pages/edit.js.erb +1 -1
  99. data/app/views/fe/admin/question_pages/error.js.erb +1 -1
  100. data/app/views/fe/admin/question_pages/show.js.erb +2 -2
  101. data/app/views/fe/admin/question_pages/show_panel.js.erb +1 -1
  102. data/app/views/fe/admin/question_pages/update.js.erb +1 -1
  103. data/app/views/fe/admin/question_sheets/edit.js.erb +1 -1
  104. data/app/views/fe/admin/question_sheets/error.js.erb +1 -1
  105. data/app/views/fe/admin/question_sheets/index.html.erb +8 -8
  106. data/app/views/fe/admin/question_sheets/new.html.erb +3 -3
  107. data/app/views/fe/admin/question_sheets/show.html.erb +5 -5
  108. data/app/views/fe/admin/question_sheets/update.js.erb +1 -1
  109. data/app/views/fe/answer_pages/_answer_page.html.erb +13 -14
  110. data/app/views/fe/answer_pages/_element.html.erb +22 -2
  111. data/app/views/fe/answer_pages/_page_name.html.erb +1 -1
  112. data/app/views/fe/answer_pages/show.html.erb +39 -0
  113. data/app/views/fe/answer_pages/update.js.erb +10 -2
  114. data/app/views/fe/answer_sheets/_answer_sheet.html.erb +4 -4
  115. data/app/views/fe/answer_sheets/_element.html.erb +9 -7
  116. data/app/views/fe/answer_sheets/_incomplete.html.erb +1 -1
  117. data/app/views/fe/answer_sheets/_page_link.html.erb +9 -7
  118. data/app/views/fe/answer_sheets/_pages_list.html.erb +3 -3
  119. data/app/views/fe/answer_sheets/_submit_to.html.erb +1 -1
  120. data/app/views/fe/answer_sheets/_title.html.erb +1 -1
  121. data/app/views/fe/answer_sheets/edit.html.erb +18 -18
  122. data/app/views/fe/answer_sheets/incomplete.js.erb +7 -4
  123. data/app/views/fe/answer_sheets/index.html.erb +1 -1
  124. data/app/views/fe/answer_sheets/show.html.erb +1 -1
  125. data/app/views/fe/applications/_logout.html.erb +1 -1
  126. data/app/views/fe/questions/fe/_acceptance.html.erb +10 -9
  127. data/app/views/fe/questions/fe/_attachment_field.html.erb +129 -10
  128. data/app/views/fe/questions/fe/_checkbox_field.html.erb +18 -16
  129. data/app/views/fe/questions/fe/_country.html.erb +6 -6
  130. data/app/views/fe/questions/fe/_date_field.html.erb +5 -4
  131. data/app/views/fe/questions/fe/_date_field_mmyy.html.erb +8 -8
  132. data/app/views/fe/questions/fe/_drop_down_field.html.erb +5 -5
  133. data/app/views/fe/questions/fe/_question_grid.html.erb +10 -10
  134. data/app/views/fe/questions/fe/_question_grid_with_total.html.erb +8 -8
  135. data/app/views/fe/questions/fe/_questions.html.erb +11 -5
  136. data/app/views/fe/questions/fe/_radio_button_field.html.erb +35 -19
  137. data/app/views/fe/questions/fe/_rating.html.erb +56 -18
  138. data/app/views/fe/questions/fe/_reference_discipler.html.erb +1 -1
  139. data/app/views/fe/questions/fe/_reference_friend.html.erb +1 -1
  140. data/app/views/fe/questions/fe/_reference_parent.html.erb +1 -1
  141. data/app/views/fe/questions/fe/_reference_peer.html.erb +1 -1
  142. data/app/views/fe/questions/fe/_reference_question.html.erb +40 -24
  143. data/app/views/fe/questions/fe/_reference_roommate.html.erb +1 -1
  144. data/app/views/fe/questions/fe/_reference_spiritual.html.erb +1 -1
  145. data/app/views/fe/questions/fe/_reference_staff.html.erb +1 -1
  146. data/app/views/fe/questions/fe/_state_chooser.html.erb +6 -6
  147. data/app/views/fe/questions/fe/_text_area_field.html.erb +14 -10
  148. data/app/views/fe/questions/fe/_text_field.html.erb +7 -6
  149. data/app/views/fe/questions/fe/_yes_no.html.erb +8 -8
  150. data/app/views/fe/questions/fe/_yes_no_field.erb +11 -8
  151. data/app/views/fe/reference_pages/_reference.html.erb +12 -12
  152. data/app/views/fe/reference_pages/edit.html.erb +4 -4
  153. data/app/views/fe/reference_sheets/done.html.erb +2 -2
  154. data/app/views/fe/reference_sheets/not_found.html.erb +3 -3
  155. data/app/views/fe/references/edit.html.erb +5 -5
  156. data/app/views/fe/references/show.html.erb +3 -3
  157. data/app/views/fe/references/submit.js.erb +3 -3
  158. data/app/views/fe/submit_pages/_thankyou.html.erb +1 -1
  159. data/app/views/fe/submit_pages/edit.html.erb +9 -9
  160. data/app/views/fe/submit_pages/error.js.erb +1 -1
  161. data/app/views/fe/submit_pages/submit.js.erb +2 -2
  162. data/app/views/layouts/fe/_error_messages_for.html.erb +1 -1
  163. data/app/views/layouts/fe/application.html.erb +3 -4
  164. data/app/views/layouts/fe/fe_admin.html.erb +30 -0
  165. data/app/views.current/fe/admin/elements/_errors.html.erb +11 -0
  166. data/app/views.current/fe/admin/elements/create.js.erb +12 -0
  167. data/app/views.current/fe/admin/elements/destroy.js.erb +4 -0
  168. data/app/views.current/fe/admin/elements/drop.js.erb +3 -0
  169. data/app/views.current/fe/admin/elements/duplicate.js.erb +3 -0
  170. data/app/views.current/fe/admin/elements/edit.js.erb +4 -0
  171. data/app/views.current/fe/admin/elements/error.js.erb +4 -0
  172. data/app/views.current/fe/admin/elements/new.js.erb +17 -0
  173. data/app/views.current/fe/admin/elements/update.js.erb +9 -0
  174. data/app/views.current/fe/admin/email_templates/_form.html.erb +8 -0
  175. data/app/views.current/fe/admin/email_templates/edit.html.erb +13 -0
  176. data/app/views.current/fe/admin/email_templates/index.html.erb +20 -0
  177. data/app/views.current/fe/admin/email_templates/new.html.erb +11 -0
  178. data/app/views.current/fe/admin/panels/_advanced_options.html.erb +49 -0
  179. data/app/views.current/fe/admin/panels/_common_boolean_fields.html.erb +1 -0
  180. data/app/views.current/fe/admin/panels/_common_boolean_fields_default.html.erb +11 -0
  181. data/app/views.current/fe/admin/panels/_common_fields.html.erb +23 -0
  182. data/app/views.current/fe/admin/panels/_condition.html.erb +6 -0
  183. data/app/views.current/fe/admin/panels/_insert.html.erb +39 -0
  184. data/app/views.current/fe/admin/panels/_nav_controls.html.erb +6 -0
  185. data/app/views.current/fe/admin/panels/_page.html.erb +3 -0
  186. data/app/views.current/fe/admin/panels/_pages_list.html.erb +16 -0
  187. data/app/views.current/fe/admin/panels/_prop_attachment_field.html.erb +2 -0
  188. data/app/views.current/fe/admin/panels/_prop_choice_field.html.erb +74 -0
  189. data/app/views.current/fe/admin/panels/_prop_date_field.html.erb +7 -0
  190. data/app/views.current/fe/admin/panels/_prop_element.html.erb +23 -0
  191. data/app/views.current/fe/admin/panels/_prop_page.html.erb +26 -0
  192. data/app/views.current/fe/admin/panels/_prop_paragraph.html.erb +46 -0
  193. data/app/views.current/fe/admin/panels/_prop_question_grid.html.erb +28 -0
  194. data/app/views.current/fe/admin/panels/_prop_question_grid_with_total.html.erb +14 -0
  195. data/app/views.current/fe/admin/panels/_prop_reference_question.html.erb +12 -0
  196. data/app/views.current/fe/admin/panels/_prop_section.html.erb +8 -0
  197. data/app/views.current/fe/admin/panels/_prop_sheet.html.erb +20 -0
  198. data/app/views.current/fe/admin/panels/_prop_text_field.html.erb +20 -0
  199. data/app/views.current/fe/admin/question_pages/_element.html.erb +28 -0
  200. data/app/views.current/fe/admin/question_pages/_element_show.html.erb +10 -0
  201. data/app/views.current/fe/admin/question_pages/_errors.html.erb +10 -0
  202. data/app/views.current/fe/admin/question_pages/_question_page.html.erb +13 -0
  203. data/app/views.current/fe/admin/question_pages/create.js.erb +11 -0
  204. data/app/views.current/fe/admin/question_pages/destroy.js.erb +5 -0
  205. data/app/views.current/fe/admin/question_pages/edit.js.erb +3 -0
  206. data/app/views.current/fe/admin/question_pages/error.js.erb +4 -0
  207. data/app/views.current/fe/admin/question_pages/show.js.erb +9 -0
  208. data/app/views.current/fe/admin/question_pages/show_panel.js.erb +3 -0
  209. data/app/views.current/fe/admin/question_pages/update.js.erb +2 -0
  210. data/app/views.current/fe/admin/question_sheets/_errors.html.erb +11 -0
  211. data/app/views.current/fe/admin/question_sheets/edit.js.erb +3 -0
  212. data/app/views.current/fe/admin/question_sheets/error.js.erb +5 -0
  213. data/app/views.current/fe/admin/question_sheets/index.html.erb +41 -0
  214. data/app/views.current/fe/admin/question_sheets/new.html.erb +15 -0
  215. data/app/views.current/fe/admin/question_sheets/show.html.erb +27 -0
  216. data/app/views.current/fe/admin/question_sheets/update.js.erb +2 -0
  217. data/app/views.current/fe/answer_pages/_answer_page.html.erb +53 -0
  218. data/app/views.current/fe/answer_pages/_element.html.erb +32 -0
  219. data/app/views.current/fe/answer_pages/_page_name.html.erb +1 -0
  220. data/app/views.current/fe/answer_pages/show.html.erb +39 -0
  221. data/app/views.current/fe/answer_pages/update.js.erb +13 -0
  222. data/app/views.current/fe/answer_sheets/_answer_sheet.html.erb +26 -0
  223. data/app/views.current/fe/answer_sheets/_element.html.erb +74 -0
  224. data/app/views.current/fe/answer_sheets/_incomplete.html.erb +10 -0
  225. data/app/views.current/fe/answer_sheets/_page_link.html.erb +9 -0
  226. data/app/views.current/fe/answer_sheets/_pages_list.html.erb +11 -0
  227. data/app/views.current/fe/answer_sheets/_submit_to.html.erb +1 -0
  228. data/app/views.current/fe/answer_sheets/_title.html.erb +1 -0
  229. data/app/views.current/fe/answer_sheets/edit.html.erb +66 -0
  230. data/app/views.current/fe/answer_sheets/incomplete.js.erb +11 -0
  231. data/app/views.current/fe/answer_sheets/index.html.erb +18 -0
  232. data/app/views.current/fe/answer_sheets/send_reference_invite.js.erb +8 -0
  233. data/app/views.current/fe/answer_sheets/show.html.erb +13 -0
  234. data/app/views.current/fe/applications/_logout.html.erb +1 -0
  235. data/app/views.current/fe/applications/show.html.erb +1 -0
  236. data/app/views.current/fe/help/builder.html +33 -0
  237. data/app/views.current/fe/help/question_grid.html +18 -0
  238. data/app/views.current/fe/questions/fe/_acceptance.html.erb +14 -0
  239. data/app/views.current/fe/questions/fe/_attachment_field.html.erb +165 -0
  240. data/app/views.current/fe/questions/fe/_checkbox_field.html.erb +53 -0
  241. data/app/views.current/fe/questions/fe/_country.html.erb +7 -0
  242. data/app/views.current/fe/questions/fe/_date_field.html.erb +7 -0
  243. data/app/views.current/fe/questions/fe/_date_field_mmyy.html.erb +9 -0
  244. data/app/views.current/fe/questions/fe/_drop_down_field.html.erb +8 -0
  245. data/app/views.current/fe/questions/fe/_paragraph.html.erb +1 -0
  246. data/app/views.current/fe/questions/fe/_question_grid.html.erb +70 -0
  247. data/app/views.current/fe/questions/fe/_question_grid_with_total.html.erb +64 -0
  248. data/app/views.current/fe/questions/fe/_questions.html.erb +15 -0
  249. data/app/views.current/fe/questions/fe/_radio_button_field.html.erb +60 -0
  250. data/app/views.current/fe/questions/fe/_rating.html.erb +64 -0
  251. data/app/views.current/fe/questions/fe/_reference_discipler.html.erb +1 -0
  252. data/app/views.current/fe/questions/fe/_reference_friend.html.erb +1 -0
  253. data/app/views.current/fe/questions/fe/_reference_parent.html.erb +1 -0
  254. data/app/views.current/fe/questions/fe/_reference_peer.html.erb +1 -0
  255. data/app/views.current/fe/questions/fe/_reference_question.html.erb +61 -0
  256. data/app/views.current/fe/questions/fe/_reference_roommate.html.erb +1 -0
  257. data/app/views.current/fe/questions/fe/_reference_spiritual.html.erb +1 -0
  258. data/app/views.current/fe/questions/fe/_reference_staff.html.erb +1 -0
  259. data/app/views.current/fe/questions/fe/_section.html.erb +1 -0
  260. data/app/views.current/fe/questions/fe/_state_chooser.html.erb +7 -0
  261. data/app/views.current/fe/questions/fe/_text_area_field.html.erb +17 -0
  262. data/app/views.current/fe/questions/fe/_text_field.html.erb +9 -0
  263. data/app/views.current/fe/questions/fe/_yes_no.html.erb +17 -0
  264. data/app/views.current/fe/questions/fe/_yes_no_field.erb +20 -0
  265. data/app/views.current/fe/reference_pages/_reference.html.erb +31 -0
  266. data/app/views.current/fe/reference_pages/edit.html.erb +24 -0
  267. data/app/views.current/fe/reference_sheets/done.html.erb +2 -0
  268. data/app/views.current/fe/reference_sheets/not_found.html.erb +5 -0
  269. data/app/views.current/fe/reference_sheets/submitted.js.erb +1 -0
  270. data/app/views.current/fe/references/edit.html.erb +8 -0
  271. data/app/views.current/fe/references/send_invite.js.erb +7 -0
  272. data/app/views.current/fe/references/show.html.erb +18 -0
  273. data/app/views.current/fe/references/submit.js.erb +3 -0
  274. data/app/views.current/fe/submit_pages/_errors.html.erb +1 -0
  275. data/app/views.current/fe/submit_pages/_thankyou.html.erb +2 -0
  276. data/app/views.current/fe/submit_pages/edit.html.erb +36 -0
  277. data/app/views.current/fe/submit_pages/error.js.erb +1 -0
  278. data/app/views.current/fe/submit_pages/submit.js.erb +3 -0
  279. data/app/views.current/layouts/fe/_error_messages_for.html.erb +7 -0
  280. data/app/views.current/layouts/fe/application.html.erb +47 -0
  281. data/app/{views/layouts/fe/fe.admin.html.erb → views.current/layouts/fe/fe_admin.html.erb} +4 -4
  282. data/config/initializers/paper_trail.rb +3 -0
  283. data/config/routes.rb +3 -1
  284. data/db/migrate/20131003041856_core.rb +23 -23
  285. data/db/migrate/20131003044250_create_reference_sheets.rb +1 -1
  286. data/db/migrate/20131003044436_add_element_and_answer_fields.rb +3 -3
  287. data/db/migrate/20131003044518_create_email_templates.rb +2 -2
  288. data/db/migrate/20131003044621_add_max_lengths.rb +1 -1
  289. data/db/migrate/20131003044714_create_join_table.rb +1 -1
  290. data/db/migrate/20131016162128_remove_question_id_from_element.rb +1 -1
  291. data/db/migrate/20140623153424_create_fe_people.rb +1 -1
  292. data/db/migrate/20140624180246_create_fe_addresses.rb +1 -1
  293. data/db/migrate/20140624182216_create_fe_phone_numbers.rb +1 -1
  294. data/db/migrate/20140625160545_create_fe_users.rb +1 -1
  295. data/db/migrate/20140808202507_add_conditional_type_to_elements.rb +1 -1
  296. data/db/migrate/20140808203609_add_conditional_answer_to_elements.rb +1 -1
  297. data/db/migrate/20141103204704_remove_short_value_column.rb +1 -1
  298. data/db/migrate/20141109154522_move_conditional_ids_used_for_choice_field_to_their_own_column.rb +1 -1
  299. data/db/migrate/20150504221439_add_all_element_ids_to_pages.rb +1 -1
  300. data/db/migrate/20150713022326_add_locale_columns.rb +1 -1
  301. data/db/migrate/20150714220730_add_locale_to_answer_sheet.rb +1 -1
  302. data/db/migrate/20150925181652_add_share_to_elements.rb +5 -0
  303. data/db/migrate/20150928085325_change_pages_all_element_ids_to_text.rb +1 -1
  304. data/db/migrate/20150930191538_add_locale_to_reference_sheets.rb +1 -1
  305. data/db/migrate/20151021181928_switch_conditional_answer_separator_to_semicolon.rb +7 -0
  306. data/db/migrate/20151021184250_add_question_sheet_id_in_refs.rb +12 -0
  307. data/db/migrate/20160201185838_add_visible_and_visibility_cache_key_to_reference_sheets.rb +6 -0
  308. data/db/migrate/20160805221415_add_rating_extra_labels.rb +10 -0
  309. data/db/migrate/20181108201746_create_versions.rb +80 -0
  310. data/db/migrate/20181218201130_increase_slug_length.rb +5 -0
  311. data/lib/fe/engine.rb +10 -10
  312. data/lib/fe/version.rb +1 -1
  313. data/lib/fe.rb +7 -1
  314. data/spec/controllers/fe/admin/elements_controller_spec.rb +30 -20
  315. data/spec/controllers/fe/admin/email_templates_controller_spec.rb +2 -2
  316. data/spec/controllers/fe/admin/question_pages_controller_spec.rb +1 -1
  317. data/spec/controllers/fe/admin/question_sheets_controller_spec.rb +4 -4
  318. data/spec/controllers/fe/answer_pages_controller_spec.rb +86 -30
  319. data/spec/controllers/fe/answer_sheets_controller_spec.rb +65 -9
  320. data/spec/dummy/app/assets/config/manifest.js +0 -0
  321. data/spec/dummy/app/models/user.rb +1 -1
  322. data/spec/dummy/app/views/layouts/application.html.erb +2 -2
  323. data/spec/dummy/config/application.rb +1 -0
  324. data/spec/dummy/config/environments/test.rb +3 -3
  325. data/spec/dummy/config/initializers/assets.rb +5 -2
  326. data/spec/dummy/config/initializers/fast_gettext.rb +1 -1
  327. data/spec/dummy/config/initializers/to_unsafe_h.rb +5 -0
  328. data/spec/dummy/config/initializers/to_unsafe_h.rb.new +5 -0
  329. data/spec/dummy/db/migrate/20141203214017_core.fe_engine.rb +23 -23
  330. data/spec/dummy/db/migrate/20141203214018_create_reference_sheets.fe_engine.rb +1 -1
  331. data/spec/dummy/db/migrate/20141203214019_add_element_and_answer_fields.fe_engine.rb +3 -3
  332. data/spec/dummy/db/migrate/20141203214020_create_email_templates.fe_engine.rb +2 -2
  333. data/spec/dummy/db/migrate/20141203214021_add_max_lengths.fe_engine.rb +1 -1
  334. data/spec/dummy/db/migrate/20141203214022_create_join_table.fe_engine.rb +1 -1
  335. data/spec/dummy/db/migrate/20141203214023_remove_question_id_from_element.fe_engine.rb +1 -1
  336. data/spec/dummy/db/migrate/20141203214024_create_fe_people.fe_engine.rb +1 -1
  337. data/spec/dummy/db/migrate/20141203214025_create_fe_addresses.fe_engine.rb +1 -1
  338. data/spec/dummy/db/migrate/20141203214027_create_fe_users.fe_engine.rb +1 -1
  339. data/spec/dummy/db/migrate/20141203214028_add_conditional_type_to_elements.fe_engine.rb +1 -1
  340. data/spec/dummy/db/migrate/20141203214029_add_conditional_answer_to_elements.fe_engine.rb +1 -1
  341. data/spec/dummy/db/migrate/20141203214030_remove_short_value_column.fe_engine.rb +1 -1
  342. data/spec/dummy/db/migrate/20141203214031_move_conditional_ids_used_for_choice_field_to_their_own_column.fe_engine.rb +1 -1
  343. data/spec/dummy/db/migrate/20150123215803_create_users.rb +1 -1
  344. data/spec/dummy/db/migrate/20150504222619_add_all_element_ids_to_pages.fe_engine.rb +1 -1
  345. data/spec/dummy/db/migrate/20150925192557_add_share_to_elements.fe_engine.rb +6 -0
  346. data/spec/dummy/db/migrate/20150930190001_create_fe_phone_numbers.fe_engine.rb +1 -1
  347. data/spec/dummy/db/migrate/20150930190002_add_locale_columns.fe_engine.rb +1 -1
  348. data/spec/dummy/db/migrate/20150930190003_add_locale_to_answer_sheet.fe_engine.rb +1 -1
  349. data/spec/dummy/db/migrate/20150930190004_change_pages_all_element_ids_to_text.fe_engine.rb +1 -1
  350. data/spec/dummy/db/migrate/20150930191756_add_locale_to_reference_sheets.fe_engine.rb +1 -1
  351. data/spec/dummy/db/migrate/20151021190027_add_question_sheet_id_in_refs.fe_engine.rb +13 -0
  352. data/spec/dummy/db/migrate/20160204164612_switch_conditional_answer_separator_to_semicolon.fe_engine.rb +8 -0
  353. data/spec/dummy/db/migrate/20160204164613_add_visible_and_visibility_cache_key_to_reference_sheets.fe_engine.rb +7 -0
  354. data/spec/dummy/db/migrate/20181108201746_create_versions.rb +80 -0
  355. data/spec/dummy/db/schema.rb +71 -79
  356. data/spec/dummy/log/test.log +101278 -419
  357. data/spec/factories/answer_sheet_question_sheets.rb +1 -1
  358. data/spec/factories/answer_sheets.rb +2 -2
  359. data/spec/factories/answers.rb +1 -1
  360. data/spec/factories/applications.rb +3 -3
  361. data/spec/factories/dummy_applications.rb +3 -3
  362. data/spec/factories/dummy_people.rb +3 -3
  363. data/spec/factories/dummy_users.rb +3 -3
  364. data/spec/factories/elements.rb +21 -21
  365. data/spec/factories/email_templates.rb +3 -3
  366. data/spec/factories/fe_addresses.rb +10 -10
  367. data/spec/factories/fe_email_addresses.rb +3 -3
  368. data/spec/factories/fe_email_templates.rb +4 -4
  369. data/spec/factories/fe_people.rb +5 -5
  370. data/spec/factories/fe_phone_numbers.rb +3 -3
  371. data/spec/factories/fe_user.rb +3 -3
  372. data/spec/factories/page.rb +1 -1
  373. data/spec/factories/page_elements.rb +1 -1
  374. data/spec/factories/paragraphs.rb +1 -1
  375. data/spec/factories/question_sheet.rb +2 -2
  376. data/spec/factories/reference_questions.rb +1 -1
  377. data/spec/factories/reference_sheets.rb +1 -1
  378. data/spec/jobs/fe/update_reference_sheet_visibility_job_spec.rb +40 -0
  379. data/spec/models/fe/answer_sheet_question_sheet_spec.rb +1 -1
  380. data/spec/models/fe/answer_spec.rb +2 -2
  381. data/spec/models/fe/application_spec.rb +94 -1
  382. data/spec/models/fe/choice_field_spec.rb +47 -1
  383. data/spec/models/fe/condition_spec.rb +2 -2
  384. data/spec/models/fe/element_spec.rb +252 -60
  385. data/spec/models/fe/email_template_spec.rb +1 -1
  386. data/spec/models/fe/page_element_spec.rb +1 -1
  387. data/spec/models/fe/page_spec.rb +57 -12
  388. data/spec/models/fe/person_spec.rb +1 -1
  389. data/spec/models/fe/question_set_spec.rb +91 -0
  390. data/spec/models/fe/question_sheet_spec.rb +11 -15
  391. data/spec/models/fe/question_spec.rb +73 -6
  392. data/spec/models/fe/reference_question_spec.rb +20 -0
  393. data/spec/models/fe/reference_sheet_spec.rb +287 -4
  394. data/spec/models/fe/text_field_spec.rb +22 -0
  395. data/spec/rails_helper.rb +79 -76
  396. metadata +195 -57
  397. data/app/assets/javascripts/fe/jquery.scrollTo-min.js +0 -7
  398. data/app/controllers/fe/concerns/answer_pages_controller_concern.rb +0 -84
  399. data/app/models/fe/concerns/answer_sheet_concern.rb +0 -85
  400. data/spec/dummy/db/migrate/20141203214026_create_create_fe_phone_numbers.fe_engine.rb +0 -17
  401. data/spec/dummy/log/development.log +0 -5
  402. /data/app/{assets/stylesheets/360front.css → views.current/fe/admin/elements/reorder.js.erb} +0 -0
@@ -0,0 +1,258 @@
1
+ /* Taken from https://github.com/mihaild/jquery-html5-upload */
2
+
3
+ (function($) {
4
+ $.fn.html5_upload = function(options) {
5
+
6
+ function get_file_name(file) {
7
+ return file.name || file.fileName;
8
+ }
9
+ function get_file_size(file) {
10
+ return file.size || file.fileSize;
11
+ }
12
+ var available_events = ['onStart', 'onStartOne', 'onProgress', 'onFinishOne', 'onFinish', 'onError'];
13
+ var options = $.extend({
14
+ onStart: function(event, total) {
15
+ return true;
16
+ },
17
+ onStartOne: function(event, name, number, total) {
18
+ return true;
19
+ },
20
+ onProgress: function(event, progress, name, number, total) {
21
+ },
22
+ onFinishOne: function(event, response, name, number, total) {
23
+ },
24
+ onFinish: function(event, total) {
25
+ },
26
+ onError: function(event, name, error) {
27
+ },
28
+ onBrowserIncompatible: function() {
29
+ alert("Sorry, but your browser is incompatible with uploading files using HTML5 (at least, with current preferences.\n Please install the latest version of Firefox, Safari or Chrome");
30
+ },
31
+ autostart: true,
32
+ autoclear: true,
33
+ stopOnFirstError: false,
34
+ sendBoundary: false,
35
+ fieldName: 'user_file[]',//ignore if sendBoundary is false
36
+ extraFields: {}, // extra fields to send with file upload request (HTML5 only)
37
+ method: 'post',
38
+
39
+ STATUSES: {
40
+ 'STARTED' : 'Started',
41
+ 'PROGRESS' : 'Progress',
42
+ 'LOADED' : 'Loaded',
43
+ 'FINISHED' : 'Finished'
44
+ },
45
+ headers: {
46
+ "Cache-Control":"no-cache",
47
+ "X-Requested-With":"XMLHttpRequest",
48
+ "X-File-Name": function(file){return encodeURIComponent(get_file_name(file))},
49
+ "X-File-Size": function(file){return get_file_size(file)},
50
+ "X-CSRF-Token": $('meta[name="csrf-token"]').attr("content"),
51
+ "Content-Type": function(file){
52
+ if (!options.sendBoundary) return 'multipart/form-data';
53
+ return false;
54
+ }
55
+ },
56
+
57
+
58
+ setName: function(text) {},
59
+ setStatus: function(text) {},
60
+ setProgress: function(value) {},
61
+
62
+ genName: function(file, number, total) {
63
+ return file + "(" + (number+1) + " of " + total + ")";
64
+ },
65
+ genStatus: function(progress, finished) {
66
+ if (finished) {
67
+ return options.STATUSES['FINISHED'];
68
+ }
69
+ if (progress == 0) {
70
+ return options.STATUSES['STARTED'];
71
+ }
72
+ else if (progress == 1) {
73
+ return options.STATUSES['LOADED'];
74
+ }
75
+ else {
76
+ return options.STATUSES['PROGRESS'];
77
+ }
78
+ },
79
+ genProgress: function(loaded, total) {
80
+ return loaded / total;
81
+ }
82
+ }, options);
83
+
84
+ function upload( files ) {
85
+ var total = files.length;
86
+ var $this = $(this);
87
+ if (!$this.triggerHandler('html5_upload.onStart', [total])) {
88
+ return false;
89
+ }
90
+ this.disabled = true;
91
+ var uploaded = 0;
92
+ var xhr = this.html5_upload['xhr'];
93
+ this.html5_upload['continue_after_abort'] = true;
94
+ function upload_file(number) {
95
+ if (number == total) {
96
+ $this.triggerHandler('html5_upload.onFinish', [total]);
97
+ options.setStatus(options.genStatus(1, true));
98
+ $this.attr("disabled", false);
99
+ if (options.autoclear) {
100
+ $this.val("");
101
+ }
102
+ return;
103
+ }
104
+ var file = files[number];
105
+ if (!$this.triggerHandler('html5_upload.onStartOne', [get_file_name(file), number, total])) {
106
+ return upload_file(number+1);
107
+ }
108
+ options.setStatus(options.genStatus(0));
109
+ options.setName(options.genName(get_file_name(file), number, total));
110
+ options.setProgress(options.genProgress(0, get_file_size(file)));
111
+ xhr.upload['onprogress'] = function(rpe) {
112
+ $this.triggerHandler('html5_upload.onProgress', [rpe.loaded / rpe.total, get_file_name(file), number, total]);
113
+ options.setStatus(options.genStatus(rpe.loaded / rpe.total));
114
+ options.setProgress(options.genProgress(rpe.loaded, rpe.total));
115
+ };
116
+ xhr.onload = function(load) {
117
+ if (xhr.status >= 205 || xhr.status < 200) {
118
+ $this.triggerHandler('html5_upload.onError', [get_file_name(file), load]);
119
+ if (!options.stopOnFirstError) {
120
+ upload_file(number+1);
121
+ }
122
+ }
123
+ else {
124
+ $this.triggerHandler('html5_upload.onFinishOne', [xhr.responseText, get_file_name(file), number, total]);
125
+ options.setStatus(options.genStatus(1, true));
126
+ options.setProgress(options.genProgress(get_file_size(file), get_file_size(file)));
127
+ upload_file(number+1);
128
+ }
129
+ };
130
+ xhr.onabort = function() {
131
+ if ($this[0].html5_upload['continue_after_abort']) {
132
+ upload_file(number+1);
133
+ }
134
+ else {
135
+ $this.attr("disabled", false);
136
+ if (options.autoclear) {
137
+ $this.val("");
138
+ }
139
+ }
140
+ };
141
+ xhr.onerror = function(e) {
142
+ $this.triggerHandler('html5_upload.onError', [get_file_name(file), e]);
143
+ if (!options.stopOnFirstError) {
144
+ upload_file(number+1);
145
+ }
146
+ };
147
+ xhr.open(options.method, typeof(options.url) == "function" ? options.url(number) : options.url, true);
148
+ $.each(options.headers,function(key,val){
149
+ val = typeof(val) == "function" ? val(file) : encodeURIComponent(val); // resolve value
150
+ if (val === false) return true; // if resolved value is boolean false, do not send this header
151
+ xhr.setRequestHeader(key, val);
152
+ });
153
+
154
+ if (!options.sendBoundary) {
155
+ xhr.send(file);
156
+ }
157
+ else {
158
+ if (window.FormData) {//Many thanks to scottt.tw
159
+ var f = new FormData();
160
+ f.append(typeof(options.fieldName) == "function" ? options.fieldName() : options.fieldName, file);
161
+ options.extraFields = typeof(options.extraFields) == "function" ? options.extraFields() : options.extraFields;
162
+ $.each(options.extraFields, function(key, val){
163
+ f.append(key, val);
164
+ });
165
+ xhr.send(f);
166
+ }
167
+ else if (file.getAsBinary) {//Thanks to jm.schelcher
168
+ var boundary = '------multipartformboundary' + (new Date).getTime();
169
+ var dashdash = '--';
170
+ var crlf = '\r\n';
171
+
172
+ /* Build RFC2388 string. */
173
+ var builder = '';
174
+
175
+ builder += dashdash;
176
+ builder += boundary;
177
+ builder += crlf;
178
+
179
+ builder += 'Content-Disposition: form-data; name="'+(typeof(options.fieldName) == "function" ? options.fieldName() : options.fieldName)+'"';
180
+
181
+ //thanks to oyejo...@gmail.com for this fix
182
+ fileName = unescape(encodeURIComponent(get_file_name(file))); //encode_utf8
183
+
184
+ builder += '; filename="' + fileName + '"';
185
+ builder += crlf;
186
+
187
+ builder += 'Content-Type: ' + file.type;
188
+ builder += crlf;
189
+ builder += crlf;
190
+
191
+ /* Append binary data. */
192
+ builder += file.getAsBinary();
193
+ builder += crlf;
194
+
195
+ /* Write boundary. */
196
+ builder += dashdash;
197
+ builder += boundary;
198
+ builder += dashdash;
199
+ builder += crlf;
200
+
201
+ xhr.setRequestHeader('content-type', 'multipart/form-data; boundary=' + boundary);
202
+ xhr.sendAsBinary(builder);
203
+ }
204
+ else {
205
+ options.onBrowserIncompatible();
206
+ }
207
+ }
208
+ }
209
+ upload_file(0);
210
+ return true;
211
+ }
212
+
213
+ try {
214
+ return this.each(function() {
215
+ var file_input = this;
216
+ this.html5_upload = {
217
+ xhr: new XMLHttpRequest(),
218
+ continue_after_abort: true
219
+ };
220
+ if (options.autostart) {
221
+ $(this).bind('change', function(e){
222
+ upload.call( e.target, this.files );
223
+ });
224
+ }
225
+ var self = this;
226
+ $.each(available_events, function(event) {
227
+ if (options[available_events[event]]) {
228
+ $(self).bind("html5_upload."+available_events[event], options[available_events[event]]);
229
+ }
230
+ });
231
+ $(this)
232
+ .bind('html5_upload.startFromDrop', function( e, dropEvent ){
233
+ if ( dropEvent.dataTransfer && dropEvent.dataTransfer.files.length ){
234
+ upload.call( file_input, dropEvent.dataTransfer.files );
235
+ }
236
+ })
237
+ .bind('html5_upload.start', upload)
238
+ .bind('html5_upload.cancelOne', function() {
239
+ this.html5_upload['xhr'].abort();
240
+ })
241
+ .bind('html5_upload.cancelAll', function() {
242
+ this.html5_upload['continue_after_abort'] = false;
243
+ this.html5_upload['xhr'].abort();
244
+ })
245
+ .bind('html5_upload.destroy', function() {
246
+ this.html5_upload['continue_after_abort'] = false;
247
+ this.xhr.abort();
248
+ delete this.html5_upload;
249
+ $(this).unbind('html5_upload.*').unbind('change', upload);
250
+ });
251
+ });
252
+ }
253
+ catch (ex) {
254
+ options.onBrowserIncompatible();
255
+ return false;
256
+ }
257
+ };
258
+ })(jQuery);
@@ -82,6 +82,10 @@ a {
82
82
  margin: 10px 0 0 0;
83
83
  }
84
84
 
85
+ a[disabled] {
86
+ pointer-events: none;
87
+ }
88
+
85
89
  /* PANEL */
86
90
 
87
91
  p.instruction {
@@ -182,7 +186,7 @@ ul#nav-controls li a:hover {
182
186
  .list-elements #at a { background-image: url("<%= asset_path('fe/icons/paper-clip.png') %>");}
183
187
  .list-elements #ref a { background-image: url("<%= asset_path('fe/icons/book-open-list.png') %>");}
184
188
 
185
- .fe_textfield textarea { width: 90%; }
189
+ .fe_textfield textarea, .q_form input[type=text] { width: 90%; }
186
190
 
187
191
 
188
192
  /* BODY SIDE */
@@ -281,6 +285,23 @@ ul.questions li {
281
285
  display: none;
282
286
  }
283
287
 
288
+ .rating_after {
289
+ padding-left: 10px;
290
+ padding-right: 10px;
291
+ }
292
+ .rating_before {
293
+ padding-right: 10px;
294
+ }
295
+ .rating_na_label {
296
+ padding-left: 10px;
297
+ }
298
+ .rating_choice {
299
+ text-align: center;
300
+ }
301
+ .rating_choice, .rating_na {
302
+ padding: 2px;
303
+ }
304
+
284
305
  div.p_content p {
285
306
  margin-bottom: 1em;
286
307
  }
@@ -60,6 +60,10 @@ input.validation-passed, textarea.validation-passed {
60
60
  font-weight: bold;
61
61
  }
62
62
 
63
+ .validation-advice ul li {
64
+ padding-left: 1em;
65
+ }
66
+
63
67
  .custom-advice {
64
68
  margin: 5px 0;
65
69
  padding: 5px;
@@ -88,4 +92,4 @@ label {
88
92
 
89
93
  .field-widget {
90
94
 
91
- }
95
+ }
@@ -3,9 +3,9 @@ module Fe::Admin::QuestionSheetsControllerConcern
3
3
 
4
4
  begin
5
5
  included do
6
- before_filter :check_valid_user
7
- before_filter :get_question_sheet, :only => [:show, :archive, :unarchive, :destroy, :edit, :update, :duplicate]
8
- layout 'fe/fe.admin'
6
+ before_action :check_valid_user
7
+ before_action :get_question_sheet, only: [:show, :archive, :unarchive, :destroy, :edit, :update, :duplicate]
8
+ layout 'fe/fe_admin'
9
9
  end
10
10
  rescue ActiveSupport::Concern::MultipleIncludedBlocks
11
11
  end
@@ -18,23 +18,23 @@ module Fe::Admin::QuestionSheetsControllerConcern
18
18
 
19
19
  respond_to do |format|
20
20
  format.html # index.rhtml
21
- format.xml { render :xml => @question_sheets.to_xml }
21
+ format.xml { render xml: @question_sheets.to_xml }
22
22
  end
23
23
  end
24
24
 
25
25
  def archive
26
26
  @question_sheet.update_attribute(:archived, true)
27
- redirect_to :back
27
+ redirect_back(fallback_location: '/')
28
28
  end
29
29
 
30
30
  def unarchive
31
31
  @question_sheet.update_attribute(:archived, false)
32
- redirect_to :back
32
+ redirect_back(fallback_location: '/')
33
33
  end
34
34
 
35
35
  def duplicate
36
36
  @question_sheet.duplicate
37
- redirect_to :back
37
+ redirect_back(fallback_location: '/')
38
38
  end
39
39
 
40
40
  # entry point: display form designer with page 1 and panels loaded
@@ -45,7 +45,7 @@ module Fe::Admin::QuestionSheetsControllerConcern
45
45
 
46
46
  respond_to do |format|
47
47
  format.html # show.rhtml
48
- format.xml { render :xml => @question_sheet.to_xml }
48
+ format.xml { render xml: @question_sheet.to_xml }
49
49
  end
50
50
  end
51
51
 
@@ -57,10 +57,10 @@ module Fe::Admin::QuestionSheetsControllerConcern
57
57
  respond_to do |format|
58
58
  if @question_sheet.save
59
59
  format.html { redirect_to fe_admin_question_sheet_path(@question_sheet) }
60
- format.xml { head :created, :location => admin_question_sheet_path(@question_sheet) }
60
+ format.xml { head :created, location: admin_question_sheet_path(@question_sheet) }
61
61
  else
62
- format.html { render :action => "new" }
63
- format.xml { render :xml => @question_sheet.errors.to_xml }
62
+ format.html { render action: "new" }
63
+ format.xml { render xml: @question_sheet.errors.to_xml }
64
64
  end
65
65
  end
66
66
  end
@@ -81,14 +81,14 @@ module Fe::Admin::QuestionSheetsControllerConcern
81
81
  params.require(:fe_question_sheet).permit!
82
82
 
83
83
  respond_to do |format|
84
- if @question_sheet.update_attributes(params[:fe_question_sheet])
84
+ if @question_sheet.update(params[:fe_question_sheet])
85
85
  format.html { redirect_to fe_admin_question_sheet_path(@question_sheet) }
86
86
  format.js
87
87
  format.xml { head :ok }
88
88
  else
89
- format.html { render :action => "edit" }
90
- format.js { render :action => "error.rjs"}
91
- format.xml { render :xml => @question_sheet.errors.to_xml }
89
+ format.html { render action: "edit" }
90
+ format.js { render action: "error.rjs"}
91
+ format.xml { render xml: @question_sheet.errors.to_xml }
92
92
  end
93
93
  end
94
94
  end
@@ -109,4 +109,3 @@ module Fe::Admin::QuestionSheetsControllerConcern
109
109
  @question_sheet = Fe::QuestionSheet.find(params[:id])
110
110
  end
111
111
  end
112
-
@@ -0,0 +1,131 @@
1
+ module Fe::AnswerPagesControllerConcern
2
+ extend ActiveSupport::Concern
3
+
4
+ begin
5
+ included do
6
+ before_action :get_answer_sheet, only: [:show, :edit, :update, :save_file, :delete_file, :index]
7
+ before_action :set_quiet_reference_email_change, only: :update
8
+ skip_before_action :verify_authenticity_token, only: :save_file
9
+ end
10
+ rescue ActiveSupport::Concern::MultipleIncludedBlocks
11
+ end
12
+
13
+ def show
14
+ @presenter = Fe::AnswerPagesPresenter.new(self, @answer_sheet, params[:a], nil, true)
15
+ questions = @presenter.questions_for_page(params[:id])
16
+ questions.set_filter(get_filter)
17
+ @elements = questions.elements
18
+ @page = Fe::Page.find(params[:id]) || Fe::Page.find_by_number(1)
19
+ end
20
+
21
+ def edit
22
+ questions = @presenter.questions_for_page(params[:id])
23
+ questions.set_filter(get_filter)
24
+ @elements = questions.elements
25
+ @page = Fe::Page.find(params[:id]) || Fe::Page.find_by_number(1)
26
+
27
+ render partial: 'answer_page', locals: { show_first: nil }
28
+ end
29
+
30
+ # validate and save captured data for a given page
31
+ # PUT /answer_sheets/1/pages/1
32
+ def update
33
+ @page = Fe::Page.find(params[:id])
34
+ questions = @presenter.all_questions_for_page(params[:id])
35
+ questions.set_filter(get_filter)
36
+ questions.post(answer_params, @answer_sheet)
37
+ questions.save
38
+ Fe::UpdateReferenceSheetVisibilityJob.perform_later(@answer_sheet, questions.questions.collect(&:id))
39
+
40
+ @elements = questions.elements
41
+
42
+ # Save references
43
+
44
+ if params[:reference].present?
45
+ params[:reference].keys.each do |id|
46
+ reference_params = params.fetch(:reference)[id].permit(:relationship, :title, :first_name, :last_name, :phone, :email, :is_staff)
47
+
48
+ # The call to Application#reference_sheets is supposed to update the visibility cache and return the right references, but
49
+ # currently it does not do that right. It needs a reload to get the right list of references. I think this may be caused
50
+ # from a change in rails 5
51
+ @answer_sheet = answer_sheet_type.find(params[:answer_sheet_id]) # load a fresh instance of @answer_sheet
52
+ @answer_sheet.reference_sheets # this call seems to be necessary to build the right refs list
53
+ ref = @answer_sheet.reference_sheets.find(id)
54
+
55
+ # if the email address has changed, we have to trash the old reference answers
56
+ ref.attributes = reference_params
57
+ ref.save(validate: false)
58
+ end
59
+ end
60
+ @presenter.active_page = nil
61
+ @answer_sheet.update(locale: session[:locale])
62
+ set_saved_at_timestamp
63
+ respond_to do |format|
64
+ format.js
65
+ #format.html
66
+ end
67
+ end
68
+
69
+ def save_file
70
+ params.permit(:Filedata)
71
+ params.permit(:user_file) # jquery html5 uploader uses user_file; handle both as flash is fallback
72
+
73
+ if params[:Filedata] || params[:user_file]
74
+ @page = Fe::Page.find(params[:id])
75
+ @presenter.active_page = @page
76
+ question = Fe::Element.find(params[:question_id])
77
+ answer = Fe::Answer.where(answer_sheet_id: @answer_sheet.id, question_id: question.id).first
78
+ question.answers = [answer] if answer
79
+
80
+ @answer = question.save_file(@answer_sheet, params[:Filedata] || params[:user_file].first)
81
+ set_saved_at_timestamp
82
+
83
+ render action: :update
84
+ else
85
+ respond_to do |format|
86
+ format.js { head :ok }
87
+ end
88
+ end
89
+ end
90
+
91
+ def delete_file
92
+ @page = Fe::Page.find(params[:id])
93
+ @presenter.active_page = @page
94
+ question = Fe::Element.find(params[:question_id])
95
+ answer = Fe::Answer.where(answer_sheet_id: @answer_sheet.id, question_id: question.id).first
96
+ question.answers = [answer] if answer
97
+
98
+ @answer = question.delete_file(@answer_sheet, answer)
99
+ set_saved_at_timestamp
100
+
101
+ render action: :update
102
+ end
103
+
104
+ protected
105
+
106
+ def get_answer_sheet
107
+ @answer_sheet = answer_sheet_type.find(params[:answer_sheet_id])
108
+ @presenter = Fe::AnswerPagesPresenter.new(self, @answer_sheet, params[:a])
109
+ end
110
+
111
+ # extending classes can override this to set a questions filter
112
+ # see Fe::QuestionSet#set_filter for more details
113
+ def get_filter
114
+ end
115
+
116
+ def answer_sheet_type
117
+ (params[:answer_sheet_type] || Fe.answer_sheet_class || 'AnswerSheet').constantize
118
+ end
119
+
120
+ def answer_params
121
+ params.fetch(:answers, {}).permit!
122
+ end
123
+
124
+ def set_saved_at_timestamp
125
+ @saved_at_timestamp = [@answer_sheet.updated_at, @answer_sheet.answers.maximum(:updated_at)].compact.max
126
+ end
127
+
128
+ def set_quiet_reference_email_change
129
+ @answer_sheet.allow_quiet_reference_email_changes = true if @answer_sheet.is_a?(Fe::ReferenceSheet) && params[:a].present?
130
+ end
131
+ end
@@ -4,7 +4,7 @@ module Fe::AnswerSheetsControllerConcern
4
4
  begin
5
5
  included do
6
6
  layout 'fe/application'
7
- before_filter :get_answer_sheet, :only => [:edit, :show, :send_reference_invite, :submit]
7
+ before_action :get_answer_sheet, only: [:edit, :show, :send_reference_invite, :submit]
8
8
  end
9
9
  rescue ActiveSupport::Concern::MultipleIncludedBlocks
10
10
  end
@@ -31,9 +31,9 @@ module Fe::AnswerSheetsControllerConcern
31
31
  unless @presenter.active_answer_sheet.pages.present?
32
32
  flash[:error] = "Sorry, there are no questions for this form yet."
33
33
  if request.env["HTTP_REFERER"]
34
- redirect_to :back
34
+ redirect_back(fallback_location: '/')
35
35
  else
36
- render :text => "", :layout => true
36
+ render html: "", layout: true
37
37
  end
38
38
  else
39
39
  @elements = @presenter.questions_for_page(:first).elements
@@ -46,7 +46,9 @@ module Fe::AnswerSheetsControllerConcern
46
46
  @question_sheet = @answer_sheet.question_sheet
47
47
  pf = Fe.table_name_prefix
48
48
  @elements = @question_sheet.pages.collect {|p| p.elements.includes(:pages).order("#{pf}pages.number,#{pf}page_elements.position").all}.flatten
49
- @elements = Fe::QuestionSet.new(@elements, @answer_sheet).elements.group_by{ |e| e.pages.first }
49
+ questions = Fe::QuestionSet.new(@elements, @answer_sheet)
50
+ questions.set_filter(get_filter)
51
+ @elements = questions.elements.group_by{ |e| e.pages.find_by(id: @question_sheet.page_ids) }
50
52
  end
51
53
 
52
54
  def send_reference_invite(reference = nil)
@@ -54,10 +56,10 @@ module Fe::AnswerSheetsControllerConcern
54
56
  if params[:reference]
55
57
  reference_params = params.fetch(:reference)[@reference.id.to_s].permit(:relationship, :title, :first_name, :last_name, :phone, :email, :is_staff)
56
58
 
57
- @reference.update_attributes(reference_params)
59
+ @reference.update(reference_params)
58
60
  end
59
61
  if @reference.valid?
60
- @reference.send_invite
62
+ @reference.send_invite(request.host)
61
63
  end
62
64
  end
63
65
 
@@ -68,6 +70,12 @@ module Fe::AnswerSheetsControllerConcern
68
70
  end
69
71
 
70
72
  protected
73
+
74
+ # extending classes can override this to set a questions filter
75
+ # see Fe::QuesitonSet#set_filter for more details
76
+ def get_filter
77
+ end
78
+
71
79
  def answer_sheet_type
72
80
  return Fe::ReferenceSheet if params[:controller] == "fe/reference_sheets"
73
81
  (params[:answer_sheet_type] || Fe.answer_sheet_class || 'AnswerSheet').constantize
@@ -4,14 +4,14 @@ module Fe::ApplicationControllerConcern
4
4
  begin
5
5
  included do
6
6
  helper_method :fe_user
7
- before_filter :set_locale
7
+ before_action :set_locale
8
8
  end
9
9
  rescue ActiveSupport::Concern::MultipleIncludedBlocks
10
10
  end
11
11
 
12
12
  def fe_user
13
13
  return nil unless current_user
14
- @fe_user ||= Fe::User.where(:user_id => current_user.id).first
14
+ @fe_user ||= Fe::User.where(user_id: current_user.id).first
15
15
  if @fe_user
16
16
  @fe_user.update_attribute(:last_login, Time.now)
17
17
  session[:login_stamped] = true
@@ -34,7 +34,7 @@ module Fe::ApplicationControllerConcern
34
34
  def current_person
35
35
  #raise "no user" unless current_user
36
36
  return nil unless current_user
37
- current_user.fe_person || Fe::Person.create(:user_id => current_user.id)
37
+ current_user.fe_person || Fe::Person.create(user_id: current_user.id)
38
38
  end
39
39
 
40
40
  def check_valid_user