Class: Decidim::BadgeCell

Inherits:
ViewModel
  • Object
show all
Defined in:
app/cells/decidim/badge_cell.rb

Instance Method Summary collapse

Instance Method Details

#badgeObject



11
12
13
# File 'app/cells/decidim/badge_cell.rb', line 11

def badge
  @options[:badge]
end

#badge_nameObject



47
48
49
# File 'app/cells/decidim/badge_cell.rb', line 47

def badge_name
  badge.translated_name
end

#descriptionObject



23
24
25
26
27
28
29
30
31
32
33
# File 'app/cells/decidim/badge_cell.rb', line 23

def description
  if own_profile? && status.level.zero?
    score_descriptions[:unearned_own]
  elsif own_profile? && status.level.positive?
    score_descriptions[:description_own]
  elsif !own_profile? && status.level.zero?
    score_descriptions[:unearned_another]
  elsif !own_profile? && status.level.positive?
    score_descriptions[:description_another]
  end
end

#level_titleObject



15
16
17
# File 'app/cells/decidim/badge_cell.rb', line 15

def level_title
  t "decidim.gamification.level", level: status.level
end

#opacityObject



51
52
53
# File 'app/cells/decidim/badge_cell.rb', line 51

def opacity
  status.level < 1 ? 0.2 : 1
end

#own_profile?Boolean

Returns:

  • (Boolean)


19
20
21
# File 'app/cells/decidim/badge_cell.rb', line 19

def own_profile?
  model == current_user
end

#smallObject



7
8
9
# File 'app/cells/decidim/badge_cell.rb', line 7

def small
  render "small"
end

#tooltipObject



35
36
37
38
39
40
41
42
43
44
45
# File 'app/cells/decidim/badge_cell.rb', line 35

def tooltip
  if own_profile?
    if status.next_level_in
      t "decidim.gamification.badges.#{badge.name}.next_level_in", score: status.next_level_in
    else
      t "decidim.gamification.reached_top"
    end
  else
    badge.description(controller.current_organization.name)
  end
end