Class: Decidim::Forms::Admin::QuestionnaireResponsePresenter
- Inherits:
-
SimpleDelegator
- Object
- SimpleDelegator
- Decidim::Forms::Admin::QuestionnaireResponsePresenter
show all
- Includes:
- TranslatableAttributes
- Defined in:
- decidim-forms/app/presenters/decidim/forms/admin/questionnaire_response_presenter.rb
Overview
Presenter for questionnaire response
Instance Method Summary
collapse
#attachment?, #default_locale?
Instance Method Details
#attachments ⇒ Object
45
46
47
48
49
|
# File 'decidim-forms/app/presenters/decidim/forms/admin/questionnaire_response_presenter.rb', line 45
def attachments
content_tag(:ul) do
safe_join(response.attachments.map { |a| pretty_attachment(a) })
end
end
|
#body ⇒ Object
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
|
# File 'decidim-forms/app/presenters/decidim/forms/admin/questionnaire_response_presenter.rb', line 26
def body
return response.body if response.body.present?
return attachments if response.attachments.any?
return "-" if response.choices.empty?
choices = response.choices.map do |choice|
{
response_option_body: choice.try(:response_option).try(:translated_body),
choice_body: body_or_custom_body(choice)
}
end
return choice(choices.first) if response.question.question_type == "single_option"
content_tag(:ul) do
safe_join(choices.map { |c| choice(c) })
end
end
|
#question ⇒ Object
22
23
24
|
# File 'decidim-forms/app/presenters/decidim/forms/admin/questionnaire_response_presenter.rb', line 22
def question
translated_attribute(response.question.body)
end
|
#response ⇒ Object
14
15
16
|
# File 'decidim-forms/app/presenters/decidim/forms/admin/questionnaire_response_presenter.rb', line 14
def response
__getobj__.fetch(:response)
end
|
#view_context ⇒ Object
18
19
20
|
# File 'decidim-forms/app/presenters/decidim/forms/admin/questionnaire_response_presenter.rb', line 18
def view_context
__getobj__.fetch(:view_context, ActionController::Base.new.view_context)
end
|