addressing comments

This commit is contained in:
Valery Sizov 2015-11-19 00:59:07 +02:00
parent 92943580cb
commit fdd5a8f2e1
5 changed files with 15 additions and 9 deletions

View file

@ -104,6 +104,10 @@ module IssuesHelper
::AwardEmoji::EMOJI_LIST
end
def note_active_class(notes, current_user)
notes.pluck(:author_id).include?(current_user.id) ? "active" : ""
end
# Required for Gitlab::Markdown::IssueReferenceFilter
module_function :url_for_issue
end

View file

@ -50,8 +50,8 @@ class Note < ActiveRecord::Base
mount_uploader :attachment, AttachmentUploader
# Scopes
scope :awards, ->{ where("is_award IS TRUE") }
scope :nonawards, ->{ where("is_award IS FALSE") }
scope :awards, ->{ where(is_award: true) }
scope :nonawards, ->{ where(is_award: false) }
scope :for_commit_id, ->(commit_id) { where(noteable_type: "Commit", commit_id: commit_id) }
scope :inline, ->{ where("line_code IS NOT NULL") }
scope :not_inline, ->{ where(line_code: [nil, '']) }

View file

@ -1,10 +1,10 @@
.awards.votes-block
- votable.notes.awards.grouped_awards.each do | vote |
.award{class: ("active" if vote.last.pluck(:author_id).include?(current_user.id)), title: emoji_author_list(vote.last, current_user)}
.icon{"data-emoji" => "#{vote.first}"}
= image_tag url_to_emoji(vote.first), height: "20px", width: "20px"
- votable.notes.awards.grouped_awards.each do | note |
.award{class: (note_active_class(note.last, current_user)), title: emoji_author_list(note.last, current_user)}
.icon{"data-emoji" => "#{note.first}"}
= image_tag url_to_emoji(note.first), height: "20px", width: "20px"
.counter
= vote.last.count
= note.last.count
.dropdown.awards-controls
%a.add-award{"data-toggle" => "dropdown", "data-target" => "#", "href" => "#"}

View file

@ -1,5 +1,6 @@
class AddIsAwardToNotes < ActiveRecord::Migration
def change
add_column :notes, :is_award, :boolean, default: false
add_column :notes, :is_award, :boolean, default: false, null: false
add_index :notes, :is_award
end
end

View file

@ -554,13 +554,14 @@ ActiveRecord::Schema.define(version: 20151116144118) do
t.boolean "system", default: false, null: false
t.text "st_diff"
t.integer "updated_by_id"
t.boolean "is_award", default: false
t.boolean "is_award", default: false, null: false
end
add_index "notes", ["author_id"], name: "index_notes_on_author_id", using: :btree
add_index "notes", ["commit_id"], name: "index_notes_on_commit_id", using: :btree
add_index "notes", ["created_at", "id"], name: "index_notes_on_created_at_and_id", using: :btree
add_index "notes", ["created_at"], name: "index_notes_on_created_at", using: :btree
add_index "notes", ["is_award"], name: "index_notes_on_is_award", using: :btree
add_index "notes", ["line_code"], name: "index_notes_on_line_code", using: :btree
add_index "notes", ["noteable_id", "noteable_type"], name: "index_notes_on_noteable_id_and_noteable_type", using: :btree
add_index "notes", ["noteable_type"], name: "index_notes_on_noteable_type", using: :btree