Skip to content

Commit

Permalink
Merge pull request #171 from DMPRoadmap/issue2509
Browse files Browse the repository at this point in the history
fixed bug that was preventing the read only version of the template f…
  • Loading branch information
briri authored May 13, 2020
2 parents 6446a16 + 217c917 commit be2a7de
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 4 deletions.
10 changes: 9 additions & 1 deletion app/controllers/org_admin/phases_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,21 @@ def show
flash[:notice] = _("You are viewing a historical version of this template. You will not be able to make changes.")
# rubocop:enable Metrics/LineLength
end
if phase.template.customization_of? && phase.template.latest?
# The user is working with the latest version so only use the modifiable sections
sections = phase.template_sections.order(:number)
else
# This is not the latest version sso just get all the sections. Everything
# will be readonly
sections = phase.sections.order(:number)
end
render("container",
locals: {
partial_path: "show",
template: phase.template,
phase: phase,
prefix_section: phase.prefix_section,
sections: phase.template_sections.order(:number),
sections: sections,
suffix_sections: phase.suffix_sections.order(:number),
current_section: Section.find_by(id: params[:section], phase_id: phase.id)
})
Expand Down
2 changes: 1 addition & 1 deletion app/views/org_admin/phases/container.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
<% unless phase.sections.all?(&:modifiable?) %>
<%= _("You may place them before or after the main template sections.") %>
<% end %>
<% else %>
<% elsif template.latest? %>
<%= link_to _('Re-order sections'),
org_admin_template_phase_versions_path(phase.template, phase),
method: "post",
Expand Down
5 changes: 3 additions & 2 deletions app/views/org_admin/sections/_index.html.erb
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
<%# locals modifiable %>

<!-- Accordion for sections -->
<div class="row">
<div class="col-md-12">
<div class="draggable-sections" data-url="<%=
sort_org_admin_template_phase_path(template, phase)
%>">

<%= render partial: "org_admin/sections/section_group",
locals: { sections: Array(prefix_section),
phase: phase,
template: template,
current_section: current_section,
panel_id: "section-#{prefix_section.id}",
modifiable: true } if prefix_section %>
modifiable: modifiable } if prefix_section %>

<%# If we are working with a modifiable phase then allow the core sections to be reordered %>
<% if phase.modifiable? %>
Expand Down

0 comments on commit be2a7de

Please sign in to comment.