comment updates

This commit is contained in:
Mark Moser
2017-02-13 18:08:51 -06:00
parent 39ba1a8369
commit 906b62247b
6 changed files with 110 additions and 11 deletions

View File

@ -1,2 +1,21 @@
<div class="comment-message"><%= comment.message %></div>
<div class="comment-message">
<%= comment.message %>
<% if policy(comment).update? %>
<label class="comment-edit-btn" for="comment-<%= comment.id %>">edit</label>
<% end %>
<% if comment.edits? %>
<div class="comment-edit-stamp">Updated <%= time_ago_in_words(comment.updated_at) %> ago</div>
<% end %>
</div>
<div class="comment-author"><%= comment.user.name %></div>
<% if policy(comment).update? %>
<input type="checkbox" id="comment-<%= comment.id %>">
<div class="comment-edit-form">
<%= render partial: 'comment_form', locals: {comment: comment, test_hash: comment.test_hash } %>
</div>
<% end %>

View File

@ -1,11 +1,25 @@
<%= render partial: 'shared/form_model_errors', locals: { obj: @comment } %>
<%= render partial: 'shared/form_model_errors', locals: { obj: comment } %>
<% # admin_update_comment_path # admin_create_comment_path %>
<%= form_for @comment, url: admin_create_comment_path(test_hash), method: :post do |form| %>
<div class="form-group">
<%= form.label :message, "Comment" %>
<%= form.text_area :message %>
</div>
<% if comment.id.nil? %>
<%= form_for comment, url: admin_create_comment_path(test_hash: test_hash), method: :post do |form| %>
<div class="form-group">
<%= form.label :message, "New Comment" %>
<%= form.text_area :message %>
</div>
<%= submit_tag "Save Comment" %>
<% end %>
<% else %>
<%= form_for comment, url: admin_update_comment_path(test_hash: test_hash, id: comment.id), method: :post do |form| %>
<div class="form-group">
<%= form.label :message, "Update Comment" %>
<%= form.text_area :message %>
</div>
<%= submit_tag "Update" %>
<% end %>
<%= submit_tag "Save Comment" %>
<% end %>

View File

@ -46,6 +46,8 @@
<div class="review-comments">
<h2 class="prft-heading">Comments</h2>
<%= render partial: 'comment', collection: @comments, locals: { test_hash: @candidate.test_hash } %>
<div><%= render partial: 'comment_form', locals: { test_hash: @candidate.test_hash } %></div>
<% if policy(QuizComment).create? %>
<%= render partial: 'comment_form', locals: {comment: @comment, test_hash: @candidate.test_hash } %>
<% end %>
</div>
</div>