diff --git a/app/services/guidance_service.rb b/app/services/guidance_service.rb index da115f0..929b3c7 100644 --- a/app/services/guidance_service.rb +++ b/app/services/guidance_service.rb @@ -20,9 +20,22 @@ end return @orgs end + def any?(org:nil, question:nil) - if org.nil? && question.nil? - return hashified_annotations? || hashified_guidance_groups? + if org.nil? + if question.nil? + return hashified_annotations? || hashified_guidance_groups? + end + if question.present? + # check each annotation/guidance group for a response to this question + # Would be nice not to have to crawl the entire list each time we want to know this + anno = orgs.reduce(false) {|found, o| found || guidance_annotations?(org: o, question: question)} + if !anno + return orgs.reduce(anno) {|found, o| found || guidance_groups_by_theme?(org: o, question: question)} + else + return anno + end + end end return guidance_annotations?(org: org, question: question) || guidance_groups_by_theme?(org: org, question: question) diff --git a/app/views/org_admin/annotations/_show.html.erb b/app/views/org_admin/annotations/_show.html.erb index d5392d9..e840fc1 100644 --- a/app/views/org_admin/annotations/_show.html.erb +++ b/app/views/org_admin/annotations/_show.html.erb @@ -5,7 +5,7 @@
<%= raw example_answer.text %>
<% end %> <% if guidance.present? %> -
<%= _('Question Specific Guidance') %>
+
<%= _('Question-Level Guidance') %>
<%= raw guidance.text %>
<% end %> diff --git a/app/views/phases/_guidances_notes.html.erb b/app/views/phases/_guidances_notes.html.erb index b080f71..45d47de 100644 --- a/app/views/phases/_guidances_notes.html.erb +++ b/app/views/phases/_guidances_notes.html.erb @@ -1,5 +1,5 @@ <%# locals: { plan, template, question, answer, guidance_service } %> -<% guidances_active = guidance_service.any? %> +<% guidances_active = guidance_service.any?(question: question) %> <% active_nav = nil %>
@@ -22,7 +22,8 @@ <% end %>
-
+ <% if guidances_active %> +
-
\ No newline at end of file +