diff options
Diffstat (limited to 'app')
-rw-r--r-- | app/assets/stylesheets/generic/typography.scss | 4 | ||||
-rw-r--r-- | app/models/concerns/issuable.rb | 16 | ||||
-rw-r--r-- | app/models/note.rb | 17 | ||||
-rw-r--r-- | app/views/projects/notes/_note.html.haml | 26 |
4 files changed, 53 insertions, 10 deletions
diff --git a/app/assets/stylesheets/generic/typography.scss b/app/assets/stylesheets/generic/typography.scss index 385a627b4be..58243bc5ba2 100644 --- a/app/assets/stylesheets/generic/typography.scss +++ b/app/assets/stylesheets/generic/typography.scss @@ -128,3 +128,7 @@ a:focus { textarea.js-gfm-input { font-family: $monospace_font; } + +.strikethrough { + text-decoration: line-through; +}
\ No newline at end of file diff --git a/app/models/concerns/issuable.rb b/app/models/concerns/issuable.rb index f49708fd6eb..b8bee0d0ec0 100644 --- a/app/models/concerns/issuable.rb +++ b/app/models/concerns/issuable.rb @@ -88,7 +88,7 @@ module Issuable # Return the number of -1 comments (downvotes) def downvotes - notes.select(&:downvote?).size + filter_superceded_votes(notes.select(&:downvote?), notes).size end def downvotes_in_percent @@ -101,7 +101,7 @@ module Issuable # Return the number of +1 comments (upvotes) def upvotes - notes.select(&:upvote?).size + filter_superceded_votes(notes.select(&:upvote?), notes).size end def upvotes_in_percent @@ -154,4 +154,16 @@ module Issuable self.labels << label end end + + private + + def filter_superceded_votes(votes, notes) + filteredvotes = [] + votes + votes.each do |vote| + if vote.superceded?(notes) + filteredvotes.delete(vote) + end + end + filteredvotes + end end diff --git a/app/models/note.rb b/app/models/note.rb index e99bc2668d6..1b7e412e9c5 100644 --- a/app/models/note.rb +++ b/app/models/note.rb @@ -459,6 +459,23 @@ class Note < ActiveRecord::Base ) end + def superceded?(notes) + return false unless vote? + notes.each do |note| + next if note == self + if note.vote? && + self[:author_id] == note[:author_id] && + self[:created_at] <= note[:created_at] + return true + end + end + false + end + + def vote? + upvote? || downvote? + end + def votable? for_issue? || (for_merge_request? && !for_diff_line?) end diff --git a/app/views/projects/notes/_note.html.haml b/app/views/projects/notes/_note.html.haml index 691c169b620..88c7b7ccf1a 100644 --- a/app/views/projects/notes/_note.html.haml +++ b/app/views/projects/notes/_note.html.haml @@ -28,14 +28,24 @@ %span.note-last-update = note_timestamp(note) - - if note.upvote? - %span.vote.upvote.label.label-success - %i.fa.fa-thumbs-up - \+1 - - if note.downvote? - %span.vote.downvote.label.label-danger - %i.fa.fa-thumbs-down - \-1 + - if note.superceded?(@notes) + - if note.upvote? + %span.vote.upvote.label.label-gray.strikethrough + %i.fa.fa-thumbs-up + \+1 + - if note.downvote? + %span.vote.downvote.label.label-gray.strikethrough + %i.fa.fa-thumbs-down + \-1 + - else + - if note.upvote? + %span.vote.upvote.label.label-success + %i.fa.fa-thumbs-up + \+1 + - if note.downvote? + %span.vote.downvote.label.label-danger + %i.fa.fa-thumbs-down + \-1 .note-body |