Don’t show comments panel if seeing final version

This commit is contained in:
Amaia Castro
2017-01-11 19:44:41 +01:00
parent a2a61341fe
commit 306e3fa59f
4 changed files with 48 additions and 22 deletions

View File

@@ -12,6 +12,7 @@ App.LegislationAnnotatable =
viewerExtension: (viewer) ->
viewer._onHighlightMouseover = (event) ->
App.LegislationAllegations.show_comments()
$("#comments-box").show()
$.event.trigger
type: "renderLegislationAnnotation"
annotation_id: $(event.target).data("annotation-id")

View File

@@ -0,0 +1,18 @@
<div class="small-12 calc-comments end column js-toggle-allegations">
<div class="draft-panel">
<div>
<span class="icon-comments" aria-hidden="true"></span> <span class="panel-title"><%= t('legislation.draft_versions.show.text_comments') %></span>
</div>
</div>
<div class="draft-comments-rotated center">
<span class="panel-title"><%= t('legislation.draft_versions.show.text_comments') %></span>
</div>
<div class="comment-box" id="comments-box" style="display: none;">
<div class="comment-header">
<span class="icon-comment" aria-hidden="true"></span>
<div class="comment-number"><%= t('legislation.draft_versions.show.loading_comments') %></div>
</div>
</div>
</div>

View File

@@ -18,13 +18,17 @@
</div>
<span><%= t('.updated_at', date: format_date(@draft_version.updated_at)) %></span>
</div>
<div class="small-12 medium-3 column">
<%= link_to t('.see_comments'), legislation_process_draft_version_annotations_path(@process, @draft_version), title: t('.see_comments'), class: "button strong" %>
</div>
<% unless @draft_version.final_version? %>
<div class="small-12 medium-3 column">
<%= link_to t('.see_comments'), legislation_process_draft_version_annotations_path(@process, @draft_version), title: t('.see_comments'), class: "button strong" %>
</div>
<% end %>
</div>
<div class="row draft-allegation medium-collapse">
<div class="small-12 calc-index column border-right js-toggle-allegations">
<div class="small-12 calc-index column border-right <%= "js-toggle-allegations" unless @draft_version.final_version? %>">
<div class="draft-panel">
<div>
<span class="icon-banner" aria-hidden="true"></span> <span class="panel-title"><%= t('.text_toc') %></span>
@@ -44,34 +48,25 @@
<div><span class="panel-title"><%= t('.text_body') %></span></div>
</div>
<div class="draft-text">
<% if @draft_version.final_version? %>
<section>
<% else %>
<section class="legislation-annotatable"
data-legislation-draft-version-id="<%= @draft_version.id %>"
data-legislation-annotatable-base-url="<%= legislation_process_draft_version_path(@process, @draft_version) %>"
>
<% end %>
<%= @draft_version.body_html.html_safe %>
</section>
</div>
</div>
<div class="small-12 calc-comments end column js-toggle-allegations">
<div class="draft-panel">
<div>
<span class="icon-comments" aria-hidden="true"></span> <span class="panel-title"><%= t('.text_comments') %></span>
</div>
</div>
<% if @draft_version.final_version? %>
<div class="small-12 calc-comments end column"></div>
<% else %>
<%= render 'comments_panel', draft_version: @draft_version %>
<% end %>
<div class="draft-comments-rotated center">
<span class="panel-title"><%= t('.text_comments') %></span>
</div>
<div class="comment-box" id="comments-box">
<div class="comment-header">
<span class="icon-comment" aria-hidden="true"></span>
<div class="comment-number"><%= t('.loading_comments') %></div>
</div>
</div>
</div>
</div>
</div>

View File

@@ -61,6 +61,18 @@ feature 'Legislation Draft Versions' do
expect(page).to_not have_content("Body of the first version")
expect(page).to have_content("Body of the second version")
end
context "for final versions" do
it "does not show the comments panel" do
final_version = create(:legislation_draft_version, process: @process, title: "Final version", body: "Final body", status: "published", final_version: true)
visit legislation_process_draft_version_path(@process, final_version)
expect(page).to have_content("Final body")
expect(page).to_not have_content("See all comments")
expect(page).to_not have_content("Comments")
end
end
end
context "See changes page" do