Module: ReactionsHelper

Included in:
IssuesHelper, JournalsHelper, MessagesHelper, NewsHelper
Defined in:
app/helpers/reactions_helper.rb

Overview

Redmine - project management software Copyright © 2006- Jean-Philippe Lang

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.

Constant Summary collapse

DISPLAY_REACTION_USERS_LIMIT =

Maximum number of users to display in the reaction button tooltip

10

Instance Method Summary collapse

Instance Method Details

#reaction_button(object) ⇒ Object



24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'app/helpers/reactions_helper.rb', line 24

def reaction_button(object)
  return unless Redmine::Reaction.visible?(object, User.current)

  detail = object.reaction_detail

  user_reaction = detail.user_reaction
  count = detail.reaction_count
  visible_user_names = detail.visible_users.take(DISPLAY_REACTION_USERS_LIMIT).map(&:name)

  tooltip = build_reaction_tooltip(visible_user_names, count)

  if Redmine::Reaction.editable?(object, User.current)
    if user_reaction.present?
      reaction_button_reacted(object, user_reaction, count, tooltip)
    else
      reaction_button_not_reacted(object, count, tooltip)
    end
  else
    reaction_button_readonly(object, count, tooltip)
  end
end

#reaction_id_for(object) ⇒ Object



46
47
48
# File 'app/helpers/reactions_helper.rb', line 46

def reaction_id_for(object)
  dom_id(object, :reaction)
end