Use comments component for investments valuation comments
This commit is contained in:
@@ -4,13 +4,13 @@
|
||||
|
||||
<% cache cache_key do %>
|
||||
<% if current_user %>
|
||||
<%= render "comments/form", { commentable: record, parent_id: nil } %>
|
||||
<%= render "comments/form", { commentable: record, parent_id: nil, valuation: valuation } %>
|
||||
<% else %>
|
||||
<%= render "shared/login_to_comment" %>
|
||||
<% end %>
|
||||
|
||||
<%= render Shared::OrderLinksComponent.new("comments", anchor: "comments") %>
|
||||
<%= render "comments/comment_list", comments: comment_tree.root_comments %>
|
||||
<%= render "comments/comment_list", comments: comment_tree.root_comments, valuation: valuation %>
|
||||
<%= paginate comment_tree.root_comments, params: { anchor: "comments" } %>
|
||||
<% end %>
|
||||
</div>
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
class Shared::CommentsComponent < ApplicationComponent
|
||||
attr_reader :record, :comment_tree
|
||||
attr_reader :record, :comment_tree, :valuation
|
||||
use_helpers :current_user, :current_order, :locale_and_user_status, :commentable_cache_key
|
||||
|
||||
def initialize(record, comment_tree)
|
||||
def initialize(record, comment_tree, valuation: false)
|
||||
@record = record
|
||||
@comment_tree = comment_tree
|
||||
@valuation = valuation
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
@@ -1,23 +0,0 @@
|
||||
<% commentable = comment_tree.commentable %>
|
||||
<% valuation = local_assigns.fetch(:valuation, false) %>
|
||||
<% cache [locale_and_user_status, comment_tree.order, commentable_cache_key(commentable), comment_tree.comments, comment_tree.comment_authors, commentable.comments_count] do %>
|
||||
<section class="expanded comments">
|
||||
<div class="row">
|
||||
<div id="comments" class="small-12 column">
|
||||
<% if user_signed_in? %>
|
||||
<% if !valuation || can?(:comment_valuation, commentable) %>
|
||||
<%= render "comments/form", { commentable: commentable,
|
||||
parent_id: nil,
|
||||
valuation: valuation } %>
|
||||
<% end %>
|
||||
<% else %>
|
||||
<%= render "shared/login_to_comment" %>
|
||||
<% end %>
|
||||
|
||||
<%= render Shared::OrderLinksComponent.new("comments", anchor: "comments") %>
|
||||
<%= render "comments/comment_list", comments: comment_tree.root_comments, valuation: valuation %>
|
||||
<%= paginate comment_tree.root_comments, params: { anchor: "comments" } %>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
<% end %>
|
||||
@@ -1,4 +1,3 @@
|
||||
<% valuation = local_assigns.fetch(:valuation, false) %>
|
||||
<% cache [locale_and_user_status, parent_id, commentable_cache_key(commentable), valuation] do %>
|
||||
<% if comments_closed_for_commentable?(commentable) %>
|
||||
<br>
|
||||
@@ -10,7 +9,7 @@
|
||||
<div data-alert class="callout primary">
|
||||
<%= sanitize(t("comments.verified_only", verify_account: link_to_verify_account)) %>
|
||||
</div>
|
||||
<% else %>
|
||||
<% elsif !valuation || can?(:comment_valuation, commentable) %>
|
||||
<% css_id = parent_or_commentable_dom_id(parent_id, commentable) %>
|
||||
<div id="js-comment-form-<%= css_id %>" class="comment-form">
|
||||
<%= form_for Comment.new, remote: true, html: { id: "new_comment_#{css_id}" } do |f| %>
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
<h2><%= t("valuation.budget_investments.valuation_comments") %></h2>
|
||||
<% unless @comment_tree.nil? %>
|
||||
<%= render "/comments/comment_tree", comment_tree: @comment_tree, valuation: true %>
|
||||
<%= render Shared::CommentsComponent.new(@investment, @comment_tree, valuation: true) %>
|
||||
<% end %>
|
||||
|
||||
Reference in New Issue
Block a user