Class: Decidim::DecidimAwesome::Admin::AuthorizationGroupForm

Inherits:
Form
  • Object
show all
Includes:
TranslatableAttributes
Defined in:
app/forms/decidim/decidim_awesome/admin/authorization_group_form.rb

Instance Method Summary collapse

Instance Method Details

#authorization_handler_options(handler_name) ⇒ Object



40
41
42
# File 'app/forms/decidim/decidim_awesome/admin/authorization_group_form.rb', line 40

def authorization_handler_options(handler_name)
  authorization_handlers_options&.dig(handler_name.to_s) || authorization_handlers&.dig(handler_name, "options").presence || {}
end

#authorization_handlers_namesObject



36
37
38
# File 'app/forms/decidim/decidim_awesome/admin/authorization_group_form.rb', line 36

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

#available_authorizationsObject

Helper for the view, at this point, ephemeral authorizations are not supported yet



58
59
60
61
62
# File 'app/forms/decidim/decidim_awesome/admin/authorization_group_form.rb', line 58

def available_authorizations
  Decidim.authorization_workflows.filter do |workflow|
    current_organization.available_authorizations.include?(workflow.name) && !workflow.ephemeral?
  end
end

#manifest(handler_name) ⇒ Object



49
50
51
# File 'app/forms/decidim/decidim_awesome/admin/authorization_group_form.rb', line 49

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

#options_attributes(handler_name) ⇒ Object



44
45
46
47
# File 'app/forms/decidim/decidim_awesome/admin/authorization_group_form.rb', line 44

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

#options_manifest(handler_name) ⇒ Object



53
54
55
# File 'app/forms/decidim/decidim_awesome/admin/authorization_group_form.rb', line 53

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

#options_schema(handler_name) ⇒ Object



32
33
34
# File 'app/forms/decidim/decidim_awesome/admin/authorization_group_form.rb', line 32

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

#parsed_authorization_handlersObject



21
22
23
24
25
26
27
28
29
30
# File 'app/forms/decidim/decidim_awesome/admin/authorization_group_form.rb', line 21

def parsed_authorization_handlers
  authorization_handlers_names.filter_map do |name|
    next if name.blank?

    [
      name,
      { options: authorization_handler_options(name) }
    ]
  end.to_h
end

#verification_settingsObject



14
15
16
17
18
19
# File 'app/forms/decidim/decidim_awesome/admin/authorization_group_form.rb', line 14

def verification_settings
  {
    authorization_handlers: parsed_authorization_handlers,
    force_authorization_help_text: force_authorization_help_text || {}
  }
end