Class: Decidim::Votings::PollingOfficers::PollingOfficersPickerCell
- Inherits:
-
Decidim::ViewModel
- Object
- Decidim::ViewModel
- Decidim::Votings::PollingOfficers::PollingOfficersPickerCell
- Defined in:
- app/cells/decidim/votings/polling_officers/polling_officers_picker_cell.rb
Overview
This cell renders a polling officers picker.
Constant Summary collapse
- MAX_POLLING_OFFICERS =
1000
Instance Method Summary collapse
- #decorated_polling_officers ⇒ Object
- #field ⇒ Object
- #filtered? ⇒ Boolean
- #filtered_polling_officers ⇒ Object
- #form ⇒ Object
- #form_name ⇒ Object
- #method_name ⇒ Object
- #more_polling_officers? ⇒ Boolean
- #more_polling_officers_count ⇒ Object
- #picker_path ⇒ Object
- #polling_officers ⇒ Object
- #polling_officers_collection_name ⇒ Object
- #polling_officers_count ⇒ Object
- #search_text ⇒ Object
- #selected_ids ⇒ Object
Instance Method Details
#decorated_polling_officers ⇒ Object
58 59 60 |
# File 'app/cells/decidim/votings/polling_officers/polling_officers_picker_cell.rb', line 58 def decorated_polling_officers filtered_polling_officers.limit(MAX_POLLING_OFFICERS) end |
#field ⇒ Object
18 19 20 |
# File 'app/cells/decidim/votings/polling_officers/polling_officers_picker_cell.rb', line 18 def field [:field] end |
#filtered? ⇒ Boolean
34 35 36 |
# File 'app/cells/decidim/votings/polling_officers/polling_officers_picker_cell.rb', line 34 def filtered? !search_text.nil? end |
#filtered_polling_officers ⇒ Object
62 63 64 |
# File 'app/cells/decidim/votings/polling_officers/polling_officers_picker_cell.rb', line 62 def filtered_polling_officers @filtered_polling_officers ||= polling_officers end |
#form ⇒ Object
14 15 16 |
# File 'app/cells/decidim/votings/polling_officers/polling_officers_picker_cell.rb', line 14 def form [:form] end |
#form_name ⇒ Object
22 23 24 |
# File 'app/cells/decidim/votings/polling_officers/polling_officers_picker_cell.rb', line 22 def form_name "#{form.object_name}[#{method_name}]" end |
#method_name ⇒ Object
26 27 28 |
# File 'app/cells/decidim/votings/polling_officers/polling_officers_picker_cell.rb', line 26 def method_name field.to_s.sub(/s$/, "_ids") end |
#more_polling_officers? ⇒ Boolean
46 47 48 |
# File 'app/cells/decidim/votings/polling_officers/polling_officers_picker_cell.rb', line 46 def more_polling_officers? @more_polling_officers ||= more_polling_officers_count.positive? end |
#more_polling_officers_count ⇒ Object
50 51 52 |
# File 'app/cells/decidim/votings/polling_officers/polling_officers_picker_cell.rb', line 50 def more_polling_officers_count @more_polling_officers_count ||= polling_officers_count - MAX_POLLING_OFFICERS end |
#picker_path ⇒ Object
38 39 40 |
# File 'app/cells/decidim/votings/polling_officers/polling_officers_picker_cell.rb', line 38 def picker_path request.path end |
#polling_officers ⇒ Object
66 67 68 |
# File 'app/cells/decidim/votings/polling_officers/polling_officers_picker_cell.rb', line 66 def polling_officers @polling_officers ||= model.available_polling_officers end |
#polling_officers_collection_name ⇒ Object
70 71 72 |
# File 'app/cells/decidim/votings/polling_officers/polling_officers_picker_cell.rb', line 70 def polling_officers_collection_name Decidim::Votings::PollingOfficer.model_name.human(count: 2) end |
#polling_officers_count ⇒ Object
54 55 56 |
# File 'app/cells/decidim/votings/polling_officers/polling_officers_picker_cell.rb', line 54 def polling_officers_count @polling_officers_count ||= filtered_polling_officers.count end |
#search_text ⇒ Object
42 43 44 |
# File 'app/cells/decidim/votings/polling_officers/polling_officers_picker_cell.rb', line 42 def search_text params[:q] end |
#selected_ids ⇒ Object
30 31 32 |
# File 'app/cells/decidim/votings/polling_officers/polling_officers_picker_cell.rb', line 30 def selected_ids form.object.send(method_name) end |