Sha256: ba1bfab775011409820262d0189ab740ce406964dee4fdb7769fabb9883d2884

Contents?: true

Size: 1.15 KB

Versions: 37

Compression:

Stored size: 1.15 KB

Contents

# frozen_string_literal: true

module Decidim
  module Admin
    # This form handles permissions for a particular action in the admin panel.
    class PermissionForm < Form
      attribute :authorization_handlers, Hash
      attribute :authorization_handlers_options, Hash

      def authorization_handlers_names
        authorization_handlers.keys.map(&:to_s)
      end

      def authorization_handler_options(handler_name)
        find_handler(handler_name)&.dig("options") || {}
      end

      def manifest(handler_name)
        Decidim::Verifications.find_workflow_manifest(handler_name)
      end

      def options_schema(handler_name)
        options_manifest(handler_name).schema.new(authorization_handler_options(handler_name))
      end

      def options_attributes(handler_name)
        manifest = options_manifest(handler_name)
        manifest ? manifest.attributes : []
      end

      private

      def options_manifest(handler_name)
        manifest(handler_name).options
      end

      def find_handler(handler_name)
        authorization_handlers[handler_name.to_s] ||
          authorization_handlers[handler_name.to_sym]
      end
    end
  end
end

Version data entries

37 entries across 37 versions & 1 rubygems

Version Path
decidim-admin-0.26.10 app/forms/decidim/admin/permission_form.rb
decidim-admin-0.26.9 app/forms/decidim/admin/permission_form.rb
decidim-admin-0.26.8 app/forms/decidim/admin/permission_form.rb
decidim-admin-0.26.7 app/forms/decidim/admin/permission_form.rb
decidim-admin-0.26.5 app/forms/decidim/admin/permission_form.rb
decidim-admin-0.26.4 app/forms/decidim/admin/permission_form.rb
decidim-admin-0.26.3 app/forms/decidim/admin/permission_form.rb
decidim-admin-0.26.2 app/forms/decidim/admin/permission_form.rb
decidim-admin-0.26.1 app/forms/decidim/admin/permission_form.rb
decidim-admin-0.26.0 app/forms/decidim/admin/permission_form.rb
decidim-admin-0.26.0.rc2 app/forms/decidim/admin/permission_form.rb
decidim-admin-0.26.0.rc1 app/forms/decidim/admin/permission_form.rb
decidim-admin-0.25.2 app/forms/decidim/admin/permission_form.rb
decidim-admin-0.25.1 app/forms/decidim/admin/permission_form.rb
decidim-admin-0.25.0 app/forms/decidim/admin/permission_form.rb
decidim-admin-0.25.0.rc4 app/forms/decidim/admin/permission_form.rb
decidim-admin-0.25.0.rc3 app/forms/decidim/admin/permission_form.rb
decidim-admin-0.25.0.rc2 app/forms/decidim/admin/permission_form.rb
decidim-admin-0.25.0.rc1 app/forms/decidim/admin/permission_form.rb
decidim-admin-0.24.3 app/forms/decidim/admin/permission_form.rb