app/views/comments/_comment.html.erb
<div id="c<%= comment.id %>" class="comment" data-comment-id="<%= comment.id %>">
<div class="comment-header" style="margin-bottom: 0;border-bottom-left-radius: 0;border-bottom-right-radius: 0;border-bottom: 0; background-color: #f8f8f8">
<div class="row">
<div class="col-6">
<a href="//publiclab.org/profile/<%= comment.author %>"><%= comment.author %></a>
commented <%= time_ago_in_words(comment.created_at) %> ago
</div>
<div class="col-6">
<% if current_user && current_user.can_edit?(comment) %>
<a class="btn btn-sm btn-outline-secondary float-right edit-comment-btn"><span class="fas fa-pencil-alt" data-comment-id="<%= comment.id %>"></span></a>
<% end %>
<% if current_user && current_user.can_delete?(comment) %>
<%= link_to(
[@map, comment],
method: "delete",
#:remote => true,
data: { confirm: "Are you sure? This cannot be undone." },
class: "btn btn-sm btn-outline-secondary float-right delete-comment-btn",
id: "comment-delete-#{comment.id}"
) do %>
<span class="fa fa-trash" data-comment-id="<%= comment.id %>"></span>
<% end %>
<% end %>
</div>
</div>
</div><!-- .comment-header -->
<div class="comment-body" style="border: 1px solid #e7e7e7;padding: 18px; margin-bottom: 20px;" data-comment-id="<%= comment.id %>"><%=raw markdown_to_html(comment.body) %></div><!-- .comment-body -->
<div class="comment-edit-form" data-comment-id="<%= comment.id %>" style="display:none">
<%= form_for([@map, comment]) do |f| %>
<%= f.text_area :body, :class => "form-control" %>
<%= f.submit "Publish", :class => "btn btn-primary" %>
<button type="button" class="btn btn-primary" onClick="$('.comment-edit-form').hide()">Cancel</button>
<% end %>
</div><!-- .comment-edit-form -->
</div><!-- .comment -->