Sha256: 70749b9baeeaaccd3350893e167c2d61167e9c407927546e5601ecdbdfb788aa

Contents?: true

Size: 1.2 KB

Versions: 25

Compression:

Stored size: 1.2 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, Array[String]
      attribute(:authorization_handlers_options, { String => Object })

      def authorization_handlers
        handlers = super || []

        handlers.index_with { |name| { "options" => authorization_handler_options(name) } }
      end

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

      def authorization_handler_options(handler_name)
        authorization_handlers_options&.dig(handler_name.to_s) || {}
      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
    end
  end
end

Version data entries

25 entries across 25 versions & 1 rubygems

Version Path
decidim-admin-0.29.1 app/forms/decidim/admin/permission_form.rb
decidim-admin-0.28.4 app/forms/decidim/admin/permission_form.rb
decidim-admin-0.27.9 app/forms/decidim/admin/permission_form.rb
decidim-admin-0.29.0 app/forms/decidim/admin/permission_form.rb
decidim-admin-0.28.3 app/forms/decidim/admin/permission_form.rb
decidim-admin-0.27.8 app/forms/decidim/admin/permission_form.rb
decidim-admin-0.29.0.rc4 app/forms/decidim/admin/permission_form.rb
decidim-admin-0.29.0.rc3 app/forms/decidim/admin/permission_form.rb
decidim-admin-0.29.0.rc2 app/forms/decidim/admin/permission_form.rb
decidim-admin-0.29.0.rc1 app/forms/decidim/admin/permission_form.rb
decidim-admin-0.28.2 app/forms/decidim/admin/permission_form.rb
decidim-admin-0.27.7 app/forms/decidim/admin/permission_form.rb
decidim-admin-0.28.1 app/forms/decidim/admin/permission_form.rb
decidim-admin-0.27.6 app/forms/decidim/admin/permission_form.rb
decidim-admin-0.28.0 app/forms/decidim/admin/permission_form.rb
decidim-admin-0.27.5 app/forms/decidim/admin/permission_form.rb
decidim-admin-0.28.0.rc5 app/forms/decidim/admin/permission_form.rb
decidim-admin-0.28.0.rc4 app/forms/decidim/admin/permission_form.rb
decidim-admin-0.27.4 app/forms/decidim/admin/permission_form.rb
decidim-admin-0.27.3 app/forms/decidim/admin/permission_form.rb