Sha256: f66bbdcdf6a9a79c3259cf91dbeda7caabe36e4eb7779363bc4d9dfb3a46bbc9

Contents?: true

Size: 1.83 KB

Versions: 5

Compression:

Stored size: 1.83 KB

Contents

# frozen_string_literal: true

module Decidim
  module Admin
    module ResourcePermissionsHelper
      # Public: Render a link to the permissions page for the resource.
      #
      # resource - The resource which permissions are going to be modified
      def resource_permissions_link(resource)
        return unless resource.allow_resource_permissions? && allowed_to?(:update, :component, component: resource.component)

        current_participatory_space_admin_proxy = ::Decidim::EngineRouter.admin_proxy(current_participatory_space)
        icon_link_to "key",
                     current_participatory_space_admin_proxy.edit_component_permissions_path(
                       current_component.id,
                       resource_name: resource.resource_manifest.name,
                       resource_id: resource.id
                     ),
                     t("actions.permissions", scope: "decidim.admin"),
                     class: "action-icon--permissions #{"action-icon--highlighted" if resource.permissions.present?}"
      end

      # Public: Render a link to the permissions page for a resource not
      # related with a component and participatory space.
      #
      # resource - The resource which permissions are going to be modified
      def free_resource_permissions_link(resource)
        resource_key = resource.resource_manifest.name.to_sym
        return unless resource.allow_resource_permissions? && allowed_to?(:update, resource_key, resource_key => resource)

        icon_link_to "key",
                     send("edit_#{resource_key}_permissions_path", resource.id, resource_name: resource.resource_manifest.name),
                     t("actions.permissions", scope: "decidim.admin"),
                     class: "action-icon--permissions #{"action-icon--highlighted" if resource.permissions.present?}"
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
decidim-admin-0.18.1 app/helpers/decidim/admin/resource_permissions_helper.rb
decidim-admin-0.17.2 app/helpers/decidim/admin/resource_permissions_helper.rb
decidim-admin-0.18.0 app/helpers/decidim/admin/resource_permissions_helper.rb
decidim-admin-0.17.1 app/helpers/decidim/admin/resource_permissions_helper.rb
decidim-admin-0.17.0 app/helpers/decidim/admin/resource_permissions_helper.rb