Class: Decidim::Proposals::ProposalsPickerCell
- Inherits:
-
ViewModel
- Object
- Cell::ViewModel
- ViewModel
- Decidim::Proposals::ProposalsPickerCell
show all
- Defined in:
- decidim-proposals/app/cells/decidim/proposals/proposals_picker_cell.rb
Overview
This cell renders a proposals picker.
Constant Summary
collapse
- MAX_PROPOSALS =
1000
Instance Method Summary
collapse
Methods inherited from ViewModel
#call, #current_user, #view_context
#_icon_classes, #apple_favicon, #application_path, #current_user_unread_data, #extended_navigation_bar, #external_icon, #favicon, #icon, #legacy_favicon, #organization_colors, #role
#with_tooltip
#decidim_modal
#element_id
#button_to, #submit_tag
#action_authorized_button_to, #action_authorized_link_to, #logged_button_to, #logged_link_to
#has_visible_scopes?, #scope_name_for_picker, #scopes_picker_field, #scopes_picker_filter, #scopes_select_field, #scopes_select_tag
#default_locale?
#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, #ordered_scopes_descendants, #ordered_scopes_descendants_for_select, #scopes_picker_field_tag, #tab_element_class_for, #translated_field_tag
#linked_classes_filter_values_for, #linked_classes_for, #resource_locator, #resource_title
Instance Method Details
#decorated_proposals ⇒ Object
45
46
47
48
49
|
# File 'decidim-proposals/app/cells/decidim/proposals/proposals_picker_cell.rb', line 45
def decorated_proposals
proposals.limit(MAX_PROPOSALS).each do |proposal|
yield Decidim::Proposals::ProposalPresenter.new(proposal)
end
end
|
#field ⇒ Object
21
22
23
|
# File 'decidim-proposals/app/cells/decidim/proposals/proposals_picker_cell.rb', line 21
def field
options[:field]
end
|
17
18
19
|
# File 'decidim-proposals/app/cells/decidim/proposals/proposals_picker_cell.rb', line 17
def form
options[:form]
end
|
25
26
27
|
# File 'decidim-proposals/app/cells/decidim/proposals/proposals_picker_cell.rb', line 25
def form_name
"#{form.object_name}[#{method_name}]"
end
|
#method_name ⇒ Object
29
30
31
|
# File 'decidim-proposals/app/cells/decidim/proposals/proposals_picker_cell.rb', line 29
def method_name
field.to_s.sub(/s$/, "_ids")
end
|
#proposals ⇒ Object
37
38
39
40
41
42
43
|
# File 'decidim-proposals/app/cells/decidim/proposals/proposals_picker_cell.rb', line 37
def proposals
@proposals ||= Decidim.find_resource_manifest(:proposals).try(:resource_scope, component)
&.includes(:component)
&.published
&.not_hidden
&.order(id: :asc)
end
|
#selected_ids ⇒ Object
33
34
35
|
# File 'decidim-proposals/app/cells/decidim/proposals/proposals_picker_cell.rb', line 33
def selected_ids
form.object.send(method_name)
end
|
#show ⇒ Object
11
12
13
|
# File 'decidim-proposals/app/cells/decidim/proposals/proposals_picker_cell.rb', line 11
def show
render
end
|