Class: Decidim::Admin::PermissionForm

Inherits:
Form show all
Defined in:
decidim-admin/app/forms/decidim/admin/permission_form.rb

Overview

This form handles permissions for a particular action in the admin panel.

Constant Summary

Constants included from Decidim::AttributeObject::TypeMap

Decidim::AttributeObject::TypeMap::Boolean, Decidim::AttributeObject::TypeMap::Decimal

Instance Attribute Summary

Attributes inherited from Decidim::AttributeObject::Form

#context

Instance Method Summary collapse

Methods inherited from Decidim::AttributeObject::Form

ensure_hash, from_model, from_params, hash_from, infer_model_name, #map_model, mimic, mimicked_model_name, model_name, #persisted?, #to_key, #to_model, #to_param, #valid?, #with_context

Methods included from Decidim::AttributeObject::Model

#[], #[]=, #attributes, #attributes_with_values, #initialize, #to_h

Instance Method Details

#authorization_handler_options(handler_name) ⇒ Object


20
21
22
# File 'decidim-admin/app/forms/decidim/admin/permission_form.rb', line 20

def authorization_handler_options(handler_name)
  authorization_handlers_options&.dig(handler_name.to_s) || {}
end

#authorization_handlersObject


10
11
12
13
14
# File 'decidim-admin/app/forms/decidim/admin/permission_form.rb', line 10

def authorization_handlers
  handlers = super || []

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

#authorization_handlers_namesObject


16
17
18
# File 'decidim-admin/app/forms/decidim/admin/permission_form.rb', line 16

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

#manifest(handler_name) ⇒ Object


24
25
26
# File 'decidim-admin/app/forms/decidim/admin/permission_form.rb', line 24

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

#options_attributes(handler_name) ⇒ Object


32
33
34
35
# File 'decidim-admin/app/forms/decidim/admin/permission_form.rb', line 32

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

#options_schema(handler_name) ⇒ Object


28
29
30
# File 'decidim-admin/app/forms/decidim/admin/permission_form.rb', line 28

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