Module: Decidim::Admin::ScopesHelper

Defined in:
decidim-admin/app/helpers/decidim/admin/scopes_helper.rb

Overview

This module includes helpers to show scopes in admin

Defined Under Namespace

Classes: Option

Instance Method Summary collapse

Instance Method Details

#organization_scope_depths(organization = current_organization) ⇒ Object


36
37
38
39
40
# File 'decidim-admin/app/helpers/decidim/admin/scopes_helper.rb', line 36

def organization_scope_depths(organization = current_organization)
  organization.scope_types.map do |scope_type|
    Option.new(scope_type.id, translated_attribute(scope_type.name))
  end.reverse
end

#organization_scope_types(organization = current_organization) ⇒ Object

Public: A formatted collection of scopes for a given organization to be used in forms.

organization - Organization object

Returns an Array.


29
30
31
32
33
34
# File 'decidim-admin/app/helpers/decidim/admin/scopes_helper.rb', line 29

def organization_scope_types(organization = current_organization)
  [Option.new("", "-")] +
    organization.scope_types.map do |scope_type|
      Option.new(scope_type.id, translated_attribute(scope_type.name))
    end
end

#scope_breadcrumbs(current_scope) ⇒ Object

Public: This helper shows the path to the given scope, linking each ancestor.

current_scope - Scope object to show


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

def scope_breadcrumbs(current_scope)
  current_scope.part_of_scopes.map do |scope|
    if scope == current_scope
      translated_attribute(scope.name)
    else
      link_to translated_attribute(scope.name), scope_scopes_path(scope)
    end
  end
end