fe 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (303) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +36 -1
  3. data/Rakefile +22 -13
  4. data/app/assets/javascripts/application.js.erb +1 -0
  5. data/app/assets/javascripts/fe/admin.js +1 -4
  6. data/app/assets/javascripts/fe/{qe.admin.js → fe.admin.js} +15 -0
  7. data/app/assets/javascripts/fe/{qe.common.js → fe.common.js} +0 -0
  8. data/app/assets/javascripts/fe/{qe.public.js → fe.public.js} +115 -27
  9. data/app/assets/javascripts/fe/rails.extra.js +6 -0
  10. data/app/assets/stylesheets/fe/{qe.screen.css.scss.erb → fe.screen.css.scss.erb} +12 -18
  11. data/app/controllers/fe/admin/elements_controller.rb +4 -4
  12. data/app/controllers/fe/admin/email_templates_controller.rb +10 -4
  13. data/app/controllers/fe/admin/question_pages_controller.rb +3 -3
  14. data/app/controllers/fe/admin/question_sheets_controller.rb +6 -5
  15. data/app/controllers/fe/applications_controller.rb +183 -0
  16. data/app/controllers/fe/concerns/answer_pages_controller_concern.rb +5 -2
  17. data/app/controllers/fe/concerns/answer_sheets_controller_concern.rb +10 -6
  18. data/app/controllers/fe/concerns/application_controller_concern.rb +34 -0
  19. data/app/controllers/fe/payments_controller.rb +184 -0
  20. data/app/controllers/fe/reference_pages_controller.rb +41 -0
  21. data/app/controllers/fe/reference_sheets_controller.rb +1 -1
  22. data/app/controllers/fe/references_controller.rb +74 -0
  23. data/app/controllers/fe/submit_pages_controller.rb +22 -0
  24. data/app/helpers/fe/application_helper.rb +14 -5
  25. data/app/mailers/fe/notifier.rb +1 -1
  26. data/app/models/fe/address.rb +3 -0
  27. data/app/models/fe/answer_pages_presenter.rb +1 -1
  28. data/app/models/fe/answer_sheet.rb +6 -2
  29. data/app/models/fe/answer_sheet_question_sheet.rb +1 -1
  30. data/app/models/fe/application.rb +58 -0
  31. data/app/models/fe/choice_field.rb +1 -1
  32. data/app/models/fe/concerns/answer_concern.rb +10 -11
  33. data/app/models/fe/concerns/answer_pages_presenter_concern.rb +16 -7
  34. data/app/models/fe/concerns/answer_sheet_concern.rb +10 -16
  35. data/app/models/fe/concerns/choice_field_concern.rb +21 -10
  36. data/app/models/fe/condition.rb +1 -1
  37. data/app/models/fe/current_address.rb +12 -0
  38. data/app/models/fe/date_field.rb +3 -3
  39. data/app/models/fe/element.rb +66 -9
  40. data/app/models/fe/email_address.rb +7 -0
  41. data/app/models/fe/email_template.rb +1 -1
  42. data/app/models/fe/option.rb +1 -1
  43. data/app/models/fe/option_group.rb +1 -1
  44. data/app/models/fe/page.rb +13 -4
  45. data/app/models/fe/page_element.rb +13 -1
  46. data/app/models/fe/page_link.rb +1 -1
  47. data/app/models/fe/paragraph.rb +1 -1
  48. data/app/models/fe/payment.rb +32 -7
  49. data/app/models/fe/payment_question.rb +1 -1
  50. data/app/models/fe/person.rb +33 -0
  51. data/app/models/fe/phone_number.rb +5 -0
  52. data/app/models/fe/presenter.rb +3 -2
  53. data/app/models/fe/question.rb +7 -7
  54. data/app/models/fe/question_grid.rb +1 -2
  55. data/app/models/fe/question_set.rb +1 -1
  56. data/app/models/fe/question_sheet.rb +9 -3
  57. data/app/models/fe/reference_question.rb +2 -2
  58. data/app/models/fe/reference_sheet.rb +28 -4
  59. data/app/models/fe/section.rb +1 -1
  60. data/app/models/fe/state_chooser.rb +1 -1
  61. data/app/models/fe/text_field.rb +3 -3
  62. data/app/models/fe/user.rb +3 -0
  63. data/app/models/staff.rb +120 -0
  64. data/app/views/fe/admin/elements/_errors.html.erb +11 -1
  65. data/app/views/fe/admin/elements/create.js.erb +3 -3
  66. data/app/views/fe/admin/elements/destroy.js.erb +2 -2
  67. data/app/views/fe/admin/elements/drop.js.erb +1 -1
  68. data/app/views/fe/admin/elements/duplicate.js.erb +1 -1
  69. data/app/views/fe/admin/elements/edit.js.erb +1 -1
  70. data/app/views/fe/admin/elements/error.js.erb +1 -1
  71. data/app/views/fe/admin/elements/new.js.erb +3 -3
  72. data/app/views/fe/admin/elements/update.js.erb +2 -2
  73. data/app/views/fe/admin/email_templates/edit.html.erb +9 -9
  74. data/app/views/fe/admin/email_templates/index.html.erb +3 -3
  75. data/app/views/fe/admin/email_templates/new.html.erb +2 -2
  76. data/app/views/fe/admin/panels/_advanced_options.html.erb +28 -1
  77. data/app/views/fe/admin/panels/_common_fields.html.erb +1 -1
  78. data/app/views/fe/admin/panels/_condition.html.erb +1 -1
  79. data/app/views/fe/admin/panels/_insert.html.erb +13 -13
  80. data/app/views/fe/admin/panels/_nav_controls.html.erb +4 -4
  81. data/app/views/fe/admin/panels/_page.html.erb +2 -2
  82. data/app/views/fe/admin/panels/_pages_list.html.erb +4 -4
  83. data/app/views/fe/admin/panels/_prop_attachment_field.html.erb +1 -1
  84. data/app/views/fe/admin/panels/_prop_choice_field.html.erb +10 -10
  85. data/app/views/fe/admin/panels/_prop_date_field.html.erb +1 -1
  86. data/app/views/fe/admin/panels/_prop_element.html.erb +7 -7
  87. data/app/views/fe/admin/panels/_prop_page.html.erb +2 -2
  88. data/app/views/fe/admin/panels/_prop_paragraph.html.erb +1 -1
  89. data/app/views/fe/admin/panels/_prop_payment_question.html.erb +1 -0
  90. data/app/views/fe/admin/panels/_prop_question_grid.html.erb +2 -2
  91. data/app/views/fe/admin/panels/_prop_question_grid_with_total.html.erb +1 -1
  92. data/app/views/fe/admin/panels/_prop_reference_question.html.erb +2 -2
  93. data/app/views/fe/admin/panels/_prop_section.html.erb +1 -1
  94. data/app/views/fe/admin/panels/_prop_sheet.html.erb +9 -9
  95. data/app/views/fe/admin/panels/_prop_text_field.html.erb +10 -10
  96. data/app/views/fe/admin/question_pages/_element.html.erb +5 -5
  97. data/app/views/fe/admin/question_pages/_element_show.html.erb +1 -1
  98. data/app/views/fe/admin/question_pages/_errors.html.erb +10 -1
  99. data/app/views/fe/admin/question_pages/_question_page.html.erb +3 -3
  100. data/app/views/fe/admin/question_pages/create.js.erb +3 -3
  101. data/app/views/fe/admin/question_pages/destroy.js.erb +3 -3
  102. data/app/views/fe/admin/question_pages/edit.js.erb +1 -1
  103. data/app/views/fe/admin/question_pages/show.js.erb +3 -2
  104. data/app/views/fe/admin/question_pages/show_panel.js.erb +1 -1
  105. data/app/views/fe/admin/question_sheets/_errors.html.erb +11 -1
  106. data/app/views/fe/admin/question_sheets/edit.js.erb +1 -1
  107. data/app/views/fe/admin/question_sheets/error.js.erb +1 -1
  108. data/app/views/fe/admin/question_sheets/index.html.erb +8 -8
  109. data/app/views/fe/admin/question_sheets/new.html.erb +1 -1
  110. data/app/views/fe/admin/question_sheets/show.html.erb +18 -18
  111. data/app/views/fe/admin/question_sheets/update.js.erb +1 -1
  112. data/app/views/fe/answer_pages/_answer_page.html.erb +27 -30
  113. data/app/views/fe/answer_pages/_element.html.erb +5 -1
  114. data/app/views/fe/answer_pages/update.js.erb +1 -1
  115. data/app/views/fe/answer_sheets/_answer_sheet.html.erb +16 -14
  116. data/app/views/fe/answer_sheets/_element.html.erb +1 -1
  117. data/app/views/fe/answer_sheets/_incomplete.html.erb +8 -8
  118. data/app/views/fe/answer_sheets/_page_link.html.erb +2 -2
  119. data/app/views/fe/answer_sheets/_pages_list.html.erb +4 -4
  120. data/app/views/fe/answer_sheets/_title.html.erb +1 -1
  121. data/app/views/fe/answer_sheets/edit.html.erb +59 -53
  122. data/app/views/fe/answer_sheets/incomplete.js.erb +2 -2
  123. data/app/views/fe/answer_sheets/send_reference_invite.js.erb +1 -1
  124. data/app/views/fe/application/_logout.html.erb +1 -0
  125. data/app/views/fe/payment_pages/_credit.html.erb +47 -0
  126. data/app/views/fe/payment_pages/_mail.html.erb +27 -0
  127. data/app/views/fe/payment_pages/_payment.html.erb +6 -0
  128. data/app/views/fe/payment_pages/_staff.html.erb +25 -0
  129. data/app/views/fe/payment_pages/_staff_results.html.erb +17 -0
  130. data/app/views/fe/payment_pages/edit.html.erb +75 -0
  131. data/app/views/fe/payment_pages/staff_search.js.erb +2 -0
  132. data/app/views/fe/payments/_credit.html.erb +47 -0
  133. data/app/views/fe/payments/_errors.html.erb +1 -0
  134. data/app/views/fe/payments/_payment.html.erb +13 -0
  135. data/app/views/fe/payments/_staff.html.erb +21 -0
  136. data/app/views/fe/payments/_staff_results.html.erb +18 -0
  137. data/app/views/fe/payments/approve.js.erb +3 -0
  138. data/app/views/fe/payments/create.js.erb +19 -0
  139. data/app/views/fe/payments/destroy.js.erb +7 -0
  140. data/app/views/fe/payments/edit.html.erb +56 -0
  141. data/app/views/fe/payments/error.js.erb +3 -0
  142. data/app/views/fe/payments/no_access.html.erb +7 -0
  143. data/app/views/fe/payments/staff_search.js.erb +1 -0
  144. data/app/views/fe/payments/update.html.erb +24 -0
  145. data/app/views/fe/questions/{_acceptance.html.erb → fe/_acceptance.html.erb} +0 -0
  146. data/app/views/fe/questions/{_attachment_field.html.erb → fe/_attachment_field.html.erb} +2 -2
  147. data/app/views/fe/questions/{_checkbox_field.html.erb → fe/_checkbox_field.html.erb} +1 -1
  148. data/app/views/fe/questions/{_country.html.erb → fe/_country.html.erb} +1 -1
  149. data/app/views/fe/questions/{_date_field.html.erb → fe/_date_field.html.erb} +0 -0
  150. data/app/views/fe/questions/{_date_field_mmyy.html.erb → fe/_date_field_mmyy.html.erb} +0 -0
  151. data/app/views/fe/questions/{_drop_down_field.html.erb → fe/_drop_down_field.html.erb} +1 -1
  152. data/app/views/fe/questions/fe/_paragraph.html.erb +1 -0
  153. data/app/views/fe/questions/fe/_payment_question.html.erb +70 -0
  154. data/app/views/fe/questions/{_question_grid.html.erb → fe/_question_grid.html.erb} +7 -7
  155. data/app/views/fe/questions/{_question_grid_with_total.html.erb → fe/_question_grid_with_total.html.erb} +1 -1
  156. data/app/views/fe/questions/{_questions.html.erb → fe/_questions.html.erb} +2 -2
  157. data/app/views/fe/questions/{_radio_button_field.html.erb → fe/_radio_button_field.html.erb} +13 -11
  158. data/app/views/fe/questions/{_rating.html.erb → fe/_rating.html.erb} +0 -0
  159. data/app/views/fe/questions/fe/_reference_discipler.html.erb +1 -0
  160. data/app/views/fe/questions/fe/_reference_friend.html.erb +1 -0
  161. data/app/views/fe/questions/fe/_reference_parent.html.erb +1 -0
  162. data/app/views/fe/questions/fe/_reference_peer.html.erb +1 -0
  163. data/app/views/fe/questions/fe/_reference_question.html.erb +38 -0
  164. data/app/views/fe/questions/fe/_reference_roommate.html.erb +1 -0
  165. data/app/views/fe/questions/fe/_reference_spiritual.html.erb +1 -0
  166. data/app/views/fe/questions/fe/_reference_staff.html.erb +1 -0
  167. data/app/views/fe/questions/fe/_section.html.erb +1 -0
  168. data/app/views/fe/questions/{_state_chooser.html.erb → fe/_state_chooser.html.erb} +0 -0
  169. data/app/views/fe/questions/{_text_area_field.html.erb → fe/_text_area_field.html.erb} +0 -0
  170. data/app/views/fe/questions/{_text_field.html.erb → fe/_text_field.html.erb} +0 -0
  171. data/app/views/fe/questions/{_yes_no.html.erb → fe/_yes_no.html.erb} +6 -6
  172. data/app/views/fe/questions/{_yes_no_field.erb → fe/_yes_no_field.erb} +1 -1
  173. data/app/views/fe/reference_pages/_reference.html.erb +31 -0
  174. data/app/views/fe/reference_pages/edit.html.erb +24 -0
  175. data/app/views/fe/reference_sheets/done.html.erb +2 -0
  176. data/app/views/fe/reference_sheets/submitted.js.erb +1 -0
  177. data/app/views/fe/references/edit.html.erb +8 -0
  178. data/app/views/fe/references/send_invite.js.erb +7 -0
  179. data/app/views/fe/references/show.html.erb +18 -0
  180. data/app/views/fe/references/submit.js.erb +3 -0
  181. data/app/views/fe/submit_pages/_errors.html.erb +1 -0
  182. data/app/views/fe/submit_pages/_thankyou.html.erb +2 -0
  183. data/app/views/fe/submit_pages/edit.html.erb +36 -0
  184. data/app/views/fe/submit_pages/error.js.erb +1 -0
  185. data/app/views/fe/submit_pages/submit.js.erb +3 -0
  186. data/app/views/layouts/fe/application.html.erb +30 -13
  187. data/app/views/layouts/fe/{qe.admin.html.erb → fe.admin.html.erb} +1 -1
  188. data/config/locales/en.yml +37 -0
  189. data/config/routes.rb +69 -27
  190. data/db/migrate/20131003041856_core.rb +4 -4
  191. data/db/migrate/20131003044518_create_email_templates.rb +1 -1
  192. data/db/migrate/20140623153424_create_fe_people.rb +12 -0
  193. data/db/migrate/20140624180246_create_fe_addresses.rb +20 -0
  194. data/db/migrate/20140624182216_create_create_fe_phone_numbers.rb +16 -0
  195. data/db/migrate/20140625160545_create_fe_users.rb +12 -0
  196. data/db/migrate/20140808202507_add_conditional_type_to_elements.rb +5 -0
  197. data/db/migrate/20140808203609_add_conditional_answer_to_elements.rb +5 -0
  198. data/db/migrate/20140828045339_create_payments.rb +13 -0
  199. data/db/migrate/20141103204704_remove_short_value_column.rb +5 -0
  200. data/db/migrate/20141109154522_move_conditional_ids_used_for_choice_field_to_their_own_column.rb +7 -0
  201. data/db/seeds.rb +7 -0
  202. data/lib/fe.rb +1 -1
  203. data/lib/fe/engine.rb +46 -1
  204. data/lib/fe/version.rb +1 -1
  205. data/lib/tasks/fe_tasks.rake +14 -0
  206. data/spec/controllers/fe/admin/elements_controller_spec.rb +1 -1
  207. data/spec/controllers/fe/admin/email_templates_controller_spec.rb +1 -1
  208. data/spec/controllers/fe/admin/question_pages_controller_spec.rb +1 -1
  209. data/spec/controllers/fe/admin/question_sheets_controller_spec.rb +1 -1
  210. data/spec/controllers/fe/answer_pages_controller_spec.rb +1 -1
  211. data/spec/controllers/fe/answer_sheets_controller_spec.rb +1 -1
  212. data/spec/controllers/fe/reference_sheets_controller_spec.rb +1 -1
  213. data/spec/dummy/README.rdoc +28 -0
  214. data/spec/dummy/Rakefile +6 -0
  215. data/spec/dummy/app/assets/javascripts/application.js +13 -0
  216. data/spec/dummy/app/assets/stylesheets/application.css +15 -0
  217. data/spec/dummy/app/controllers/application_controller.rb +5 -0
  218. data/spec/dummy/app/helpers/application_helper.rb +2 -0
  219. data/spec/dummy/app/views/layouts/application.html.erb +14 -0
  220. data/spec/dummy/bin/bundle +3 -0
  221. data/spec/dummy/bin/rails +4 -0
  222. data/spec/dummy/bin/rake +4 -0
  223. data/spec/dummy/config.ru +4 -0
  224. data/spec/dummy/config/application.rb +29 -0
  225. data/spec/dummy/config/boot.rb +5 -0
  226. data/spec/dummy/config/database.yml +25 -0
  227. data/spec/dummy/config/environment.rb +5 -0
  228. data/spec/dummy/config/environments/development.rb +37 -0
  229. data/spec/dummy/config/environments/production.rb +82 -0
  230. data/spec/dummy/config/environments/test.rb +39 -0
  231. data/spec/dummy/config/initializers/assets.rb +8 -0
  232. data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
  233. data/spec/dummy/config/initializers/cookies_serializer.rb +3 -0
  234. data/spec/dummy/config/initializers/filter_parameter_logging.rb +4 -0
  235. data/spec/dummy/config/initializers/inflections.rb +16 -0
  236. data/spec/dummy/config/initializers/mime_types.rb +4 -0
  237. data/spec/dummy/config/initializers/session_store.rb +3 -0
  238. data/spec/dummy/config/initializers/wrap_parameters.rb +14 -0
  239. data/spec/dummy/config/locales/en.yml +23 -0
  240. data/spec/dummy/config/routes.rb +56 -0
  241. data/spec/dummy/config/secrets.yml +22 -0
  242. data/spec/dummy/db/schema.rb +203 -0
  243. data/spec/dummy/db/test.sqlite3 +0 -0
  244. data/spec/dummy/log/test.log +440 -0
  245. data/spec/dummy/public/404.html +67 -0
  246. data/spec/dummy/public/422.html +67 -0
  247. data/spec/dummy/public/500.html +66 -0
  248. data/spec/dummy/public/favicon.ico +0 -0
  249. data/spec/factories/answer_sheet_question_sheets.rb +4 -0
  250. data/spec/factories/answer_sheets.rb +1 -1
  251. data/spec/factories/applications.rb +7 -0
  252. data/spec/factories/elements.rb +19 -0
  253. data/spec/factories/fe_addresses.rb +14 -0
  254. data/spec/factories/fe_email_addresses.rb +7 -0
  255. data/spec/factories/fe_people.rb +10 -0
  256. data/spec/factories/fe_phone_numbers.rb +7 -0
  257. data/spec/factories/page.rb +9 -0
  258. data/spec/factories/page_elements.rb +5 -0
  259. data/spec/factories/payments.rb +7 -0
  260. data/spec/factories/question_sheet.rb +10 -0
  261. data/spec/models/fe/answer_sheet_question_sheet_spec.rb +3 -3
  262. data/spec/models/fe/answer_spec.rb +5 -5
  263. data/spec/models/fe/application_spec.rb +8 -0
  264. data/spec/models/fe/attachment_field_spec.rb +1 -1
  265. data/spec/models/fe/choice_field_spec.rb +29 -2
  266. data/spec/models/fe/condition_spec.rb +5 -5
  267. data/spec/models/fe/date_field_spec.rb +9 -9
  268. data/spec/models/fe/element_spec.rb +139 -9
  269. data/spec/models/fe/email_template_spec.rb +2 -2
  270. data/spec/models/fe/option_group_spec.rb +1 -1
  271. data/spec/models/fe/option_spec.rb +1 -1
  272. data/spec/models/fe/page_element_spec.rb +3 -3
  273. data/spec/models/fe/page_link_spec.rb +1 -1
  274. data/spec/models/fe/page_spec.rb +43 -11
  275. data/spec/models/fe/paragraph_spec.rb +4 -4
  276. data/spec/models/fe/payment_question_spec.rb +65 -0
  277. data/spec/models/fe/person_spec.rb +4 -0
  278. data/spec/models/fe/question_grid_spec.rb +1 -1
  279. data/spec/models/fe/question_grid_with_total_spec.rb +1 -1
  280. data/spec/models/fe/question_set_spec.rb +1 -1
  281. data/spec/models/fe/question_sheet_spec.rb +5 -5
  282. data/spec/models/fe/question_spec.rb +13 -12
  283. data/spec/models/fe/reference_question_spec.rb +4 -4
  284. data/spec/models/fe/reference_sheet_spec.rb +8 -8
  285. data/spec/models/fe/section_spec.rb +1 -1
  286. data/spec/models/fe/state_chooser_spec.rb +1 -1
  287. data/spec/models/fe/text_field_spec.rb +3 -3
  288. data/spec/{spec_helper.rb → rails_helper.rb} +3 -3
  289. data/spec/support/database.txt +3 -3
  290. metadata +261 -75
  291. data/app/views/fe/questions/_paragraph.html.erb +0 -1
  292. data/app/views/fe/questions/_reference_discipler.html.erb +0 -1
  293. data/app/views/fe/questions/_reference_friend.html.erb +0 -1
  294. data/app/views/fe/questions/_reference_parent.html.erb +0 -1
  295. data/app/views/fe/questions/_reference_peer.html.erb +0 -1
  296. data/app/views/fe/questions/_reference_question.html.erb +0 -38
  297. data/app/views/fe/questions/_reference_roommate.html.erb +0 -1
  298. data/app/views/fe/questions/_reference_spiritual.html.erb +0 -1
  299. data/app/views/fe/questions/_reference_staff.html.erb +0 -1
  300. data/app/views/fe/questions/_section.html.erb +0 -1
  301. data/lib/generators/fe/install_generator.rb +0 -132
  302. data/lib/tasks/qe_tasks.rake +0 -4
  303. data/spec/models/fe/answer_sheet_spec.rb +0 -8
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e6fb928bc8a7a5dc262c00b6cd4a6e0f03fb48ad
4
- data.tar.gz: 19fe655b392bc19829ec71a9f9e9ffe77f7e2396
3
+ metadata.gz: ab8bef6577ff95fc7c33695a64217ca1436844ae
4
+ data.tar.gz: bf3d6f5eac700ce6c9d2185aa0a655f3825f100a
5
5
  SHA512:
6
- metadata.gz: 0d8bdb48f8d3bb12d862924535ae1d710b9fe2df2b5c9529825f379f274f72662c99107bc5cd847471ba165d5f1497b744d5c40b48e1e5693d1a110300cdbcab
7
- data.tar.gz: 631b59ab65ee309d80a7e7419fddee57d5922d62006345a4db35f5200c7d938662410141d35f5f34991a224d3299eed433d0dcd4d467624b590e8501e7b50f53
6
+ metadata.gz: cd8180a211513f1651368c173d330fd22a8a25b5837a6ccf56e302db02c48416adb962eed75af11c9b728cd4f26259352fc32d124581cf7f0e519e74fe884d6c
7
+ data.tar.gz: 113bd04128aa3e34002305267127fab5e43b3741a4686c49228d560f73535cf9117390faaaa90ed9b1756ea494eee3357900730fa2980058bffe18bdf0a0ae53
data/README.md CHANGED
@@ -7,6 +7,7 @@ This project rocks and uses MIT-LICENSE.
7
7
  ### Development
8
8
 
9
9
  ### Testing
10
+
10
11
  Setup a testing environment that mimics the Travis CI setup:
11
12
 
12
13
  rake setup_dummy_app
@@ -15,6 +16,40 @@ Run specs:
15
16
 
16
17
  rake spec
17
18
 
18
-
19
+ Run a specific spec:
20
+
21
+ ruby -I$GEM_HOME/gems/rspec-core-3.0.2/lib:$GEM_HOME/gems/rspec-support-3.0.2/lib -S -I fe/spec rspec spec/models/fe/element_spec.rb
22
+
23
+ ### Example enclosing app
24
+
25
+ rails new
26
+
27
+ ## install devise
28
+
29
+ # add to gemfile
30
+
31
+ gem 'devise'
32
+
33
+ # run
34
+
35
+ bundle install
36
+ rails generate devise:install
37
+ rails generate devise User
38
+
39
+ # add to gemfile
40
+
41
+ github: 'CruGlobal/qe', branch: 'fe'
42
+
43
+ # run
44
+
45
+ bundle exec rake fe_engine:install:migrations
46
+
47
+ # add example user
48
+
49
+ bundle exec rails console
50
+
51
+ User.new({ :email => 'user@example.com', :password => 'password', :password_confirmation => 'password'}).save
19
52
 
53
+ # start server
20
54
 
55
+ bundle exec rails server
data/Rakefile CHANGED
@@ -1,27 +1,32 @@
1
- begin
2
- require 'bundler/setup'
3
- rescue LoadError
4
- puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
5
- end
1
+ require 'bundler/setup'
2
+ require 'thor'
6
3
 
7
4
  APP_RAKEFILE = File.expand_path("../spec/dummy/Rakefile", __FILE__)
8
5
  load 'rails/tasks/engine.rake' if File.exists? 'spec/dummy/Rakefile'
9
6
 
7
+
10
8
  Bundler::GemHelper.install_tasks
11
9
 
10
+ ENV['ENGINE'] = 'fe_engine'
11
+
12
12
  require "rspec/core/rake_task"
13
13
  RSpec::Core::RakeTask.new(:spec) do |spec|
14
- spec.pattern = 'spec/**/*_spec.rb'
14
+ unless File.directory?("spec/dummy")
15
+ Rake::Task['dummy:app'].invoke unless ENV['SKIP_DUMMY_APP']
16
+ end
17
+ spec.rspec_opts = "-I #{File.expand_path('../spec/', __FILE__)}"
18
+ spec.pattern = FileList[File.expand_path('../spec/**/*_spec.rb', __FILE__)]
15
19
  end
16
20
  task default: :spec
17
21
 
18
- ENV['DUMMY_PATH'] = 'spec/dummy'
22
+
23
+ require 'rails/dummy/tasks'
24
+
19
25
  # ENV['ENGINE']
20
26
  # ENV['TEMPLATE']
21
27
 
22
28
  task :setup_dummy_app do
23
29
  # Nuke any previous testing envs (for local development purposes).
24
- Rake::Task["app:db:drop"].invoke if Dir.exists? "spec/dummy"
25
30
  FileUtils.remove_dir("spec/dummy", force=true) if Dir.exists? "spec/dummy"
26
31
 
27
32
  # Use system here (rather than Rake::Task['task'].invoke) so a new rails env
@@ -30,19 +35,23 @@ task :setup_dummy_app do
30
35
  # because the "deleted" spec/dummy would still have it's "Dummy" rails app
31
36
  # name in the Ruby VM environment.
32
37
  #
33
- system({"DISABLE_MIGRATE" => "true", "DISABLE_CREATE" => "true"}, "rake dummy:app")
38
+ system({"DISABLE_MIGRATE" => "true",
39
+ "DISABLE_CREATE" => "true"}, "rake dummy:app")
34
40
 
35
41
  # Bring in the customized mysql/postgres testing database.yml.
36
- File.delete("spec/dummy/config/database.yml")
37
- FileUtils.cp("spec/support/database.txt", "spec/dummy/config/database.yml")
42
+ database_path = "spec/dummy/config/database.yml"
43
+ File.delete(database_path) if File.exists?(database_path)
44
+ FileUtils.cp("spec/support/database.txt", database_path)
38
45
 
39
46
  Rake::Task["install_engine"].invoke
40
47
  end
41
48
 
42
49
  task :install_engine do
43
50
  # Use system so that we load the dummy app's Rake commands.
44
- system("rake app:db:create")
51
+
52
+ # Drop any existing db so that it is recreated; Hide output so there's no stack trace if the db doesn't exist
53
+ system('cd spec/dummy && rake db:drop >/dev/null 2>&1')
45
54
 
46
55
  # Use system so that we funcitonally test the install generator.
47
- system("cd spec/dummy && rails g fe:install && rake db:migrate && rake db:test:prepare")
56
+ system("cd spec/dummy && rake db:create && rake db:migrate && rake db:test:prepare")
48
57
  end
@@ -0,0 +1 @@
1
+ //= require fe.public.js
@@ -1,7 +1,4 @@
1
- //= require jquery
2
- //= require jquery_ujs
3
- //= require jquery.ui.all
4
1
  //= require fe/fe.common.js
5
2
  //= require fe/fe.admin.js
6
3
  //= require fe/jquery.scrollTo-min.js
7
- //= require rails.extra.js
4
+ //= require fe/rails.extra.js
@@ -31,6 +31,21 @@ $(function() {
31
31
  return false;
32
32
  });
33
33
 
34
+ $(document).on('click', 'input[name=future_affect][type=radio]', function() {
35
+ if ($(this).val() == "yes") {
36
+ $(".future_answer, .future_target").show();
37
+ } else if ($(this).val() == "no") {
38
+ $(".future_answer, .future_target").hide();
39
+ }
40
+ });
41
+
42
+ $(document).on('click', "input[name='element[conditional_type]'][type=radio]", function() {
43
+ if ($(this).val() == "Fe::Page") {
44
+ $(".future_page").show();
45
+ } else if ($(this).val() == "Fe::Element") {
46
+ $(".future_page").hide();
47
+ }
48
+ });
34
49
  });
35
50
  // used by form designer
36
51
 
@@ -1,13 +1,26 @@
1
+ //= require jquery
2
+ //= require jquery_ujs
3
+ //= require jquery-ui
4
+ //= require fe/fe.common.js
5
+ //= require fe/jquery.scrollTo-min.js
6
+ //= require fe/rails.extra.js
7
+ //= require fe/jquery.validate.pack.js
8
+
1
9
  // used by answer sheets
10
+
2
11
  (function($) {
12
+ //debugger;
3
13
  $(function() {
4
14
 
5
15
  $(document).on('click', '.save_button', function() {
6
16
  $.fe.pageHandler.savePage($(this).closest('.answer-page'), true);
7
17
  });
8
18
 
19
+ //debugger;
9
20
  $(document).on('keydown', '#payment_staff_first, #payment_staff_last', function(e) {
21
+ //debugger;
10
22
  if (e.which == 13) {
23
+ console.log('staff_search click');
11
24
  $('#staff_search').trigger('click');
12
25
  return false;
13
26
  }
@@ -44,6 +57,33 @@
44
57
  $(this).parent().find('.charsRemaining').html('');
45
58
  });
46
59
 
60
+ // Payment submission
61
+ $(document).on('click', '.submit_payment', function() {
62
+ var form = $(this).closest('form');
63
+ $this = $(this);
64
+ $.ajax({url: $(this).attr('data-url'), data: form.serializeArray(), type: 'POST', dataType:'script',
65
+ beforeSend: function (xhr) {
66
+ $('body').trigger('ajax:loading', xhr);
67
+ if ($this.data('disable-with') !== null) {
68
+ $this.attr('disabled','disabled');
69
+ $this.data('enabled-text', $(this).html());
70
+ $this.attr('value', $this.data('disable-with'));
71
+ }
72
+ },
73
+ complete: function (xhr) {
74
+ $('body').trigger('ajax:complete', xhr);
75
+ $this.removeAttr('disabled');
76
+ $this.attr('value', $this.data('enabled-text'));
77
+ },
78
+ error: function (xhr, status, error) {
79
+ $('body').trigger('ajax:failure', [xhr, status, error]);
80
+ $this.removeAttribute('disabled');
81
+ $this.attr('value', $this.data('enabled-text'));
82
+ }
83
+ });
84
+ return false;
85
+ });
86
+
47
87
  });
48
88
  $.fe = {};
49
89
  $.fe.pageHandler = {
@@ -150,25 +190,32 @@
150
190
  // save form if any changes were made
151
191
  savePage : function(page, force) {
152
192
  if (page == null) page = $('#' + this.current_page);
153
- form_data = this.captureForm(page);
154
- if( form_data ) {
155
- if( page.data('form_data') == null || page.data('form_data').data !== form_data.data || force === true) { // if any changes
156
- page.data('form_data', form_data);
157
- $.ajax({url: form_data.url, type: 'put', data: form_data.data, beforeSend: function (xhr) {
158
- $('#spinner_' + page.attr('id')).show();
159
- },
160
- complete: function (xhr) {
161
- $('#spinner_' + page.attr('id')).hide();
162
- },
163
- error: function() {
164
- page.data('form_data', null); // on error, force save for next call to save
165
- // WARNING: race conditions with load & show?
166
- // sort of a mess if save fails while another page is already loading!!
167
- }});
168
- }
169
- }
170
- // Update last saved stamp
171
- },
193
+ // don't save more than once per second
194
+ timeNow = new Date();
195
+ if (typeof(lastSave) != "undefined" && lastSave && !force && (timeNow - lastSave < 1000)) {
196
+ return true;
197
+ }
198
+ lastSave = timeNow;
199
+ form_data = this.captureForm(page);
200
+ if( form_data ) {
201
+ if( page.data('form_data') == null || page.data('form_data').data !== form_data.data || force === true) { // if any changes
202
+ page.data('form_data', form_data);
203
+ $.ajax({url: form_data.url, type: 'put', data: form_data.data,
204
+ beforeSend: function (xhr) {
205
+ $('#spinner_' + page.attr('id')).show();
206
+ },
207
+ complete: function (xhr) {
208
+ $('#spinner_' + page.attr('id')).hide();
209
+ },
210
+ error: function() {
211
+ page.data('form_data', null); // on error, force save for next call to save
212
+ // WARNING: race conditions with load & show?
213
+ // sort of a mess if save fails while another page is already loading!!
214
+ }});
215
+ }
216
+ }
217
+ // Update last saved stamp
218
+ },
172
219
 
173
220
  savePages : function(force) {
174
221
  $('.answer-page').each(function() {$.fe.pageHandler.savePage($(this), force)})
@@ -244,7 +291,7 @@
244
291
  var all_valid = ($('#list-pages li.incomplete').length == 0);
245
292
 
246
293
  // Make sure any necessary payments are made
247
- var payments_made = $('.payment_question.required').length == $('.payment').length
294
+ var payments_made = $('.payment_question.required').length <= $('.payment').length
248
295
 
249
296
 
250
297
  if( payments_made)
@@ -287,13 +334,54 @@
287
334
  }
288
335
  },
289
336
 
290
- // is page loaded? (useful for toggling enabled state of questions)
291
- isPageLoaded : function(page)
292
- {
293
- return $('#' + page)[0] != null
294
- }
295
-
296
- };
337
+ // is page loaded? (useful for toggling enabled state of questions)
338
+ isPageLoaded : function(page)
339
+ {
340
+ return $('#' + page)[0] != null
341
+ },
342
+
343
+ checkConditional : function($element_li) {
344
+ matchable_answers = String($element_li.data('conditional_answer')).split(',').map(function(s) { return s.trim(); })
345
+ if ($element_li.hasClass('fe::choicefield') && $element_li.hasClass('yes-no')) {
346
+ if ($(matchable_answers).filter([1, '1', true, 'true', 'yes']).length > 0) {
347
+ matchable_answers = [1, '1', true, 'true', 'yes'];
348
+ }
349
+ vals = $([$element_li.find("input[type=radio]:checked").val()]);
350
+ } else if ($element_li.hasClass('fe::choicefield') && $element_li.hasClass('checkbox')) {
351
+ vals = $element_li.find("input[type=checkbox]:checked").map(function(i, el) { return $(el).val(); });
352
+ } else {
353
+ vals = $([$element_li.find("input:visible, select:visible").val()]);
354
+ }
355
+ match = $(matchable_answers).filter(vals).length > 0;
356
+
357
+ console.log('checkConditional match: ' + match);
358
+
359
+ switch ($element_li.data('conditional_type')) {
360
+ case 'Fe::Element':
361
+ if (match) {
362
+ $("#element_" + $element_li.data('conditional_id')).show();
363
+ } else {
364
+ $("#element_" + $element_li.data('conditional_id')).hide();
365
+ }
366
+ case 'Fe::Page':
367
+ li_id = "li#fe_application_" + $element_li.data('application_id') + '-fe_page_' + $element_li.data('conditional_id') + '-li';
368
+ if (match) {
369
+ $(li_id).show();
370
+ } else {
371
+ $(li_id).hide();
372
+ }
373
+ }
374
+ }
375
+
376
+ };
377
+
378
+ $(document).on('click', "li.conditional input, li.conditional select", function() {
379
+ console.log('click');
380
+ $.fe.pageHandler.checkConditional($(this).closest('li'));
381
+ });
382
+ $(document).on('keyup', "li.conditional input, li.conditional select", function() { $(this).click(); });
383
+ $(document).on('blug', "li.conditional input, li.conditional select", function() { $(this).click(); });
384
+ $(document).on('change', "li.conditional select", function() { $(this).click(); });
297
385
 
298
386
  })(jQuery);
299
387
 
@@ -0,0 +1,6 @@
1
+ (function($) {
2
+ // Enable sortable items
3
+ $(function() {
4
+ setUpJsHelpers();
5
+ });
6
+ })(jQuery);
@@ -2,6 +2,10 @@
2
2
  /* Summer Project Form Engines */
3
3
  /* *********************************************************** */
4
4
 
5
+ /*
6
+ *= require jquery-ui
7
+ */
8
+
5
9
  /* RESET */
6
10
  ul, li, body, p {
7
11
  list-style: none;
@@ -90,24 +94,15 @@ ul#list-pages {
90
94
  margin: 20px 0 0 0;
91
95
  }
92
96
 
93
- #list-pages li a {
94
- background: url("<%= asset_path('fe/icons/document--pencil.png') %>") no-repeat 4px 50%;
95
- padding: 8px 0 8px 24px;
96
- border-bottom: 1px dotted #999;
97
- display: block;
98
- margin-right: 8px;
97
+ #list-pages li {
98
+ padding: 3px 0;
99
99
  }
100
100
 
101
- #list-pages li.active {
102
- background-color: #fff;
101
+ #list-pages li a {
102
+ padding: 2px 0;
103
103
  }
104
104
 
105
- #list-pages li.active a {
106
- margin-right: 0;
107
- border: 1px solid #F7931E;
108
- border-right: none;
109
- margin-top: -1px;
110
- }
105
+ #list-pages li.active a {}
111
106
 
112
107
  #link-page-add {
113
108
  background: #f0f0f0 url("<%= asset_path('fe/icons/add.png') %>") no-repeat 4px 50%;
@@ -193,7 +188,6 @@ ul#nav-controls li a:hover {
193
188
  #preview {
194
189
  width: 689px;
195
190
  float: right;
196
- border: 1px solid #F7931E;
197
191
  padding: 10px;
198
192
  }
199
193
 
@@ -546,7 +540,7 @@ td.actions a {padding: 2px 10px 2px 20px;}
546
540
  padding: 5px;
547
541
 
548
542
  ul {
549
- color:red;
550
- font-weight: bold;
543
+ color:red;
544
+ font-weight: bold;
551
545
  }
552
- }
546
+ }
@@ -1,6 +1,6 @@
1
1
  class Fe::Admin::ElementsController < ApplicationController
2
2
  before_filter :check_valid_user
3
- layout 'fe.admin'
3
+ layout 'fe/fe.admin'
4
4
 
5
5
  before_filter :get_page
6
6
 
@@ -157,9 +157,9 @@ class Fe::Admin::ElementsController < ApplicationController
157
157
  if element.question_grid_id
158
158
  element.set_position(element.question_grid.position(@page), @page)
159
159
  element.question_grid_id = nil
160
- elsif element.conditional_id
160
+ elsif element.choice_field_id
161
161
  element.set_position(element.choice_field.position(@page), @page)
162
- element.conditional_id = nil
162
+ element.choice_field_id = nil
163
163
  end
164
164
  element.save!
165
165
  render :action => :drop
@@ -179,7 +179,7 @@ class Fe::Admin::ElementsController < ApplicationController
179
179
  end
180
180
 
181
181
  def element_params
182
- params.fetch(:element, {}).permit(:style, :label, :tooltip, :position, :source, :value_xpath, :text_xpath, :question_grid_id, :cols, :total_cols, :css_id, :css_class, :related_question_sheet_id, :conditional_id, :hide_option_labels, :slug, :required, :is_confidential, :hide_label, :object_name, :attribute_name, :max_length)
182
+ params.fetch(:element, {}).permit(:style, :label, :tooltip, :position, :source, :value_xpath, :text_xpath, :question_grid_id, :cols, :total_cols, :css_id, :css_class, :related_question_sheet_id, :conditional_id, :hide_option_labels, :slug, :required, :is_confidential, :hide_label, :object_name, :attribute_name, :max_length, :content, :conditional_type, :conditional_id, :conditional_answer)
183
183
  end
184
184
 
185
185
  end