Module: Decidim::Admin::ImportsHelper

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

Instance Method Summary collapse

Instance Method Details

#admin_imports_example_path(component, options) ⇒ Object

Route to the correct importer example 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 importer example.



37
38
39
# File 'app/helpers/decidim/admin/imports_helper.rb', line 37

def admin_imports_example_path(component, options)
  EngineRouter.admin_proxy(component.participatory_space).example_component_imports_path(options.merge(component_id: component))
end

#admin_imports_path(component, options) ⇒ Object

Route to the correct importer 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 importer.



27
28
29
# File 'app/helpers/decidim/admin/imports_helper.rb', line 27

def admin_imports_path(component, options)
  EngineRouter.admin_proxy(component.participatory_space).new_component_import_path(options.merge(component_id: component))
end

#import_dropdown(component = current_component, resource_id: nil) ⇒ Object

Renders an import dropdown for the provided component. Additional dropdown items can be given as block.

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

current component.

resource_id - The resource id that is passed to route.

Returns a rendered dropdown.



15
16
17
18
19
# File 'app/helpers/decidim/admin/imports_helper.rb', line 15

def import_dropdown(component = current_component, resource_id: nil)
  render "decidim/admin/imports/dropdown", component:, resource_id:, custom: block_given? do
    yield if block_given?
  end
end

#mime_typesObject

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



42
43
44
45
# File 'app/helpers/decidim/admin/imports_helper.rb', line 42

def mime_types
  accepted_mime_types = Decidim::Admin::Import::Readers::ACCEPTED_MIME_TYPES.keys
  accepted_mime_types.index_with { |mime_type| I18n.t("decidim.admin.imports.new.accepted_mime_types.#{mime_type}") }
end

#user_groupsObject

Returns verified user groups of current user



48
49
50
# File 'app/helpers/decidim/admin/imports_helper.rb', line 48

def user_groups
  Decidim::UserGroups::ManageableUserGroups.for(current_user).verified
end