Class: Decidim::Proposals::Admin::ProposalForm
- Inherits:
-
ProposalBaseForm
show all
- Includes:
- AttachmentAttributes, HasUploadValidations
- Defined in:
- app/forms/decidim/proposals/admin/proposal_form.rb
Overview
A form object to be used when admin users want to create a proposal.
Instance Method Summary
collapse
#author, #geocoded?, #geocoding_enabled?, #has_address?, #meeting_as_author, #meetings, #participatory_space_manifest
Instance Method Details
#documents ⇒ Object
45
46
47
48
49
50
51
52
53
|
# File 'app/forms/decidim/proposals/admin/proposal_form.rb', line 45
def documents
result = super
if should_use_add_documents?(result)
else
result.is_a?(Array) ? result : []
end
end
|
#documents=(value) ⇒ Object
34
35
36
37
38
39
40
41
42
43
|
# File 'app/forms/decidim/proposals/admin/proposal_form.rb', line 34
def documents=(value)
case value
when String
super(parse_string_documents(value))
when Integer
super([value])
else
super
end
end
|
#map_model(model) ⇒ Object
24
25
26
27
28
29
30
31
32
|
# File 'app/forms/decidim/proposals/admin/proposal_form.rb', line 24
def map_model(model)
super
presenter = ProposalPresenter.new(model)
self.title = presenter.title(all_locales: title.is_a?(Hash))
self.body = presenter.editor_body(all_locales: body.is_a?(Hash))
self.documents = model.attachments.ids
self.add_documents = model.attachments.map { |att| { id: att.id, title: att.title } }
end
|
#notify_missing_attachment_if_errored ⇒ Object
55
56
57
|
# File 'app/forms/decidim/proposals/admin/proposal_form.rb', line 55
def notify_missing_attachment_if_errored
errors.add(:add_documents, :needs_to_be_reattached) if errors.any? && add_documents.present?
end
|