fe 0.0.3
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 +7 -0
- data/MIT-LICENSE +20 -0
- data/README.md +20 -0
- data/Rakefile +48 -0
- data/app/assets/images/fe/ajax-loader.gif +0 -0
- data/app/assets/images/fe/butgrad.png +0 -0
- data/app/assets/images/fe/icons/add.png +0 -0
- data/app/assets/images/fe/icons/application_form.png +0 -0
- data/app/assets/images/fe/icons/application_form_add.png +0 -0
- data/app/assets/images/fe/icons/arrow-move.png +0 -0
- data/app/assets/images/fe/icons/arrow_out.png +0 -0
- data/app/assets/images/fe/icons/asterisk_yellow.png +0 -0
- data/app/assets/images/fe/icons/book-open-list.png +0 -0
- data/app/assets/images/fe/icons/book_open.png +0 -0
- data/app/assets/images/fe/icons/briefcase.png +0 -0
- data/app/assets/images/fe/icons/calendar_view_day.png +0 -0
- data/app/assets/images/fe/icons/checkbox.png +0 -0
- data/app/assets/images/fe/icons/copy_paste.gif +0 -0
- data/app/assets/images/fe/icons/disk.png +0 -0
- data/app/assets/images/fe/icons/document--pencil.png +0 -0
- data/app/assets/images/fe/icons/document-copy.png +0 -0
- data/app/assets/images/fe/icons/map_magnify.png +0 -0
- data/app/assets/images/fe/icons/minus-button.png +0 -0
- data/app/assets/images/fe/icons/move.png +0 -0
- data/app/assets/images/fe/icons/page_error.png +0 -0
- data/app/assets/images/fe/icons/page_valid.png +0 -0
- data/app/assets/images/fe/icons/page_white.png +0 -0
- data/app/assets/images/fe/icons/page_white_add.png +0 -0
- data/app/assets/images/fe/icons/page_white_error.png +0 -0
- data/app/assets/images/fe/icons/paper-clip.png +0 -0
- data/app/assets/images/fe/icons/pencil-small.png +0 -0
- data/app/assets/images/fe/icons/pencil.png +0 -0
- data/app/assets/images/fe/icons/question-balloon.png +0 -0
- data/app/assets/images/fe/icons/radio.png +0 -0
- data/app/assets/images/fe/icons/star-small.png +0 -0
- data/app/assets/images/fe/icons/table.png +0 -0
- data/app/assets/images/fe/icons/text_align_left.png +0 -0
- data/app/assets/images/fe/icons/text_horizontalrule.png +0 -0
- data/app/assets/images/fe/icons/textfield.png +0 -0
- data/app/assets/images/fe/indent.png +0 -0
- data/app/assets/images/fe/overlay.png +0 -0
- data/app/assets/images/fe/selected_bg.jpg +0 -0
- data/app/assets/images/fe/status.gif +0 -0
- data/app/assets/images/fe/tooltip/black.png +0 -0
- data/app/assets/images/fe/tooltip/black_arrow.png +0 -0
- data/app/assets/images/fe/tooltip/black_arrow_big.png +0 -0
- data/app/assets/images/fe/tooltip/black_big.png +0 -0
- data/app/assets/images/fe/tooltip/white.png +0 -0
- data/app/assets/images/fe/tooltip/white_arrow.png +0 -0
- data/app/assets/images/fe/tooltip/white_arrow_big.png +0 -0
- data/app/assets/images/fe/tooltip/white_big.png +0 -0
- data/app/assets/images/fe/uploadify/cancel.png +0 -0
- data/app/assets/images/fe/uploadify/uploadify.swf +0 -0
- data/app/assets/javascripts/fe/admin.js +7 -0
- data/app/assets/javascripts/fe/jquery.metadata.js +122 -0
- data/app/assets/javascripts/fe/jquery.scrollTo-min.js +7 -0
- data/app/assets/javascripts/fe/jquery.uploadify.v2.1.0.js +258 -0
- data/app/assets/javascripts/fe/jquery.validate.pack.js +15 -0
- data/app/assets/javascripts/fe/qe.admin.js +115 -0
- data/app/assets/javascripts/fe/qe.common.js +57 -0
- data/app/assets/javascripts/fe/qe.public.js +331 -0
- data/app/assets/javascripts/fe/swfobject.js +4 -0
- data/app/assets/stylesheets/fe/qe.screen.css.scss.erb +552 -0
- data/app/assets/stylesheets/fe/reset.css +55 -0
- data/app/assets/stylesheets/fe/validation.css +91 -0
- data/app/controllers/fe/admin/elements_controller.rb +185 -0
- data/app/controllers/fe/admin/email_templates_controller.rb +61 -0
- data/app/controllers/fe/admin/question_pages_controller.rb +113 -0
- data/app/controllers/fe/admin/question_sheets_controller.rb +106 -0
- data/app/controllers/fe/answer_pages_controller.rb +3 -0
- data/app/controllers/fe/answer_sheets_controller.rb +3 -0
- data/app/controllers/fe/concerns/answer_pages_controller_concern.rb +80 -0
- data/app/controllers/fe/concerns/answer_sheets_controller_concern.rb +84 -0
- data/app/controllers/fe/reference_sheets_controller.rb +29 -0
- data/app/helpers/fe/answer_pages_helper.rb +19 -0
- data/app/helpers/fe/application_helper.rb +49 -0
- data/app/mailers/fe/notifier.rb +22 -0
- data/app/models/fe/answer.rb +13 -0
- data/app/models/fe/answer_pages_presenter.rb +13 -0
- data/app/models/fe/answer_sheet.rb +10 -0
- data/app/models/fe/answer_sheet_question_sheet.rb +7 -0
- data/app/models/fe/attachment_field.rb +7 -0
- data/app/models/fe/choice_field.rb +7 -0
- data/app/models/fe/concerns/answer_concern.rb +36 -0
- data/app/models/fe/concerns/answer_pages_presenter_concern.rb +99 -0
- data/app/models/fe/concerns/answer_sheet_concern.rb +61 -0
- data/app/models/fe/concerns/choice_field_concern.rb +131 -0
- data/app/models/fe/condition.rb +53 -0
- data/app/models/fe/date_field.rb +52 -0
- data/app/models/fe/element.rb +164 -0
- data/app/models/fe/email_template.rb +7 -0
- data/app/models/fe/option.rb +10 -0
- data/app/models/fe/option_group.rb +10 -0
- data/app/models/fe/page.rb +101 -0
- data/app/models/fe/page_element.rb +9 -0
- data/app/models/fe/page_link.rb +15 -0
- data/app/models/fe/paragraph.rb +10 -0
- data/app/models/fe/payment.rb +52 -0
- data/app/models/fe/payment_question.rb +22 -0
- data/app/models/fe/presenter.rb +23 -0
- data/app/models/fe/question.rb +256 -0
- data/app/models/fe/question_grid.rb +26 -0
- data/app/models/fe/question_grid_with_total.rb +11 -0
- data/app/models/fe/question_set.rb +82 -0
- data/app/models/fe/question_sheet.rb +73 -0
- data/app/models/fe/reference_question.rb +42 -0
- data/app/models/fe/reference_sheet.rb +149 -0
- data/app/models/fe/section.rb +12 -0
- data/app/models/fe/state_chooser.rb +10 -0
- data/app/models/fe/text_field.rb +29 -0
- data/app/views/fe/admin/elements/_errors.html.erb +1 -0
- data/app/views/fe/admin/elements/create.js.erb +11 -0
- data/app/views/fe/admin/elements/destroy.js.erb +4 -0
- data/app/views/fe/admin/elements/drop.js.erb +2 -0
- data/app/views/fe/admin/elements/duplicate.js.erb +2 -0
- data/app/views/fe/admin/elements/edit.js.erb +4 -0
- data/app/views/fe/admin/elements/error.js.erb +4 -0
- data/app/views/fe/admin/elements/new.js.erb +10 -0
- data/app/views/fe/admin/elements/reorder.js.erb +0 -0
- data/app/views/fe/admin/elements/update.js.erb +9 -0
- data/app/views/fe/admin/email_templates/_form.html.erb +8 -0
- data/app/views/fe/admin/email_templates/edit.html.erb +13 -0
- data/app/views/fe/admin/email_templates/index.html.erb +20 -0
- data/app/views/fe/admin/email_templates/new.html.erb +11 -0
- data/app/views/fe/admin/panels/_advanced_options.html.erb +16 -0
- data/app/views/fe/admin/panels/_common_fields.html.erb +24 -0
- data/app/views/fe/admin/panels/_condition.html.erb +6 -0
- data/app/views/fe/admin/panels/_insert.html.erb +39 -0
- data/app/views/fe/admin/panels/_nav_controls.html.erb +6 -0
- data/app/views/fe/admin/panels/_page.html.erb +3 -0
- data/app/views/fe/admin/panels/_pages_list.html.erb +16 -0
- data/app/views/fe/admin/panels/_prop_attachment_field.html.erb +2 -0
- data/app/views/fe/admin/panels/_prop_choice_field.html.erb +46 -0
- data/app/views/fe/admin/panels/_prop_date_field.html.erb +7 -0
- data/app/views/fe/admin/panels/_prop_element.html.erb +30 -0
- data/app/views/fe/admin/panels/_prop_page.html.erb +21 -0
- data/app/views/fe/admin/panels/_prop_paragraph.html.erb +32 -0
- data/app/views/fe/admin/panels/_prop_question_grid.html.erb +23 -0
- data/app/views/fe/admin/panels/_prop_question_grid_with_total.html.erb +14 -0
- data/app/views/fe/admin/panels/_prop_reference_question.html.erb +12 -0
- data/app/views/fe/admin/panels/_prop_section.html.erb +2 -0
- data/app/views/fe/admin/panels/_prop_sheet.html.erb +17 -0
- data/app/views/fe/admin/panels/_prop_text_field.html.erb +20 -0
- data/app/views/fe/admin/question_pages/_element.html.erb +18 -0
- data/app/views/fe/admin/question_pages/_element_show.html.erb +10 -0
- data/app/views/fe/admin/question_pages/_errors.html.erb +1 -0
- data/app/views/fe/admin/question_pages/_question_page.html.erb +13 -0
- data/app/views/fe/admin/question_pages/create.js.erb +11 -0
- data/app/views/fe/admin/question_pages/destroy.js.erb +5 -0
- data/app/views/fe/admin/question_pages/edit.js.erb +3 -0
- data/app/views/fe/admin/question_pages/error.js.erb +4 -0
- data/app/views/fe/admin/question_pages/show.js.erb +8 -0
- data/app/views/fe/admin/question_pages/show_panel.js.erb +3 -0
- data/app/views/fe/admin/question_pages/update.js.erb +2 -0
- data/app/views/fe/admin/question_sheets/_errors.html.erb +1 -0
- data/app/views/fe/admin/question_sheets/edit.js.erb +3 -0
- data/app/views/fe/admin/question_sheets/error.js.erb +5 -0
- data/app/views/fe/admin/question_sheets/index.html.erb +41 -0
- data/app/views/fe/admin/question_sheets/new.html.erb +15 -0
- data/app/views/fe/admin/question_sheets/show.html.erb +27 -0
- data/app/views/fe/admin/question_sheets/update.js.erb +2 -0
- data/app/views/fe/answer_pages/_answer_page.html.erb +56 -0
- data/app/views/fe/answer_pages/_element.html.erb +9 -0
- data/app/views/fe/answer_pages/update.js.erb +5 -0
- data/app/views/fe/answer_sheets/_answer_sheet.html.erb +24 -0
- data/app/views/fe/answer_sheets/_element.html.erb +54 -0
- data/app/views/fe/answer_sheets/_incomplete.html.erb +10 -0
- data/app/views/fe/answer_sheets/_page_link.html.erb +7 -0
- data/app/views/fe/answer_sheets/_pages_list.html.erb +11 -0
- data/app/views/fe/answer_sheets/_title.html.erb +1 -0
- data/app/views/fe/answer_sheets/edit.html.erb +60 -0
- data/app/views/fe/answer_sheets/incomplete.js.erb +5 -0
- data/app/views/fe/answer_sheets/index.html.erb +18 -0
- data/app/views/fe/answer_sheets/send_reference_invite.js.erb +8 -0
- data/app/views/fe/answer_sheets/show.html.erb +13 -0
- data/app/views/fe/help/builder.html +33 -0
- data/app/views/fe/help/question_grid.html +18 -0
- data/app/views/fe/questions/_acceptance.html.erb +13 -0
- data/app/views/fe/questions/_attachment_field.html.erb +42 -0
- data/app/views/fe/questions/_checkbox_field.html.erb +49 -0
- data/app/views/fe/questions/_country.html.erb +7 -0
- data/app/views/fe/questions/_date_field.html.erb +7 -0
- data/app/views/fe/questions/_date_field_mmyy.html.erb +9 -0
- data/app/views/fe/questions/_drop_down_field.html.erb +7 -0
- data/app/views/fe/questions/_paragraph.html.erb +1 -0
- data/app/views/fe/questions/_question_grid.html.erb +65 -0
- data/app/views/fe/questions/_question_grid_with_total.html.erb +57 -0
- data/app/views/fe/questions/_questions.html.erb +9 -0
- data/app/views/fe/questions/_radio_button_field.html.erb +41 -0
- data/app/views/fe/questions/_rating.html.erb +25 -0
- data/app/views/fe/questions/_reference_discipler.html.erb +1 -0
- data/app/views/fe/questions/_reference_friend.html.erb +1 -0
- data/app/views/fe/questions/_reference_parent.html.erb +1 -0
- data/app/views/fe/questions/_reference_peer.html.erb +1 -0
- data/app/views/fe/questions/_reference_question.html.erb +38 -0
- data/app/views/fe/questions/_reference_roommate.html.erb +1 -0
- data/app/views/fe/questions/_reference_spiritual.html.erb +1 -0
- data/app/views/fe/questions/_reference_staff.html.erb +1 -0
- data/app/views/fe/questions/_section.html.erb +1 -0
- data/app/views/fe/questions/_state_chooser.html.erb +7 -0
- data/app/views/fe/questions/_text_area_field.html.erb +6 -0
- data/app/views/fe/questions/_text_field.html.erb +8 -0
- data/app/views/fe/questions/_yes_no.html.erb +17 -0
- data/app/views/fe/questions/_yes_no_field.erb +17 -0
- data/app/views/fe/reference_sheets/not_found.html.erb +5 -0
- data/app/views/layouts/fe/application.html.erb +31 -0
- data/app/views/layouts/fe/qe.admin.html.erb +30 -0
- data/config/routes.rb +49 -0
- data/db/migrate/20131003041856_core.rb +91 -0
- data/db/migrate/20131003044250_create_reference_sheets.rb +23 -0
- data/db/migrate/20131003044436_add_element_and_answer_fields.rb +10 -0
- data/db/migrate/20131003044518_create_email_templates.rb +17 -0
- data/db/migrate/20131003044621_add_max_lengths.rb +8 -0
- data/db/migrate/20131003044714_create_join_table.rb +11 -0
- data/db/migrate/20131016162128_remove_question_id_from_element.rb +9 -0
- data/lib/fe.rb +22 -0
- data/lib/fe/engine.rb +19 -0
- data/lib/fe/version.rb +3 -0
- data/lib/generators/fe/install_generator.rb +132 -0
- data/lib/tasks/qe_tasks.rake +4 -0
- data/spec/controllers/fe/admin/elements_controller_spec.rb +4 -0
- data/spec/controllers/fe/admin/email_templates_controller_spec.rb +4 -0
- data/spec/controllers/fe/admin/question_pages_controller_spec.rb +4 -0
- data/spec/controllers/fe/admin/question_sheets_controller_spec.rb +4 -0
- data/spec/controllers/fe/answer_pages_controller_spec.rb +4 -0
- data/spec/controllers/fe/answer_sheets_controller_spec.rb +4 -0
- data/spec/controllers/fe/reference_sheets_controller_spec.rb +4 -0
- data/spec/factories/answer_sheets.rb +5 -0
- data/spec/factories/answers.rb +4 -0
- data/spec/factories/paragraphs.rb +4 -0
- data/spec/factories/question_sheet.rb +5 -0
- data/spec/factories/reference_questions.rb +4 -0
- data/spec/models/fe/answer_sheet_question_sheet_spec.rb +6 -0
- data/spec/models/fe/answer_sheet_spec.rb +8 -0
- data/spec/models/fe/answer_spec.rb +13 -0
- data/spec/models/fe/attachment_field_spec.rb +4 -0
- data/spec/models/fe/choice_field_spec.rb +5 -0
- data/spec/models/fe/condition_spec.rb +8 -0
- data/spec/models/fe/date_field_spec.rb +49 -0
- data/spec/models/fe/element_spec.rb +12 -0
- data/spec/models/fe/email_template_spec.rb +5 -0
- data/spec/models/fe/option_group_spec.rb +4 -0
- data/spec/models/fe/option_spec.rb +4 -0
- data/spec/models/fe/page_element_spec.rb +6 -0
- data/spec/models/fe/page_link_spec.rb +4 -0
- data/spec/models/fe/page_spec.rb +14 -0
- data/spec/models/fe/paragraph_spec.rb +17 -0
- data/spec/models/fe/question_grid_spec.rb +4 -0
- data/spec/models/fe/question_grid_with_total_spec.rb +4 -0
- data/spec/models/fe/question_set_spec.rb +4 -0
- data/spec/models/fe/question_sheet_spec.rb +8 -0
- data/spec/models/fe/question_spec.rb +20 -0
- data/spec/models/fe/reference_question_spec.rb +17 -0
- data/spec/models/fe/reference_sheet_spec.rb +11 -0
- data/spec/models/fe/section_spec.rb +4 -0
- data/spec/models/fe/state_chooser_spec.rb +4 -0
- data/spec/models/fe/text_field_spec.rb +17 -0
- data/spec/spec_helper.rb +66 -0
- data/spec/support/database.txt +28 -0
- metadata +508 -0
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
html, body, div, span, applet, object, iframe,
|
|
2
|
+
h1, h2, h3, h4, h5, h6, p, blockquote, pre,
|
|
3
|
+
a, abbr, acronym, address, big, cite, code,
|
|
4
|
+
del, dfn, em, font, img, ins, kbd, q, s, samp,
|
|
5
|
+
small, strike, strong, sub, sup, tt, var,
|
|
6
|
+
dl, dt, dd, ol, ul, li,
|
|
7
|
+
fieldset, form, label, legend,
|
|
8
|
+
table, caption, tbody, tfoot, thead, tr, th, td {
|
|
9
|
+
margin: 0;
|
|
10
|
+
padding: 0;
|
|
11
|
+
border: 0;
|
|
12
|
+
outline: 0;
|
|
13
|
+
font-weight: inherit;
|
|
14
|
+
font-style: inherit;
|
|
15
|
+
font-size: 100%;
|
|
16
|
+
font-family: inherit;
|
|
17
|
+
vertical-align: baseline;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/* remember to define focus styles! */
|
|
21
|
+
|
|
22
|
+
:focus {
|
|
23
|
+
outline: 0;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
body {
|
|
27
|
+
line-height: 1;
|
|
28
|
+
color: black;
|
|
29
|
+
background: white;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
ol, ul {
|
|
33
|
+
list-style: none;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/* tables still need 'cellspacing="0"' in the markup */
|
|
37
|
+
|
|
38
|
+
table {
|
|
39
|
+
border-collapse: separate;
|
|
40
|
+
border-spacing: 0;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
caption, th, td {
|
|
44
|
+
text-align: left;
|
|
45
|
+
font-weight: normal;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
blockquote:before, blockquote:after,
|
|
49
|
+
q:before, q:after {
|
|
50
|
+
content: "";
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
blockquote, q {
|
|
54
|
+
quotes: "" "";
|
|
55
|
+
}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
.fieldWithErrors {
|
|
2
|
+
border: solid 1px red !important;
|
|
3
|
+
background: #fee;
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
#errorExplanation {
|
|
7
|
+
width: 30em;
|
|
8
|
+
border: 1px solid red;
|
|
9
|
+
margin-bottom: 1em;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
#errorExplanation h2 {
|
|
13
|
+
text-align: left;
|
|
14
|
+
font-weight: bold;
|
|
15
|
+
padding: 0.5em;
|
|
16
|
+
font-size: 12px;
|
|
17
|
+
background-color: #c00;
|
|
18
|
+
color: #fff;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
#errorExplanation p {
|
|
22
|
+
color: #333;
|
|
23
|
+
margin-bottom: 0;
|
|
24
|
+
padding: 0.5em;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
#errorExplanation ul li {
|
|
28
|
+
padding: 0.5em;
|
|
29
|
+
font-size: small;
|
|
30
|
+
list-style-type: square;
|
|
31
|
+
margin-left: 0.5em;
|
|
32
|
+
list-style-position: inside;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
input.disabled {
|
|
36
|
+
border: 1px solid #F2F2F2;
|
|
37
|
+
background-color: #F2F2F2;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
input.required, textarea.required {
|
|
41
|
+
border: 1px solid #ccc;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
input.validation-failed, textarea.validation-failed {
|
|
45
|
+
border: 1px solid #FF3300;
|
|
46
|
+
color: #FF3300;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
input.validation-passed, textarea.validation-passed {
|
|
50
|
+
border: 1px solid #ccc;
|
|
51
|
+
color: #000;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
.validation-advice {
|
|
55
|
+
margin: 5px 0;
|
|
56
|
+
padding: 5px;
|
|
57
|
+
background: #ffe5df;
|
|
58
|
+
border: solid 1px #efbeb3;
|
|
59
|
+
color: black;
|
|
60
|
+
font-weight: bold;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
.custom-advice {
|
|
64
|
+
margin: 5px 0;
|
|
65
|
+
padding: 5px;
|
|
66
|
+
background-color: #C8AA00;
|
|
67
|
+
color: #FFF;
|
|
68
|
+
font-weight: bold;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
fieldset {
|
|
72
|
+
padding: 1em;
|
|
73
|
+
margin-bottom: 0.5em;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
label {
|
|
77
|
+
font-weight: bold;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
.form-row {
|
|
81
|
+
clear: both;
|
|
82
|
+
padding: 0.5em;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
.field-label {
|
|
86
|
+
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
.field-widget {
|
|
90
|
+
|
|
91
|
+
}
|
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
class Fe::Admin::ElementsController < ApplicationController
|
|
2
|
+
before_filter :check_valid_user
|
|
3
|
+
layout 'fe.admin'
|
|
4
|
+
|
|
5
|
+
before_filter :get_page
|
|
6
|
+
|
|
7
|
+
# GET /elements/1
|
|
8
|
+
def show
|
|
9
|
+
@element = Fe::Element.find(params[:id])
|
|
10
|
+
|
|
11
|
+
respond_to do |format|
|
|
12
|
+
format.js
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
# GET /element/1/edit
|
|
17
|
+
def edit
|
|
18
|
+
@element = Fe::Element.find(params[:id])
|
|
19
|
+
|
|
20
|
+
# for dependencies
|
|
21
|
+
if @element.question?
|
|
22
|
+
(3 - @element.conditions.length).times { @element.conditions.build }
|
|
23
|
+
@questions_before_this = @page.questions_before_position(@element.position(@page))
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
respond_to do |format|
|
|
27
|
+
format.js
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
def new
|
|
32
|
+
@questions = params[:element_type].constantize.active.order('label')
|
|
33
|
+
|
|
34
|
+
@style = element_params[:style]
|
|
35
|
+
if @style
|
|
36
|
+
@questions = @questions.where(:style => @style).uniq
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
def use_existing
|
|
41
|
+
@element = Fe::Element.find(params[:id])
|
|
42
|
+
# Don't put the same question on a questionnaire twice
|
|
43
|
+
unless @page.question_sheet.elements.include?(@element)
|
|
44
|
+
@page_element = Fe::PageElement.create(:element => @element, :page => @page)
|
|
45
|
+
end
|
|
46
|
+
@question_sheet = @page.question_sheet
|
|
47
|
+
render :create
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
# POST /elements
|
|
51
|
+
def create
|
|
52
|
+
@element = params[:element_type].constantize.new(element_params)
|
|
53
|
+
@element.required = true if @element.question?
|
|
54
|
+
@question_sheet = @page.question_sheet
|
|
55
|
+
|
|
56
|
+
respond_to do |format|
|
|
57
|
+
if @element.save!
|
|
58
|
+
@page_element = Fe::PageElement.create(:element => @element, :page => @page)
|
|
59
|
+
format.js
|
|
60
|
+
else
|
|
61
|
+
format.js { render :action => 'error.rjs' }
|
|
62
|
+
end
|
|
63
|
+
end
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
# PUT /elements/1
|
|
67
|
+
def update
|
|
68
|
+
@element = Fe::Element.find(params[:id])
|
|
69
|
+
|
|
70
|
+
respond_to do |format|
|
|
71
|
+
if @element.update_attributes(element_params)
|
|
72
|
+
format.js
|
|
73
|
+
else
|
|
74
|
+
format.js { render :action => 'error.rjs' }
|
|
75
|
+
end
|
|
76
|
+
end
|
|
77
|
+
end
|
|
78
|
+
|
|
79
|
+
# DELETE /elements/1
|
|
80
|
+
# DELETE /elements/1.xml
|
|
81
|
+
def destroy
|
|
82
|
+
@element = Fe::Element.find(params[:id])
|
|
83
|
+
# Start by removing the element from the page
|
|
84
|
+
page_element = Fe::PageElement.where(:element_id => @element.id, :page_id => @page.id).first
|
|
85
|
+
page_element.destroy if page_element
|
|
86
|
+
|
|
87
|
+
# If this element is not on any other pages, is not a question or has no answers, Destroy it
|
|
88
|
+
if @element.reuseable? && (Fe::PageElement.where(:element_id => params[:id]).present? || @element.has_response?)
|
|
89
|
+
@element.update_attributes(:question_grid_id => nil, :conditional_id => nil)
|
|
90
|
+
else
|
|
91
|
+
@element.destroy
|
|
92
|
+
end
|
|
93
|
+
|
|
94
|
+
respond_to do |format|
|
|
95
|
+
format.js
|
|
96
|
+
end
|
|
97
|
+
end
|
|
98
|
+
|
|
99
|
+
def reorder
|
|
100
|
+
# since we don't know the name of the list, just find the first param that is an array
|
|
101
|
+
params.each_key do |key|
|
|
102
|
+
if key.include?('questions_list')
|
|
103
|
+
grid_id = key.sub('questions_list_', '').to_i
|
|
104
|
+
# See if we're ordering inside of a grid
|
|
105
|
+
if grid_id > 0
|
|
106
|
+
Fe::Element.find(grid_id).elements.each do |element|
|
|
107
|
+
if index = params[key].index(element.id.to_s)
|
|
108
|
+
element.position = index + 1
|
|
109
|
+
element.save(:validate => false)
|
|
110
|
+
end
|
|
111
|
+
end
|
|
112
|
+
else
|
|
113
|
+
@page.page_elements.each do |page_element|
|
|
114
|
+
if index = params[key].index(page_element.element_id.to_s)
|
|
115
|
+
page_element.position = index + 1
|
|
116
|
+
page_element.save(:validate => false)
|
|
117
|
+
@element = page_element.element
|
|
118
|
+
end
|
|
119
|
+
end
|
|
120
|
+
end
|
|
121
|
+
end
|
|
122
|
+
end
|
|
123
|
+
|
|
124
|
+
respond_to do |format|
|
|
125
|
+
format.js
|
|
126
|
+
end
|
|
127
|
+
end
|
|
128
|
+
|
|
129
|
+
def drop
|
|
130
|
+
element = Fe::Element.find(params[:draggable_element].split('_')[1]) # element being dropped
|
|
131
|
+
target = Fe::Element.find(params[:id])
|
|
132
|
+
case target.class.to_s
|
|
133
|
+
when 'QuestionGrid', 'QuestionGridWithTotal'
|
|
134
|
+
# abort if the element is already in this box
|
|
135
|
+
if element.question_grid_id == params[:id].to_i
|
|
136
|
+
render :nothing => true
|
|
137
|
+
else
|
|
138
|
+
element.question_grid_id = params[:id]
|
|
139
|
+
element.save!
|
|
140
|
+
end
|
|
141
|
+
when 'ChoiceField'
|
|
142
|
+
# abort if the element is already in this box
|
|
143
|
+
if element.conditional_id == params[:id].to_i
|
|
144
|
+
render :nothing => true
|
|
145
|
+
else
|
|
146
|
+
element.conditional_id = params[:id]
|
|
147
|
+
element.save!
|
|
148
|
+
end
|
|
149
|
+
end
|
|
150
|
+
# Remove page element for this page since it's now in a grid
|
|
151
|
+
Fe::PageElement.where(:page_id => @page.id, :element_id => element.id).first.try(:destroy)
|
|
152
|
+
end
|
|
153
|
+
|
|
154
|
+
def remove_from_grid
|
|
155
|
+
element = Fe::Element.find(params[:id])
|
|
156
|
+
Fe::PageElement.create(:element_id => element.id, :page_id => @page.id) unless Fe::PageElement.where(:element_id => element.id, :page_id => @page.id).first
|
|
157
|
+
if element.question_grid_id
|
|
158
|
+
element.set_position(element.question_grid.position(@page), @page)
|
|
159
|
+
element.question_grid_id = nil
|
|
160
|
+
elsif element.conditional_id
|
|
161
|
+
element.set_position(element.choice_field.position(@page), @page)
|
|
162
|
+
element.conditional_id = nil
|
|
163
|
+
end
|
|
164
|
+
element.save!
|
|
165
|
+
render :action => :drop
|
|
166
|
+
end
|
|
167
|
+
|
|
168
|
+
def duplicate
|
|
169
|
+
element = Fe::Element.find(params[:id])
|
|
170
|
+
@element = element.duplicate(@page, element.question_grid || element.choice_field)
|
|
171
|
+
respond_to do |format|
|
|
172
|
+
format.js
|
|
173
|
+
end
|
|
174
|
+
end
|
|
175
|
+
|
|
176
|
+
private
|
|
177
|
+
def get_page
|
|
178
|
+
@page = Fe::Page.find(params[:page_id])
|
|
179
|
+
end
|
|
180
|
+
|
|
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)
|
|
183
|
+
end
|
|
184
|
+
|
|
185
|
+
end
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
class Fe::Admin::EmailTemplatesController < ApplicationController
|
|
2
|
+
before_filter :check_valid_user
|
|
3
|
+
layout 'fe.admin'
|
|
4
|
+
|
|
5
|
+
def index
|
|
6
|
+
@email_templates = Fe::EmailTemplate.order('name')
|
|
7
|
+
|
|
8
|
+
respond_to do |format|
|
|
9
|
+
format.html
|
|
10
|
+
end
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
def new
|
|
14
|
+
@email_template = Fe::EmailTemplate.new
|
|
15
|
+
|
|
16
|
+
respond_to do |format|
|
|
17
|
+
format.html
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
def edit
|
|
22
|
+
@email_template = Fe::EmailTemplate.find(params[:id])
|
|
23
|
+
|
|
24
|
+
respond_to do |format|
|
|
25
|
+
format.html
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
def create
|
|
30
|
+
@email_template = Fe::EmailTemplate.new(params[:email_template])
|
|
31
|
+
|
|
32
|
+
respond_to do |format|
|
|
33
|
+
if @email_template.save
|
|
34
|
+
format.html { redirect_to admin_email_templates_path }
|
|
35
|
+
else
|
|
36
|
+
format.html { render :action => :new }
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
def update
|
|
42
|
+
@email_template = Fe::EmailTemplate.find(params[:id])
|
|
43
|
+
|
|
44
|
+
respond_to do |format|
|
|
45
|
+
if @email_template.update_attributes(params[:email_template])
|
|
46
|
+
format.html { redirect_to admin_email_templates_path }
|
|
47
|
+
else
|
|
48
|
+
format.html { render :action => "edit" }
|
|
49
|
+
end
|
|
50
|
+
end
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
def destroy
|
|
54
|
+
@email_template = Fe::EmailTemplate.find(params[:id])
|
|
55
|
+
@email_template.destroy
|
|
56
|
+
|
|
57
|
+
respond_to do |format|
|
|
58
|
+
format.html { redirect_to email_templates_path }
|
|
59
|
+
end
|
|
60
|
+
end
|
|
61
|
+
end
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
class Fe::Admin::QuestionPagesController < ApplicationController
|
|
2
|
+
before_filter :check_valid_user
|
|
3
|
+
layout 'fe.admin'
|
|
4
|
+
|
|
5
|
+
before_filter :get_sheet
|
|
6
|
+
|
|
7
|
+
# selecting a page
|
|
8
|
+
# GET /pages/1
|
|
9
|
+
def show
|
|
10
|
+
@page = @question_sheet.pages.find(params[:id])
|
|
11
|
+
@elements = @page.elements
|
|
12
|
+
|
|
13
|
+
respond_to do |format|
|
|
14
|
+
format.js
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
# GET /pages/1/edit
|
|
19
|
+
def edit
|
|
20
|
+
@page = @question_sheet.pages.find(params[:id])
|
|
21
|
+
|
|
22
|
+
respond_to do |format|
|
|
23
|
+
format.js
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
# POST /pages
|
|
28
|
+
def create
|
|
29
|
+
@page = @question_sheet.pages.build(:label => next_label, :number => @question_sheet.pages.length + 1)
|
|
30
|
+
@all_pages = @question_sheet.pages
|
|
31
|
+
|
|
32
|
+
respond_to do |format|
|
|
33
|
+
if @page.save
|
|
34
|
+
format.js
|
|
35
|
+
else
|
|
36
|
+
format.js { render :action => "error.rjs"}
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
# PUT /pages/1
|
|
42
|
+
def update
|
|
43
|
+
@page = @question_sheet.pages.find(params[:id])
|
|
44
|
+
|
|
45
|
+
respond_to do |format|
|
|
46
|
+
if @page.update_attributes(page_params)
|
|
47
|
+
@all_pages = @question_sheet.pages
|
|
48
|
+
format.js { render action: :destroy }
|
|
49
|
+
else
|
|
50
|
+
format.js { render :action => "error.rjs"}
|
|
51
|
+
end
|
|
52
|
+
end
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
# DELETE /pages/1
|
|
56
|
+
def destroy
|
|
57
|
+
unless @question_sheet.pages.length <= 1
|
|
58
|
+
@page = @question_sheet.pages.find(params[:id])
|
|
59
|
+
@page.destroy
|
|
60
|
+
|
|
61
|
+
@all_pages = @question_sheet.pages
|
|
62
|
+
@page = @all_pages[0]
|
|
63
|
+
|
|
64
|
+
respond_to do |format|
|
|
65
|
+
format.js
|
|
66
|
+
end
|
|
67
|
+
end
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
# load panel all AJAX-like
|
|
71
|
+
# GET
|
|
72
|
+
def show_panel
|
|
73
|
+
@tab_name = params[:panel_name]
|
|
74
|
+
@panel_name = params[:panel_name] == "properties" ? "prop_sheet" : params[:panel_name]
|
|
75
|
+
@all_pages = @question_sheet.pages # for pages_list
|
|
76
|
+
@page = @question_sheet.pages.find(params[:id])
|
|
77
|
+
|
|
78
|
+
respond_to do |format|
|
|
79
|
+
format.js # load panel
|
|
80
|
+
end
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
def reorder
|
|
84
|
+
@question_sheet.pages.each do |page|
|
|
85
|
+
if params['list-pages'].index(page.id.to_s)
|
|
86
|
+
page.number = params['list-pages'].index(page.id.to_s) + 1
|
|
87
|
+
page.save!
|
|
88
|
+
@page = page
|
|
89
|
+
end
|
|
90
|
+
end
|
|
91
|
+
render :nothing => true
|
|
92
|
+
end
|
|
93
|
+
|
|
94
|
+
private
|
|
95
|
+
def get_sheet
|
|
96
|
+
@question_sheet = Fe::QuestionSheet.find(params[:question_sheet_id])
|
|
97
|
+
end
|
|
98
|
+
|
|
99
|
+
# next unused label with "Untitled form" prefix
|
|
100
|
+
def next_label
|
|
101
|
+
Fe.next_label("Page", untitled_labels)
|
|
102
|
+
end
|
|
103
|
+
|
|
104
|
+
# returns a list of existing Untitled forms
|
|
105
|
+
# (having a separate method makes it easy to mock in the spec)
|
|
106
|
+
def untitled_labels
|
|
107
|
+
Page.where("label like 'Page%'").map {|s| s.label}
|
|
108
|
+
end
|
|
109
|
+
|
|
110
|
+
def page_params
|
|
111
|
+
params.fetch(:page, {}).permit(:label, :hidden, :no_cache)
|
|
112
|
+
end
|
|
113
|
+
end
|