comment updates
This commit is contained in:
parent
39ba1a8369
commit
906b62247b
28
.sass-lint.yml
Normal file
28
.sass-lint.yml
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
# https://github.com/sasstools/sass-lint/tree/master/docs/rules
|
||||||
|
files:
|
||||||
|
include: app/assets/stylesheets/**/*.scss
|
||||||
|
|
||||||
|
options:
|
||||||
|
formatter: stylish
|
||||||
|
merge-default-rules: true
|
||||||
|
|
||||||
|
rules:
|
||||||
|
class-name-format: 0
|
||||||
|
id-name-format: 0
|
||||||
|
leading-zero:
|
||||||
|
- 1
|
||||||
|
- include: true
|
||||||
|
no-duplicate-properties:
|
||||||
|
- 1
|
||||||
|
-
|
||||||
|
exclude:
|
||||||
|
- src # for @font mixins
|
||||||
|
no-qualifying-elements:
|
||||||
|
- 1
|
||||||
|
- allow-element-with-attribute: true # input[type='email'] but not div.class-name
|
||||||
|
quotes: 0
|
||||||
|
no-vendor-prefixes:
|
||||||
|
-
|
||||||
|
excluded-identifiers:
|
||||||
|
- -moz-osx-font-smoothing
|
||||||
|
- -webkit-font-smoothing
|
@ -34,10 +34,42 @@
|
|||||||
margin-bottom: 30px;
|
margin-bottom: 30px;
|
||||||
text-align: right;
|
text-align: right;
|
||||||
|
|
||||||
&:before {
|
&::before {
|
||||||
content: '- ';
|
content: '- ';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.comment-edit-stamp {
|
||||||
|
color: rgba($gray-dark, 0.65);
|
||||||
|
font-size: 0.75em;
|
||||||
|
text-align: right;
|
||||||
|
}
|
||||||
|
|
||||||
|
.comment-edit-btn {
|
||||||
|
cursor: pointer;
|
||||||
|
display: inline-block;
|
||||||
|
font-size: 0.85em;
|
||||||
|
font-weight: bold;
|
||||||
|
padding: 2px 5px;
|
||||||
|
|
||||||
|
&:hover {
|
||||||
|
background-color: $gray-base;
|
||||||
|
color: $gray-lighter;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.comment-edit-form {
|
||||||
|
display: none;
|
||||||
|
margin: 30px 0;
|
||||||
|
padding: 10px 0;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
[type="checkbox"] {
|
||||||
|
&:checked + .comment-edit-form {
|
||||||
|
display: block;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.review_meta {
|
.review_meta {
|
||||||
|
@ -4,4 +4,8 @@ class QuizComment < ApplicationRecord
|
|||||||
belongs_to :candidate, foreign_key: :test_hash, primary_key: :test_hash
|
belongs_to :candidate, foreign_key: :test_hash, primary_key: :test_hash
|
||||||
|
|
||||||
validates :message, presence: true
|
validates :message, presence: true
|
||||||
|
|
||||||
|
def edits?
|
||||||
|
updated_at > (created_at + 5.seconds)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
@ -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>
|
<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 %>
|
||||||
|
@ -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 %>
|
<% if comment.id.nil? %>
|
||||||
<%= form_for @comment, url: admin_create_comment_path(test_hash), method: :post do |form| %>
|
|
||||||
<div class="form-group">
|
<%= form_for comment, url: admin_create_comment_path(test_hash: test_hash), method: :post do |form| %>
|
||||||
<%= form.label :message, "Comment" %>
|
<div class="form-group">
|
||||||
<%= form.text_area :message %>
|
<%= form.label :message, "New Comment" %>
|
||||||
</div>
|
<%= 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 %>
|
<% end %>
|
||||||
|
@ -46,6 +46,8 @@
|
|||||||
<div class="review-comments">
|
<div class="review-comments">
|
||||||
<h2 class="prft-heading">Comments</h2>
|
<h2 class="prft-heading">Comments</h2>
|
||||||
<%= render partial: 'comment', collection: @comments, locals: { test_hash: @candidate.test_hash } %>
|
<%= 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>
|
||||||
</div>
|
</div>
|
||||||
|
Loading…
Reference in New Issue
Block a user