Sha256: 54571131b1b1c1e1acfcb69677c09629e59c2218cd14c2349434a11cfe31a05f

Contents?: true

Size: 1.31 KB

Versions: 36

Compression:

Stored size: 1.31 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

      # Public: Check if the given scopable object has the scope enabled or not.
      #
      # scopable - A scopable object.
      #
      # Returns a Boolean.
      def scopes_enabled?(scopable)
        scopable.scopes_enabled?
      end
    end
  end
end

Version data entries

36 entries across 36 versions & 2 rubygems

Version Path
decidim-admin-0.9.3 app/helpers/decidim/admin/scopes_helper.rb
decidim-admin-0.9.2 app/helpers/decidim/admin/scopes_helper.rb
decidim-admin-0.9.1 app/helpers/decidim/admin/scopes_helper.rb
decidim-admin-0.9.0 app/helpers/decidim/admin/scopes_helper.rb
decidim-admin-0.8.4 app/helpers/decidim/admin/scopes_helper.rb
decidim-admin-0.8.3 app/helpers/decidim/admin/scopes_helper.rb
decidim-admin-0.8.2 app/helpers/decidim/admin/scopes_helper.rb
decidim-admin-0.8.1 app/helpers/decidim/admin/scopes_helper.rb
decidim-admin-0.8.0 app/helpers/decidim/admin/scopes_helper.rb
decidim-admin-0.7.4 app/helpers/decidim/admin/scopes_helper.rb
decidim-admin-0.7.3 app/helpers/decidim/admin/scopes_helper.rb
decidim-admin-0.7.2 app/helpers/decidim/admin/scopes_helper.rb
decidim-admin-0.7.1 app/helpers/decidim/admin/scopes_helper.rb
decidim-admin-0.7.0 app/helpers/decidim/admin/scopes_helper.rb
decidim-admin-0.6.8 app/helpers/decidim/admin/scopes_helper.rb
decidim-0.6.8 decidim-admin/app/helpers/decidim/admin/scopes_helper.rb
decidim-admin-0.6.7 app/helpers/decidim/admin/scopes_helper.rb
decidim-0.6.7 decidim-admin/app/helpers/decidim/admin/scopes_helper.rb
decidim-admin-0.6.6 app/helpers/decidim/admin/scopes_helper.rb
decidim-0.6.6 decidim-admin/app/helpers/decidim/admin/scopes_helper.rb