Module: Decidim::ParticipatoryProcesses::ParticipatoryProcessHelper
- Includes:
- AttachmentsHelper, CheckBoxesTreeHelper, FiltersHelper, IconHelper, ResourceReferenceHelper, SanitizeHelper
- Defined in:
- decidim-participatory_processes/app/helpers/decidim/participatory_processes/participatory_process_helper.rb
Overview
Helpers related to the Participatory Process layout.
Constant Summary
Constants included from IconHelper
IconHelper::DEFAULT_RESOURCE_TYPE_ICONS
Instance Method Summary collapse
- #filter_dates_values ⇒ Object
- #filter_sections ⇒ Object
- #filter_types_values ⇒ Object
-
#participatory_process_cta_path(process) ⇒ Object
Public: Returns the path for the participatory process cta button.
-
#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.
- #process_types ⇒ Object
-
#step_dates(participatory_process_step) ⇒ Object
Public: Returns the dates for a step in a readable format like “01/01/2016 - 05/02/2016”.
Methods included from CheckBoxesTreeHelper
#check_boxes_tree_options, #filter_areas_values, #filter_categories_values, #filter_global_scopes_values, #filter_origin_values, #filter_scopes_values, #filter_text_for, #filter_tree_from_array, #flat_filter_values, #resource_filter_scope_values
Methods included from ResourceReferenceHelper
Methods included from SanitizeHelper
#decidim_html_escape, #decidim_sanitize, #decidim_sanitize_admin, #decidim_sanitize_editor, #decidim_sanitize_editor_admin, #decidim_sanitize_newsletter, #decidim_url_escape, included
Methods included from IconHelper
#component_icon, #manifest_icon, #resource_icon, #resource_type_icon, #resource_type_icon_key, #text_with_resource_icon
Methods included from LayoutHelper
#_icon_classes, #apple_favicon, #application_path, #current_user_unread_data, #extended_navigation_bar, #external_icon, #favicon, #icon, #legacy_favicon, #organization_colors, #role
Methods included from TooltipHelper
Methods included from ModalHelper
Methods included from AttachmentsHelper
#attachment_title, #attachments_for, #attachments_tab_panel_items
Methods included from FiltersHelper
Instance Method Details
#filter_dates_values ⇒ Object
95 96 97 |
# File 'decidim-participatory_processes/app/helpers/decidim/participatory_processes/participatory_process_helper.rb', line 95 def filter_dates_values flat_filter_values(:all, :upcoming, :past, :active, scope: "decidim.participatory_processes.participatory_processes.filters.names") end |
#filter_sections ⇒ Object
73 74 75 76 77 78 79 80 |
# File 'decidim-participatory_processes/app/helpers/decidim/participatory_processes/participatory_process_helper.rb', line 73 def filter_sections [ { method: :with_date, collection: filter_dates_values, label_scope: "decidim.participatory_processes.participatory_processes.filters", id: "date" }, { method: :with_any_scope, collection: filter_global_scopes_values, label_scope: "decidim.shared.participatory_space_filters.filters", id: "scope" }, { method: :with_any_area, collection: filter_areas_values, label_scope: "decidim.shared.participatory_space_filters.filters", id: "area" }, { method: :with_any_type, collection: filter_types_values, label_scope: "decidim.participatory_processes.participatory_processes.filters", id: "type" } ].reject { |item| item[:collection].blank? } end |
#filter_types_values ⇒ Object
86 87 88 89 90 91 92 93 |
# File 'decidim-participatory_processes/app/helpers/decidim/participatory_processes/participatory_process_helper.rb', line 86 def filter_types_values return if process_types.blank? type_values = process_types.map { |type| [type.id.to_s, translated_attribute(type.title)] } type_values.prepend(["", t("decidim.participatory_processes.participatory_processes.filters.names.all")]) filter_tree_from_array(type_values) end |
#participatory_process_cta_path(process) ⇒ Object
Public: Returns the path for the participatory process cta button
Returns a String with path.
28 29 30 31 32 33 34 |
# File 'decidim-participatory_processes/app/helpers/decidim/participatory_processes/participatory_process_helper.rb', line 28 def participatory_process_cta_path(process) return participatory_process_path(process) if process.active_step&.cta_path.blank? path, params = participatory_process_path(process).split("?") "#{path}/#{process.active_step.cta_path}" + (params.present? ? "?#{params}" : "") 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
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'decidim-participatory_processes/app/helpers/decidim/participatory_processes/participatory_process_helper.rb', line 40 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).path(variant: :big) ) end |
#process_nav_items(participatory_space) ⇒ Object
Items to display in the navigation of a process
61 62 63 64 65 66 67 68 69 70 71 |
# File 'decidim-participatory_processes/app/helpers/decidim/participatory_processes/participatory_process_helper.rb', line 61 def process_nav_items(participatory_space) components = participatory_space.components.published.or(Decidim::Component.where(id: try(:current_component))) components.map do |component| { name: translated_attribute(component.name), url: main_component_path(component), active: is_active_link?(main_component_path(component), :inclusive) } end end |
#process_types ⇒ Object
82 83 84 |
# File 'decidim-participatory_processes/app/helpers/decidim/participatory_processes/participatory_process_helper.rb', line 82 def process_types @process_types ||= Decidim::ParticipatoryProcessType.joins(:processes).distinct 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 'decidim-participatory_processes/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 |