Class: Decidim::Proposals::ProposalsPickerCell
- Inherits:
-
ViewModel
- Object
- ViewModel
- Decidim::Proposals::ProposalsPickerCell
- Defined in:
- 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
- #decorated_proposals ⇒ Object
- #field ⇒ Object
- #form ⇒ Object
- #form_name ⇒ Object
- #method_name ⇒ Object
- #proposals ⇒ Object
- #selected_ids ⇒ Object
- #show ⇒ Object
Instance Method Details
#decorated_proposals ⇒ Object
45 46 47 48 49 |
# File '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 'app/cells/decidim/proposals/proposals_picker_cell.rb', line 21 def field [:field] end |
#form ⇒ Object
17 18 19 |
# File 'app/cells/decidim/proposals/proposals_picker_cell.rb', line 17 def form [:form] end |
#form_name ⇒ Object
25 26 27 |
# File '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 '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 '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 '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 'app/cells/decidim/proposals/proposals_picker_cell.rb', line 11 def show render end |