diff --git a/app/controllers/plans_controller.rb b/app/controllers/plans_controller.rb index 080f0d3..d7adfd5 100644 --- a/app/controllers/plans_controller.rb +++ b/app/controllers/plans_controller.rb @@ -1,6 +1,6 @@ +require 'pp' class PlansController < ApplicationController include ConditionalUserMailer - require 'pp' helper PaginableHelper helper SettingsTemplateHelper include FeedbacksHelper @@ -160,10 +160,7 @@ readonly = !plan.editable_by?(current_user.id) - guidance_groups_ids = plan.guidance_groups.collect(&:id) - - guidance_groups = GuidanceGroup.where(published: true, id: guidance_groups_ids) - + guidance_groups = GuidanceGroup.where(published: true, id: plan.guidance_group_ids) # Since the answers have been pre-fetched through plan (see Plan.load_for_phase) # we create a hash whose keys are question id and value is the answer associated answers = plan.answers.reduce({}){ |m, a| m[a.question_id] = a; m } @@ -173,7 +170,8 @@ plan: plan, phase: phase, readonly: readonly, question_guidance: plan.guidance_by_question_as_hash, guidance_groups: guidance_groups, - answers: answers }) + answers: answers, + guidance_service: GuidanceService.new(plan) }) end # PUT /plans/1 diff --git a/app/views/guidance_groups/_index_by_theme.html.erb b/app/views/guidance_groups/_index_by_theme.html.erb index 3c39eff..8ba4226 100644 --- a/app/views/guidance_groups/_index_by_theme.html.erb +++ b/app/views/guidance_groups/_index_by_theme.html.erb @@ -11,22 +11,36 @@ <% guidance_groups_by_theme.each_pair do |guidance_group, theme_hash| %> <% theme_hash.each_pair do |theme, guidances| %>
+<<<<<<< HEAD
>>>>>> parent of ac3dbec2... Revert "lookup hash guidance groups by org. DMPRoadmap/roadmap#1409" data-toggle="collapse" href="<%= "##{guidances.object_id}" %>" aria-expanded="false" aria-controls="<%= "##{guidances.object_id}" %>">
" +======= + id="<%= "#{guidances.object_id}" %>" +>>>>>>> parent of ac3dbec2... Revert "lookup hash guidance groups by org. DMPRoadmap/roadmap#1409" class="panel-collapse collapse" role="tabpanel" aria-labelledby="<%= "panel-heading-#{guidances.object_id}" %>"> @@ -39,4 +53,8 @@
<% end %> <% end %> +<<<<<<< HEAD
+======= + +>>>>>>> parent of ac3dbec2... Revert "lookup hash guidance groups by org. DMPRoadmap/roadmap#1409" diff --git a/app/views/phases/_edit_plan_answers.html.erb b/app/views/phases/_edit_plan_answers.html.erb index 41cc613..e01758b 100644 --- a/app/views/phases/_edit_plan_answers.html.erb +++ b/app/views/phases/_edit_plan_answers.html.erb @@ -72,7 +72,12 @@
- <%= render partial: '/phases/guidances_notes', locals: { plan: plan, template: phase.template, question: question, answer: answer, question_guidance: question_guidance, guidance_groups: guidance_groups, base_template_org: base_template_org } %> + <%= render partial: '/phases/guidances_notes', locals: { + plan: plan, + template: phase.template, + question: question, + answer: answer, + guidance_service: guidance_service } %>
<%= raw('
') if i != section.questions.length - 1 %> diff --git a/app/views/phases/_guidances_notes.html.erb b/app/views/phases/_guidances_notes.html.erb index 9ad6e2a..b080f71 100644 --- a/app/views/phases/_guidances_notes.html.erb +++ b/app/views/phases/_guidances_notes.html.erb @@ -1,7 +1,6 @@ -<%# locals: { plan, template, question, answer, question_guidance, guidance_groups } %> -<% annotations = question.annotations.where(type: Annotation.types[:guidance]) %> -<% guidance_set = question_guidance[question.id] || {} %> -<% guidances_active = (annotations.present? || guidance_set.length > 0) %> +<%# locals: { plan, template, question, answer, guidance_service } %> +<% guidances_active = guidance_service.any? %> +<% active_nav = nil %>