Sha256: 1826a58a2a5490c9c3805437453441ab7f10d1f58c9b61c1aaac096ff9e8180c

Contents?: true

Size: 1.49 KB

Versions: 37

Compression:

Stored size: 1.49 KB

Contents

# frozen_string_literal: true

module Decidim
  module Admin
    # This module includes helpers to show scopes in admin
    module ResourceScopeHelper
      # Public: This helper shows the th with the scope label.
      #
      # scope_label - I18n translation to show
      #
      def th_resource_scope_label(scope_label = t("decidim.admin.resources.index.headers.scope"))
        return unless resource_with_scopes_enabled?

        content_tag(:th, scope_label)
      end

      # Public: This helper shows the td for the given scope.
      #
      # current_scope - Scope object to show
      #
      def td_resource_scope_for(current_scope)
        return unless resource_with_scopes_enabled?

        scope_name = if current_scope
                       translated_attribute(current_scope.name)
                     else
                       t("decidim.scopes.global")
                     end
        content_tag(:td, scope_name)
      end

      # Public: This helper shows th with the sort link element.
      def th_scope_sort_link
        return unless resource_with_scopes_enabled?

        content_tag(:th) do
          sort_link(query, :scope_name, t("decidim.admin.resources.index.headers.scope"))
        end
      end

      private

      def resource_with_scopes_enabled?
        if defined? current_component
          current_component.scopes_enabled? || current_participatory_space.scopes_enabled?
        else
          current_participatory_space.scopes_enabled?
        end
      end
    end
  end
end

Version data entries

37 entries across 37 versions & 1 rubygems

Version Path
decidim-admin-0.29.1 app/helpers/decidim/admin/resource_scope_helper.rb
decidim-admin-0.28.4 app/helpers/decidim/admin/resource_scope_helper.rb
decidim-admin-0.27.9 app/helpers/decidim/admin/resource_scope_helper.rb
decidim-admin-0.29.0 app/helpers/decidim/admin/resource_scope_helper.rb
decidim-admin-0.28.3 app/helpers/decidim/admin/resource_scope_helper.rb
decidim-admin-0.27.8 app/helpers/decidim/admin/resource_scope_helper.rb
decidim-admin-0.29.0.rc4 app/helpers/decidim/admin/resource_scope_helper.rb
decidim-admin-0.29.0.rc3 app/helpers/decidim/admin/resource_scope_helper.rb
decidim-admin-0.29.0.rc2 app/helpers/decidim/admin/resource_scope_helper.rb
decidim-admin-0.29.0.rc1 app/helpers/decidim/admin/resource_scope_helper.rb
decidim-admin-0.28.2 app/helpers/decidim/admin/resource_scope_helper.rb
decidim-admin-0.27.7 app/helpers/decidim/admin/resource_scope_helper.rb
decidim-admin-0.28.1 app/helpers/decidim/admin/resource_scope_helper.rb
decidim-admin-0.27.6 app/helpers/decidim/admin/resource_scope_helper.rb
decidim-admin-0.26.10 app/helpers/decidim/admin/resource_scope_helper.rb
decidim-admin-0.26.9 app/helpers/decidim/admin/resource_scope_helper.rb
decidim-admin-0.28.0 app/helpers/decidim/admin/resource_scope_helper.rb
decidim-admin-0.27.5 app/helpers/decidim/admin/resource_scope_helper.rb
decidim-admin-0.28.0.rc5 app/helpers/decidim/admin/resource_scope_helper.rb
decidim-admin-0.28.0.rc4 app/helpers/decidim/admin/resource_scope_helper.rb