Commit fb0279f3113f58b1cbdbe04acabe874ac4d231f9

Authored by Riyad Preukschas
1 parent 3f72af99

Fix vote counting to only count main target notes (not mixed in ones)

app/assets/javascripts/notes.js
@@ -230,7 +230,7 @@ var NoteList = { @@ -230,7 +230,7 @@ var NoteList = {
230 updateVotes: 230 updateVotes:
231 function() { 231 function() {
232 var votes = $("#votes .votes"); 232 var votes = $("#votes .votes");
233 - var notes = $("#notes-list, #new-notes-list").find(".note.vote"); 233 + var notes = $("#notes-list, #new-notes-list").find(".note .vote");
234 234
235 // only update if there is a vote display 235 // only update if there is a vote display
236 if (votes.size()) { 236 if (votes.size()) {
app/helpers/notes_helper.rb
@@ -12,11 +12,5 @@ module NotesHelper @@ -12,11 +12,5 @@ module NotesHelper
12 !@mixed_targets || @main_target_type == note.noteable_type 12 !@mixed_targets || @main_target_type == note.noteable_type
13 end 13 end
14 14
15 - def note_vote_class(note)  
16 - if note.upvote?  
17 - "vote upvote"  
18 - elsif note.downvote?  
19 - "vote downvote"  
20 - end  
21 end 15 end
22 end 16 end
app/views/notes/_note.html.haml
1 -%li{id: dom_id(note), class: "note #{note_vote_class(note)}"} 1 +%li{id: dom_id(note), class: "note"}
2 = image_tag gravatar_icon(note.author.email), class: "avatar s32" 2 = image_tag gravatar_icon(note.author.email), class: "avatar s32"
3 %div.note-author 3 %div.note-author
4 %strong= note.author_name 4 %strong= note.author_name
@@ -6,14 +6,19 @@ @@ -6,14 +6,19 @@
6 %cite.cgray 6 %cite.cgray
7 = time_ago_in_words(note.updated_at) 7 = time_ago_in_words(note.updated_at)
8 ago 8 ago
9 - - if note.upvote?  
10 - %span.label.label-success  
11 - %i.icon-thumbs-up  
12 - \+1  
13 - - if note.downvote?  
14 - %span.label.label-error  
15 - %i.icon-thumbs-down  
16 - \-1 9 +
  10 + -# only show vote if it's a note for the main target
  11 + - if note_for_main_target?(note)
  12 + - if note.upvote?
  13 + %span.vote.upvote.label.label-success
  14 + %i.icon-thumbs-up
  15 + \+1
  16 + - if note.downvote?
  17 + %span.vote.downvote.label.label-error
  18 + %i.icon-thumbs-down
  19 + \-1
  20 +
  21 + -# remove button
17 - if(note.author_id == current_user.id) || can?(current_user, :admin_note, @project) 22 - if(note.author_id == current_user.id) || can?(current_user, :admin_note, @project)
18 = link_to [@project, note], confirm: 'Are you sure?', method: :delete, remote: true, class: "cred delete-note btn very_small" do 23 = link_to [@project, note], confirm: 'Are you sure?', method: :delete, remote: true, class: "cred delete-note btn very_small" do
19 %i.icon-trash 24 %i.icon-trash