diff --git a/app/controllers/legislation/annotations_controller.rb b/app/controllers/legislation/annotations_controller.rb index 93de149fa..dc3ff4834 100644 --- a/app/controllers/legislation/annotations_controller.rb +++ b/app/controllers/legislation/annotations_controller.rb @@ -8,7 +8,7 @@ class Legislation::AnnotationsController < ApplicationController load_and_authorize_resource :draft_version, through: :process load_and_authorize_resource - has_orders %w{most_voted newest oldest}, only: :show + has_orders %w{most_voted newest}, only: :show def index @annotations = @draft_version.annotations @@ -16,7 +16,15 @@ class Legislation::AnnotationsController < ApplicationController def show @commentable = @annotation - @comment_tree = CommentTree.new(@commentable, params[:page], @current_order) + + if params[:sub_annotation_ids].present? + @sub_annotations = Legislation::Annotation.where(id: params[:sub_annotation_ids].split(',')) + annotations = [@commentable, @sub_annotations] + else + annotations = [@commentable] + end + + @comment_tree = MergedCommentTree.new(annotations, params[:page], @current_order) set_comment_flags(@comment_tree.comments) end diff --git a/app/views/legislation/annotations/_annotation_link.html.erb b/app/views/legislation/annotations/_annotation_link.html.erb new file mode 100644 index 000000000..74f841abd --- /dev/null +++ b/app/views/legislation/annotations/_annotation_link.html.erb @@ -0,0 +1,3 @@ +<%= link_to legislation_process_draft_version_annotation_path(annotation.draft_version.process, annotation.draft_version, annotation, sub_annotation_ids: "") do %> + +<% end %> \ No newline at end of file diff --git a/app/views/legislation/annotations/_comment_header.html.erb b/app/views/legislation/annotations/_comment_header.html.erb new file mode 100644 index 000000000..f8602aa7e --- /dev/null +++ b/app/views/legislation/annotations/_comment_header.html.erb @@ -0,0 +1,10 @@ + + +
+ <%= t('legislation.annotations.comments.comments_count', + count: annotation.comments.roots.count) %> +
+ + + <%= render "annotation_link", annotation: annotation %> + \ No newline at end of file diff --git a/app/views/legislation/annotations/_comments.html.erb b/app/views/legislation/annotations/_comments.html.erb new file mode 100644 index 000000000..b86ae1287 --- /dev/null +++ b/app/views/legislation/annotations/_comments.html.erb @@ -0,0 +1,29 @@ +<% annotation.comments.roots.sort_by_most_voted. + limit(Legislation::Annotation::COMMENTS_PAGE_SIZE).each do |comment| %> +
+
+

<%= truncate comment.body, length: 250 %>

+
+
+
+ <% if comment.body.length > 250 %> +
+ <%= link_to legislation_process_draft_version_annotation_path(annotation.draft_version.process, annotation.draft_version, annotation) do %> + <%= t('legislation.annotations.comments.see_complete') %> + <% end %> +
+ <% end %> +
+ <%= link_to legislation_process_draft_version_annotation_path(annotation.draft_version.process, annotation.draft_version, annotation, anchor: "comment_#{comment.id}") do %> + <%= t('legislation.annotations.comments.replies_count', count: comment.children.size) %> + <% end %> +
+
+
+
+ <%= render 'comments/votes', comment: comment %> +
+
+
+
+<% end %> \ No newline at end of file diff --git a/app/views/legislation/annotations/_comments_box.html.erb b/app/views/legislation/annotations/_comments_box.html.erb index 5f0fec421..79fdbef4b 100644 --- a/app/views/legislation/annotations/_comments_box.html.erb +++ b/app/views/legislation/annotations/_comments_box.html.erb @@ -1,41 +1,11 @@
- -
<%= t('legislation.annotations.comments.comments_count', count: annotation.comments.roots.count) %>
- <%= link_to legislation_process_draft_version_annotation_path(annotation.draft_version.process, annotation.draft_version, annotation) do %> - - <% end %> + <%= render "comment_header", annotation: annotation %>
- <% annotation.comments.roots.sort_by_most_voted.limit(Legislation::Annotation::COMMENTS_PAGE_SIZE).each do |comment| %> -
-
-

<%= truncate comment.body, length: 250 %>

-
-
-
- <% if comment.body.length > 250 %> -
- <%= link_to legislation_process_draft_version_annotation_path(annotation.draft_version.process, annotation.draft_version, annotation) do %> - <%= t('legislation.annotations.comments.see_complete') %> - <% end %> -
- <% end %> -
- <%= link_to legislation_process_draft_version_annotation_path(annotation.draft_version.process, annotation.draft_version, annotation, anchor: "comment_#{comment.id}") do %> - <%= t('legislation.annotations.comments.replies_count', count: comment.children.size) %> - <% end %> -
-
-
-
- <%= render 'comments/votes', comment: comment %> -
-
-
+
+ <%= render "comments", annotation: annotation %>
- <% end %> -