Class: Decidim::Templates::Admin::ProposalAnswerTemplateForm

Inherits:
TemplateForm
  • Object
show all
Defined in:
app/forms/decidim/templates/admin/proposal_answer_template_form.rb

Instance Method Summary collapse

Instance Method Details

#component_has_been_selectedObject



30
31
32
# File 'app/forms/decidim/templates/admin/proposal_answer_template_form.rb', line 30

def component_has_been_selected
  errors.add(:select_component, :blank) if select_component
end

#map_model(model) ⇒ Object



14
15
16
17
# File 'app/forms/decidim/templates/admin/proposal_answer_template_form.rb', line 14

def map_model(model)
  self.proposal_state_id = model.field_values["proposal_state_id"]&.to_i
  self.component_constraint = model.templatable&.id
end

#proposal_state_id_is_validObject



23
24
25
26
27
28
# File 'app/forms/decidim/templates/admin/proposal_answer_template_form.rb', line 23

def proposal_state_id_is_valid
  if Decidim::Proposals::ProposalState.where(decidim_component_id: component_constraint).find_by(id: proposal_state_id).blank?
    errors.add(:proposal_state_id,
               :blank)
  end
end

#skip_name_validationObject



19
20
21
# File 'app/forms/decidim/templates/admin/proposal_answer_template_form.rb', line 19

def skip_name_validation
  select_component
end