diff --git a/app/assets/stylesheets/request-for-comments.css.scss b/app/assets/stylesheets/request-for-comments.css.scss index cbaf9d36..6448e6e7 100644 --- a/app/assets/stylesheets/request-for-comments.css.scss +++ b/app/assets/stylesheets/request-for-comments.css.scss @@ -17,3 +17,50 @@ width: 100%; height: 200px; } + +.ace_tooltip { + display: none !important; +} + +p.comment { + width: 400px; +} + +.popover-header { + width: 100%; + overflow: hidden; + padding-bottom: 10px; + margin: auto; +} + +.popover-username { + font-weight: bold; + width: 60%; + float: left; +} + +.popover-date { + text-align: right; + color: #008cba; + margin-left: 60%; + font-size: x-small; +} + +.popover-updated { + text-align: right; + margin-left: 60%; + font-size: x-small; +} + +.popover-comment { + word-wrap: break-word; + margin-bottom: 10px; +} + +.popover-divider { + width: 100%; + height: 1px; + background-color: #008cba; + overflow: hidden; + margin-bottom: 10px; +} diff --git a/app/controllers/comments_controller.rb b/app/controllers/comments_controller.rb index f6e4f7fb..01dcd9d5 100644 --- a/app/controllers/comments_controller.rb +++ b/app/controllers/comments_controller.rb @@ -19,6 +19,8 @@ class CommentsController < ApplicationController @comments = Comment.where(file_id: params[:file_id]) @comments.map{|comment| comment.username = comment.user.displayname + comment.date = comment.created_at.strftime('%d.%m.%Y %k:%M') + comment.updated = (comment.created_at != comment.updated_at) } else @comments = [] diff --git a/app/models/comment.rb b/app/models/comment.rb index ceeb9c36..a5946ac9 100644 --- a/app/models/comment.rb +++ b/app/models/comment.rb @@ -1,7 +1,7 @@ class Comment < ActiveRecord::Base # inherit the creation module: encapsulates that this is a polymorphic user, offers some aliases and makes sure that all necessary attributes are set. include Creation - attr_accessor :username + attr_accessor :username, :date, :updated belongs_to :file, class_name: 'CodeOcean::File' belongs_to :user, polymorphic: true diff --git a/app/policies/comment_policy.rb b/app/policies/comment_policy.rb index ef7a0922..549c8438 100644 --- a/app/policies/comment_policy.rb +++ b/app/policies/comment_policy.rb @@ -12,7 +12,7 @@ class CommentPolicy < ApplicationPolicy everyone end - [:new?, :destroy?].each do |action| + [:new?, :destroy?, :update?].each do |action| define_method(action) { admin? || author? } end diff --git a/app/views/comments/index.json.jbuilder b/app/views/comments/index.json.jbuilder index 85172014..55dfac49 100644 --- a/app/views/comments/index.json.jbuilder +++ b/app/views/comments/index.json.jbuilder @@ -1,4 +1,4 @@ json.array!(@comments) do |comment| - json.extract! comment, :id, :user_id, :file_id, :row, :column, :text, :username + json.extract! comment, :id, :user_id, :file_id, :row, :column, :text, :username, :date, :updated json.url comment_url(comment, format: :json) end diff --git a/app/views/request_for_comments/show.html.erb b/app/views/request_for_comments/show.html.erb index 6a21ca24..ab60ef91 100644 --- a/app/views/request_for_comments/show.html.erb +++ b/app/views/request_for_comments/show.html.erb @@ -64,6 +64,8 @@