From 306e3fa59f94558a3262a592f434b147586d29a4 Mon Sep 17 00:00:00 2001 From: Amaia Castro Date: Wed, 11 Jan 2017 19:44:41 +0100 Subject: [PATCH] =?UTF-8?q?Don=E2=80=99t=20show=20comments=20panel=20if=20?= =?UTF-8?q?seeing=20final=20version?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../legislation_annotatable.js.coffee | 1 + .../draft_versions/_comments_panel.html.erb | 18 +++++++++ .../legislation/draft_versions/show.html.erb | 39 ++++++++----------- .../legislation/draft_versions_spec.rb | 12 ++++++ 4 files changed, 48 insertions(+), 22 deletions(-) create mode 100644 app/views/legislation/draft_versions/_comments_panel.html.erb diff --git a/app/assets/javascripts/legislation_annotatable.js.coffee b/app/assets/javascripts/legislation_annotatable.js.coffee index ce9e9b8d7..f1df2927a 100644 --- a/app/assets/javascripts/legislation_annotatable.js.coffee +++ b/app/assets/javascripts/legislation_annotatable.js.coffee @@ -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") diff --git a/app/views/legislation/draft_versions/_comments_panel.html.erb b/app/views/legislation/draft_versions/_comments_panel.html.erb new file mode 100644 index 000000000..94523b557 --- /dev/null +++ b/app/views/legislation/draft_versions/_comments_panel.html.erb @@ -0,0 +1,18 @@ +
+
+
+ <%= t('legislation.draft_versions.show.text_comments') %> +
+
+ +
+ <%= t('legislation.draft_versions.show.text_comments') %> +
+ + +
diff --git a/app/views/legislation/draft_versions/show.html.erb b/app/views/legislation/draft_versions/show.html.erb index 6bee874c4..d89926929 100644 --- a/app/views/legislation/draft_versions/show.html.erb +++ b/app/views/legislation/draft_versions/show.html.erb @@ -18,13 +18,17 @@ <%= t('.updated_at', date: format_date(@draft_version.updated_at)) %> -
- <%= link_to t('.see_comments'), legislation_process_draft_version_annotations_path(@process, @draft_version), title: t('.see_comments'), class: "button strong" %> -
+ + <% unless @draft_version.final_version? %> +
+ <%= link_to t('.see_comments'), legislation_process_draft_version_annotations_path(@process, @draft_version), title: t('.see_comments'), class: "button strong" %> +
+ <% end %> +
-
+
">
<%= t('.text_toc') %> @@ -44,34 +48,25 @@
<%= t('.text_body') %>
+ <% if @draft_version.final_version? %> +
+ <% else %>
+ <% end %> <%= @draft_version.body_html.html_safe %>
-
-
-
- <%= t('.text_comments') %> -
-
+ <% if @draft_version.final_version? %> +
+ <% else %> + <%= render 'comments_panel', draft_version: @draft_version %> + <% end %> -
- <%= t('.text_comments') %> -
- -
-
- -
<%= t('.loading_comments') %>
-
-
- -
diff --git a/spec/features/legislation/draft_versions_spec.rb b/spec/features/legislation/draft_versions_spec.rb index c7f761669..cd655ae4a 100644 --- a/spec/features/legislation/draft_versions_spec.rb +++ b/spec/features/legislation/draft_versions_spec.rb @@ -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