fe 1.0.0 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
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
@@ -1,20 +1,23 @@
1
1
  # QuestionSheet represents a particular form
2
2
  module Fe
3
- class QuestionSheet < ActiveRecord::Base
3
+ class QuestionSheet < ApplicationRecord
4
4
  self.table_name = self.table_name.sub('fe_', Fe.table_name_prefix)
5
5
 
6
+ attr_accessor :old_id
7
+ attr_accessor :element_id_mappings
8
+
6
9
  has_many :pages, -> { order('number') },
7
- :dependent => :destroy
10
+ dependent: :destroy
8
11
 
9
12
  has_many :answer_sheet_question_sheets
10
13
 
11
14
  has_many :answer_sheets,
12
- :through => :answer_sheet_question_sheets
15
+ through: :answer_sheet_question_sheets
13
16
  has_many :question_sheets,
14
- :through => :answer_sheet_question_sheets
17
+ through: :answer_sheet_question_sheets
15
18
 
16
- scope :active, -> { where(:archived => false) }
17
- scope :archived, -> { where(:archived => true) }
19
+ scope :active, -> { where(archived: false) }
20
+ scope :archived, -> { where(archived: true) }
18
21
 
19
22
  validates_presence_of :label
20
23
 
@@ -24,16 +27,11 @@ module Fe
24
27
 
25
28
  # create a new form with a page already attached
26
29
  def self.new_with_page
27
- question_sheet = self.new(:label => next_label)
28
- question_sheet.pages.build(:label => 'Page 1', :number => 1)
30
+ question_sheet = self.new(label: next_label)
31
+ question_sheet.pages.build(label: 'Page 1', number: 1)
29
32
  question_sheet
30
33
  end
31
34
 
32
- # count all questions including ones inside a grid
33
- def questions_count
34
- all_elements.questions.count
35
- end
36
-
37
35
  def questions
38
36
  all_elements.questions
39
37
  end
@@ -43,8 +41,8 @@ module Fe
43
41
  end
44
42
 
45
43
  def all_elements
46
- element_ids = pages.pluck(:all_element_ids).compact.join(',').split(',')
47
- element_ids.present? ? Element.where(id: element_ids).order(element_ids.collect{ |id| "id=#{id} DESC" }.join(', ')) : Element.where("1 = 0")
44
+ element_ids = pages.pluck(:all_element_ids).compact.join(',').split(',').find_all(&:present?)
45
+ element_ids.present? ? Element.where(id: element_ids).order(Arel.sql(element_ids.collect{ |id| "id=#{id} DESC" }.join(', '))) : Element.where("1 = 0")
48
46
  end
49
47
 
50
48
  # Pages get duplicated
@@ -53,13 +51,48 @@ module Fe
53
51
  def duplicate
54
52
  new_sheet = QuestionSheet.new(self.attributes.merge(id: nil))
55
53
  new_sheet.label = self.label + ' - COPY'
56
- new_sheet.save(:validate => false)
54
+ new_sheet.save(validate: false)
57
55
  self.pages.each do |page|
58
56
  page.copy_to(new_sheet)
59
57
  end
60
58
  new_sheet
61
59
  end
62
60
 
61
+ def export_to_yaml
62
+ atts = attributes.to_hash
63
+ atts[:pages] = pages.collect(&:export_hash)
64
+ atts.to_yaml
65
+ end
66
+
67
+ def self.create_from_yaml(filename)
68
+ # NOTE: yaml will break if some classes aren't loaded before YAML::load, strange
69
+ Fe::Element.distinct.where.not(kind: 'Fe::Style').pluck(:kind).each(&:constantize)
70
+
71
+ sheet_data = YAML::load(File.read(filename))
72
+ sheet_data[:old_id] = sheet_data.delete("id")
73
+ pages = sheet_data.delete(:pages)
74
+ puts("Create import by data #{sheet_data}")
75
+ question_sheet = Fe::QuestionSheet.create!(sheet_data)
76
+ question_sheet.element_id_mappings = []
77
+ pages.each do |page_atts|
78
+ page = Page.create_from_import(page_atts, question_sheet)
79
+ question_sheet.pages << page
80
+ end
81
+ # set page conditional_id values to new ids based on old_id
82
+ question_sheet.all_elements.each do |el|
83
+ if el.conditional_type != "Fe::Page" && el.conditional_id.present?
84
+ # noop
85
+ end
86
+
87
+ # note that conditional elements are already translated to new ids in the element import so no need to do it here
88
+ if el.conditional_type == "Fe::Page" && el.conditional_id
89
+ el.update(conditional_id: question_sheet.pages.detect{ |el2| el2.old_id == el.conditional_id }&.id)
90
+ end
91
+ end
92
+
93
+ question_sheet
94
+ end
95
+
63
96
  private
64
97
 
65
98
  # next unused label with "Untitled form" prefix
@@ -2,12 +2,15 @@
2
2
  # - a question that provides a fields to specify a reference
3
3
  module Fe
4
4
  class ReferenceQuestion < Question
5
+ has_many :reference_sheets, foreign_key: :question_id
6
+
7
+ after_save :update_references_question_sheet_ids
5
8
 
6
9
  def response(app=nil)
7
10
  return unless app
8
11
  # A reference is the same if the related_question_sheet corresponding to the question is the same
9
12
  reference = Fe::ReferenceSheet.find_by_applicant_answer_sheet_id_and_question_id(app.id, id)
10
- reference || Fe::ReferenceSheet.create(:applicant_answer_sheet_id => app.id, :question_id => id)
13
+ reference || Fe::ReferenceSheet.create(applicant_answer_sheet_id: app.id, question_id: id)
11
14
  end
12
15
 
13
16
  def has_response?(app = nil)
@@ -15,11 +18,11 @@ module Fe
15
18
  reference = response(app)
16
19
  reference && reference.valid?
17
20
  else
18
- Fe::ReferenceSheet.where(:question_id => id).count > 0
21
+ Fe::ReferenceSheet.where(question_id: id).count > 0
19
22
  end
20
23
  end
21
24
 
22
- def display_response(app=nil)
25
+ def display_response(app = nil, humanize = false)
23
26
  response(app).to_s
24
27
  end
25
28
 
@@ -28,5 +31,8 @@ module Fe
28
31
  "fe/reference_#{style}"
29
32
  end
30
33
 
34
+ def update_references_question_sheet_ids
35
+ reference_sheets.where(status: :created).update_all(question_sheet_id: related_question_sheet_id, updated_at: Time.now)
36
+ end
31
37
  end
32
38
  end
@@ -1,40 +1,49 @@
1
1
  require 'validates_email_format_of'
2
2
  require 'aasm'
3
3
  module Fe
4
- class ReferenceSheet < ActiveRecord::Base
4
+ class ReferenceSheet < ApplicationRecord
5
5
  include Fe::AnswerSheetConcern
6
6
  include Rails.application.routes.url_helpers
7
7
  include AASM
8
8
  include AccessKeyGenerator
9
9
 
10
+ attr_accessor :allow_quiet_reference_email_changes
11
+
10
12
  self.table_name = "#{Fe.table_name_prefix}references"
11
13
  self.inheritance_column = 'fake'
12
14
 
15
+ scope :visible, -> { where(visible: true) }
16
+
13
17
  belongs_to :question,
14
- :class_name => 'Fe::ReferenceQuestion',
15
- :foreign_key => 'question_id'
18
+ class_name: 'Fe::ReferenceQuestion',
19
+ foreign_key: 'question_id'
16
20
 
17
21
  belongs_to :applicant_answer_sheet,
18
- :class_name => "::#{Fe.answer_sheet_class}",
19
- :foreign_key => "applicant_answer_sheet_id"
22
+ class_name: "::#{Fe.answer_sheet_class}",
23
+ foreign_key: "applicant_answer_sheet_id"
20
24
 
21
- validates_presence_of :first_name, :last_name, :phone, :email, :relationship, :on => :update, :message => "can't be blank"
22
- validates :email, :email_format => { :on => :update, :message => "doesn't look right." }
25
+ # using belongs_to :question_sheet doesn't work, it uses the Fe::AnswerSheetConcern#question_sheet implementation
26
+ belongs_to :question_sheet_ref, optional: true, class_name: 'Fe::QuestionSheet', foreign_key: :question_sheet_id
23
27
 
24
- delegate :style, :to => :question
28
+ validates_presence_of :first_name, :last_name, :phone, :email, :relationship, on: :update, message: "can't be blank"
29
+ validates :email, email_format: { on: :update, message: "doesn't look right." }
25
30
 
26
- before_save :check_email_change
31
+ delegate :style, to: :question
27
32
 
33
+ before_save :reset_reference, if: :new_reference_requested?
34
+ after_save :notify_old_reference_not_needed, if: :new_reference_requested?
35
+ before_create :set_question_sheet
28
36
  after_destroy :notify_reference_of_deletion
37
+ after_create :update_visible
29
38
 
30
- aasm :initial => :created, :column => :status do
39
+ aasm column: :status do
31
40
 
32
- state :started, :enter => Proc.new {|ref|
33
- ref.started_at = Time.now
41
+ state :started, enter: Proc.new {
42
+ update(started_at: Time.now)
34
43
  }
35
- state :created
36
- state :completed, :enter => Proc.new {|ref|
37
- ref.submitted_at = Time.now
44
+ state :created, initial: true
45
+ state :completed, enter: Proc.new {
46
+ update(submitted_at: Time.now)
38
47
  # SpReferenceMailer.deliver_completed(ref)
39
48
  =begin
40
49
  Fe::Notifier.notification(ref.email, # RECIPIENTS
@@ -59,26 +68,46 @@ module Fe
59
68
  'password' => person.user.password_plain}).deliver
60
69
  =end
61
70
 
62
- ref.applicant_answer_sheet.complete(ref)
71
+ applicant_answer_sheet.complete(self)
63
72
  }
64
73
 
65
74
  event :start do
66
- transitions :to => :started, :from => :created
75
+ transitions to: :started, from: :created
67
76
  end
68
77
 
69
78
  event :submit do
70
- transitions :to => :completed, :from => :started
71
- transitions :to => :completed, :from => :created
79
+ transitions to: :completed, from: :started
80
+ transitions to: :completed, from: :created
72
81
  end
73
82
 
74
83
  event :unsubmit do
75
- transitions :to => :started, :from => :completed
84
+ transitions to: :started, from: :completed
76
85
  end
77
86
  end
78
87
 
79
88
  alias_method :application, :applicant_answer_sheet
80
89
  delegate :applicant, to: :application
81
90
 
91
+ def computed_visibility_cache_key
92
+ return @computed_visibility_cache_key if @computed_visibility_cache_key
93
+ return nil unless question # keep from crashing for tests
94
+ answers = Fe::Answer.where(question_id: question.visibility_affecting_element_ids,
95
+ answer_sheet_id: applicant_answer_sheet)
96
+ answers.collect(&:cache_key_with_version).join('/')
97
+ end
98
+
99
+ def update_visible(page = nil)
100
+ if visibility_cache_key == computed_visibility_cache_key
101
+ visible
102
+ else
103
+ self.visible = question.visible?(applicant_answer_sheet, page)
104
+ self.visibility_cache_key = computed_visibility_cache_key
105
+ # save only these columns and don't check validations, but do record updated_at
106
+ # as it is significant enough of an event that we probably want that to set updated_at
107
+ Fe::ReferenceSheet.where(id: id).update_all(visibility_cache_key: self.computed_visibility_cache_key, visible: self.visible, updated_at: Time.now)
108
+ end
109
+ end
110
+
82
111
  def frozen?
83
112
  !%w(started created).include?(self.status)
84
113
  end
@@ -86,7 +115,7 @@ module Fe
86
115
  def email_sent?() !self.email_sent_at.nil? end
87
116
 
88
117
  # send email invite
89
- def send_invite
118
+ def send_invite(host)
90
119
  return if self.email.blank?
91
120
 
92
121
  application = self.applicant_answer_sheet
@@ -98,7 +127,7 @@ module Fe
98
127
  'applicant_full_name' => application.applicant.name,
99
128
  'applicant_email' => application.applicant.email,
100
129
  'applicant_home_phone' => application.applicant.phone,
101
- 'reference_url' => edit_fe_reference_sheet_url(self, :a => self.access_key, :host => ActionMailer::Base.default_url_options[:host])}).deliver
130
+ 'reference_url' => edit_fe_reference_sheet_url(self, a: self.access_key, host: host)}).deliver_now
102
131
  # Send notification to applicant
103
132
  Notifier.notification(applicant_answer_sheet.applicant.email, # RECIPIENTS
104
133
  Fe.from_email, # FROM
@@ -106,10 +135,10 @@ module Fe
106
135
  {'applicant_full_name' => applicant_answer_sheet.applicant.name,
107
136
  'reference_full_name' => self.name,
108
137
  'reference_email' => self.email,
109
- 'application_url' => edit_fe_answer_sheet_url(applicant_answer_sheet, :host => ActionMailer::Base.default_url_options[:host])}).deliver
138
+ 'application_url' => edit_fe_answer_sheet_url(applicant_answer_sheet, host: host)}).deliver_now
110
139
 
111
140
  self.email_sent_at = Time.now
112
- self.save(:validate => false)
141
+ self.save(validate: false)
113
142
 
114
143
  true
115
144
  end
@@ -126,52 +155,78 @@ module Fe
126
155
  name
127
156
  end
128
157
 
129
- def required?
130
- question.required?(applicant_answer_sheet)
131
- end
132
-
133
158
  def reference?
134
159
  true
135
160
  end
136
161
 
137
162
  # Can't rely on answer_sheet's implementation for old reference's that might have id's that may match an application id
138
163
  def question_sheet
139
- QuestionSheet.find(question.related_question_sheet_id) if question && question.related_question_sheet_id
164
+ question_sheet_ref
140
165
  end
141
166
 
142
- # Can't rely on answer_sheet's implementation for old reference's that might have id's that may match an application id
143
167
  def question_sheets
144
- [question_sheet]
168
+ [question_sheet_ref]
145
169
  end
146
170
 
147
171
  def question_sheet_ids
148
- [question_sheet.try(:id)].compact
172
+ [question_sheet_id].compact
149
173
  end
150
174
 
151
175
  def display_type
152
176
  question.label.split(/:| \(/).first
153
177
  end
154
178
 
179
+ def optional?
180
+ question.try(:hidden?, applicant_answer_sheet)
181
+ end
182
+
183
+ def required?
184
+ question.required?(applicant_answer_sheet) && !optional?
185
+ end
186
+
187
+ def all_affecting_questions_answered
188
+ return false unless question
189
+ question.visibility_affecting_questions.all? { |q| q.has_response?(applicant_answer_sheet) }
190
+ end
191
+
155
192
  protected
193
+
194
+ def set_question_sheet
195
+ self.question_sheet_id = question.try(:related_question_sheet_id)
196
+ end
197
+
156
198
  # if the email address has changed, we have to trash the old reference answers
157
- def check_email_change
158
- if !new_record? && changed.include?('email')
159
- answers.destroy_all
160
- # Every time the email address changes, generate a new access_key
161
- generate_access_key
162
- self.email_sent_at = nil
163
- self.status = 'created'
164
- end
199
+ def reset_reference
200
+ answers.destroy_all
201
+ # Every time the email address changes, generate a new access_key
202
+ generate_access_key
203
+ self.email_sent_at = nil
204
+ self.status = 'created'
205
+ end
206
+
207
+ def notify_old_reference_not_needed
208
+ return unless email_sent_at_was.present? && email_was.present?
209
+ notify_reference_not_needed(self, email_was, first_name_was, last_name_was)
165
210
  end
166
211
 
167
212
  def notify_reference_of_deletion
168
- if email.present?
169
- Notifier.notification(email,
170
- Fe.from_email,
171
- "Reference Deleted",
172
- {'reference_full_name' => self.name,
173
- 'applicant_full_name' => applicant_answer_sheet.name}).deliver
174
- end
213
+ return unless email_sent_at.present? && email.present?
214
+ notify_reference_not_needed(self, email, first_name, last_name)
215
+ end
216
+
217
+ def notify_reference_not_needed(ref, ref_email, ref_first_name, ref_last_name)
218
+ # inform referrer that they no longer need to fill out reference
219
+ Fe::Notifier.notification(
220
+ ref_email, # RECIPIENTS
221
+ Fe.from_email, # FROM
222
+ 'Reference Deleted',
223
+ { 'reference_full_name' => "#{ref_first_name} #{ref_last_name}",
224
+ 'applicant_full_name' => applicant_answer_sheet.applicant.name }
225
+ ).deliver_now
226
+ end
227
+
228
+ def new_reference_requested?
229
+ !allow_quiet_reference_email_changes && !new_record? && !completed? && email_changed?
175
230
  end
176
231
  end
177
232
  end
@@ -3,8 +3,8 @@ require 'carmen'
3
3
  # - drop down of states
4
4
  module Fe
5
5
  class StateChooser < Question
6
- def choices(country = 'US')
7
- @states = Carmen.states(country)
6
+ def choices(locale = nil, country = 'US')
7
+ @states = _(Carmen.states(country))
8
8
  end
9
9
  end
10
10
  end
@@ -14,9 +14,9 @@ module Fe
14
14
  end
15
15
 
16
16
  # css class names for javascript-based validation
17
- def validation_class(answer_sheet)
17
+ def validation_class(answer_sheet, page = nil)
18
18
  validation = ''
19
- validation += ' required' if self.required?(answer_sheet)
19
+ validation += ' required' if self.required?(answer_sheet, page)
20
20
  # validate-number, etc.
21
21
  validate_style = ['number', 'currency-dollar', 'email', 'url', 'phone'].find {|v| v == self.style }
22
22
  if validate_style
@@ -1,3 +1,3 @@
1
- class Fe::User < ActiveRecord::Base
1
+ class Fe::User < ApplicationRecord
2
2
  belongs_to :user
3
3
  end
data/app/models/staff.rb CHANGED
@@ -1,9 +1,9 @@
1
- class Staff < ActiveRecord::Base
1
+ class Staff < ApplicationRecord
2
2
  self.table_name = "ministry_staff"
3
3
  belongs_to :person
4
4
 
5
- belongs_to :primary_address, :class_name => "StaffAddress", :foreign_key => :fk_primaryAddress
6
- belongs_to :secondary_address, :class_name => "StaffAddress", :foreign_key => :fk_secondaryAddress
5
+ belongs_to :primary_address, class_name: "StaffAddress", foreign_key: :fk_primaryAddress
6
+ belongs_to :secondary_address, class_name: "StaffAddress", foreign_key: :fk_secondaryAddress
7
7
 
8
8
  alias_attribute :preferred_name, :preferredName
9
9
 
@@ -72,13 +72,13 @@ class Staff < ActiveRecord::Base
72
72
  ]
73
73
  end
74
74
 
75
- scope :specialty_roles, -> { where(:jobStatus => "Staff Full Time").where(:ministry => "Campus Ministry").
76
- where(:removedFromPeopleSoft => "N").where("jobTitle NOT IN (?)", field_roles).order(:jobTitle).order(:lastName) }
75
+ scope :specialty_roles, -> { where(jobStatus: "Staff Full Time").where(ministry: "Campus Ministry").
76
+ where(removedFromPeopleSoft: "N").where("jobTitle NOT IN (?)", field_roles).order(:jobTitle).order(:lastName) }
77
77
 
78
78
  def self.get_roles(region)
79
79
  result = {}
80
80
  Staff.strategy_order.each do |strategy|
81
- result[strategy] = specialty_roles.where(:strategy => strategy).where(:region => region)
81
+ result[strategy] = specialty_roles.where(strategy: strategy).where(region: region)
82
82
  end
83
83
  result
84
84
  end
@@ -1,11 +1,11 @@
1
1
  <% if @page_element %>
2
2
  $('#question_modal').dialog('close');
3
- $('#page-preview').html('<%= escape_javascript(render('fe/admin/question_pages/question_page')) %>');
3
+ $('#page-preview').html('<%= escape_javascript(render("fe/admin/question_pages/question_page")) %>');
4
4
  $('#element_<%= dom_id(@element) %>').hide();
5
- $('#element_form_<%= dom_id(@element) %>').html('<%= escape_javascript(render('fe/admin/panels/prop_element',:element => @element)) %>');
5
+ $('#element_form_<%= dom_id(@element) %>').html('<%= escape_javascript(render("fe/admin/panels/prop_element", element: @element)) %>');
6
6
  $('#element_form_<%= dom_id(@element) %>').show();
7
7
  selectElement("#element_<%= @element.id %>");
8
- $.scrollTo("#element_<%= @element.id %>");
8
+ scrollTo("#element_<%= @element.id %>");
9
9
  setUpSortables();
10
10
  <% else %>
11
11
  alert('That question already exists on this question sheet')
@@ -1,4 +1,4 @@
1
1
  $('#element_<%= @element.id %>').remove()
2
- $('#panel').html('<%= escape_javascript(render('fe/admin/panels/insert')) %>')
2
+ $('#panel').html('<%= escape_javascript(render("fe/admin/panels/insert")) %>')
3
3
  activeElement = ''
4
4
  switchTab('insert')
@@ -1,3 +1,3 @@
1
- $('#page-preview').html('<%= escape_javascript(render('fe/admin/question_pages/question_page', :page => @page)) %>')
1
+ $('#page-preview').html('<%= escape_javascript(render("fe/admin/question_pages/question_page", page: @page)) %>')
2
2
  $('#list-pages li').removeClass('active')
3
3
  setUpJsHelpers();
@@ -1,3 +1,3 @@
1
- $('#page-preview').html('<%= escape_javascript(render('fe/admin/question_pages/question_page')) %>')
1
+ $('#page-preview').html('<%= escape_javascript(render("fe/admin/question_pages/question_page")) %>')
2
2
  selectElement("#element_<%= @element.id %>")
3
3
  setUpSortables();
@@ -1,4 +1,4 @@
1
1
  $('#element_<%= dom_id(@element) %>').hide()
2
- $('#element_form_<%= dom_id(@element) %>').html('<%= escape_javascript(render('fe/admin/panels/prop_element',:element => @element)) %>')
2
+ $('#element_form_<%= dom_id(@element) %>').html('<%= escape_javascript(render("fe/admin/panels/prop_element", element: @element)) %>')
3
3
  $('#element_form_<%= dom_id(@element) %>').show();
4
4
  selectElement("#element_<%= @element.id %>")
@@ -1,4 +1,4 @@
1
- $('#errors').html('<%= escape_javascript(render('errors', :element => @element)) %>')
1
+ $('#errors').html('<%= escape_javascript(render("errors", element: @element)) %>')
2
2
  <% @element.errors.each do |attr_name, message| %>
3
3
  addError('element_<%= attr_name %>')
4
4
  <% end %>
@@ -1,10 +1,17 @@
1
+ <% if @questions.any? %>
1
2
  if ($('#question_modal')[0] == null) {
2
3
  $('body').append('<div id="question_modal"></div>');
3
4
  }
4
- $('#question_modal').html('<%= link_to("Add \"#{params[:human_type]}\"", fe_admin_question_sheet_page_elements_path(:question_sheet_id => @page.question_sheet_id, :page_id => @page.id,
5
- :element_type => params[:element_type], "element[style]" => @style, format: :js),
6
- :remote => true,
7
- :method => :post,
8
- :class => "add_type") %><p>Or you can also use an existing <%= params[:human_type] %> element. If you are unsure, just <strong>Add <%= params[:human_type] %>.</strong></p><div id="questions_div" title=""></div>');
9
- $('#questions_div').html("<%= escape_javascript(render('fe/questions/fe/questions', :questions => @questions)) %>")
5
+ $('#question_modal').html('<%= link_to("Add \"#{params[:human_type]}\"", fe_admin_question_sheet_page_elements_path(question_sheet_id: @page.question_sheet_id, page_id: @page.id,
6
+ element_type: params[:element_type], "element[style]" => @style, format: :js),
7
+ remote: true,
8
+ method: :post,
9
+ class: "add_type",
10
+ data: { disable_with: "Add \"#{params[:human_type]}\"" }) %><p>Or you can also copy an existing <%= params[:human_type] %> element. If you are unsure, just <strong>Add <%= params[:human_type] %>.</strong></p><div id="questions_div" title=""></div>');
11
+ $('#questions_div').html("<%= escape_javascript(render("fe/questions/fe/questions", questions: @questions)) %>")
10
12
  $('#question_modal').dialog({width: 500, height: 400});
13
+ <% else %>
14
+ $.post('<%= fe_admin_question_sheet_page_elements_path(question_sheet_id: @page.question_sheet_id,
15
+ page_id: @page.id,
16
+ element_type: params[:element_type], "element[style]" => @style, format: :js) %>');
17
+ <% end %>
@@ -1,5 +1,5 @@
1
1
  $('#element_form_<%= dom_id(@element) %>').hide();
2
- $('#element_<%= dom_id(@element) %>').html('<%= escape_javascript(render('fe/admin/question_pages/element_show', :element => @element)) %>')
2
+ $('#element_<%= dom_id(@element) %>').html('<%= escape_javascript(render("fe/admin/question_pages/element_show", element: @element)) %>')
3
3
  $('#element_<%= dom_id(@element) %>').show()
4
4
  clearCurrentElement()
5
5
  $('#questions_list').sortable('refresh');
@@ -1,8 +1,8 @@
1
1
  <p><label for="email_template_name" class="desc">Template Name</label>
2
- <%= f.text_field :name, :class => "text", :size => 93 %></p>
2
+ <%= f.text_field :name, class: "text", size: 93 %></p>
3
3
 
4
4
  <p><label for="email_template_subject" class="desc">Subject</label>
5
- <%= f.text_field :subject, :class => "text", :size => 93 %></p>
5
+ <%= f.text_field :subject, class: "text", size: 93 %></p>
6
6
 
7
7
  <p><label for="email_template_content" class="desc">Content</label>
8
- <%= f.text_area :content, :rows => 25, :cols => 80, :class => "text" %>
8
+ <%= f.text_area :content, rows: 25, cols: 80, class: "text" %>
@@ -3,10 +3,10 @@
3
3
 
4
4
  <%= error_messages_for :email_template %>
5
5
 
6
- <%= form_for(:email_template, :url => fe_admin_email_template_path(@email_template), :html => { :method => :put } ) do |f| %>
7
- <%= render 'form', f: f %>
6
+ <%= form_for(:email_template, url: fe_admin_email_template_path(@email_template), html: { method: :put } ) do |f| %>
7
+ <%= render "form", f: f %>
8
8
 
9
- <p><%= submit_tag "Update" %> or <%= link_to "Cancel", fe_admin_email_templates_path, :class => "cancel" %></p>
9
+ <p><%= submit_tag "Update" %> or <%= link_to "Cancel", fe_admin_email_templates_path, class: "cancel" %></p>
10
10
  <% end %>
11
11
 
12
12
 
@@ -8,13 +8,13 @@
8
8
  </tr>
9
9
  <% for email_template in @email_templates %>
10
10
  <tr class="<%= cycle("","alt") %>">
11
- <td><%= link_to email_template.name, edit_fe_admin_email_template_path(email_template), :class => "email-template" %></td>
12
- <td class="actions"><%= link_to 'Destroy', fe_admin_email_template_path(email_template), data: {confirm: 'Are you sure?'}, :method => :delete, :class => "destroy" %></td>
11
+ <td><%= link_to email_template.name, edit_fe_admin_email_template_path(email_template), class: "email-template" %></td>
12
+ <td class="actions"><%= link_to "Destroy", fe_admin_email_template_path(email_template), data: {confirm: "Are you sure?"}, method: :delete, class: "destroy" %></td>
13
13
  </tr>
14
14
  <% end %>
15
15
  </table>
16
16
 
17
17
  <br />
18
18
 
19
- <%= link_to 'New Template', new_fe_admin_email_template_path, :method => :GET, :class => "add-link" %>
19
+ <%= link_to "New Template", new_fe_admin_email_template_path, method: :GET, class: "add-link" %>
20
20
  </div>
@@ -3,9 +3,9 @@
3
3
 
4
4
  <%= error_messages_for :email_template %>
5
5
 
6
- <%= form_for(:email_template, :url => fe_admin_email_templates_path) do |f| %>
7
- <%= render :partial => 'form', :locals => {:f => f}%>
6
+ <%= form_for(:email_template, url: fe_admin_email_templates_path) do |f| %>
7
+ <%= render partial: "form", locals: {f: f}%>
8
8
 
9
- <p><%= submit_tag "Create" %> or <%= link_to "Cancel", fe_admin_email_templates_path, :class => "cancel" %></p>
9
+ <p><%= submit_tag "Create" %> or <%= link_to "Cancel", fe_admin_email_templates_path, class: "cancel" %></p>
10
10
  <% end %>
11
11
  </div>