Module: Decidim::Challenges::ChallengesHelper
- Included in:
- ChallengeGCell
- Defined in:
- app/helpers/decidim/challenges/challenges_helper.rb
Overview
Custom helpers, scoped to the challenges engine.
Instance Method Summary collapse
- #challenge_associated_solutions(challenge) ⇒ Object
- #filter_sections ⇒ Object
- #truncate_description(description) ⇒ Object
Instance Method Details
#challenge_associated_solutions(challenge) ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 |
# File 'app/helpers/decidim/challenges/challenges_helper.rb', line 21 def challenge_associated_solutions(challenge) solutions_component = Decidim::Component.find_by(participatory_space: challenge.participatory_space, manifest_name: "solutions") return [] unless solutions_component&.published? problems_component = Decidim::Component.find_by(participatory_space: challenge.participatory_space, manifest_name: "problems") if problems_component&.published? challenge.problems.published.map { |problem| problem.solutions.published }.flatten else challenge.solutions.published end end |
#filter_sections ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'app/helpers/decidim/challenges/challenges_helper.rb', line 8 def filter_sections items = [] items.append(method: :with_any_state, collection: filter_custom_state_values, label_scope: "decidim.shared.filters", id: "state") items.append(method: :related_to, collection: linked_classes_filter_values_for(Decidim::Challenges::Challenge), label_scope: "decidim.shared.filters", id: "related_to", type: :radio_buttons) if current_participatory_space.has_subscopes? items.append(method: :with_any_scope, collection: filter_global_scopes_values, label_scope: "decidim.shared.filters", id: "scope") end items.reject { |item| item[:collection].blank? } end |
#truncate_description(description) ⇒ Object
33 34 35 36 |
# File 'app/helpers/decidim/challenges/challenges_helper.rb', line 33 def truncate_description(description) translated_description = raw translated_attribute description decidim_sanitize(html_truncate(translated_description, length: 200)) end |