Module: Decidim::ParticipatoryProcesses::ParticipatoryProcessHelper
- Includes:
- AttachmentsHelper, CheckBoxesTreeHelper, FiltersHelper, IconHelper, ResourceReferenceHelper, SanitizeHelper
- Included in:
- ContentBlocks::MainDataCell, ProcessStepCell
- Defined in:
- app/helpers/decidim/participatory_processes/participatory_process_helper.rb
Overview
Helpers related to the Participatory Process layout.
Instance Method Summary collapse
- #available_taxonomy_filters ⇒ Object
- #filter_dates_values ⇒ Object
- #filter_sections ⇒ Object
-
#participatory_process_group_cta_settings(process_group) ⇒ Object
Public: Returns the settings of a cta content block associated if exists.
-
#process_nav_items(participatory_space) ⇒ Object
Items to display in the navigation of a process.
-
#step_dates(participatory_process_step) ⇒ Object
Public: Returns the dates for a step in a readable format like “01/01/2016 - 05/02/2016”.
Instance Method Details
#available_taxonomy_filters ⇒ Object
89 90 91 |
# File 'app/helpers/decidim/participatory_processes/participatory_process_helper.rb', line 89 def available_taxonomy_filters Decidim::TaxonomyFilter.for(current_organization).for_manifest(:participatory_processes) end |
#filter_dates_values ⇒ Object
93 94 95 |
# File 'app/helpers/decidim/participatory_processes/participatory_process_helper.rb', line 93 def filter_dates_values flat_filter_values(:all, :upcoming, :past, :active, scope: "decidim.participatory_processes.participatory_processes.filters.names") end |
#filter_sections ⇒ Object
75 76 77 78 79 80 81 82 83 84 85 86 87 |
# File 'app/helpers/decidim/participatory_processes/participatory_process_helper.rb', line 75 def filter_sections items = [ { method: :with_date, name: "[with_date]", collection: filter_dates_values, label: t("decidim.participatory_processes.participatory_processes.filters.date"), id: "date" } ] available_taxonomy_filters.find_each do |taxonomy_filter| items.append(method: :with_any_taxonomies, name: "[with_any_taxonomies][#{taxonomy_filter.root_taxonomy_id}]", collection: filter_taxonomy_values_for(taxonomy_filter), label: decidim_sanitize_translated(taxonomy_filter.name), id: "taxonomy-#{taxonomy_filter.root_taxonomy_id}") end items.reject { |item| item[:collection].blank? } end |
#participatory_process_group_cta_settings(process_group) ⇒ Object
Public: Returns the settings of a cta content block associated if exists
Returns a Hash with content block settings or nil
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'app/helpers/decidim/participatory_processes/participatory_process_helper.rb', line 29 def participatory_process_group_cta_settings(process_group) block = Decidim::ContentBlock.for_scope( :participatory_process_group_homepage, organization: current_organization ).find_by( manifest_name: "cta", scoped_resource_id: process_group.id ) cta_settings = block&.settings return if cta_settings.blank? || cta_settings..blank? OpenStruct.new( text: translated_attribute(cta_settings.), path: cta_settings., image_url: block.images_container.attached_uploader(:background_image).variant_url(:big) ) end |
#process_nav_items(participatory_space) ⇒ Object
Items to display in the navigation of a process
50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 |
# File 'app/helpers/decidim/participatory_processes/participatory_process_helper.rb', line 50 def process_nav_items(participatory_space) components = participatory_space .components .published.or(Decidim::Component.where(id: try(:current_component))) .where(visible: true) [ *(if participatory_space.members_public_page? [{ name: t("member_menu_item", scope: "layouts.decidim.participatory_process_navigation"), url: decidim_participatory_processes.participatory_process_members_path(participatory_space), active: is_active_link?(decidim_participatory_processes.participatory_process_members_path(participatory_space), :inclusive) }] end ) ] + components.map do |component| { id: component.id, name: decidim_escape_translated(component.name), url: main_component_path(component), active: is_active_link?(main_component_path(component), :inclusive) } end.compact end |
#step_dates(participatory_process_step) ⇒ Object
Public: Returns the dates for a step in a readable format like “01/01/2016 - 05/02/2016”.
participatory_process_step - The step to format to
Returns a String with the formatted dates.
20 21 22 23 |
# File 'app/helpers/decidim/participatory_processes/participatory_process_helper.rb', line 20 def step_dates(participatory_process_step) dates = [participatory_process_step.start_date, participatory_process_step.end_date] dates.map { |date| date ? l(date.to_date, format: :decidim_short) : "?" }.join(" - ") end |