Class: Decidim::Initiatives::Admin::InitiativeTypeForm

Inherits:
Form show all
Includes:
TranslatableAttributes
Defined in:
decidim-initiatives/app/forms/decidim/initiatives/admin/initiative_type_form.rb

Overview

A form object used to collect the all the initiative type attributes.

Constant Summary collapse

DEFAULT_MINIMUM_COMMITTEE_MEMBERS =
2

Constants included from AttributeObject::TypeMap

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

Instance Attribute Summary

Attributes inherited from AttributeObject::Form

#context

Instance Method Summary collapse

Methods included from TranslatableAttributes

#default_locale?

Methods inherited from 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 AttributeObject::Model

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

Instance Method Details

#minimum_committee_membersObject


46
47
48
49
50
51
# File 'decidim-initiatives/app/forms/decidim/initiatives/admin/initiative_type_form.rb', line 46

def minimum_committee_members
  return 0 unless promoting_committee_enabled?
  return DEFAULT_MINIMUM_COMMITTEE_MEMBERS if super.blank?

  super
end

#minimum_committee_members=(value) ⇒ Object


42
43
44
# File 'decidim-initiatives/app/forms/decidim/initiatives/admin/initiative_type_form.rb', line 42

def minimum_committee_members=(value)
  super(value.presence)
end

#signature_type_optionsObject


53
54
55
56
57
58
59
60
61
62
# File 'decidim-initiatives/app/forms/decidim/initiatives/admin/initiative_type_form.rb', line 53

def signature_type_options
  Initiative.signature_types.keys.map do |type|
    [
      I18n.t(
        type,
        scope: %w(activemodel attributes initiative signature_type_values)
      ), type
    ]
  end
end