fe 0.0.4 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (218) hide show
  1. checksums.yaml +4 -4
  2. data/Rakefile +16 -36
  3. data/app/assets/javascripts/fe/admin.js +0 -1
  4. data/app/assets/javascripts/fe/fe.admin.js +40 -16
  5. data/app/assets/javascripts/fe/fe.common.js +48 -14
  6. data/app/assets/javascripts/fe/fe.public.js +1 -414
  7. data/app/assets/javascripts/fe/fe.public.nojquery.js +450 -0
  8. data/app/assets/javascripts/fe/jquery.validate.pack.js +3 -15
  9. data/app/assets/stylesheets/360front.css +0 -0
  10. data/app/assets/stylesheets/fe/fe.screen.css.scss.erb +69 -10
  11. data/app/controllers/fe/admin/elements_controller.rb +64 -48
  12. data/app/controllers/fe/admin/email_templates_controller.rb +2 -2
  13. data/app/controllers/fe/admin/question_pages_controller.rb +1 -1
  14. data/app/controllers/fe/admin/question_sheets_controller.rb +2 -103
  15. data/app/controllers/fe/concerns/admin/question_sheets_controller_concern.rb +112 -0
  16. data/app/controllers/fe/concerns/answer_pages_controller_concern.rb +2 -1
  17. data/app/controllers/fe/concerns/answer_sheets_controller_concern.rb +1 -1
  18. data/app/controllers/fe/concerns/application_controller_concern.rb +13 -0
  19. data/app/controllers/fe/reference_sheets_controller.rb +2 -0
  20. data/app/controllers/fe/references_controller.rb +1 -0
  21. data/app/helpers/fe/application_helper.rb +5 -0
  22. data/app/mailers/fe/notifier.rb +11 -4
  23. data/app/models/answer_sheet.rb +2 -0
  24. data/app/models/fe/application.rb +2 -1
  25. data/app/models/fe/concerns/answer_pages_presenter_concern.rb +10 -1
  26. data/app/models/fe/concerns/answer_sheet_concern.rb +38 -8
  27. data/app/models/fe/concerns/choice_field_concern.rb +17 -10
  28. data/app/models/fe/date_field.rb +1 -1
  29. data/app/models/fe/element.rb +105 -31
  30. data/app/models/fe/page.rb +52 -20
  31. data/app/models/fe/page_element.rb +6 -1
  32. data/app/models/fe/page_link.rb +6 -3
  33. data/app/models/fe/person.rb +11 -8
  34. data/app/models/fe/question.rb +2 -6
  35. data/app/models/fe/question_grid.rb +1 -1
  36. data/app/models/fe/question_grid_with_total.rb +15 -0
  37. data/app/models/fe/question_set.rb +1 -1
  38. data/app/models/fe/question_sheet.rb +15 -13
  39. data/app/models/fe/reference_question.rb +0 -10
  40. data/app/models/fe/reference_sheet.rb +17 -13
  41. data/app/models/staff.rb +2 -0
  42. data/app/validators/email_validator.rb +11 -0
  43. data/app/views/fe/admin/elements/create.js.erb +1 -0
  44. data/app/views/fe/admin/elements/drop.js.erb +1 -0
  45. data/app/views/fe/admin/elements/duplicate.js.erb +1 -0
  46. data/app/views/fe/admin/panels/_advanced_options.html.erb +9 -3
  47. data/app/views/fe/admin/panels/_common_fields.html.erb +19 -5
  48. data/app/views/fe/admin/panels/_page.html.erb +1 -1
  49. data/app/views/fe/admin/panels/_prop_choice_field.html.erb +20 -11
  50. data/app/views/fe/admin/panels/_prop_element.html.erb +2 -9
  51. data/app/views/fe/admin/panels/_prop_page.html.erb +8 -3
  52. data/app/views/fe/admin/panels/_prop_paragraph.html.erb +38 -24
  53. data/app/views/fe/admin/panels/_prop_section.html.erb +8 -2
  54. data/app/views/fe/admin/panels/_prop_sheet.html.erb +4 -1
  55. data/app/views/fe/admin/question_pages/_element.html.erb +11 -1
  56. data/app/views/fe/answer_pages/_answer_page.html.erb +9 -8
  57. data/app/views/fe/answer_pages/_element.html.erb +6 -7
  58. data/app/views/fe/answer_pages/_page_name.html.erb +1 -0
  59. data/app/views/fe/answer_pages/update.js.erb +3 -3
  60. data/app/views/fe/answer_sheets/_answer_sheet.html.erb +3 -3
  61. data/app/views/fe/answer_sheets/_element.html.erb +52 -34
  62. data/app/views/fe/answer_sheets/_incomplete.html.erb +1 -1
  63. data/app/views/fe/answer_sheets/_page_link.html.erb +2 -2
  64. data/app/views/fe/answer_sheets/_pages_list.html.erb +3 -3
  65. data/app/views/fe/answer_sheets/_submit_to.html.erb +1 -0
  66. data/app/views/fe/answer_sheets/edit.html.erb +14 -14
  67. data/app/views/fe/answer_sheets/incomplete.js.erb +3 -0
  68. data/app/views/fe/answer_sheets/index.html.erb +3 -3
  69. data/app/views/fe/answer_sheets/show.html.erb +1 -1
  70. data/app/views/fe/applications/_logout.html.erb +1 -0
  71. data/app/views/fe/applications/show.html.erb +1 -0
  72. data/app/views/fe/questions/fe/_acceptance.html.erb +3 -3
  73. data/app/views/fe/questions/fe/_attachment_field.html.erb +7 -3
  74. data/app/views/fe/questions/fe/_checkbox_field.html.erb +26 -24
  75. data/app/views/fe/questions/fe/_date_field.html.erb +1 -2
  76. data/app/views/fe/questions/fe/_date_field_mmyy.html.erb +2 -2
  77. data/app/views/fe/questions/fe/_drop_down_field.html.erb +3 -2
  78. data/app/views/fe/questions/fe/_paragraph.html.erb +1 -1
  79. data/app/views/fe/questions/fe/_question_grid.html.erb +14 -9
  80. data/app/views/fe/questions/fe/_question_grid_with_total.html.erb +21 -14
  81. data/app/views/fe/questions/fe/_questions.html.erb +2 -2
  82. data/app/views/fe/questions/fe/_radio_button_field.html.erb +12 -11
  83. data/app/views/fe/questions/fe/_rating.html.erb +9 -8
  84. data/app/views/fe/questions/fe/_reference_discipler.html.erb +1 -1
  85. data/app/views/fe/questions/fe/_reference_friend.html.erb +1 -1
  86. data/app/views/fe/questions/fe/_reference_parent.html.erb +1 -1
  87. data/app/views/fe/questions/fe/_reference_peer.html.erb +1 -1
  88. data/app/views/fe/questions/fe/_reference_question.html.erb +22 -15
  89. data/app/views/fe/questions/fe/_reference_roommate.html.erb +1 -1
  90. data/app/views/fe/questions/fe/_reference_spiritual.html.erb +1 -1
  91. data/app/views/fe/questions/fe/_reference_staff.html.erb +1 -1
  92. data/app/views/fe/questions/fe/_section.html.erb +1 -1
  93. data/app/views/fe/questions/fe/_text_area_field.html.erb +10 -3
  94. data/app/views/fe/questions/fe/_text_field.html.erb +1 -1
  95. data/app/views/fe/questions/fe/_yes_no_field.erb +3 -3
  96. data/app/views/fe/reference_pages/_reference.html.erb +11 -11
  97. data/app/views/fe/reference_pages/edit.html.erb +7 -7
  98. data/app/views/fe/reference_sheets/done.html.erb +2 -2
  99. data/app/views/fe/reference_sheets/not_found.html.erb +4 -4
  100. data/app/views/fe/references/edit.html.erb +6 -6
  101. data/app/views/fe/references/show.html.erb +7 -7
  102. data/app/views/fe/references/submit.js.erb +1 -1
  103. data/app/views/fe/submit_pages/_thankyou.html.erb +1 -1
  104. data/app/views/fe/submit_pages/edit.html.erb +9 -9
  105. data/app/views/layouts/fe/_error_messages_for.html.erb +7 -0
  106. data/app/views/layouts/fe/application.html.erb +1 -1
  107. data/config/routes.rb +0 -36
  108. data/db/migrate/20131003044250_create_reference_sheets.rb +1 -0
  109. data/db/migrate/20140623153424_create_fe_people.rb +1 -1
  110. data/db/migrate/20140624180246_create_fe_addresses.rb +1 -1
  111. data/db/migrate/20140624182216_create_fe_phone_numbers.rb +16 -0
  112. data/db/migrate/20140625160545_create_fe_users.rb +1 -1
  113. data/db/migrate/20150504221439_add_all_element_ids_to_pages.rb +5 -0
  114. data/db/migrate/20150713022326_add_locale_columns.rb +9 -0
  115. data/db/migrate/20150714220730_add_locale_to_answer_sheet.rb +5 -0
  116. data/db/migrate/20150928085325_change_pages_all_element_ids_to_text.rb +5 -0
  117. data/db/migrate/20150930191538_add_locale_to_reference_sheets.rb +5 -0
  118. data/lib/access_key_generator.rb +12 -0
  119. data/lib/distinct_distinct_patch.rb +20 -0
  120. data/lib/fe.rb +4 -0
  121. data/lib/fe/engine.rb +16 -4
  122. data/lib/fe/version.rb +1 -1
  123. data/spec/controllers/fe/admin/elements_controller_spec.rb +201 -1
  124. data/spec/controllers/fe/admin/email_templates_controller_spec.rb +26 -1
  125. data/spec/controllers/fe/admin/question_pages_controller_spec.rb +8 -1
  126. data/spec/controllers/fe/admin/question_sheets_controller_spec.rb +48 -1
  127. data/spec/controllers/fe/answer_pages_controller_spec.rb +73 -1
  128. data/spec/controllers/fe/answer_sheets_controller_spec.rb +80 -1
  129. data/spec/controllers/fe/reference_pages_controller.rb +4 -0
  130. data/spec/controllers/fe/references_controller_spec.rb +4 -0
  131. data/spec/controllers/fe/submit_pages_controller_spec.rb +4 -0
  132. data/spec/dummy/app/controllers/application_controller.rb +5 -0
  133. data/spec/dummy/app/helpers/application_helper.rb +9 -0
  134. data/spec/dummy/app/models/application.rb +3 -0
  135. data/spec/dummy/app/models/person.rb +11 -0
  136. data/spec/dummy/app/models/user.rb +3 -0
  137. data/spec/dummy/config/application.rb +2 -1
  138. data/spec/dummy/config/database.yml +20 -17
  139. data/spec/dummy/config/environments/production.rb +1 -5
  140. data/spec/dummy/config/environments/test.rb +3 -1
  141. data/spec/dummy/config/initializers/fast_gettext.rb +5 -0
  142. data/spec/dummy/config/secrets.yml +2 -2
  143. data/spec/dummy/db/migrate/20141203214017_core.fe_engine.rb +92 -0
  144. data/spec/dummy/db/migrate/20141203214018_create_reference_sheets.fe_engine.rb +25 -0
  145. data/spec/dummy/db/migrate/20141203214019_add_element_and_answer_fields.fe_engine.rb +11 -0
  146. data/spec/dummy/db/migrate/20141203214020_create_email_templates.fe_engine.rb +18 -0
  147. data/spec/dummy/db/migrate/20141203214021_add_max_lengths.fe_engine.rb +9 -0
  148. data/spec/dummy/db/migrate/20141203214022_create_join_table.fe_engine.rb +12 -0
  149. data/spec/dummy/db/migrate/20141203214023_remove_question_id_from_element.fe_engine.rb +10 -0
  150. data/spec/dummy/db/migrate/20141203214024_create_fe_people.fe_engine.rb +13 -0
  151. data/spec/dummy/db/migrate/20141203214025_create_fe_addresses.fe_engine.rb +21 -0
  152. data/{db/migrate/20140624182216_create_create_fe_phone_numbers.rb → spec/dummy/db/migrate/20141203214026_create_create_fe_phone_numbers.fe_engine.rb} +1 -0
  153. data/spec/dummy/db/migrate/20141203214027_create_fe_users.fe_engine.rb +13 -0
  154. data/spec/dummy/db/migrate/20141203214028_add_conditional_type_to_elements.fe_engine.rb +6 -0
  155. data/spec/dummy/db/migrate/20141203214029_add_conditional_answer_to_elements.fe_engine.rb +6 -0
  156. data/spec/dummy/db/migrate/20141203214030_remove_short_value_column.fe_engine.rb +6 -0
  157. data/spec/dummy/db/migrate/20141203214031_move_conditional_ids_used_for_choice_field_to_their_own_column.fe_engine.rb +8 -0
  158. data/spec/dummy/db/migrate/20150123215803_create_users.rb +9 -0
  159. data/spec/dummy/db/migrate/20150504222619_add_all_element_ids_to_pages.fe_engine.rb +6 -0
  160. data/spec/dummy/db/migrate/20150930190001_create_fe_phone_numbers.fe_engine.rb +20 -0
  161. data/spec/dummy/db/migrate/20150930190002_add_locale_columns.fe_engine.rb +10 -0
  162. data/spec/dummy/db/migrate/20150930190003_add_locale_to_answer_sheet.fe_engine.rb +6 -0
  163. data/spec/dummy/db/migrate/20150930190004_change_pages_all_element_ids_to_text.fe_engine.rb +6 -0
  164. data/spec/dummy/db/migrate/20150930191756_add_locale_to_reference_sheets.fe_engine.rb +6 -0
  165. data/spec/dummy/db/schema.rb +50 -20
  166. data/spec/dummy/log/development.log +5 -0
  167. data/spec/factories/applications.rb +0 -1
  168. data/spec/factories/dummy_applications.rb +6 -0
  169. data/spec/factories/dummy_people.rb +6 -0
  170. data/spec/factories/dummy_users.rb +6 -0
  171. data/spec/factories/elements.rb +28 -3
  172. data/spec/factories/email_templates.rb +5 -0
  173. data/spec/factories/fe_email_templates.rb +9 -0
  174. data/spec/factories/fe_people.rb +0 -2
  175. data/spec/factories/fe_user.rb +6 -0
  176. data/spec/factories/question_sheet.rb +1 -1
  177. data/spec/factories/reference_sheets.rb +9 -0
  178. data/spec/mailers/fe/notifier_spec.rb +39 -0
  179. data/spec/models/fe/choice_field_spec.rb +20 -0
  180. data/spec/models/fe/element_spec.rb +185 -0
  181. data/spec/models/fe/page_spec.rb +112 -0
  182. data/spec/models/fe/question_sheet_spec.rb +106 -0
  183. data/spec/models/fe/reference_sheet_spec.rb +20 -0
  184. data/spec/rails_helper.rb +41 -13
  185. data/spec/support/choices.xml +6 -0
  186. metadata +136 -48
  187. data/app/assets/javascripts/fe/rails.extra.js +0 -6
  188. data/app/controllers/fe/applications_controller.rb +0 -183
  189. data/app/controllers/fe/payments_controller.rb +0 -184
  190. data/app/models/fe/payment.rb +0 -77
  191. data/app/models/fe/payment_question.rb +0 -22
  192. data/app/views/fe/admin/panels/_prop_payment_question.html.erb +0 -1
  193. data/app/views/fe/application/_logout.html.erb +0 -1
  194. data/app/views/fe/payment_pages/_credit.html.erb +0 -47
  195. data/app/views/fe/payment_pages/_mail.html.erb +0 -27
  196. data/app/views/fe/payment_pages/_payment.html.erb +0 -6
  197. data/app/views/fe/payment_pages/_staff.html.erb +0 -25
  198. data/app/views/fe/payment_pages/_staff_results.html.erb +0 -17
  199. data/app/views/fe/payment_pages/edit.html.erb +0 -75
  200. data/app/views/fe/payment_pages/staff_search.js.erb +0 -2
  201. data/app/views/fe/payments/_credit.html.erb +0 -47
  202. data/app/views/fe/payments/_errors.html.erb +0 -1
  203. data/app/views/fe/payments/_payment.html.erb +0 -13
  204. data/app/views/fe/payments/_staff.html.erb +0 -21
  205. data/app/views/fe/payments/_staff_results.html.erb +0 -18
  206. data/app/views/fe/payments/approve.js.erb +0 -3
  207. data/app/views/fe/payments/create.js.erb +0 -19
  208. data/app/views/fe/payments/destroy.js.erb +0 -7
  209. data/app/views/fe/payments/edit.html.erb +0 -56
  210. data/app/views/fe/payments/error.js.erb +0 -3
  211. data/app/views/fe/payments/no_access.html.erb +0 -7
  212. data/app/views/fe/payments/staff_search.js.erb +0 -1
  213. data/app/views/fe/payments/update.html.erb +0 -24
  214. data/app/views/fe/questions/fe/_payment_question.html.erb +0 -70
  215. data/db/migrate/20140828045339_create_payments.rb +0 -13
  216. data/spec/dummy/db/test.sqlite3 +0 -0
  217. data/spec/factories/payments.rb +0 -7
  218. data/spec/models/fe/payment_question_spec.rb +0 -65
@@ -1,5 +1,5 @@
1
1
  <div class="submission_errors">
2
- <p>You still need to answer questions on the following pages:</p>
2
+ <p><%= _('You still need to answer questions on the following pages:') %></p>
3
3
  <ul>
4
4
  <% @answer_sheet.pages.each do |page| %>
5
5
  <% unless page.complete?(@answer_sheet) %>
@@ -2,6 +2,6 @@
2
2
  <% if session[:attempted_submit] && page_link.page.has_questions? %>
3
3
  <% css_class = page_link.page.complete?(@answer_sheet) ? 'complete' : 'incomplete' %>
4
4
  <% end %>
5
- <%= li_page_active_if(@presenter.active_page && page_link.page == @presenter.active_page, :id => page_link.dom_id + '-li', :class => css_class, :style => ('display:none' if @answer_sheet.question_sheet.hidden_pages(@answer_sheet).include?(page_link.page))) do %>
6
- <%= link_to_function(page_link.label, load_page_js(page_link), :id => page_link.dom_id + '-link', 'data-page-id' => page_link.dom_id, :class => 'page_link', :href => page_link.load_path) %>
5
+ <%= li_page_active_if(@presenter.active_page && page_link.page == @presenter.active_page, :id => page_link.dom_id + '-li', :class => css_class, :style => ('display:none' if page_link.page.hidden?(@answer_sheet))) do %>
6
+ <%= link_to_function(page_link.label(session[:locale]), load_page_js(page_link), :id => page_link.dom_id + '-link', 'data-page-id' => page_link.dom_id, :class => 'page_link', :href => page_link.load_path) %>
7
7
  <% end -%>
@@ -1,11 +1,11 @@
1
1
  <div id="panel-pages">
2
- <h4>Application Sections</h4>
2
+ <h4><%= _('Application Sections') %></h4>
3
3
  <div id="page_ajax_spinner" style="display:none;">
4
4
  <div>
5
- <%= image_tag 'qe/ajax-loader.gif' %> Loading...
5
+ <%= image_tag 'fe/ajax-loader.gif' %> <%= _('Loading...') %>
6
6
  </div>
7
7
  </div>
8
8
  <ul id="list-pages" class="navigation-list">
9
9
  <%= render :partial => 'fe/answer_sheets/page_link', :collection => @presenter.page_links %>
10
10
  </ul>
11
- </div>
11
+ </div>
@@ -0,0 +1 @@
1
+ <%= hidden_field_tag 'submit_to', submit_fe_answer_sheet_path(@answer_sheet), :id => 'submit_to' %>
@@ -8,8 +8,8 @@
8
8
  <%= render :partial => 'fe/answer_sheets/pages_list' %>
9
9
  </div>
10
10
  <div id="legend">
11
- <%= image_tag('fe/icons/question-balloon.png') %> Rolling over this symbol gives you help<br/>
12
- <%= image_tag('fe/icons/star-small.png') %> Marks a required field
11
+ <%= image_tag('fe/icons/question-balloon.png') %> <%= _('Rolling over this symbol gives you help') %><br/>
12
+ <%= image_tag('fe/icons/star-small.png') %> <%= _('Marks a required field') %>
13
13
  </div>
14
14
  </div>
15
15
 
@@ -23,7 +23,7 @@
23
23
  page_handler = $.fe.pageHandler;
24
24
  page_handler.initialize('<%= @presenter.active_page_link.try(:dom_id) %>');
25
25
  // Event.observe(window, 'unload', page_handler.savePage);
26
-
26
+
27
27
  // Validation.add('validate-phone', 'Please enter a valid phone number +1-800-555-1234 x102', {
28
28
  // pattern: /((\(\d{3}\)?)|(\d{3}))((\s|-|\.|\/)?)(\d{3})((\s|-|\.|\/)?)(\d{4})\s*([xX]|[eE][xX][tT])?\.?\s*\d*$/
29
29
  // });
@@ -34,33 +34,33 @@
34
34
  // return $F(elm);
35
35
  // });
36
36
  // })
37
-
37
+
38
38
  // global responders for all Ajax requests
39
39
  $(function() {
40
- $('#page_ajax_spinner').ajaxStart(function() {
41
- $(this).show();
40
+ $(document).ajaxStart(function() {
41
+ $('#page_ajax_spinner').show();
42
+ $('#page_ajax_spinner').css({top: $(window).scrollTop() + 200});
42
43
  }).ajaxComplete(function() {
43
- $(this).hide();
44
+ $('#page_ajax_spinner').hide();
44
45
  })
45
46
  });
46
47
  });
47
48
  function updateTotals() {
48
49
  // Set up js for all question grids with totals
49
50
  <% if @page %>
50
- <% @page.question_sheet.pages.collect(&:question_grid_with_totals).flatten.each do |question_grid_with_total|
51
+ <% @page.question_sheet.pages.collect(&:question_grid_with_totals).flatten.each do |question_grid_with_total|
51
52
  question_grid_with_total.total_cols.split(',').collect(&:to_i).each do |col| -%>
52
53
  try {
53
- updateTotal('<%= "#{question_grid_with_total.id}_#{col - 1}" %>')
54
- $$(".col_<%= "#{question_grid_with_total.id}_#{col - 1}" %>").each(function(e) {
55
- Event.observe(e, 'blur', function(event) {
56
- updateTotal('<%= "#{question_grid_with_total.id}_#{col - 1}" %>')
57
- });
54
+ updateTotal('<%= "#{question_grid_with_total.id}_#{col - 1}" %>');
55
+ $(".col_<%= "#{question_grid_with_total.id}_#{col - 1}" %>").change(function(e) {
56
+ updateTotal('<%= "#{question_grid_with_total.id}_#{col - 1}" %>');
58
57
  });
59
58
  } catch(e) {}
60
59
  <% end
61
60
  end %>
62
61
  <% end %>
63
62
  }
63
+ $(function() { $(document).trigger('fePageLoaded'); });
64
64
  </script>
65
- <%= hidden_field_tag 'submit_to', submit_fe_answer_sheet_path(@answer_sheet), :id => 'submit_to' %>
65
+ <%= render "fe/answer_sheets/submit_to" %>
66
66
  <% end %>
@@ -1,3 +1,6 @@
1
+ if ($('#submit_message').length == 0) {
2
+ $("ul#questions_list").filter(":visible").append("<li><div id=\"submit_message\"></div></li>");
3
+ }
1
4
  $('#submit_message').html('<%= escape_javascript(render('incomplete')) %>')
2
5
  <% @answer_sheet.pages.each do |page| %>
3
6
  $('#<%= dom_id(@answer_sheet) %>-<%= dom_id(page) %>-li').replaceWith('<%= escape_javascript(render('fe/answer_sheets/page_link', :page_link => @presenter.new_page_link(@answer_sheet, page))) %>')
@@ -1,6 +1,6 @@
1
1
  <h1>Questionnaires</h1>
2
2
 
3
- <% form_tag answer_sheets_path() do %>
3
+ <% form_tag fe_answer_sheets_path do %>
4
4
  <%= select_tag("question_sheet_id", options_for_select(@question_sheets)) %>
5
5
  <%= submit_tag("Capture") %>
6
6
  <% end -%>
@@ -8,8 +8,8 @@
8
8
  <table cellspacing="0" class="list">
9
9
  <% for answer_sheet in @answer_sheets %>
10
10
  <tr>
11
- <td><%= link_to answer_sheet.question_sheet.label, edit_answer_sheet_path(answer_sheet) %></td>
12
- <td><%= link_to 'Review', answer_sheet_path(answer_sheet), :method => :get %></td>
11
+ <td><%= link_to answer_sheet.question_sheet.label, edit_fe_answer_sheet_path(answer_sheet) %></td>
12
+ <td><%= link_to 'Review', fe_answer_sheet_path(answer_sheet), :method => :get %></td>
13
13
  </tr>
14
14
  <% end %>
15
15
  </table>
@@ -8,6 +8,6 @@
8
8
 
9
9
  <div id="preview" class="answer-page">
10
10
 
11
- <%= render :partial => 'answer_sheets/answer_sheet', :locals => {:answer_sheet => @answer_sheet, :elements => @elements } %>
11
+ <%= render :partial => 'fe/answer_sheets/answer_sheet', :locals => {:answer_sheet => @answer_sheet, :elements => @elements } %>
12
12
 
13
13
  </div>
@@ -0,0 +1 @@
1
+ <% if user_signed_in? %><%= link_to(_("Log Out"), destroy_user_session_path, { :method => :delete, :style => "color: #fff;", :id => "link-log-out" }) %><% end %>
@@ -0,0 +1 @@
1
+ Implement the applications show view in your app
@@ -5,9 +5,9 @@
5
5
  checked,
6
6
  :id => dom_id(acceptance),
7
7
  :class => css_class,
8
- :disabled => @answer_sheet.frozen?&&!@answer_sheet.reference?,
9
- :readonly => @answer_sheet.frozen?&&!@answer_sheet.reference? %>
8
+ :disabled => @answer_sheet.frozen?&&!@answer_sheet.try(:reference?),
9
+ :readonly => @answer_sheet.frozen?&&!@answer_sheet.try(:reference?) %>
10
10
  <label class="choice" for="<%= dom_id(acceptance) %>">
11
- <%= raw acceptance.label %>
11
+ <%= raw acceptance.label(session[:locale]) %>
12
12
  </label>
13
13
  <%= hidden_field_tag "answers[#{acceptance.id}]", '', :id => '' %>
@@ -1,6 +1,9 @@
1
1
  <% if @presenter %>
2
- <% if @answer_sheet.frozen? && !@answer_sheet.reference? %>
3
- Current File: <%= link_to(answer.attachment_file_name, answer.attachment.url) %>
2
+ <% if @answer_sheet.frozen? && !@answer_sheet.try(:reference?) %>
3
+ <% answer = attachment_field.responses(@answer_sheet).first %>
4
+ <% if answer %>
5
+ Current File: <%= link_to(answer.attachment_file_name, answer.attachment.url) %>
6
+ <% end %>
4
7
  <% else %>
5
8
  <div class="uploader">
6
9
  <input id="<%= dom_id(attachment_field) %>_file_uploader" name="image_uploader" type="file" />
@@ -34,7 +37,8 @@
34
37
  '_http_accept': 'application/javascript',
35
38
  '_method': 'post',
36
39
  '<%= session_key_name %>' : encodeURIComponent('<%= u cookies[session_key_name] %>'),
37
- 'authenticity_token': encodeURIComponent('<%= u form_authenticity_token %>')
40
+ 'authenticity_token': encodeURIComponent('<%= u form_authenticity_token %>'),
41
+ 'answer_sheet_type': answer_sheet_type
38
42
  }
39
43
  });
40
44
  </script>
@@ -2,47 +2,49 @@
2
2
  <tr id="<%= dom_id(checkbox_field) %>">
3
3
  <td>
4
4
  <label for="<%= dom_id(checkbox_field) %>" class="desc">
5
- <%= raw checkbox_field.label %>
6
- <% if checkbox_field.required?(@answer_sheet) -%><span class="required">required</span><% end -%>
5
+ <%= raw checkbox_field.label(session[:locale]) %>
6
+ <% if checkbox_field.required?(@answer_sheet, @page) -%><span class="required">required</span><% end -%>
7
7
  <%= tip(checkbox_field.tooltip) if checkbox_field.tooltip.present? %>
8
8
  </label>
9
9
  </td>
10
- <% checkbox_field.choices.each_with_index do |choice, num| -%>
10
+ <% choices = checkbox_field.choices(session[:locale]) %>
11
+ <% choices.each_with_index do |choice, num| -%>
11
12
  <td>
12
- <% css_class = 'checkbox ' -%>
13
- <% dom_id = dom_id(checkbox_field) + "_" + pretty_tag(choice[1])
14
- last_choice = (num == checkbox_field.choices.length - 1)
13
+ <% css_class = checkbox_field.css_class.to_s + ' checkbox ' -%>
14
+ <% dom_id = dom_id(checkbox_field) + "_" + pretty_tag(choice[1])
15
+ last_choice = (num == choices.length - 1)
15
16
  css_class += checkbox_field.validation_class(@answer_sheet) if last_choice
16
17
  -%>
17
18
  <%= hidden_field_tag "answers[#{checkbox_field.id}][#{num}]", '', :id => '' %>
18
19
  <div class="field field_check">
19
20
  <%= check_box_tag "answers[#{checkbox_field.id}][#{num}]", choice[1],
20
- checkbox_field.has_answer?(choice[1], @answer_sheet),
21
- :id => dom_id,
21
+ checkbox_field.has_answer?(choice[1], @answer_sheet),
22
+ :id => dom_id,
22
23
  :class => css_class,
23
- :disabled => @answer_sheet.frozen?&&!@presenter.reference?,
24
- :readonly => @answer_sheet.frozen?&&!@presenter.reference? %>
24
+ :disabled => @answer_sheet.frozen?&&!@presenter.try(:reference?),
25
+ :readonly => @answer_sheet.frozen?&&!@presenter.try(:reference?) %>
25
26
  </div>
26
27
  </td>
27
28
  <% end -%>
28
29
  </tr>
29
30
  <% else %>
30
31
  <div id="<%= dom_id(checkbox_field) %>">
31
- <% css_class = 'checkbox ' -%>
32
- <% checkbox_field.choices.each_with_index do |choice, num| -%>
33
- <% dom_id = dom_id(checkbox_field) + "_" + pretty_tag(choice[1])
34
- last_choice = (num == checkbox_field.choices.length - 1)
35
- css_class += checkbox_field.validation_class(@answer_sheet) if last_choice
36
- -%>
37
- <%= hidden_field_tag "answers[#{checkbox_field.id}][#{num}]", '', :id => '' %>
38
- <div class="field field_check">
39
- <%= check_box_tag "answers[#{checkbox_field.id}][#{num}]", choice[1],
40
- checkbox_field.has_answer?(choice[1], @answer_sheet),
41
- :id => dom_id,
32
+ <% css_class = checkbox_field.css_class.to_s + ' checkbox ' -%>
33
+ <% choices = checkbox_field.choices(session[:locale]) %>
34
+ <% choices.each_with_index do |choice, num| -%>
35
+ <% dom_id = dom_id(checkbox_field) + "_" + pretty_tag(choice[1])
36
+ last_choice = (num == choices.length - 1)
37
+ css_class += checkbox_field.validation_class(@answer_sheet) if last_choice
38
+ %>
39
+ <%= hidden_field_tag "answers[#{checkbox_field.id}][#{num}]", '', :id => '' %>
40
+ <div class="field field_check">
41
+ <%= check_box_tag "answers[#{checkbox_field.id}][#{num}]", choice[1],
42
+ checkbox_field.has_answer?(choice[1], @answer_sheet),
43
+ :id => dom_id,
42
44
  :class => css_class,
43
- :disabled => @answer_sheet.frozen?&&!@presenter.reference?,
44
- :readonly => @answer_sheet.frozen?&&!@presenter.reference? %>
45
- <label class="choice" for="<%= dom_id %>"><%= choice[0] %></label>
45
+ :disabled => @answer_sheet.frozen?&&!@presenter.try(:reference?),
46
+ :readonly => @answer_sheet.frozen?&&!@presenter.try(:reference?) %>
47
+ <label class="choice" for="<%= dom_id %>"><%= choice[0] %></label>
46
48
  </div>
47
49
  <% end -%>
48
50
  </div>
@@ -1,7 +1,6 @@
1
1
  <%= calendar_date_select_tag "answers[#{date_field.id}]", date_field.format_date_response(@answer_sheet),
2
2
  :class => 'text ' + date_field.validation_class(@answer_sheet),
3
3
  :id => dom_id(date_field),
4
- :disabled => @answer_sheet.frozen?&&!@presenter.reference?,
4
+ :disabled => @answer_sheet.frozen?&&!@presenter.try(:reference?),
5
5
  :readonly => true %>
6
- <div id="advice-validate-date-<%= dom_id(date_field) %>" class="validation-advice" style="display: none;">Please enter a valid date (MM/DD/YYYY).</div>
7
6
  <div id="advice-required-<%= dom_id(date_field) %>" class="validation-advice" style="display: none;">This is a required field.</div>
@@ -1,8 +1,8 @@
1
1
  <%= select_month(date_field_mmyy.response(@answer_sheet), :include_blank => true,
2
2
  :prefix => "answers[#{date_field_mmyy.id}]",
3
- :class => 'select ' + date_field_mmyy.validation_class(@answer_sheet)) %>
3
+ :class => 'select ' + date_field_mmyy.validation_class(@answer_sheet)) %>
4
4
  <%= select_year(date_field_mmyy.response(@answer_sheet), :include_blank => true,
5
- :start_year => Time.now.year - 50, :end_year => Time.now.year + 7,
5
+ :start_year => Time.now.year - 50, :end_year => Time.now.year + 7,
6
6
  :prefix => "answers[#{date_field_mmyy.id}]",
7
7
  :class => 'select ' + date_field_mmyy.validation_class(@answer_sheet)) %>
8
8
 
@@ -1,7 +1,8 @@
1
+ <% choices = drop_down_field.choices(session[:locale]) %>
1
2
  <% locked = drop_down_field.locked?(params, @answer_sheet, @presenter) %>
2
3
  <%= select_tag "answers[#{drop_down_field.id}]",
3
- options_for_select([""] + drop_down_field.choices, drop_down_field.response(@answer_sheet).to_s),
4
- :class => 'select ' + drop_down_field.validation_class(@answer_sheet),
4
+ options_for_select([""] + choices, drop_down_field.response(@answer_sheet).to_s),
5
+ :class => 'form-control select ' + drop_down_field.validation_class(@answer_sheet) + " #{drop_down_field.css_class}",
5
6
  :id => dom_id(drop_down_field),
6
7
  :disabled => locked,
7
8
  :readonly => locked %>
@@ -1 +1 @@
1
- <div class="p_content"><%= raw paragraph.content %></div>
1
+ <div class="p_content <%= paragraph.css_class %>"><%= raw paragraph.content(session[:locale]) %></div>
@@ -2,8 +2,8 @@
2
2
  <div class="droppable" data-url="<%= drop_fe_admin_question_sheet_page_element_path(@page.question_sheet_id, @page.id, question_grid.id) %>">
3
3
  <% if question_grid.label.present? && !question_grid.hide_label? -%>
4
4
  <label class="desc gridname">
5
- <%= raw question_grid.label %>
6
- <% if question_grid.required?(@answer_sheet) -%><span class="required">required</span><% end -%>
5
+ <%= raw question_grid.label(session[:locale]) %>
6
+ <% if question_grid.required?(@answer_sheet, @page) -%><span class="required">required</span><% end -%>
7
7
  </label>
8
8
  <% end %>
9
9
  <div class="sub_q">
@@ -19,7 +19,7 @@
19
19
  </div>
20
20
  <%- else -%>
21
21
  <% if question_grid.label.present? && !question_grid.hide_label? -%>
22
- <label class="desc gridname"><%= raw question_grid.label %></label>
22
+ <label class="desc gridname"><%= raw question_grid.label(session[:locale]) %></label>
23
23
  <% end %>
24
24
  <% headers = question_grid.cols.to_s.split(';') %>
25
25
  <% if headers.length > 1 %>
@@ -37,16 +37,17 @@
37
37
  <% end %>
38
38
  <% else %>
39
39
  <tr >
40
- <%- col_count = 0
40
+ <%- col_count = 0; previous_element = nil;
41
41
  question_grid.elements.each do |element| -%>
42
- <td id="element_<%= element.id %>" class="hidecell">
42
+ <td style="<%= 'display:none' if previous_element && previous_element.conditional == element && !previous_element.conditional_match(@answer_sheet) %>" class="hidecell <%= element.class.to_s.downcase.gsub('::','_') %> <%= element.style.to_s.downcase %> <%= 'conditional' if element.conditional %>" id="element_<%= element.id %>" <% if element.conditional %>data-conditional_id="<%= element.conditional_id %>" data-conditional_type="<%= element.conditional_type %>" data-conditional_answer="<%= element.conditional_answer %>" data-application_id="<%= @answer_sheet.id %>" data-answer_sheet_id_prefix="<%= @answer_sheet.class.name.underscore.gsub('/','_') %>"<% end %>>
43
43
  <%# grid_el = @elements.to_a.find {|el| el.id == element.id} %>
44
44
  <%= render :partial => 'fe/answer_pages/element', :object => element, :locals => {:col => col_count} %>
45
45
  </td>
46
- <%- col_count += 1
47
- if col_count % question_grid.num_cols == 0 && element != question_grid.elements.last then col_count = 0 -%></tr><tr><%- end -%>
46
+ <%- previous_element = element;
47
+ col_count += 1
48
+ if col_count % question_grid.num_cols == 0 && element != question_grid.elements.last then col_count = 0 -%></tr><tr><%- end -%>
48
49
  <%- end -%>
49
- <%- while col_count < question_grid.num_cols do
50
+ <%- while col_count < question_grid.num_cols do
50
51
  col_count += 1-%>
51
52
  <td>&nbsp;</td>
52
53
  <%- end unless col_count == 0-%>
@@ -57,8 +58,12 @@
57
58
  <% if headers[0].to_s.strip.present? %>
58
59
  <div class="header"><%= headers[0] %></div>
59
60
  <% end %>
61
+ <% previous_element = nil %>
60
62
  <% question_grid.elements.each do |element| -%>
61
- <div class="row" id="element_<%= element.id %>"><%= render :partial => 'fe/answer_pages/element', :object => element, :locals => {:in_grid => true} %></div>
63
+ <div style="<%= 'display:none' if previous_element && previous_element.conditional == element && !previous_element.conditional_match(@answer_sheet) %>" class="row <%= element.class.to_s.downcase.gsub('::','_') %> <%= element.style.to_s.downcase %> <%= 'conditional' if element.conditional %>" id="element_<%= element.id %>" <% if element.conditional %>data-conditional_id="<%= element.conditional_id %>" data-conditional_type="<%= element.conditional_type %>" data-conditional_answer="<%= element.conditional_answer %>" data-application_id="<%= @answer_sheet.id %>" data-answer_sheet_id_prefix="<%= @answer_sheet.class.name.underscore.gsub('/','_') %>"<% end %>>
64
+ <%= render :partial => 'fe/answer_pages/element', :object => element, :locals => {:in_grid => true} %>
65
+ </div>
66
+ <% previous_element = element %>
62
67
  <% end %>
63
68
  <div class="clear"></div>
64
69
  <% end %>
@@ -1,19 +1,19 @@
1
1
  <%- if ['question_pages', 'question_sheets', 'elements'].include?(controller.controller_name) -%>
2
2
  <div class="droppable" data-url="<%= drop_fe_admin_question_sheet_page_element_path(@page.question_sheet_id, @page.id, question_grid_with_total.id) %>">
3
- <label class="desc"><%= raw question_grid_with_total.label %></label>
3
+ <label class="desc"><%= raw question_grid_with_total.label(session[:locale]) %></label>
4
4
  <div>
5
- <ul class="questions" id="questions_list_<%= question_grid_with_total.id %>">
5
+ <ul class="questions" id="questions_list_<%= question_grid_with_total.id %>" data-sortable="true" data-sortable-url="<%= reorder_fe_admin_question_sheet_page_elements_path(@page.question_sheet_id, @page.id) %>" data-sortable-handle=".handle">
6
6
  <%- if question_grid_with_total.elements.length > 0 -%>
7
- <%= render :partial => 'question_pages/element', :collection => question_grid_with_total.elements, :locals => {:in_grid => true} %>
7
+ <%= render :partial => 'fe/admin/question_pages/element', :collection => question_grid_with_total.elements, :locals => {:in_grid => true} %>
8
8
  <%- else -%>
9
9
  Grid
10
10
  <%- end -%>
11
11
  </ul>
12
12
  </div>
13
- </div>
13
+ </div>
14
14
  <%- else -%>
15
- <label class="desc"><%= raw question_grid_with_total.label %></label>
16
- <table class="grid">
15
+ <label class="desc"><%= raw question_grid_with_total.label(session[:locale]) %></label>
16
+ <table class="grid with_total">
17
17
  <% headers = question_grid_with_total.cols.to_s.split(';') %>
18
18
  <% if headers.detect {|h| h.strip.present?} %>
19
19
  <tr>
@@ -22,29 +22,36 @@
22
22
  <%- end -%>
23
23
  </tr>
24
24
  <% end %>
25
- <tr >
25
+ <tr>
26
26
  <%- col_count = 0
27
27
  question_grid_with_total.elements.each do |element| -%>
28
28
  <td id="element_<%= element.id %>">
29
- <% grid_el = @elements.to_a.find {|el| el.id == element.id} %>
30
- <%= render :partial => 'answer_pages/element', :object => grid_el, :locals => {:in_grid => true, :col => col_count} if grid_el %>
29
+ <%# grid_el = @elements.to_a.find {|el| el.id == element.id} %>
30
+ <% col_count = (col_count + 1) % question_grid_with_total.num_cols %>
31
+ <%= render :partial => 'fe/answer_pages/element', :object => element, :locals => {:in_grid => true, :col => col_count} %>
31
32
  </td>
32
33
  <%- col_count += 1
33
34
  if col_count % question_grid_with_total.num_cols == 0 && element != question_grid_with_total.elements.last then col_count = 0 -%></tr><tr><%- end -%>
34
35
  <%- end -%>
35
- <%- while col_count < question_grid_with_total.num_cols do
36
+ <%- while col_count < question_grid_with_total.num_cols do
36
37
  col_count += 1-%>
37
38
  <td>&nbsp;</td>
38
39
  <%- end unless col_count == 0-%>
39
40
  </tr>
40
41
  <%- if question_grid_with_total.total_cols.present? -%>
41
- <tr>
42
+ <tr class="total">
42
43
  <td>Total</td>
43
- <%- total_cols = question_grid_with_total.total_cols.split(',').collect(&:to_i)
44
- (question_grid_with_total.num_cols - 1).times do |i|
45
- if total_cols.include?(i + 2) -%>
44
+ <%- total_cols = question_grid_with_total.total_cols.split(',').collect(&:to_i)
45
+ (question_grid_with_total.num_cols - 1).times do |i|
46
+ ci = i + 2
47
+ if total_cols.include?(ci) -%>
46
48
  <td>
47
49
  <%= text_field_tag "total_#{question_grid_with_total.id}_#{i + 1}", '', :class => 'text validate-number', :readonly => true %>
50
+ <script>
51
+ $("#<%= "total_#{question_grid_with_total.id}_#{i + 1}" %>").closest("table").find("td:nth-child(<%= ci %>)").change(function() {
52
+ updateTotal("<%= question_grid_with_total.id %>_<%= i+1 %>");
53
+ });
54
+ </script>
48
55
  </td>
49
56
  <% else %>
50
57
  <td>&nbsp;</td>
@@ -1,8 +1,8 @@
1
1
  <ul>
2
2
  <% questions.each do |question| %>
3
- <li><%= link_to(use_existing_fe_admin_question_sheet_page_element_path(:question_sheet_id => @page.question_sheet_id, :page_id => @page.id, :id => question.id),
3
+ <li><%= link_to(use_existing_fe_admin_question_sheet_page_element_path(:question_sheet_id => @page.question_sheet_id, :page_id => @page.id, :id => question.id),
4
4
  :remote => true, :method => :post) do %>
5
- <span>select</span><label><%= raw question.label %></label>
5
+ <span>select</span><label><%= raw question.label(session[:locale]) %></label>
6
6
  <% end %>
7
7
  </li>
8
8
  <% end %>
@@ -1,41 +1,42 @@
1
+ <% choices = radio_button_field.choices(session[:locale]) %>
1
2
  <% css_class = 'radio ' -%>
2
- <% css_class += 'required' if radio_button_field.required? %>
3
+ <% css_class += 'required' if radio_button_field.required?(@answer_sheet, @page) %>
3
4
  <% if radio_button_field.hide_option_labels? && !['question_pages', 'question_sheets', 'elements'].include?(controller.controller_name) %>
4
5
  <tr id="<%= dom_id(radio_button_field) %>">
5
6
  <td class="col1">
6
7
  <label for="<%= dom_id(radio_button_field) %>" class="desc">
7
- <%= raw radio_button_field.label %>
8
- <% if radio_button_field.required?(@answer_sheet) -%><span class="required">required</span><% end -%>
8
+ <%= raw radio_button_field.label(session[:locale]) %>
9
+ <% if radio_button_field.required?(@answer_sheet, @page) -%><span class="required">required</span><% end -%>
9
10
  <%= tip(radio_button_field.tooltip) if radio_button_field.tooltip.present? %>
10
11
  </label>
11
12
  </td>
12
- <% radio_button_field.choices.each_with_index do |choice, num| -%>
13
+ <% choices.each_with_index do |choice, num| -%>
13
14
  <td class="col">
14
15
  <% dom_id = dom_id(radio_button_field) + "_" + pretty_tag(choice[1])
15
- last_choice = (num == radio_button_field.choices.length - 1)
16
+ last_choice = (num == choices.length - 1)
16
17
  css_class += radio_button_field.validation_class(@answer_sheet) if last_choice
17
18
  checked = radio_button_field.has_answer?(choice[1], @answer_sheet) -%>
18
19
  <%= radio_button_tag "answers[#{radio_button_field.id}]", choice[1], checked,
19
20
  :id => dom_id,
20
21
  :class => css_class,
21
- :disabled => @answer_sheet.frozen?&&!@presenter.reference?,
22
- :readonly => @answer_sheet.frozen?&&!@presenter.reference? %>
22
+ :disabled => @answer_sheet.frozen?&&!@presenter.try(:reference?),
23
+ :readonly => @answer_sheet.frozen?&&!@presenter.try(:reference?) %>
23
24
  </td>
24
25
  <% end -%>
25
26
  </tr>
26
27
  <% else %>
27
28
  <div id="<%= dom_id(radio_button_field) %>">
28
- <% radio_button_field.choices.each_with_index do |choice, num| -%>
29
+ <% choices.each_with_index do |choice, num| -%>
29
30
  <% dom_id = dom_id(radio_button_field) + "_" + pretty_tag(choice[1])
30
- last_choice = (num == radio_button_field.choices.length - 1)
31
+ last_choice = (num == choices.length - 1)
31
32
  css_class += radio_button_field.validation_class(@answer_sheet) if last_choice
32
33
  checked = radio_button_field.has_answer?(choice[1], @answer_sheet) -%>
33
34
  <div class="radio-set">
34
35
  <%= radio_button_tag "answers[#{radio_button_field.id}]", choice[1], checked,
35
36
  :id => dom_id,
36
37
  :class => css_class,
37
- :disabled => @answer_sheet.frozen?&&!@presenter.reference?,
38
- :readonly => @answer_sheet.frozen?&&!@presenter.reference? %>
38
+ :disabled => @answer_sheet.frozen?&&!@presenter.try(:reference?),
39
+ :readonly => @answer_sheet.frozen?&&!@presenter.try(:reference?) %>
39
40
  <label class="choice" for="<%= dom_id %>"><%= choice[0] %></label>
40
41
  </div>
41
42
  <% end -%>