Class: Decidim::BadgeCell
- Inherits:
-
ViewModel
- Object
- ViewModel
- Decidim::BadgeCell
- Defined in:
- app/cells/decidim/badge_cell.rb
Instance Method Summary collapse
- #badge ⇒ Object
- #badge_name ⇒ Object
- #description ⇒ Object
- #level_title ⇒ Object
- #opacity ⇒ Object
- #own_profile? ⇒ Boolean
- #small ⇒ Object
- #tooltip ⇒ Object
Instance Method Details
#badge ⇒ Object
11 12 13 |
# File 'app/cells/decidim/badge_cell.rb', line 11 def badge @options[:badge] end |
#badge_name ⇒ Object
47 48 49 |
# File 'app/cells/decidim/badge_cell.rb', line 47 def badge_name badge.translated_name end |
#description ⇒ Object
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_title ⇒ Object
15 16 17 |
# File 'app/cells/decidim/badge_cell.rb', line 15 def level_title t "decidim.gamification.level", level: status.level end |
#opacity ⇒ Object
51 52 53 |
# File 'app/cells/decidim/badge_cell.rb', line 51 def opacity status.level < 1 ? 0.2 : 1 end |
#own_profile? ⇒ Boolean
19 20 21 |
# File 'app/cells/decidim/badge_cell.rb', line 19 def own_profile? model == current_user end |
#small ⇒ Object
7 8 9 |
# File 'app/cells/decidim/badge_cell.rb', line 7 def small render "small" end |
#tooltip ⇒ Object
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 |