Module: Decidim::FiltersHelper
- Includes:
- IconHelper
- Included in:
- Assemblies::AssembliesHelper, Meetings::Directory::ApplicationHelper, ParticipatoryProcesses::ParticipatoryProcessHelper, ResourceTypesFilterCell
- Defined in:
- decidim-core/app/helpers/decidim/filters_helper.rb
Overview
Helper that provides a single method to create filter resource forms
Instance Method Summary collapse
- #filter_for_resource(skip_to_id) ⇒ Object
-
#filter_form_for(filter, url = url_for, html_options = {}) ⇒ Object
This method wraps everything in a div with class filters and calls the form_for helper with a custom builder.
- #filter_search_label(label, id) ⇒ Object
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_url, #current_user_unread_data, #external_icon, #favicon, #icon, #legacy_favicon, #role, #root_url
Methods included from TooltipHelper
Methods included from ModalHelper
#decidim_drawer, #decidim_modal
Methods included from OrganizationHelper
#current_organization_name, #organization_colors, #organization_description_label, #organization_name
Methods included from TranslatableAttributes
#attachment?, #default_locale?
Instance Method Details
#filter_for_resource(skip_to_id) ⇒ Object
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'decidim-core/app/helpers/decidim/filters_helper.rb', line 39 def filter_for_resource(skip_to_id) case skip_to_id when "proposals" I18n.t("decidim/proposals/proposal.other", scope: "activerecord.models") when "meetings" I18n.t("decidim/meetings/meeting.other", scope: "activerecord.models") when "debates" I18n.t("decidim/debates/debate.other", scope: "activerecord.models") when "sortitions" I18n.t("decidim/sortitions/sortition.other", scope: "activerecord.models") when "surveys" I18n.t("decidim/surveys/survey.other", scope: "activerecord.models") when "projects" I18n.t("decidim/budgets/project.other", scope: "activerecord.models") when "initiatives" I18n.t("decidim/initiative.other", scope: "activerecord.models") else "" end end |
#filter_form_for(filter, url = url_for, html_options = {}) ⇒ Object
This method wraps everything in a div with class filters and calls the form_for helper with a custom builder
filter - A filter object url - A String with the URL to post the from. Self URL by default. html_options - Extra HTML options to be passed to form_for block - A block to be called with the form builder
Returns the filter resource form wrapped in a div
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'decidim-core/app/helpers/decidim/filters_helper.rb', line 17 def filter_form_for(filter, url = url_for, = {}) form_for( filter, namespace: filter_form_namespace, builder: FilterFormBuilder, url:, as: :filter, method: :get, remote: true, html: { id: nil }.merge() ) do |form| inner = [] inner << hidden_field_tag("per_page", params[:per_page], id: nil) if params[:per_page] inner << capture { yield form } inner.join.html_safe end end |
#filter_search_label(label, id) ⇒ Object
35 36 37 |
# File 'decidim-core/app/helpers/decidim/filters_helper.rb', line 35 def filter_search_label(label, id) I18n.t("decidim.searches.filters.resource", label:, collection: filter_for_resource(id)) end |