Module: Decidim::Proposals::ParticipatoryTextsHelper

Defined in:
app/helpers/decidim/proposals/participatory_texts_helper.rb

Overview

Simple helper to handle markup variations for participatory texts related partials

Instance Method Summary collapse

Instance Method Details

#mime_types_with_document_examplesObject

Public: A formatted collection of mime_type to be used in forms.



20
21
22
23
24
25
26
27
28
29
30
# File 'app/helpers/decidim/proposals/participatory_texts_helper.rb', line 20

def mime_types_with_document_examples
  links = ""
  accepted_mime_types = Decidim::Proposals::DocToMarkdown::ACCEPTED_MIME_TYPES.keys
  accepted_mime_types.each_with_index do |mime_type, index|
    links += link_to t(".accepted_mime_types.#{mime_type}"),
                     asset_pack_path("media/documents/participatory_text.#{mime_type}"),
                     download: "participatory_text.#{mime_type}"
    links += ", " unless accepted_mime_types.length == index + 1
  end
  links
end

#preview_participatory_text_section_title(proposal) ⇒ Object

Returns the title for a given participatory text section.

proposal - The current proposal item.

Returns a string with the title of the section, subsection or article.



12
13
14
15
16
# File 'app/helpers/decidim/proposals/participatory_texts_helper.rb', line 12

def preview_participatory_text_section_title(proposal)
  title = decidim_html_escape(present(proposal).title)
  translated = t(proposal.participatory_text_level, scope: "decidim.proposals.admin.participatory_texts.sections", title:)
  translated.html_safe
end