Sha256: c7e55e5b9005a9b13fb2bee47e2e0852ac0e512d18b2bd6792744ec8455bc4f9

Contents?: true

Size: 1.3 KB

Versions: 60

Compression:

Stored size: 1.3 KB

Contents

# frozen_string_literal: true

module Decidim
  module Admin
    # This module includes helpers to show scopes in admin
    module ScopesHelper
      Option = Struct.new(:id, :name)

      # Public: This helper shows the path to the given scope, linking each ancestor.
      #
      # current_scope - Scope object to show
      #
      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

      # Public: A formatted collection of scopes for a given organization to be used
      # in forms.
      #
      # organization - Organization object
      #
      # Returns an Array.
      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

      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
    end
  end
end

Version data entries

60 entries across 60 versions & 1 rubygems

Version Path
decidim-admin-0.25.0.rc4 app/helpers/decidim/admin/scopes_helper.rb
decidim-admin-0.25.0.rc3 app/helpers/decidim/admin/scopes_helper.rb
decidim-admin-0.25.0.rc2 app/helpers/decidim/admin/scopes_helper.rb
decidim-admin-0.25.0.rc1 app/helpers/decidim/admin/scopes_helper.rb
decidim-admin-0.24.3 app/helpers/decidim/admin/scopes_helper.rb
decidim-admin-0.23.6 app/helpers/decidim/admin/scopes_helper.rb
decidim-admin-0.24.2 app/helpers/decidim/admin/scopes_helper.rb
decidim-admin-0.23.5 app/helpers/decidim/admin/scopes_helper.rb
decidim-admin-0.24.1 app/helpers/decidim/admin/scopes_helper.rb
decidim-admin-0.24.0 app/helpers/decidim/admin/scopes_helper.rb
decidim-admin-0.24.0.rc2 app/helpers/decidim/admin/scopes_helper.rb
decidim-admin-0.23.4 app/helpers/decidim/admin/scopes_helper.rb
decidim-admin-0.24.0.rc1 app/helpers/decidim/admin/scopes_helper.rb
decidim-admin-0.23.3 app/helpers/decidim/admin/scopes_helper.rb
decidim-admin-0.23.2 app/helpers/decidim/admin/scopes_helper.rb
decidim-admin-0.23.1 app/helpers/decidim/admin/scopes_helper.rb
decidim-admin-0.23.1.rc1 app/helpers/decidim/admin/scopes_helper.rb
decidim-admin-0.23.0 app/helpers/decidim/admin/scopes_helper.rb
decidim-admin-0.22.0 app/helpers/decidim/admin/scopes_helper.rb
decidim-admin-0.21.0 app/helpers/decidim/admin/scopes_helper.rb