diff --git a/app/controllers/templates_controller.rb b/app/controllers/templates_controller.rb index bcde979..61ad438 100644 --- a/app/controllers/templates_controller.rb +++ b/app/controllers/templates_controller.rb @@ -107,7 +107,7 @@ def admin_previewphase @phase = Phase.find(params[:id]) authorize @phase.template - @template = Phase.template + @template = @phase.template end diff --git a/app/models/question.rb b/app/models/question.rb index d6ec73e..7a37132 100644 --- a/app/models/question.rb +++ b/app/models/question.rb @@ -96,11 +96,12 @@ # pulls together guidance from various sources for question guidances = {} theme_ids = question.theme_ids - - GuidanceGroup.where(org_id: org.id).each do |group| - group.guidances.each do |g| - g.themes.where("id IN (?)", theme_ids).each do |gg| - guidances["#{group.name} " + I18n.t('admin.guidance_lowercase_on') + " #{gg.title}"] = g + if theme_ids.present? + GuidanceGroup.where(org_id: org.id).each do |group| + group.guidances.each do |g| + g.themes.where("id IN (?)", theme_ids).each do |gg| + guidances["#{group.name} " + I18n.t('admin.guidance_lowercase_on') + " #{gg.title}"] = g + end end end end diff --git a/app/views/templates/_preview_question.html.erb b/app/views/templates/_preview_question.html.erb index dee1c97..37d3fb1 100644 --- a/app/views/templates/_preview_question.html.erb +++ b/app/views/templates/_preview_question.html.erb @@ -8,7 +8,7 @@
<% if q_format.title == t("helpers.checkbox") || q_format.title == t("helpers.multi_select_box") || q_format.title == t("helpers.radio_buttons") || q_format.title == t("helpers.dropdown") %> - <% options = question.options.order("number") %> + <% options = question.question_options.order("number") %> <% if q_format.title == t("helpers.checkbox") %> diff --git a/app/views/templates/admin_previewphase.html.erb b/app/views/templates/admin_previewphase.html.erb index 12c2507..58de962 100644 --- a/app/views/templates/admin_previewphase.html.erb +++ b/app/views/templates/admin_previewphase.html.erb @@ -2,63 +2,58 @@ <%= stylesheet_link_tag "admin" %>

- <%= @version.phase.dmptemplate.title %> - -
- <%= link_to t("org_admin.templates.back_to_edit_phase_label"), - admin_phase_dmptemplate_path(:id => @version.phase_id, :version_id => @version.id, :edit => "true"), - :class => 'btn btn-primary' %> - <%= link_to t("org_admin.templates.view_all_templates"), - admin_index_dmptemplate_path, - :class => 'btn btn-primary' %> -
+ <%= @template.title %> + +
+ <%= link_to t("org_admin.templates.back_to_edit_phase_label"), + admin_phase_template_path(id: @phase.id, edit: "true"), + class: 'btn btn-primary' %> + <%= link_to t("org_admin.templates.view_all_templates"), + admin_index_template_path, + class: 'btn btn-primary' %> +

-<%= render :partial => "admin_nav_tabs", locals: {dmptemplate: @version.phase.dmptemplate, active: @version.phase_id} %> +<%= render partial: "admin_nav_tabs", locals: {template: @template, active: @phase.id} %>
-
- <% sections = @version.sections %> - <% sections.order(:number).each do |section| %> - <%if (section.organisation_id == @version.phase.dmptemplate.organisation_id ) || ( section.organisation_id == current_user.organisation_id) then%> - -
- -
-
- <%= raw section.description %> -
-
- <% section.questions.order("number").each do |question| %> - <% last_question_id = section.questions.order("number DESC").first.id%> - - - <%= render :partial => 'preview_question', locals: {question: question}%> - - <% if last_question_id == question.id then %> -
- <% else %> -
- <% end %> - - <%end%> -
-
-
- <%end%> - <%end%> -
-
\ No newline at end of file +
+ <% sections = @phase.sections %> + <% sections.order(:number).each do |section| %> +
+ +
+
+ <%= raw section.description %> +
+
+ <% last_question_id = section.questions.order("number DESC").first.id%> + + <% section.questions.order("number").each do |question| %> + + <%= render partial: 'preview_question', locals: {question: question}%> + <% if last_question_id == question.id then %> +
+ <% else %> +
+ <% end %> + + <% end %> +
+
+
+ <% end %> +
+
\ No newline at end of file