Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added org abbreviation to 'Guidance' sections and added customized ex… #1347

Merged
merged 1 commit into from
Apr 5, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion app/controllers/answers_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ def create_or_update
}).find(p_params[:plan_id])
@question = @answer.question
@section = @plan.get_section(@question.section_id)
template = @section.phase.template

render json: {
"question" => {
Expand All @@ -66,7 +67,7 @@ def create_or_update
"locking" => @stale_answer ?
render_to_string(partial: 'answers/locking', locals: { question: @question, answer: @stale_answer, user: @answer.user }, formats: [:html]) :
nil,
"form" => render_to_string(partial: 'answers/new_edit', locals: { question: @question, answer: @answer, readonly: false, locking: false }, formats: [:html]),
"form" => render_to_string(partial: 'answers/new_edit', locals: { template: template, question: @question, answer: @answer, readonly: false, locking: false }, formats: [:html]),
"answer_status" => render_to_string(partial: 'answers/status', locals: { answer: @answer}, formats: [:html])
},
"section" => {
Expand Down
8 changes: 2 additions & 6 deletions app/views/annotations/_show.html.erb
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
<% org = template.org.abbreviation.present? ? template.org.abbreviation : template.org.name %>
<% if example_answer.present? || guidance.present? %>
<% if guidance.present? %>
<dl<%= for_plan ? ' class="dl-horizontal"' : '' %>>
<% if example_answer.present? %>
<dt><%= _('Example answer') %></dt>
<dd><%= raw example_answer.text %><dd>
<% end %>
<% if guidance.present? %>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this if is no longer needed

<dt><%= _('Guidance') %></dt>
<dt><%= template.customization_of.nil? ? _('Guidance') : _('%{org} Guidance') % { org: guidance.org.short_name } %></dt>
<dd><%= raw guidance.text %></dd>
<% end %>
</dl>
Expand Down
3 changes: 2 additions & 1 deletion app/views/answers/_locking.html.erb
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<div class="answer_notice">
<p><%= _('The following answer cannot be saved') %></p>
<%= render partial: '/answers/new_edit', locals: { question: question, answer: answer, readonly: true, locking: true } %>
<%# We do not need to re-show example answers in this lock conflict section so leave template nil %>
<%= render partial: '/answers/new_edit', locals: { template: nil, question: question, answer: answer, readonly: true, locking: true } %>
<p><%= _('since %{name} saved the answer below while you were editing. Please, combine your changes and then save the answer again.') % { name: user.name} %></p>
</div>
23 changes: 13 additions & 10 deletions app/views/answers/_new_edit.html.erb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<%# locals: { question, answer, readonly, locking } %>
<%# locals: { template, question, answer, readonly, locking } %>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this partial is used also for previewing a template, did you test if still works?

<!--
This partial creates a form for each type of question. The local variables are: plan, answer, question, readonly
-->
Expand Down Expand Up @@ -64,15 +64,18 @@
<%= f.button(_('Save'), class: "btn btn-default", type: "submit") %>
</fieldset>
<!--Example Answer area -->
<% annotation = question.first_example_answer %>
<% if annotation.present? && annotation.text.present? %>
<div class="panel panel-default">
<span class="label label-default">
<%="#{annotation.org.abbreviation} "%> <%=_('example answer')%>
</span>
<div class="panel-body">
<%= raw annotation.text %>
<% annotations = [question.first_example_answer] %>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is workable but I don't think is understandable at a glance. A more simplistic approach would be question.annotations.where(type: Annotation.types[:example_answer]) which would bring both example answers in one go. Obviously we should move data access to the controllers or model

<% annotations << question.get_example_answer(template.org.id) if template.present? && template.org.present? %>
<% annotations.each do |annotation| %>
<% if annotation.present? && annotation.org.present? %>
<div class="panel panel-default">
<span class="label label-default">
<%="#{annotation.org.abbreviation} "%> <%=_('example answer')%>
</span>
<div class="panel-body">
<%= raw annotation.text %>
</div>
</div>
</div>
<% end %>
<% end %>
<% end %>
2 changes: 1 addition & 1 deletion app/views/phases/_edit_plan_answers.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
<div class="question-form">
<div id="<%= "answer-locking-#{question.id}" %>" class="answer-locking"></div>
<div id="<%= "answer-form-#{question.id}" %>" class="answer-form">
<%= render(partial: '/answers/new_edit', locals: { question: question, answer: answer, readonly: readonly, locking: false }) %>
<%= render(partial: '/answers/new_edit', locals: { template: phase.template, question: question, answer: answer, readonly: readonly, locking: false }) %>
</div>
<div id="<%= "answer-status-#{question.id}" %>" class="mt-10">
<%= render(partial: '/answers/status', locals: { answer: answer }) %>
Expand Down