fe 0.0.4 → 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.
- checksums.yaml +5 -5
- data/README.md +4 -4
- data/Rakefile +16 -36
- data/app/assets/config/fe/manifest.js +3 -0
- data/app/assets/config/manifest.js +3 -0
- data/app/assets/javascripts/application.js.erb +1 -1
- data/app/assets/javascripts/fe/admin.js +0 -2
- data/app/assets/javascripts/fe/fe.admin.js +40 -20
- data/app/assets/javascripts/fe/fe.common.js.erb +98 -0
- data/app/assets/javascripts/fe/fe.public.js +2 -416
- data/app/assets/javascripts/fe/fe.public.nojquery.js.erb +526 -0
- data/app/assets/javascripts/fe/jquery.html5_upload.js +258 -0
- data/app/assets/javascripts/fe/jquery.validate.pack.js +3 -15
- data/app/assets/stylesheets/fe/fe.screen.css.scss.erb +90 -10
- data/app/assets/stylesheets/fe/validation.css +5 -1
- data/app/controllers/concerns/fe/admin/question_sheets_controller_concern.rb +111 -0
- data/app/controllers/concerns/fe/answer_pages_controller_concern.rb +131 -0
- data/app/controllers/{fe/concerns → concerns/fe}/answer_sheets_controller_concern.rb +15 -7
- data/app/controllers/{fe/concerns → concerns/fe}/application_controller_concern.rb +15 -2
- data/app/controllers/fe/admin/elements_controller.rb +102 -64
- data/app/controllers/fe/admin/email_templates_controller.rb +7 -7
- data/app/controllers/fe/admin/question_pages_controller.rb +9 -9
- data/app/controllers/fe/admin/question_sheets_controller.rb +2 -103
- data/app/controllers/fe/reference_pages_controller.rb +11 -11
- data/app/controllers/fe/reference_sheets_controller.rb +6 -4
- data/app/controllers/fe/references_controller.rb +20 -19
- data/app/controllers/fe/submit_pages_controller.rb +5 -5
- data/app/helpers/fe/answer_pages_helper.rb +1 -1
- data/app/helpers/fe/application_helper.rb +8 -3
- data/app/jobs/fe/update_reference_sheet_visibility_job.rb +11 -0
- data/app/mailers/fe/notifier.rb +12 -5
- data/app/models/answer_sheet.rb +2 -0
- data/app/models/application_record.rb +3 -0
- data/app/models/{fe/concerns → concerns/fe}/answer_concern.rb +2 -2
- data/app/models/{fe/concerns → concerns/fe}/answer_pages_presenter_concern.rb +15 -5
- data/app/models/concerns/fe/answer_sheet_concern.rb +125 -0
- data/app/models/{fe/concerns → concerns/fe}/choice_field_concern.rb +56 -31
- data/app/models/fe/address.rb +2 -2
- data/app/models/fe/answer.rb +1 -1
- data/app/models/fe/answer_sheet.rb +1 -1
- data/app/models/fe/answer_sheet_question_sheet.rb +2 -2
- data/app/models/fe/application.rb +15 -10
- data/app/models/fe/condition.rb +4 -4
- data/app/models/fe/date_field.rb +2 -2
- data/app/models/fe/element.rb +201 -45
- data/app/models/fe/email_address.rb +2 -2
- data/app/models/fe/email_template.rb +1 -1
- data/app/models/fe/page.rb +138 -31
- data/app/models/fe/page_element.rb +8 -3
- data/app/models/fe/page_link.rb +6 -3
- data/app/models/fe/paragraph.rb +1 -1
- data/app/models/fe/person.rb +16 -13
- data/app/models/fe/phone_number.rb +1 -1
- data/app/models/fe/question.rb +64 -44
- data/app/models/fe/question_grid.rb +16 -4
- data/app/models/fe/question_grid_with_total.rb +15 -0
- data/app/models/fe/question_set.rb +54 -14
- data/app/models/fe/question_sheet.rb +54 -19
- data/app/models/fe/reference_question.rb +9 -13
- data/app/models/fe/reference_sheet.rb +113 -54
- data/app/models/fe/state_chooser.rb +2 -2
- data/app/models/fe/text_field.rb +2 -2
- data/app/models/fe/user.rb +1 -1
- data/app/models/staff.rb +8 -6
- data/app/validators/email_validator.rb +11 -0
- data/app/views/fe/admin/elements/create.js.erb +4 -3
- data/app/views/fe/admin/elements/destroy.js.erb +1 -1
- data/app/views/fe/admin/elements/drop.js.erb +2 -1
- data/app/views/fe/admin/elements/duplicate.js.erb +2 -1
- data/app/views/fe/admin/elements/edit.js.erb +1 -1
- data/app/views/fe/admin/elements/error.js.erb +1 -1
- data/app/views/fe/admin/elements/new.js.erb +13 -6
- data/app/views/fe/admin/elements/update.js.erb +1 -1
- data/app/views/fe/admin/email_templates/_form.html.erb +3 -3
- data/app/views/fe/admin/email_templates/edit.html.erb +3 -3
- data/app/views/fe/admin/email_templates/index.html.erb +3 -3
- data/app/views/fe/admin/email_templates/new.html.erb +3 -3
- data/app/views/fe/admin/panels/_advanced_options.html.erb +16 -10
- data/app/views/fe/admin/panels/_common_boolean_fields.html.erb +1 -0
- data/app/views/fe/admin/panels/_common_boolean_fields_default.html.erb +11 -0
- data/app/views/fe/admin/panels/_common_fields.html.erb +18 -19
- data/app/views/fe/admin/panels/_condition.html.erb +1 -1
- data/app/views/fe/admin/panels/_insert.html.erb +25 -25
- data/app/views/fe/admin/panels/_nav_controls.html.erb +4 -4
- data/app/views/fe/admin/panels/_page.html.erb +2 -2
- data/app/views/fe/admin/panels/_pages_list.html.erb +3 -3
- data/app/views/fe/admin/panels/_prop_attachment_field.html.erb +2 -2
- data/app/views/fe/admin/panels/_prop_choice_field.html.erb +52 -24
- data/app/views/fe/admin/panels/_prop_date_field.html.erb +1 -1
- data/app/views/fe/admin/panels/_prop_element.html.erb +7 -14
- data/app/views/fe/admin/panels/_prop_page.html.erb +11 -6
- data/app/views/fe/admin/panels/_prop_paragraph.html.erb +38 -24
- data/app/views/fe/admin/panels/_prop_question_grid.html.erb +7 -2
- data/app/views/fe/admin/panels/_prop_question_grid_with_total.html.erb +2 -2
- data/app/views/fe/admin/panels/_prop_reference_question.html.erb +3 -3
- data/app/views/fe/admin/panels/_prop_section.html.erb +8 -2
- data/app/views/fe/admin/panels/_prop_sheet.html.erb +7 -4
- data/app/views/fe/admin/panels/_prop_text_field.html.erb +12 -12
- data/app/views/fe/admin/question_pages/_element.html.erb +16 -6
- data/app/views/fe/admin/question_pages/_element_show.html.erb +2 -2
- data/app/views/fe/admin/question_pages/_question_page.html.erb +4 -4
- data/app/views/fe/admin/question_pages/create.js.erb +3 -3
- data/app/views/fe/admin/question_pages/destroy.js.erb +3 -3
- data/app/views/fe/admin/question_pages/edit.js.erb +1 -1
- data/app/views/fe/admin/question_pages/error.js.erb +1 -1
- data/app/views/fe/admin/question_pages/show.js.erb +2 -2
- data/app/views/fe/admin/question_pages/show_panel.js.erb +1 -1
- data/app/views/fe/admin/question_pages/update.js.erb +1 -1
- data/app/views/fe/admin/question_sheets/edit.js.erb +1 -1
- data/app/views/fe/admin/question_sheets/error.js.erb +1 -1
- data/app/views/fe/admin/question_sheets/index.html.erb +8 -8
- data/app/views/fe/admin/question_sheets/new.html.erb +3 -3
- data/app/views/fe/admin/question_sheets/show.html.erb +5 -5
- data/app/views/fe/admin/question_sheets/update.js.erb +1 -1
- data/app/views/fe/answer_pages/_answer_page.html.erb +14 -14
- data/app/views/fe/answer_pages/_element.html.erb +25 -6
- data/app/views/fe/answer_pages/_page_name.html.erb +1 -0
- data/app/views/fe/answer_pages/show.html.erb +39 -0
- data/app/views/fe/answer_pages/update.js.erb +11 -3
- data/app/views/fe/answer_sheets/_answer_sheet.html.erb +6 -6
- data/app/views/fe/answer_sheets/_element.html.erb +55 -35
- data/app/views/fe/answer_sheets/_incomplete.html.erb +1 -1
- data/app/views/fe/answer_sheets/_page_link.html.erb +9 -7
- data/app/views/fe/answer_sheets/_pages_list.html.erb +4 -4
- data/app/views/fe/answer_sheets/_submit_to.html.erb +1 -0
- data/app/views/fe/answer_sheets/_title.html.erb +1 -1
- data/app/views/fe/answer_sheets/edit.html.erb +24 -24
- data/app/views/fe/answer_sheets/incomplete.js.erb +9 -3
- data/app/views/fe/answer_sheets/index.html.erb +3 -3
- data/app/views/fe/answer_sheets/show.html.erb +1 -1
- data/app/views/fe/applications/_logout.html.erb +1 -0
- data/app/views/fe/applications/show.html.erb +1 -0
- data/app/views/fe/questions/fe/_acceptance.html.erb +11 -10
- data/app/views/fe/questions/fe/_attachment_field.html.erb +133 -10
- data/app/views/fe/questions/fe/_checkbox_field.html.erb +34 -30
- data/app/views/fe/questions/fe/_country.html.erb +6 -6
- data/app/views/fe/questions/fe/_date_field.html.erb +5 -5
- data/app/views/fe/questions/fe/_date_field_mmyy.html.erb +8 -8
- data/app/views/fe/questions/fe/_drop_down_field.html.erb +7 -6
- data/app/views/fe/questions/fe/_paragraph.html.erb +1 -1
- data/app/views/fe/questions/fe/_question_grid.html.erb +21 -16
- data/app/views/fe/questions/fe/_question_grid_with_total.html.erb +25 -18
- data/app/views/fe/questions/fe/_questions.html.erb +11 -5
- data/app/views/fe/questions/fe/_radio_button_field.html.erb +42 -25
- data/app/views/fe/questions/fe/_rating.html.erb +57 -18
- data/app/views/fe/questions/fe/_reference_discipler.html.erb +1 -1
- data/app/views/fe/questions/fe/_reference_friend.html.erb +1 -1
- data/app/views/fe/questions/fe/_reference_parent.html.erb +1 -1
- data/app/views/fe/questions/fe/_reference_peer.html.erb +1 -1
- data/app/views/fe/questions/fe/_reference_question.html.erb +44 -21
- data/app/views/fe/questions/fe/_reference_roommate.html.erb +1 -1
- data/app/views/fe/questions/fe/_reference_spiritual.html.erb +1 -1
- data/app/views/fe/questions/fe/_reference_staff.html.erb +1 -1
- data/app/views/fe/questions/fe/_section.html.erb +1 -1
- data/app/views/fe/questions/fe/_state_chooser.html.erb +6 -6
- data/app/views/fe/questions/fe/_text_area_field.html.erb +17 -6
- data/app/views/fe/questions/fe/_text_field.html.erb +7 -6
- data/app/views/fe/questions/fe/_yes_no.html.erb +8 -8
- data/app/views/fe/questions/fe/_yes_no_field.erb +12 -9
- data/app/views/fe/reference_pages/_reference.html.erb +15 -15
- data/app/views/fe/reference_pages/edit.html.erb +9 -9
- data/app/views/fe/reference_sheets/done.html.erb +2 -2
- data/app/views/fe/reference_sheets/not_found.html.erb +4 -4
- data/app/views/fe/references/edit.html.erb +6 -6
- data/app/views/fe/references/show.html.erb +8 -8
- data/app/views/fe/references/submit.js.erb +3 -3
- data/app/views/fe/submit_pages/_thankyou.html.erb +1 -1
- data/app/views/fe/submit_pages/edit.html.erb +12 -12
- data/app/views/fe/submit_pages/error.js.erb +1 -1
- data/app/views/fe/submit_pages/submit.js.erb +2 -2
- data/app/views/layouts/fe/_error_messages_for.html.erb +7 -0
- data/app/views/layouts/fe/application.html.erb +4 -5
- data/app/views/layouts/fe/fe_admin.html.erb +30 -0
- data/app/views.current/fe/admin/elements/_errors.html.erb +11 -0
- data/app/views.current/fe/admin/elements/create.js.erb +12 -0
- data/app/views.current/fe/admin/elements/destroy.js.erb +4 -0
- data/app/views.current/fe/admin/elements/drop.js.erb +3 -0
- data/app/views.current/fe/admin/elements/duplicate.js.erb +3 -0
- data/app/views.current/fe/admin/elements/edit.js.erb +4 -0
- data/app/views.current/fe/admin/elements/error.js.erb +4 -0
- data/app/views.current/fe/admin/elements/new.js.erb +17 -0
- data/app/views.current/fe/admin/elements/reorder.js.erb +0 -0
- data/app/views.current/fe/admin/elements/update.js.erb +9 -0
- data/app/views.current/fe/admin/email_templates/_form.html.erb +8 -0
- data/app/views.current/fe/admin/email_templates/edit.html.erb +13 -0
- data/app/views.current/fe/admin/email_templates/index.html.erb +20 -0
- data/app/views.current/fe/admin/email_templates/new.html.erb +11 -0
- data/app/views.current/fe/admin/panels/_advanced_options.html.erb +49 -0
- data/app/views.current/fe/admin/panels/_common_boolean_fields.html.erb +1 -0
- data/app/views.current/fe/admin/panels/_common_boolean_fields_default.html.erb +11 -0
- data/app/views.current/fe/admin/panels/_common_fields.html.erb +23 -0
- data/app/views.current/fe/admin/panels/_condition.html.erb +6 -0
- data/app/views.current/fe/admin/panels/_insert.html.erb +39 -0
- data/app/views.current/fe/admin/panels/_nav_controls.html.erb +6 -0
- data/app/views.current/fe/admin/panels/_page.html.erb +3 -0
- data/app/views.current/fe/admin/panels/_pages_list.html.erb +16 -0
- data/app/views.current/fe/admin/panels/_prop_attachment_field.html.erb +2 -0
- data/app/views.current/fe/admin/panels/_prop_choice_field.html.erb +74 -0
- data/app/views.current/fe/admin/panels/_prop_date_field.html.erb +7 -0
- data/app/views.current/fe/admin/panels/_prop_element.html.erb +23 -0
- data/app/views.current/fe/admin/panels/_prop_page.html.erb +26 -0
- data/app/views.current/fe/admin/panels/_prop_paragraph.html.erb +46 -0
- data/app/views.current/fe/admin/panels/_prop_question_grid.html.erb +28 -0
- data/app/views.current/fe/admin/panels/_prop_question_grid_with_total.html.erb +14 -0
- data/app/views.current/fe/admin/panels/_prop_reference_question.html.erb +12 -0
- data/app/views.current/fe/admin/panels/_prop_section.html.erb +8 -0
- data/app/views.current/fe/admin/panels/_prop_sheet.html.erb +20 -0
- data/app/views.current/fe/admin/panels/_prop_text_field.html.erb +20 -0
- data/app/views.current/fe/admin/question_pages/_element.html.erb +28 -0
- data/app/views.current/fe/admin/question_pages/_element_show.html.erb +10 -0
- data/app/views.current/fe/admin/question_pages/_errors.html.erb +10 -0
- data/app/views.current/fe/admin/question_pages/_question_page.html.erb +13 -0
- data/app/views.current/fe/admin/question_pages/create.js.erb +11 -0
- data/app/views.current/fe/admin/question_pages/destroy.js.erb +5 -0
- data/app/views.current/fe/admin/question_pages/edit.js.erb +3 -0
- data/app/views.current/fe/admin/question_pages/error.js.erb +4 -0
- data/app/views.current/fe/admin/question_pages/show.js.erb +9 -0
- data/app/views.current/fe/admin/question_pages/show_panel.js.erb +3 -0
- data/app/views.current/fe/admin/question_pages/update.js.erb +2 -0
- data/app/views.current/fe/admin/question_sheets/_errors.html.erb +11 -0
- data/app/views.current/fe/admin/question_sheets/edit.js.erb +3 -0
- data/app/views.current/fe/admin/question_sheets/error.js.erb +5 -0
- data/app/views.current/fe/admin/question_sheets/index.html.erb +41 -0
- data/app/views.current/fe/admin/question_sheets/new.html.erb +15 -0
- data/app/views.current/fe/admin/question_sheets/show.html.erb +27 -0
- data/app/views.current/fe/admin/question_sheets/update.js.erb +2 -0
- data/app/views.current/fe/answer_pages/_answer_page.html.erb +53 -0
- data/app/views.current/fe/answer_pages/_element.html.erb +32 -0
- data/app/views.current/fe/answer_pages/_page_name.html.erb +1 -0
- data/app/views.current/fe/answer_pages/show.html.erb +39 -0
- data/app/views.current/fe/answer_pages/update.js.erb +13 -0
- data/app/views.current/fe/answer_sheets/_answer_sheet.html.erb +26 -0
- data/app/views.current/fe/answer_sheets/_element.html.erb +74 -0
- data/app/views.current/fe/answer_sheets/_incomplete.html.erb +10 -0
- data/app/views.current/fe/answer_sheets/_page_link.html.erb +9 -0
- data/app/views.current/fe/answer_sheets/_pages_list.html.erb +11 -0
- data/app/views.current/fe/answer_sheets/_submit_to.html.erb +1 -0
- data/app/views.current/fe/answer_sheets/_title.html.erb +1 -0
- data/app/views.current/fe/answer_sheets/edit.html.erb +66 -0
- data/app/views.current/fe/answer_sheets/incomplete.js.erb +11 -0
- data/app/views.current/fe/answer_sheets/index.html.erb +18 -0
- data/app/views.current/fe/answer_sheets/send_reference_invite.js.erb +8 -0
- data/app/views.current/fe/answer_sheets/show.html.erb +13 -0
- data/app/views.current/fe/applications/_logout.html.erb +1 -0
- data/app/views.current/fe/applications/show.html.erb +1 -0
- data/app/views.current/fe/help/builder.html +33 -0
- data/app/views.current/fe/help/question_grid.html +18 -0
- data/app/views.current/fe/questions/fe/_acceptance.html.erb +14 -0
- data/app/views.current/fe/questions/fe/_attachment_field.html.erb +165 -0
- data/app/views.current/fe/questions/fe/_checkbox_field.html.erb +53 -0
- data/app/views.current/fe/questions/fe/_country.html.erb +7 -0
- data/app/views.current/fe/questions/fe/_date_field.html.erb +7 -0
- data/app/views.current/fe/questions/fe/_date_field_mmyy.html.erb +9 -0
- data/app/views.current/fe/questions/fe/_drop_down_field.html.erb +8 -0
- data/app/views.current/fe/questions/fe/_paragraph.html.erb +1 -0
- data/app/views.current/fe/questions/fe/_question_grid.html.erb +70 -0
- data/app/views.current/fe/questions/fe/_question_grid_with_total.html.erb +64 -0
- data/app/views.current/fe/questions/fe/_questions.html.erb +15 -0
- data/app/views.current/fe/questions/fe/_radio_button_field.html.erb +60 -0
- data/app/views.current/fe/questions/fe/_rating.html.erb +64 -0
- data/app/views.current/fe/questions/fe/_reference_discipler.html.erb +1 -0
- data/app/views.current/fe/questions/fe/_reference_friend.html.erb +1 -0
- data/app/views.current/fe/questions/fe/_reference_parent.html.erb +1 -0
- data/app/views.current/fe/questions/fe/_reference_peer.html.erb +1 -0
- data/app/views.current/fe/questions/fe/_reference_question.html.erb +61 -0
- data/app/views.current/fe/questions/fe/_reference_roommate.html.erb +1 -0
- data/app/views.current/fe/questions/fe/_reference_spiritual.html.erb +1 -0
- data/app/views.current/fe/questions/fe/_reference_staff.html.erb +1 -0
- data/app/views.current/fe/questions/fe/_section.html.erb +1 -0
- data/app/views.current/fe/questions/fe/_state_chooser.html.erb +7 -0
- data/app/views.current/fe/questions/fe/_text_area_field.html.erb +17 -0
- data/app/views.current/fe/questions/fe/_text_field.html.erb +9 -0
- data/app/views.current/fe/questions/fe/_yes_no.html.erb +17 -0
- data/app/views.current/fe/questions/fe/_yes_no_field.erb +20 -0
- data/app/views.current/fe/reference_pages/_reference.html.erb +31 -0
- data/app/views.current/fe/reference_pages/edit.html.erb +24 -0
- data/app/views.current/fe/reference_sheets/done.html.erb +2 -0
- data/app/views.current/fe/reference_sheets/not_found.html.erb +5 -0
- data/app/views.current/fe/reference_sheets/submitted.js.erb +1 -0
- data/app/views.current/fe/references/edit.html.erb +8 -0
- data/app/views.current/fe/references/send_invite.js.erb +7 -0
- data/app/views.current/fe/references/show.html.erb +18 -0
- data/app/views.current/fe/references/submit.js.erb +3 -0
- data/app/views.current/fe/submit_pages/_errors.html.erb +1 -0
- data/app/views.current/fe/submit_pages/_thankyou.html.erb +2 -0
- data/app/views.current/fe/submit_pages/edit.html.erb +36 -0
- data/app/views.current/fe/submit_pages/error.js.erb +1 -0
- data/app/views.current/fe/submit_pages/submit.js.erb +3 -0
- data/app/views.current/layouts/fe/_error_messages_for.html.erb +7 -0
- data/app/views.current/layouts/fe/application.html.erb +47 -0
- data/app/{views/layouts/fe/fe.admin.html.erb → views.current/layouts/fe/fe_admin.html.erb} +4 -4
- data/config/initializers/paper_trail.rb +3 -0
- data/config/routes.rb +3 -37
- data/db/migrate/20131003041856_core.rb +23 -23
- data/db/migrate/20131003044250_create_reference_sheets.rb +2 -1
- data/db/migrate/20131003044436_add_element_and_answer_fields.rb +3 -3
- data/db/migrate/20131003044518_create_email_templates.rb +2 -2
- data/db/migrate/20131003044621_add_max_lengths.rb +1 -1
- data/db/migrate/20131003044714_create_join_table.rb +1 -1
- data/db/migrate/20131016162128_remove_question_id_from_element.rb +1 -1
- data/db/migrate/20140623153424_create_fe_people.rb +2 -2
- data/db/migrate/20140624180246_create_fe_addresses.rb +2 -2
- data/db/migrate/{20140624182216_create_create_fe_phone_numbers.rb → 20140624182216_create_fe_phone_numbers.rb} +2 -2
- data/db/migrate/20140625160545_create_fe_users.rb +2 -2
- data/db/migrate/20140808202507_add_conditional_type_to_elements.rb +1 -1
- data/db/migrate/20140808203609_add_conditional_answer_to_elements.rb +1 -1
- data/db/migrate/20141103204704_remove_short_value_column.rb +1 -1
- data/db/migrate/20141109154522_move_conditional_ids_used_for_choice_field_to_their_own_column.rb +1 -1
- data/db/migrate/20150504221439_add_all_element_ids_to_pages.rb +5 -0
- data/db/migrate/20150713022326_add_locale_columns.rb +9 -0
- data/db/migrate/20150714220730_add_locale_to_answer_sheet.rb +5 -0
- data/db/migrate/20150925181652_add_share_to_elements.rb +5 -0
- data/db/migrate/20150928085325_change_pages_all_element_ids_to_text.rb +5 -0
- data/db/migrate/20150930191538_add_locale_to_reference_sheets.rb +5 -0
- data/db/migrate/20151021181928_switch_conditional_answer_separator_to_semicolon.rb +7 -0
- data/db/migrate/20151021184250_add_question_sheet_id_in_refs.rb +12 -0
- data/db/migrate/20160201185838_add_visible_and_visibility_cache_key_to_reference_sheets.rb +6 -0
- data/db/migrate/20160805221415_add_rating_extra_labels.rb +10 -0
- data/db/migrate/20181108201746_create_versions.rb +80 -0
- data/db/migrate/20181218201130_increase_slug_length.rb +5 -0
- data/lib/access_key_generator.rb +12 -0
- data/lib/distinct_distinct_patch.rb +20 -0
- data/lib/fe/engine.rb +26 -14
- data/lib/fe/version.rb +1 -1
- data/lib/fe.rb +11 -1
- data/spec/controllers/fe/admin/elements_controller_spec.rb +211 -1
- data/spec/controllers/fe/admin/email_templates_controller_spec.rb +26 -1
- data/spec/controllers/fe/admin/question_pages_controller_spec.rb +8 -1
- data/spec/controllers/fe/admin/question_sheets_controller_spec.rb +48 -1
- data/spec/controllers/fe/answer_pages_controller_spec.rb +129 -1
- data/spec/controllers/fe/answer_sheets_controller_spec.rb +136 -1
- data/spec/controllers/fe/reference_pages_controller.rb +4 -0
- data/spec/controllers/fe/references_controller_spec.rb +4 -0
- data/spec/controllers/fe/submit_pages_controller_spec.rb +4 -0
- data/spec/dummy/app/assets/config/manifest.js +0 -0
- data/spec/dummy/app/controllers/application_controller.rb +5 -0
- data/spec/dummy/app/helpers/application_helper.rb +9 -0
- data/spec/dummy/app/models/application.rb +3 -0
- data/spec/dummy/app/models/person.rb +11 -0
- data/spec/dummy/app/models/user.rb +3 -0
- data/spec/dummy/app/views/layouts/application.html.erb +2 -2
- data/spec/dummy/config/application.rb +3 -1
- data/spec/dummy/config/database.yml +20 -17
- data/spec/dummy/config/environments/production.rb +1 -5
- data/spec/dummy/config/environments/test.rb +4 -2
- data/spec/dummy/config/initializers/assets.rb +5 -2
- data/spec/dummy/config/initializers/fast_gettext.rb +5 -0
- data/spec/dummy/config/initializers/to_unsafe_h.rb +5 -0
- data/spec/dummy/config/initializers/to_unsafe_h.rb.new +5 -0
- data/spec/dummy/config/secrets.yml +2 -2
- data/spec/dummy/db/migrate/20141203214017_core.fe_engine.rb +92 -0
- data/spec/dummy/db/migrate/20141203214018_create_reference_sheets.fe_engine.rb +25 -0
- data/spec/dummy/db/migrate/20141203214019_add_element_and_answer_fields.fe_engine.rb +11 -0
- data/spec/dummy/db/migrate/20141203214020_create_email_templates.fe_engine.rb +18 -0
- data/spec/dummy/db/migrate/20141203214021_add_max_lengths.fe_engine.rb +9 -0
- data/spec/dummy/db/migrate/20141203214022_create_join_table.fe_engine.rb +12 -0
- data/spec/dummy/db/migrate/20141203214023_remove_question_id_from_element.fe_engine.rb +10 -0
- data/spec/dummy/db/migrate/20141203214024_create_fe_people.fe_engine.rb +13 -0
- data/spec/dummy/db/migrate/20141203214025_create_fe_addresses.fe_engine.rb +21 -0
- data/spec/dummy/db/migrate/20141203214027_create_fe_users.fe_engine.rb +13 -0
- data/spec/dummy/db/migrate/20141203214028_add_conditional_type_to_elements.fe_engine.rb +6 -0
- data/spec/dummy/db/migrate/20141203214029_add_conditional_answer_to_elements.fe_engine.rb +6 -0
- data/spec/dummy/db/migrate/20141203214030_remove_short_value_column.fe_engine.rb +6 -0
- data/spec/dummy/db/migrate/20141203214031_move_conditional_ids_used_for_choice_field_to_their_own_column.fe_engine.rb +8 -0
- data/spec/dummy/db/migrate/20150123215803_create_users.rb +9 -0
- data/spec/dummy/db/migrate/20150504222619_add_all_element_ids_to_pages.fe_engine.rb +6 -0
- data/spec/dummy/db/migrate/20150925192557_add_share_to_elements.fe_engine.rb +6 -0
- data/spec/dummy/db/migrate/20150930190001_create_fe_phone_numbers.fe_engine.rb +20 -0
- data/spec/dummy/db/migrate/20150930190002_add_locale_columns.fe_engine.rb +10 -0
- data/spec/dummy/db/migrate/20150930190003_add_locale_to_answer_sheet.fe_engine.rb +6 -0
- data/spec/dummy/db/migrate/20150930190004_change_pages_all_element_ids_to_text.fe_engine.rb +6 -0
- data/spec/dummy/db/migrate/20150930191756_add_locale_to_reference_sheets.fe_engine.rb +6 -0
- data/spec/dummy/db/migrate/20151021190027_add_question_sheet_id_in_refs.fe_engine.rb +13 -0
- data/spec/dummy/db/migrate/20160204164612_switch_conditional_answer_separator_to_semicolon.fe_engine.rb +8 -0
- data/spec/dummy/db/migrate/20160204164613_add_visible_and_visibility_cache_key_to_reference_sheets.fe_engine.rb +7 -0
- data/spec/dummy/db/migrate/20181108201746_create_versions.rb +80 -0
- data/spec/dummy/db/schema.rb +91 -69
- data/spec/dummy/log/test.log +101278 -419
- data/spec/factories/answer_sheet_question_sheets.rb +1 -1
- data/spec/factories/answer_sheets.rb +2 -2
- data/spec/factories/answers.rb +1 -1
- data/spec/factories/applications.rb +3 -4
- data/spec/factories/dummy_applications.rb +6 -0
- data/spec/factories/dummy_people.rb +6 -0
- data/spec/factories/dummy_users.rb +6 -0
- data/spec/factories/elements.rb +35 -10
- data/spec/factories/email_templates.rb +5 -0
- data/spec/factories/fe_addresses.rb +10 -10
- data/spec/factories/fe_email_addresses.rb +3 -3
- data/spec/factories/fe_email_templates.rb +9 -0
- data/spec/factories/fe_people.rb +5 -7
- data/spec/factories/fe_phone_numbers.rb +3 -3
- data/spec/factories/fe_user.rb +6 -0
- data/spec/factories/page.rb +1 -1
- data/spec/factories/page_elements.rb +1 -1
- data/spec/factories/paragraphs.rb +1 -1
- data/spec/factories/question_sheet.rb +3 -3
- data/spec/factories/reference_questions.rb +1 -1
- data/spec/factories/reference_sheets.rb +9 -0
- data/spec/jobs/fe/update_reference_sheet_visibility_job_spec.rb +40 -0
- data/spec/mailers/fe/notifier_spec.rb +39 -0
- data/spec/models/fe/answer_sheet_question_sheet_spec.rb +1 -1
- data/spec/models/fe/answer_spec.rb +2 -2
- data/spec/models/fe/application_spec.rb +94 -1
- data/spec/models/fe/choice_field_spec.rb +66 -0
- data/spec/models/fe/condition_spec.rb +2 -2
- data/spec/models/fe/element_spec.rb +414 -37
- data/spec/models/fe/email_template_spec.rb +1 -1
- data/spec/models/fe/page_element_spec.rb +1 -1
- data/spec/models/fe/page_spec.rb +168 -11
- data/spec/models/fe/person_spec.rb +1 -1
- data/spec/models/fe/question_set_spec.rb +91 -0
- data/spec/models/fe/question_sheet_spec.rb +103 -1
- data/spec/models/fe/question_spec.rb +73 -6
- data/spec/models/fe/reference_question_spec.rb +20 -0
- data/spec/models/fe/reference_sheet_spec.rb +305 -2
- data/spec/models/fe/text_field_spec.rb +22 -0
- data/spec/rails_helper.rb +85 -54
- data/spec/support/choices.xml +6 -0
- metadata +310 -84
- data/app/assets/javascripts/fe/fe.common.js +0 -57
- data/app/assets/javascripts/fe/jquery.scrollTo-min.js +0 -7
- data/app/assets/javascripts/fe/rails.extra.js +0 -6
- data/app/controllers/fe/applications_controller.rb +0 -183
- data/app/controllers/fe/concerns/answer_pages_controller_concern.rb +0 -83
- data/app/controllers/fe/payments_controller.rb +0 -184
- data/app/models/fe/concerns/answer_sheet_concern.rb +0 -55
- data/app/models/fe/payment.rb +0 -77
- data/app/models/fe/payment_question.rb +0 -22
- data/app/views/fe/admin/panels/_prop_payment_question.html.erb +0 -1
- data/app/views/fe/application/_logout.html.erb +0 -1
- data/app/views/fe/payment_pages/_credit.html.erb +0 -47
- data/app/views/fe/payment_pages/_mail.html.erb +0 -27
- data/app/views/fe/payment_pages/_payment.html.erb +0 -6
- data/app/views/fe/payment_pages/_staff.html.erb +0 -25
- data/app/views/fe/payment_pages/_staff_results.html.erb +0 -17
- data/app/views/fe/payment_pages/edit.html.erb +0 -75
- data/app/views/fe/payment_pages/staff_search.js.erb +0 -2
- data/app/views/fe/payments/_credit.html.erb +0 -47
- data/app/views/fe/payments/_errors.html.erb +0 -1
- data/app/views/fe/payments/_payment.html.erb +0 -13
- data/app/views/fe/payments/_staff.html.erb +0 -21
- data/app/views/fe/payments/_staff_results.html.erb +0 -18
- data/app/views/fe/payments/approve.js.erb +0 -3
- data/app/views/fe/payments/create.js.erb +0 -19
- data/app/views/fe/payments/destroy.js.erb +0 -7
- data/app/views/fe/payments/edit.html.erb +0 -56
- data/app/views/fe/payments/error.js.erb +0 -3
- data/app/views/fe/payments/no_access.html.erb +0 -7
- data/app/views/fe/payments/staff_search.js.erb +0 -1
- data/app/views/fe/payments/update.html.erb +0 -24
- data/app/views/fe/questions/fe/_payment_question.html.erb +0 -70
- data/db/migrate/20140828045339_create_payments.rb +0 -13
- data/spec/dummy/db/test.sqlite3 +0 -0
- data/spec/factories/payments.rb +0 -7
- data/spec/models/fe/payment_question_spec.rb +0 -65
|
@@ -0,0 +1,526 @@
|
|
|
1
|
+
//= require fe/fe.common.js
|
|
2
|
+
|
|
3
|
+
// used by answer sheets
|
|
4
|
+
|
|
5
|
+
(function($) {
|
|
6
|
+
<% if Fe.bootstrap %>
|
|
7
|
+
// http://stackoverflow.com/questions/18754020/bootstrap-3-with-jquery-validation-plugin
|
|
8
|
+
$.validator.setDefaults({
|
|
9
|
+
errorElement: "span",
|
|
10
|
+
errorClass: "help-block",
|
|
11
|
+
highlight: function (element, errorClass, validClass) {
|
|
12
|
+
$(element).closest('.form-group').addClass('has-error');
|
|
13
|
+
},
|
|
14
|
+
unhighlight: function (element, errorClass, validClass) {
|
|
15
|
+
$(element).closest('.form-group').removeClass('has-error');
|
|
16
|
+
},
|
|
17
|
+
errorPlacement: function (error, element) {
|
|
18
|
+
if (element.parent('.input-group').length || element.prop('type') === 'checkbox' || element.prop('type') === 'radio') {
|
|
19
|
+
error.appendTo(element.closest('div:not(.field'));
|
|
20
|
+
} else {
|
|
21
|
+
error.insertAfter(element);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
<% end %>
|
|
26
|
+
|
|
27
|
+
$(document).on('click', '.save_button', function() {
|
|
28
|
+
fe.pageHandler.savePage($(this).closest('.answer-page'), true);
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
$(document).on('click', '.reference_send_invite', function() {
|
|
32
|
+
var el = this;
|
|
33
|
+
var form_elements = $(el).closest('form').find('input:not(.dont_submit), textarea:not(.dont_submit), select:not(.dont_submit)');
|
|
34
|
+
var data = form_elements.serializeArray();
|
|
35
|
+
|
|
36
|
+
data.push({name: 'answer_sheet_type', value: answer_sheet_type});
|
|
37
|
+
$.ajax({url: $(el).attr('href'), data: data, dataType: 'script', type: 'POST',
|
|
38
|
+
beforeSend: function (xhr) {
|
|
39
|
+
$('body').trigger('ajax:loading', xhr);
|
|
40
|
+
},
|
|
41
|
+
complete: function (xhr) {
|
|
42
|
+
$('body').trigger('ajax:complete', xhr);
|
|
43
|
+
},
|
|
44
|
+
error: function (xhr, status, error) {
|
|
45
|
+
$('body').trigger('ajax:failure', [xhr, status, error]);
|
|
46
|
+
}
|
|
47
|
+
});
|
|
48
|
+
return false;
|
|
49
|
+
});
|
|
50
|
+
$(document).on('focus', 'textarea[maxlength]', function() {
|
|
51
|
+
var max = parseInt($(this).attr('maxlength'));
|
|
52
|
+
$(this).parent().find('.charsRemaining').html('You have ' + (max - $(this).val().length) + ' characters remaining');
|
|
53
|
+
}).on('keyup', 'textarea[maxlength]', function(){
|
|
54
|
+
var max = parseInt($(this).attr('maxlength'));
|
|
55
|
+
if($(this).val().length > max){
|
|
56
|
+
$(this).val($(this).val().substr(0, $(this).attr('maxlength')));
|
|
57
|
+
}
|
|
58
|
+
$(this).parent().find('.charsRemaining').html('You have ' + (max - $(this).val().length) + ' characters remaining');
|
|
59
|
+
}).on('blur', 'textarea[maxlength]', function() {
|
|
60
|
+
$(this).parent().find('.charsRemaining').html('');
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
window.fe = {};
|
|
64
|
+
fe.pageHandler = {
|
|
65
|
+
|
|
66
|
+
initialize : function(page) {
|
|
67
|
+
this.auto_save_frequency = 30; // seconds
|
|
68
|
+
this.timer_id = null;
|
|
69
|
+
|
|
70
|
+
this.current_page = page;
|
|
71
|
+
$('#' + page).data('form_data', this.captureForm($('#' + page)));
|
|
72
|
+
this.registerAutoSave();
|
|
73
|
+
|
|
74
|
+
this.page_validation = {}; // validation objects for each page
|
|
75
|
+
this.enableValidation(page);
|
|
76
|
+
|
|
77
|
+
$(document).trigger('feShowPage'); // allow other code to handle show page event by using $(document).on('feShowPage', function() { ... });
|
|
78
|
+
|
|
79
|
+
// this.background_load = false;
|
|
80
|
+
// this.final_submission = false;
|
|
81
|
+
},
|
|
82
|
+
|
|
83
|
+
// swap to a different page
|
|
84
|
+
showPage : function(page) {
|
|
85
|
+
// hide the old
|
|
86
|
+
$('#' + this.current_page + '-li').removeClass('active');
|
|
87
|
+
$('#' + this.current_page).hide();
|
|
88
|
+
|
|
89
|
+
// HACK: Need to clear the main error message when returning to the submit page
|
|
90
|
+
// It is very confusing to users to be there when they revisit the page
|
|
91
|
+
$('#submit_message, .submit_message').hide();
|
|
92
|
+
$('#application_errors, .application_errors').html('');
|
|
93
|
+
|
|
94
|
+
// show the new
|
|
95
|
+
// $('#' + page + '-li').removeClass('incomplete');
|
|
96
|
+
// $('#' + page + '-li').removeClass('valid');
|
|
97
|
+
$('#' + page + '-li').addClass('active');
|
|
98
|
+
$('#' + page).show();
|
|
99
|
+
this.current_page = page;
|
|
100
|
+
this.registerAutoSave(page);
|
|
101
|
+
fixGridColumnWidths();
|
|
102
|
+
$(document).trigger('feShowPage'); // allow other code to handle show page event by using $(document).on('feShowPage', function() { ... });
|
|
103
|
+
},
|
|
104
|
+
|
|
105
|
+
// callback onSuccess
|
|
106
|
+
pageLoadedBackground : function(response, textStatus, jqXHR) {
|
|
107
|
+
//this.pageLoaded(response, textStatus, jqXHR, true)
|
|
108
|
+
fe.pageHandler.pageLoaded(response, textStatus, jqXHR, true)
|
|
109
|
+
},
|
|
110
|
+
|
|
111
|
+
// callback onSuccess
|
|
112
|
+
pageLoaded : function(response, textStatus, jqXHR, background_load) {
|
|
113
|
+
background_load = typeof background_load !== 'undefined' ? background_load : false;
|
|
114
|
+
|
|
115
|
+
// var response = new String(transport.responseText);
|
|
116
|
+
var match = response.match(/<div id=\"(.*?)\"/i); // what did I just load? parse out the first div id
|
|
117
|
+
if( match != null )
|
|
118
|
+
{
|
|
119
|
+
var page = match[1];
|
|
120
|
+
if (response.match(/<html/)) {
|
|
121
|
+
alert("There was a problem loading that page. To work on other pages, please refresh the website.");
|
|
122
|
+
document.location = document.location;
|
|
123
|
+
} else if ($('#'+page).length > 0) {
|
|
124
|
+
$('#'+page).replaceWith(response);
|
|
125
|
+
} else {
|
|
126
|
+
$('#preview').append(response);
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
if (!background_load) { fe.pageHandler.showPage(page); } // show after load, unless loading in background
|
|
130
|
+
setUpJsHelpers();
|
|
131
|
+
fe.pageHandler.enableValidation(page);
|
|
132
|
+
if (background_load) { fe.pageHandler.validatePage(page, true); }
|
|
133
|
+
$('#' + page).data('form_data', fe.pageHandler.captureForm($('#' + page)));
|
|
134
|
+
}
|
|
135
|
+
$('#page_ajax_spinner').hide();
|
|
136
|
+
$('.reference_send_invite').button();
|
|
137
|
+
updateTotals();
|
|
138
|
+
$(document).trigger('fePageLoaded'); // allow other code to handle page load event by using $(document).on('fePageLoaded', function() { ... });
|
|
139
|
+
},
|
|
140
|
+
|
|
141
|
+
loadPage : function(page, url, background_load, validate_current_page) {
|
|
142
|
+
background_load = typeof background_load !== 'undefined' ? background_load : false;
|
|
143
|
+
validate_current_page = typeof validate_current_page !== 'undefined' ? validate_current_page : true;
|
|
144
|
+
|
|
145
|
+
if (validate_current_page) {
|
|
146
|
+
isValid = this.validatePage(this.current_page); // mark current page as valid (or not) as we're leaving
|
|
147
|
+
} else {
|
|
148
|
+
isValid = true
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
// Provide a way for enclosing apps to not go to the next page until the current page is valid
|
|
152
|
+
// They can do that with this:
|
|
153
|
+
//
|
|
154
|
+
// $(document).on 'fePageLoaded', (evt, page) ->
|
|
155
|
+
// $(".page > form").addClass('enforce-valid-before-next');
|
|
156
|
+
//
|
|
157
|
+
if (!isValid && $('#' + this.current_page + "-form").hasClass('enforce-valid-before-next')) {
|
|
158
|
+
// scroll up to where the error is
|
|
159
|
+
scrollTo($(".help-block:visible")[0].closest("li"));
|
|
160
|
+
return;
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
this.unregisterAutoSave(); // don't auto-save while loading/saving
|
|
164
|
+
// will register auto-save on new page once loaded/shown
|
|
165
|
+
|
|
166
|
+
this.savePage();
|
|
167
|
+
|
|
168
|
+
if (!background_load) {
|
|
169
|
+
if ($('a[name="main"]').length == 1) {
|
|
170
|
+
scrollTo('a[name="main"]');
|
|
171
|
+
} else {
|
|
172
|
+
scrollTo('#main');
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
if (fe.pageHandler.isPageLoaded(page) && page.match('no_cache') == null) {
|
|
177
|
+
// if already loaded (element exists) excluding pages that need reloading
|
|
178
|
+
if (!background_load) { fe.pageHandler.showPage(page); }
|
|
179
|
+
$('#page_ajax_spinner').hide();
|
|
180
|
+
} else {
|
|
181
|
+
$.ajax({
|
|
182
|
+
url: url,
|
|
183
|
+
type: 'GET',
|
|
184
|
+
data: {'answer_sheet_type':answer_sheet_type},
|
|
185
|
+
success: background_load ? fe.pageHandler.pageLoadedBackground : fe.pageHandler.pageLoaded,
|
|
186
|
+
error: function (xhr, status, error) {
|
|
187
|
+
alert("There was a problem loading that page. We've been notified and will fix it as soon as possible. To work on other pages, please refresh the website.");
|
|
188
|
+
document.location = document.location;
|
|
189
|
+
},
|
|
190
|
+
beforeSend: function (xhr) {
|
|
191
|
+
$('body').trigger('ajax:loading', xhr);
|
|
192
|
+
},
|
|
193
|
+
complete: function (xhr) {
|
|
194
|
+
$('body').trigger('ajax:complete', xhr);
|
|
195
|
+
}
|
|
196
|
+
});
|
|
197
|
+
}
|
|
198
|
+
},
|
|
199
|
+
|
|
200
|
+
// save form if any changes were made
|
|
201
|
+
savePage : function(page, force, blocking) {
|
|
202
|
+
|
|
203
|
+
if (page == null) page = $('#' + this.current_page);
|
|
204
|
+
if (typeof blocking == "undefined") blocking = false;
|
|
205
|
+
|
|
206
|
+
// don't save more than once per second
|
|
207
|
+
timeNow = new Date();
|
|
208
|
+
if (typeof(lastSave) != "undefined" && lastSave && !force && (timeNow - lastSave < 1000)) {
|
|
209
|
+
return true;
|
|
210
|
+
}
|
|
211
|
+
lastSave = timeNow;
|
|
212
|
+
form_data = this.captureForm(page);
|
|
213
|
+
if( form_data ) {
|
|
214
|
+
if( page.data('form_data') == null || page.data('form_data').data !== form_data.data || force === true) { // if any changes
|
|
215
|
+
page.data('form_data', form_data);
|
|
216
|
+
$.ajax({url: form_data.url, type: 'put', data: form_data.data,
|
|
217
|
+
beforeSend: function (xhr) {
|
|
218
|
+
$('#spinner_' + page.attr('id')).show();
|
|
219
|
+
},
|
|
220
|
+
complete: function (xhr) {
|
|
221
|
+
$('#spinner_' + page.attr('id')).hide();
|
|
222
|
+
},
|
|
223
|
+
success: function (xhr) {
|
|
224
|
+
page.data('save_fails', 0)
|
|
225
|
+
},
|
|
226
|
+
async: !blocking,
|
|
227
|
+
error: function() {
|
|
228
|
+
save_fails = page.data('save_fails') == null ? 0 : page.data('save_fails');
|
|
229
|
+
save_fails += 1;
|
|
230
|
+
page.data('save_fails', save_fails)
|
|
231
|
+
|
|
232
|
+
if (save_fails >= 3) {
|
|
233
|
+
alert("There was a problem saving that page. We've been notified and will fix it as soon as possible. This might happen if you logged out on another tab. The page will now reload.");
|
|
234
|
+
document.location = document.location;
|
|
235
|
+
} else {
|
|
236
|
+
page.data('save_fails', save_fails + 1)
|
|
237
|
+
page.data('form_data', null); // on error, force save for next call to save
|
|
238
|
+
// WARNING: race conditions with load & show?
|
|
239
|
+
// sort of a mess if save fails while another page is already loading!!
|
|
240
|
+
}
|
|
241
|
+
}});
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
// Update last saved stamp
|
|
245
|
+
},
|
|
246
|
+
|
|
247
|
+
savePages : function(force) {
|
|
248
|
+
$('.answer-page').each(function() {fe.pageHandler.savePage(null, force)})
|
|
249
|
+
},
|
|
250
|
+
|
|
251
|
+
// setup a timer to auto-save (only one timer, for the page being viewed)
|
|
252
|
+
registerAutoSave: function(page) {
|
|
253
|
+
this.timer_id = setInterval(this.savePages, this.auto_save_frequency * 1000);
|
|
254
|
+
},
|
|
255
|
+
|
|
256
|
+
unregisterAutoSave: function() {
|
|
257
|
+
if( this.timer_id != null )
|
|
258
|
+
{
|
|
259
|
+
clearInterval(this.timer_id);
|
|
260
|
+
this.timer_id = null;
|
|
261
|
+
}
|
|
262
|
+
},
|
|
263
|
+
|
|
264
|
+
// serialize form data and extract url to post to
|
|
265
|
+
captureForm : function(page) {
|
|
266
|
+
form_el = $('#' + page.attr('id') + '-form');
|
|
267
|
+
if( form_el[0] == null ) return null;
|
|
268
|
+
form_all_el = form_el.find("input:not(.dont_submit), textarea:not(.dont_submit), select:not(.dont_submit)");
|
|
269
|
+
return {url: form_el.attr('action'), data: form_all_el.serialize() + '&answer_sheet_type=' + answer_sheet_type};
|
|
270
|
+
},
|
|
271
|
+
|
|
272
|
+
|
|
273
|
+
// enable form validation (when form is loaded)
|
|
274
|
+
enableValidation : function(page) {
|
|
275
|
+
// Provide a way for enclosing apps to not have validation continually as people fill things out
|
|
276
|
+
// They can do that with this:
|
|
277
|
+
//
|
|
278
|
+
// $(document).on 'fePageLoaded', (evt, page) ->
|
|
279
|
+
// $(".page > form").addClass('no-ongoing-validation');
|
|
280
|
+
//
|
|
281
|
+
$('#' + page + '-form:not(.no-ongoing-validation)').validate({onsubmit:false, focusInvalid:true, onfocusout: function(element) { this.element(element);}});
|
|
282
|
+
$('#' + page + '-form:not(.no-ongoing-validation):input').change(function() {
|
|
283
|
+
fe.pageHandler.validatePage(page, true);
|
|
284
|
+
});
|
|
285
|
+
},
|
|
286
|
+
|
|
287
|
+
validatePage : function(page, page_classes_only) {
|
|
288
|
+
page_classes_only = typeof page_classes_only !== 'undefined' ? page_classes_only : false;
|
|
289
|
+
|
|
290
|
+
// Provide a way for enclosing apps to never validate a form
|
|
291
|
+
// They can do that with this:
|
|
292
|
+
//
|
|
293
|
+
// $(document).on 'fePageLoaded', (evt, page) ->
|
|
294
|
+
// $(".page > form").addClass('no-validation');
|
|
295
|
+
//
|
|
296
|
+
if ($('#' + this.current_page + "-form").hasClass('no-validation')) { return; }
|
|
297
|
+
|
|
298
|
+
try {
|
|
299
|
+
var li = $('#' + page + '-li');
|
|
300
|
+
var form = $('#' + page + '-form');
|
|
301
|
+
|
|
302
|
+
valid = form.valid();
|
|
303
|
+
|
|
304
|
+
if (!page_classes_only) {
|
|
305
|
+
// Move radio button errors up
|
|
306
|
+
$('input[type=radio].error').closest('tr').addClass('error');
|
|
307
|
+
$('.choice_field input[type=radio].error').removeClass('error')
|
|
308
|
+
.closest('.choice_field')
|
|
309
|
+
.addClass('error');
|
|
310
|
+
$('div.yesno label.error').hide();
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
if (valid) {
|
|
314
|
+
li.removeClass('incomplete');
|
|
315
|
+
li.addClass('complete');
|
|
316
|
+
$(document).trigger('fePageValid', page); // allow other code to handle show page event by using $(document).on('fePageValid', function() { ... });
|
|
317
|
+
} else {
|
|
318
|
+
li.removeClass('complete');
|
|
319
|
+
li.addClass('incomplete');
|
|
320
|
+
$(document).trigger('fePageInvalid', page); // allow other code to handle show page event by using $(document).on('fePageInvalid', function() { ... });
|
|
321
|
+
}
|
|
322
|
+
return valid;
|
|
323
|
+
}
|
|
324
|
+
catch(err) {
|
|
325
|
+
|
|
326
|
+
// If the user clicks too quickly, sometimes the page element isn't properly defined yet.
|
|
327
|
+
// If we don't catch the error, js stops execution. If we catch it, the user just has to click again.
|
|
328
|
+
}
|
|
329
|
+
$('page_ajax_spinner').hide();
|
|
330
|
+
},
|
|
331
|
+
|
|
332
|
+
// callback when falls to 0 active Ajax requests
|
|
333
|
+
completeAll : function()
|
|
334
|
+
{
|
|
335
|
+
$('.page:visible #submit_button').attr('disabled', true)
|
|
336
|
+
$('#submit_message, .submit_message').html('');
|
|
337
|
+
$('#submit_message, .submit_message').hide();
|
|
338
|
+
// validate all the pages
|
|
339
|
+
$('.page_link').each(function(index, page) {
|
|
340
|
+
fe.pageHandler.validatePage($(page).attr('data-page-id'));
|
|
341
|
+
});
|
|
342
|
+
var all_valid = ($('#list-pages li.incomplete').length == 0);
|
|
343
|
+
|
|
344
|
+
// Make sure any necessary payments are made
|
|
345
|
+
var payments_made = $('.payment_question.required').length <= $('.payment').length
|
|
346
|
+
|
|
347
|
+
|
|
348
|
+
if( payments_made)
|
|
349
|
+
{
|
|
350
|
+
// force an async save (so it finishes before submitting) in case any input fields on submit_page
|
|
351
|
+
this.savePage(null, true, true);
|
|
352
|
+
|
|
353
|
+
// submit the application
|
|
354
|
+
if($('#submit_to')[0] != null)
|
|
355
|
+
{
|
|
356
|
+
url = $('#submit_to').val();
|
|
357
|
+
// clear out pages array to force reload. This enables "frozen" apps
|
|
358
|
+
// immediately after submission - :onSuccess (for USCM which stays in the application vs. redirecting to the dashboard)
|
|
359
|
+
var curr = fe.pageHandler.current_page;
|
|
360
|
+
$.ajax({url: url, dataType:'script',
|
|
361
|
+
data: {answer_sheet_type: answer_sheet_type, a: $('input[type=hidden][name=a]').val()},
|
|
362
|
+
type:'post',
|
|
363
|
+
beforeSend: function(xhr) {
|
|
364
|
+
$('body').trigger('ajax:loading', xhr);
|
|
365
|
+
},
|
|
366
|
+
success: function(xhr) {
|
|
367
|
+
$('#list-pages a').each(function() {
|
|
368
|
+
if ($(this).attr('data-page-id') != curr) $('#' + $(this).attr('data-page-id')).remove();
|
|
369
|
+
})
|
|
370
|
+
},
|
|
371
|
+
complete: function(xhr) {
|
|
372
|
+
$('body').trigger('ajax:complete', xhr);
|
|
373
|
+
var btn = $('#submit_button');
|
|
374
|
+
if (btn) { btn.attr('disabled', false); }
|
|
375
|
+
}
|
|
376
|
+
});
|
|
377
|
+
}
|
|
378
|
+
}
|
|
379
|
+
else
|
|
380
|
+
{
|
|
381
|
+
// some pages aren't valid
|
|
382
|
+
$('#submit_message, .submit_message').html("Please make a payment");
|
|
383
|
+
$('#submit_message, .submit_message').show();
|
|
384
|
+
|
|
385
|
+
var btn = $('#submit_button'); if (btn) { btn.attr('disabled', false); }
|
|
386
|
+
}
|
|
387
|
+
},
|
|
388
|
+
|
|
389
|
+
// is page loaded? (useful for toggling enabled state of questions)
|
|
390
|
+
isPageLoaded : function(page)
|
|
391
|
+
{
|
|
392
|
+
return $('#' + page)[0] != null
|
|
393
|
+
},
|
|
394
|
+
|
|
395
|
+
checkConditional : function($element) {
|
|
396
|
+
matchable_answers = String($element.data('conditional_answer')).split(';').map(function(s) { return s.trim(); })
|
|
397
|
+
if ($element.hasClass('fe_choicefield') && ($element.hasClass('style_yes-no') || $element.hasClass('yes-no'))) {
|
|
398
|
+
if ($(matchable_answers).filter([1, '1', true, 'true', 'yes', 'Yes']).length > 0) {
|
|
399
|
+
matchable_answers = [1, '1', true, 'true', 'yes', 'Yes'];
|
|
400
|
+
}
|
|
401
|
+
if ($(matchable_answers).filter([0, '0', false, 'false', 'no', 'No']).length > 0) {
|
|
402
|
+
matchable_answers = [0, '0', false, 'false', 'no', 'No'];
|
|
403
|
+
}
|
|
404
|
+
vals = $([$element.find("input[type=radio]:checked").val()]);
|
|
405
|
+
} else if ($element.hasClass('fe_choicefield') && $element.hasClass('checkbox')) {
|
|
406
|
+
vals = $element.find("input[type=checkbox]:checked").map(function(i, el) { return $(el).val(); });
|
|
407
|
+
} else if ($element.hasClass('fe_choicefield') && $element.hasClass('radio')) {
|
|
408
|
+
vals = $([$element.find("input[type=radio]:checked").val()]);
|
|
409
|
+
} else {
|
|
410
|
+
vals = $([$element.find("input:visible, select:visible").val()]);
|
|
411
|
+
}
|
|
412
|
+
match = $(matchable_answers).filter(vals).length > 0 || (matchable_answers == "" && vals.length == 0);
|
|
413
|
+
|
|
414
|
+
switch ($element.data('conditional_type')) {
|
|
415
|
+
case 'Fe::Element':
|
|
416
|
+
if (match) {
|
|
417
|
+
$("#element_" + $element.data('conditional_id')).show();
|
|
418
|
+
} else {
|
|
419
|
+
$("#element_" + $element.data('conditional_id')).hide();
|
|
420
|
+
}
|
|
421
|
+
break;
|
|
422
|
+
case 'Fe::Page':
|
|
423
|
+
prefix = $element.data('answer_sheet_id_prefix');
|
|
424
|
+
pg = prefix + '_' + $element.data('application_id') + '-fe_page_' + $element.data('conditional_id');
|
|
425
|
+
li_id = 'li#'+pg+'-li';
|
|
426
|
+
li_id += ', li#'+pg+'-no_cache-li';
|
|
427
|
+
|
|
428
|
+
if (match) {
|
|
429
|
+
$(li_id).show();
|
|
430
|
+
// load the page (in the background) to determine validity
|
|
431
|
+
this.loadPage(pg, $(li_id).find('a').attr('href'), true);
|
|
432
|
+
} else {
|
|
433
|
+
$(li_id).hide();
|
|
434
|
+
}
|
|
435
|
+
break;
|
|
436
|
+
}
|
|
437
|
+
},
|
|
438
|
+
|
|
439
|
+
next : function(validate_current_page) {
|
|
440
|
+
validate_current_page = typeof validate_current_page !== 'undefined' ? validate_current_page : false;
|
|
441
|
+
|
|
442
|
+
curr_page_link = $('#'+fe.pageHandler.current_page+"-link");
|
|
443
|
+
//fe.pageHandler.loadPage('application_22544-fe_page_165-no_cache','/fe/answer_sheets/22544/page/165/edit'); return false;
|
|
444
|
+
page_link = curr_page_link
|
|
445
|
+
.parents('.application_section')
|
|
446
|
+
.nextAll()
|
|
447
|
+
.filter(function() { return $(this).find('a.page_link:visible').length > 0 })
|
|
448
|
+
.first()
|
|
449
|
+
.find('a.page_link');
|
|
450
|
+
$(".answer-page:visible div.buttons button").prop("disabled", true)
|
|
451
|
+
fe.pageHandler.loadPage(page_link.data('page-id'), page_link.attr('href'), false, validate_current_page);
|
|
452
|
+
},
|
|
453
|
+
|
|
454
|
+
prev : function() {
|
|
455
|
+
curr_page_link = $('#'+fe.pageHandler.current_page+"-link");
|
|
456
|
+
//fe.pageHandler.loadPage('application_22544-fe_page_165-no_cache','/fe/answer_sheets/22544/page/165/edit'); return false;
|
|
457
|
+
page_link = curr_page_link
|
|
458
|
+
.parents('.application_section')
|
|
459
|
+
.prevAll()
|
|
460
|
+
.filter(function() { return $(this).find('a.page_link:visible').length > 0 })
|
|
461
|
+
.first()
|
|
462
|
+
.find('a.page_link');
|
|
463
|
+
$(".answer-page:visible div.buttons button").prop("disabled", true)
|
|
464
|
+
fe.pageHandler.loadPage(page_link.data('page-id'), page_link.attr('href'));
|
|
465
|
+
}
|
|
466
|
+
|
|
467
|
+
};
|
|
468
|
+
|
|
469
|
+
$(document).on('click', ".conditional input, .conditional select", function() {
|
|
470
|
+
fe.pageHandler.checkConditional($(this).closest('.conditional'));
|
|
471
|
+
});
|
|
472
|
+
$(document).on('keyup', ".conditional input, .conditional select", function() { $(this).click(); });
|
|
473
|
+
$(document).on('blug', ".conditional input, .conditional select", function() { $(this).click(); });
|
|
474
|
+
$(document).on('change', ".conditional select", function() { $(this).click(); });
|
|
475
|
+
|
|
476
|
+
$(document).on('keyup', 'textarea[maxlength]', function() {
|
|
477
|
+
maxlength = parseInt($(this).attr('maxlength'));
|
|
478
|
+
remaining = maxlength - $(this).val().length;
|
|
479
|
+
$('#'+$(this).attr('id')+'_count').val(remaining);
|
|
480
|
+
});
|
|
481
|
+
|
|
482
|
+
$(document).on('click', 'a[disabled]', function(event) {
|
|
483
|
+
event.preventDefault();
|
|
484
|
+
});
|
|
485
|
+
})(jQuery);
|
|
486
|
+
|
|
487
|
+
$(function() {
|
|
488
|
+
fixGridColumnWidths();
|
|
489
|
+
setUpCalendars();
|
|
490
|
+
});
|
|
491
|
+
|
|
492
|
+
|
|
493
|
+
function updateTotal(id) {
|
|
494
|
+
try {
|
|
495
|
+
total = 0;
|
|
496
|
+
$(".col_" + id).each(function(index, el) {
|
|
497
|
+
total += Number($(el).val().replace(',',''));
|
|
498
|
+
});
|
|
499
|
+
$('#total_' + id).val(total).trigger('totalChanged');
|
|
500
|
+
} catch(e) {
|
|
501
|
+
}
|
|
502
|
+
}
|
|
503
|
+
|
|
504
|
+
function submitToFrame(id, url) {
|
|
505
|
+
form = $('<form method="post" action="'+url+'.js" endtype="multipart/form-data"></form>')
|
|
506
|
+
var csrf_token = $('meta[name=csrf-token]').attr('content'),
|
|
507
|
+
csrf_param = $('meta[name=csrf-param]').attr('content'),
|
|
508
|
+
dom_id = '#attachment_field_' + id,
|
|
509
|
+
metadata_input = '<input name="'+csrf_param+'" value="'+csrf_token+'" type="hidden" />',
|
|
510
|
+
file_field = '<input type="file" name="answers['+ id + ']>';
|
|
511
|
+
if ($(dom_id).val() == '') return;
|
|
512
|
+
form.hide()
|
|
513
|
+
.append(metadata_input)
|
|
514
|
+
.append(file_field)
|
|
515
|
+
.appendTo('body');
|
|
516
|
+
$(dom_id + "-spinner").show();
|
|
517
|
+
form.submit();
|
|
518
|
+
return false
|
|
519
|
+
}
|
|
520
|
+
|
|
521
|
+
function scrollTo(el) {
|
|
522
|
+
if ($(el).length == 0) { return; }
|
|
523
|
+
$('html, body').animate({
|
|
524
|
+
scrollTop: $(el).offset().top
|
|
525
|
+
}, 1000);
|
|
526
|
+
}
|