Module: Decidim::Accountability::ApplicationHelper

Includes:
Comments::CommentsHelper, PaginateHelper
Included in:
ContentBlocks::HighlightedResultsCell, HighlightedResultsForComponentCell
Defined in:
decidim-accountability/app/helpers/decidim/accountability/application_helper.rb

Overview

Custom helpers, scoped to the accountability engine.

Instance Method Summary collapse

Methods included from Comments::CommentsHelper

#comments_for, #inline_comments_for

Methods included from PaginateHelper

#decidim_paginate

Instance Method Details

#active_class_if_current(scope) ⇒ Object


21
22
23
# File 'decidim-accountability/app/helpers/decidim/accountability/application_helper.rb', line 21

def active_class_if_current(scope)
  "class=active" if scope.to_s == current_scope.to_s
end

#categories_labelObject


25
26
27
# File 'decidim-accountability/app/helpers/decidim/accountability/application_helper.rb', line 25

def categories_label
  translated_attribute(component_settings.categories_label).presence || t("results.home.categories_label", scope: "decidim.accountability")
end

#display_count(count) ⇒ Object


17
18
19
# File 'decidim-accountability/app/helpers/decidim/accountability/application_helper.rb', line 17

def display_count(count)
  heading_parent_level_results(count)
end

#display_percentage(number) ⇒ Object


11
12
13
14
15
# File 'decidim-accountability/app/helpers/decidim/accountability/application_helper.rb', line 11

def display_percentage(number)
  return if number.blank?

  number_to_percentage(number, precision: 1, strip_insignificant_zeros: true, locale: I18n.locale)
end

#heading_leaf_level_results(count) ⇒ Object


42
43
44
45
46
47
48
49
# File 'decidim-accountability/app/helpers/decidim/accountability/application_helper.rb', line 42

def heading_leaf_level_results(count)
  text = translated_attribute(component_settings.heading_leaf_level_results).presence
  if text
    pluralize(count, text)
  else
    t("results.count.results_count", scope: "decidim.accountability", count: count)
  end
end

#heading_parent_level_results(count) ⇒ Object


33
34
35
36
37
38
39
40
# File 'decidim-accountability/app/helpers/decidim/accountability/application_helper.rb', line 33

def heading_parent_level_results(count)
  text = translated_attribute(component_settings.heading_parent_level_results).presence
  if text
    pluralize(count, text)
  else
    t("results.count.results_count", scope: "decidim.accountability", count: count)
  end
end

#subcategories_labelObject


29
30
31
# File 'decidim-accountability/app/helpers/decidim/accountability/application_helper.rb', line 29

def subcategories_label
  translated_attribute(component_settings.subcategories_label).presence || t("results.home.subcategories_label", scope: "decidim.accountability")
end