summaryrefslogtreecommitdiffstats
path: root/app/helpers/reactions_helper.rb
diff options
context:
space:
mode:
Diffstat (limited to 'app/helpers/reactions_helper.rb')
-rw-r--r--app/helpers/reactions_helper.rb16
1 files changed, 8 insertions, 8 deletions
diff --git a/app/helpers/reactions_helper.rb b/app/helpers/reactions_helper.rb
index 911da7127..e02e1c9f9 100644
--- a/app/helpers/reactions_helper.rb
+++ b/app/helpers/reactions_helper.rb
@@ -26,15 +26,15 @@ module ReactionsHelper
detail = object.reaction_detail
- reaction = detail.user_reaction
+ 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.writable?(object, User.current)
- if reaction&.persisted?
- reaction_button_reacted(object, reaction, count, tooltip)
+ 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
@@ -52,7 +52,7 @@ module ReactionsHelper
def reaction_button_reacted(object, reaction, count, tooltip)
reaction_button_wrapper object do
link_to(
- sprite_icon('thumb-up-filled', count),
+ sprite_icon('thumb-up-filled', count.nonzero?, style: :filled),
reaction_path(reaction, object_type: object.class.name, object_id: object),
remote: true, method: :delete,
class: ['icon', 'reaction-button', 'reacted'],
@@ -64,7 +64,7 @@ module ReactionsHelper
def reaction_button_not_reacted(object, count, tooltip)
reaction_button_wrapper object do
link_to(
- sprite_icon('thumb-up', count),
+ sprite_icon('thumb-up', count.nonzero?),
reactions_path(object_type: object.class.name, object_id: object),
remote: true, method: :post,
class: 'icon reaction-button',
@@ -76,13 +76,13 @@ module ReactionsHelper
def reaction_button_readonly(object, count, tooltip)
reaction_button_wrapper object do
tag.span(class: 'icon reaction-button readonly', title: tooltip) do
- sprite_icon('thumb-up', count)
+ sprite_icon('thumb-up', count.nonzero?)
end
end
end
def reaction_button_wrapper(object, &)
- tag.span(data: { 'reaction-button-id': reaction_id_for(object) }, &)
+ tag.span(class: 'reaction-button-wrapper', data: { 'reaction-button-id': reaction_id_for(object) }, &)
end
def build_reaction_tooltip(visible_user_names, count)