Class: Decidim::Posts::PostForm

Inherits:
Form
  • Object
show all
Includes:
AttachmentAttributes, TranslatableAttributes
Defined in:
app/forms/decidim/posts/post_form.rb

Instance Method Summary collapse

Instance Method Details

#has_attachments?Boolean

def component_suggested_hashtags

@component_suggested_hashtags ||= ordered_hashtag_list(current_component.current_settings.suggested_hashtags)

end

Returns:

  • (Boolean)


87
88
89
# File 'app/forms/decidim/posts/post_form.rb', line 87

def has_attachments?
  post.has_attachments? && errors[:documents].empty? && documents.present?
end

#has_error_in_attachments?Boolean

Returns:

  • (Boolean)


91
92
93
# File 'app/forms/decidim/posts/post_form.rb', line 91

def has_error_in_attachments?
  errors[:documents].present?
end

#map_model(model) ⇒ Object

delegate :categories, to: :current_component



40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# File 'app/forms/decidim/posts/post_form.rb', line 40

def map_model(model)
  self.body = translated_attribute(model.body)
  self.highlighted = model.highlighted
  self.fixed = model.fixed
  self.category = model.category
  self.enable_comments = model.enable_comments

  self.questions = model.questions.map do |question|
    QuestionForm.from_model(question)
  end

  # @suggested_hashtags = Decidim::ContentRenderers::HashtagRenderer.new(body).extra_hashtags.map(&:name).map(&:downcase)

  # presenter = PostPresenter.new(model)
  # self.body = presenter.editor_body(all_locales: body.is_a?(Hash))

  self.documents = model.attachments
end