Module: Decidim::ParticipatoryProcesses::ParticipatoryProcessHelper

Includes:
AttachmentsHelper, FiltersHelper, IconHelper, ResourceReferenceHelper, SanitizeHelper, WidgetUrlsHelper
Included in:
ContentBlocks::HighlightedProcessesCell
Defined in:
decidim-participatory_processes/app/helpers/decidim/participatory_processes/participatory_process_helper.rb

Overview

Helpers related to the Participatory Process layout.

Instance Method Summary collapse

Methods included from ResourceReferenceHelper

#resource_reference

Methods included from SanitizeHelper

#decidim_html_escape, #decidim_sanitize, #decidim_sanitize_newsletter, #decidim_url_escape, included

Methods included from WidgetUrlsHelper

#embed_modal_for

Methods included from IconHelper

#component_icon, #manifest_icon, #resource_icon

Methods included from LayoutHelper

#_icon_classes, #extended_navigation_bar, #external_icon, #favicon, #icon, #organization_colors, #role

Methods included from AttachmentsHelper

#attachment_title, #attachments_for

Methods included from FiltersHelper

#filter_form_for

Instance Method Details

#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.button_url.blank?

  OpenStruct.new(
    text: translated_attribute(cta_settings.button_text),
    path: cta_settings.button_url,
    image_url: block.images_container.background_image.big.url
  )
end

#render_highlighted_partial_for(promoted_item) ⇒ Object

Public: Invokes the appropriate partial for a promoted participatory process or group based on the type name

promoted_item - Can be a Decidim::ParticipatoryProcess or

Decidim::ParticipatoryProcessGroup

65
66
67
68
69
# File 'decidim-participatory_processes/app/helpers/decidim/participatory_processes/participatory_process_helper.rb', line 65

def render_highlighted_partial_for(promoted_item)
  name = promoted_item.class.name.demodulize.underscore.gsub("participatory_", "promoted_")

  render partial: name, locals: { name => promoted_item }.symbolize_keys
end

#step_dates(participatory_process_step) ⇒ Object

Public: Returns the dates for a step in a readable format like “2016-01-01 - 2016-02-05”.

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 ? localize(date.to_date, format: :default) : "?" }.join(" - ")
end