Class: Decidim::Budgets::Admin::ProjectForm
- Inherits:
-
Form
- Object
- AttributeObject::Form
- Form
- Decidim::Budgets::Admin::ProjectForm
- Includes:
- ApplicationHelper, AttachmentAttributes, HasTaxonomyFormAttributes, TranslatableAttributes, TranslationsHelper
- Defined in:
- decidim-budgets/app/forms/decidim/budgets/admin/project_form.rb
Overview
This class holds a Form to create/update projects from Decidim's admin panel.
Constant Summary
Constants included from AmendmentsHelper
Constants included from AttributeObject::TypeMap
AttributeObject::TypeMap::Boolean, AttributeObject::TypeMap::Decimal
Instance Attribute Summary
Attributes inherited from AttributeObject::Form
Instance Method Summary collapse
-
#budget ⇒ Object
Finds the Budget from the decidim_budgets_budget_id.
- #geocoded? ⇒ Boolean
- #geocoding_enabled? ⇒ Boolean
- #has_address? ⇒ Boolean
- #map_model(model) ⇒ Object
- #participatory_space_manifest ⇒ Object
- #proposals ⇒ Object
Methods included from ApplicationHelper
#add_body_classes, #cell, #edit_link, #extra_admin_link, #html_truncate, #layout_item_classes, #present, #prevent_timeout_seconds, #resolve_presenter_class, #text_initials
Methods included from CacheHelper
Methods included from AmendmentsHelper
#accept_and_reject_buttons_for, #action_button_card_for, #allowed_to_accept_and_reject?, #allowed_to_promote?, #amendments_enabled?, #amendments_form_field_for, #amendments_form_fields_label, #amendments_form_fields_value, #can_participate_in_private_space?, #can_react_to_emendation?, #current_step, #emendation_actions_for, #emendation_announcement_for, #promote_button_for, #render_emendation_body, #total_steps, #wizard_aside_back_url, #wizard_header_title
Methods included from RichTextEditorHelper
Methods included from ContextualHelpHelper
Methods included from DecidimFormHelper
#areas_for_select, #base_error_messages, #decidim_form_for, #decidim_form_slug_url, #editor_field_tag, #form_field_has_error?, #form_required_explanation, #name_with_locale, #tab_element_class_for, #translated_field_tag
Methods included from OmniauthHelper
#normalize_provider_name, #oauth_icon, #provider_name
Methods included from TranslationsHelper
empty_translatable, ensure_translatable, multi_translation, translated_in_current_locale?
Methods included from TranslatableAttributes
#attachment?, #default_locale?
Methods inherited from AttributeObject::Form
ensure_hash, from_model, from_params, hash_from, infer_model_name, 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
#budget ⇒ Object
Finds the Budget from the decidim_budgets_budget_id.
Returns a Decidim::Budgets:Budget
66 67 68 |
# File 'decidim-budgets/app/forms/decidim/budgets/admin/project_form.rb', line 66 def budget @budget ||= context[:budget] end |
#geocoded? ⇒ Boolean
59 60 61 |
# File 'decidim-budgets/app/forms/decidim/budgets/admin/project_form.rb', line 59 def geocoded? latitude.present? && longitude.present? end |
#geocoding_enabled? ⇒ Boolean
51 52 53 |
# File 'decidim-budgets/app/forms/decidim/budgets/admin/project_form.rb', line 51 def geocoding_enabled? Decidim::Map.available?(:geocoding) && current_component.settings.geocoding_enabled? end |
#has_address? ⇒ Boolean
55 56 57 |
# File 'decidim-budgets/app/forms/decidim/budgets/admin/project_form.rb', line 55 def has_address? geocoding_enabled? && address.present? end |
#map_model(model) ⇒ Object
36 37 38 39 |
# File 'decidim-budgets/app/forms/decidim/budgets/admin/project_form.rb', line 36 def map_model(model) self.proposal_ids = model.linked_resources(:proposals, "included_proposals").pluck(:id) self.selected = model.selected? end |
#participatory_space_manifest ⇒ Object
41 42 43 |
# File 'decidim-budgets/app/forms/decidim/budgets/admin/project_form.rb', line 41 def participatory_space_manifest @participatory_space_manifest ||= current_component.participatory_space.manifest.name end |
#proposals ⇒ Object
45 46 47 48 49 |
# File 'decidim-budgets/app/forms/decidim/budgets/admin/project_form.rb', line 45 def proposals @proposals ||= Decidim.find_resource_manifest(:proposals).try(:resource_scope, current_component) &.where(id: proposal_ids) &.order(title: :asc) end |