From d383f049f5dbb774848ba16a961cb9d17cd053b7 Mon Sep 17 00:00:00 2001 From: Will Gutierrez Date: Wed, 10 Feb 2021 16:06:38 -0800 Subject: [PATCH 1/6] merge comments/_edit & comments/_form partials --- app/views/comments/_edit.html.erb | 104 ----------------- app/views/comments/_form.html.erb | 187 +++++++++++++++++++++--------- 2 files changed, 131 insertions(+), 160 deletions(-) delete mode 100644 app/views/comments/_edit.html.erb diff --git a/app/views/comments/_edit.html.erb b/app/views/comments/_edit.html.erb deleted file mode 100644 index 588f03495d..0000000000 --- a/app/views/comments/_edit.html.erb +++ /dev/null @@ -1,104 +0,0 @@ - \ No newline at end of file diff --git a/app/views/comments/_form.html.erb b/app/views/comments/_form.html.erb index f64ec05607..799a412862 100644 --- a/app/views/comments/_form.html.erb +++ b/app/views/comments/_form.html.erb @@ -1,104 +1,156 @@ + +<% comment_id_string = comment ? comment.id.to_s : nil %> -<% comment_form_id = get_comment_form_id(location, local_assigns[:reply_to], nil) %> -
-
" <% if local_assigns[:aid].blank? %>method="post"<% end %>> - <% if current_user && current_user.id == @node.uid %> - - Add a template - +<% comment_form_id = get_comment_form_id(location, local_assigns[:reply_to], comment_id_string) %> +
+ " +> + + action="/comment/create/<%= @node.nid %>" + data-remote="true" + <% else %> + action = "/comment/update/<%= comment.id %>" + <% end %> + method="post" + <% if location == :edit %> + style="display: none;" <% end %> -

<%= title %>

+ > +

+ <%= title %> +

+ - + - <% locals = (location == :reply) ? - { :location => location, :reply_to => reply_to } : - { :location => location } - %> + <% locals = {} %> + <% locals[:location] = location %> + <% locals[:reply_to] = reply_to if location == :reply %> + <% locals[:comment_id] = comment.id.to_s if comment %> <%= render :partial => "editor/toolbar", :locals => locals %> - - <% if local_assigns[:reply_to].present? %> - <%= hidden_field_tag :reply_to, local_assigns[:reply_to] %> - <% end %> - - - -
- <% - body = body || params[:body] - # Look for comment templates - if params[:body].nil? && @node && @node.has_power_tag('comment-template') - body = Node.find_by(slug: @node.power_tag('comment-template')).try(:body) - end - %> - <% if is_new_contributor %> + + +
+ <% if location != :edit && is_new_contributor %>
<% cache('feature_welcome-msg', skip_digest: true) do %> <%= feature("welcome-msg") %> <% end %>
<% end %> - + style=" + border: 1px solid #bbb; + border-bottom-left-radius: 0; + border-bottom-right-radius: 0; + border-bottom: 0; + padding: 10px; + " + placeholder="<%= placeholder %>" + <% comment_text = location == :edit ? comment.comment : params[:body] %> + ><%= comment_text %>

- - - + + -

-