Module: Decidim::Admin::ExportsHelper

Defined in:
app/helpers/decidim/admin/exports_helper.rb

Instance Method Summary collapse

Instance Method Details



39
40
41
42
43
# File 'app/helpers/decidim/admin/exports_helper.rb', line 39

def dropdown_id(filters)
  return "export-dropdown" if filters.empty?

  "export-selection-dropdown"
end

#export_dropdown(component = current_component, resource_id = nil, apply_search: false) ⇒ Object

Renders an export dropdown for the provided component, including an item for each exportable artifact and format.

component - The component to render the export dropdown for. Defaults to the

current component.

Returns a rendered dropdown.



13
14
15
16
17
18
19
20
21
# File 'app/helpers/decidim/admin/exports_helper.rb', line 13

def export_dropdown(component = current_component, resource_id = nil, apply_search: false)
  filters =
    if apply_search && respond_to?(:query)
      { id_in: query.result.map(&:id) }
    else
      {}
    end
  render_dropdown(component:, resource_id:, filters:)
end

#export_dropdowns(query, component = current_component, resource_id = nil) ⇒ Object



23
24
25
26
27
# File 'app/helpers/decidim/admin/exports_helper.rb', line 23

def export_dropdowns(query, component = current_component, resource_id = nil)
  return export_dropdown(component, resource_id, apply_search: false) if query.conditions.empty?

  export_dropdown(component, resource_id, apply_search: false).concat(export_dropdown(component, resource_id, apply_search: true))
end

#exports_path(component, options) ⇒ Object

Routes to the correct exporter for a component.

component - The component to be routed. options - Extra options that need to be passed to the route.

Returns the path to the component exporter.



35
36
37
# File 'app/helpers/decidim/admin/exports_helper.rb', line 35

def exports_path(component, options)
  EngineRouter.admin_proxy(component.participatory_space).component_exports_path(options.merge(component_id: component))
end