Class: HasHelpers::Resource::ListPresenter
- Inherits:
-
BasePresenter
- Object
- BasePresenter
- HasHelpers::Resource::ListPresenter
- Defined in:
- app/presenters/has_helpers/resource/list_presenter.rb
Overview
HasHelpers::Resource::ListPresenter is used to represent overview information for a resource record. The presenter is meant to display tabular data. Each list presenter has rows (RowPresenters) and each row has cells (CellPresenters).
Instance Attribute Summary collapse
- #actions ⇒ Object
-
#caption ⇒ Object
Returns the value of attribute caption.
-
#caption_options ⇒ Object
Returns the value of attribute caption_options.
-
#caption_template ⇒ Object
Returns the value of attribute caption_template.
-
#current_user ⇒ Object
writeonly
Sets the attribute current_user.
- #header_options ⇒ Object
-
#headers ⇒ Object
Returns the value of attribute headers.
- #icons ⇒ Object
-
#is_dropdown ⇒ Object
Returns the value of attribute is_dropdown.
-
#is_sublist ⇒ Object
Returns the value of attribute is_sublist.
-
#items ⇒ Object
E.g., :rows => [ HasHelpers::Resource::RowPresenter.new(:items => [=> "Hello", => "World"]), HasHelpers::Resource::RowPresenter.new(:items => [=> "Adios"]) ] This manner of setting Row presenters explicitly offers the most flexibility and control.
-
#rows ⇒ Object
Returns the assigned values of
@rowsor items converted to rows. -
#service ⇒ Object
Returns the value of attribute service.
-
#skin ⇒ Object
Returns the value of attribute skin.
-
#subcaption ⇒ Object
Returns the value of attribute subcaption.
-
#tags ⇒ Object
Returns presenter instances for all the options passed to :tags.
Attributes inherited from BasePresenter
Instance Method Summary collapse
-
#has_rows_to_toggle ⇒ Object
Some lists may have data which should not be display in the initial (closed) state, but which should be accessible when a user toggles to an open state.
- #header_details_template ⇒ Object
Methods inherited from BasePresenter
#==, #error_on, #initialize, wrap, wrap_with_options
Methods included from Attributes
Constructor Details
This class inherits a constructor from HasHelpers::BasePresenter
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class HasHelpers::BasePresenter
Instance Attribute Details
#actions ⇒ Object
90 91 92 93 94 95 96 97 98 |
# File 'app/presenters/has_helpers/resource/list_presenter.rb', line 90 def actions (@actions || []).map do |action_or_attrs| if action_or_attrs.is_a?(Hash) ::HasHelpers::Resource::ActionPresenter.new(action_or_attrs) else action_or_attrs end end end |
#caption ⇒ Object
Returns the value of attribute caption.
9 10 11 |
# File 'app/presenters/has_helpers/resource/list_presenter.rb', line 9 def caption @caption end |
#caption_options ⇒ Object
Returns the value of attribute caption_options.
9 10 11 |
# File 'app/presenters/has_helpers/resource/list_presenter.rb', line 9 def @caption_options end |
#caption_template ⇒ Object
Returns the value of attribute caption_template.
9 10 11 |
# File 'app/presenters/has_helpers/resource/list_presenter.rb', line 9 def caption_template @caption_template end |
#current_user=(value) ⇒ Object (writeonly)
Sets the attribute current_user
7 8 9 |
# File 'app/presenters/has_helpers/resource/list_presenter.rb', line 7 def current_user=(value) @current_user = value end |
#header_options ⇒ Object
104 105 106 |
# File 'app/presenters/has_helpers/resource/list_presenter.rb', line 104 def @header_options || {} end |
#headers ⇒ Object
Returns the value of attribute headers.
9 10 11 |
# File 'app/presenters/has_helpers/resource/list_presenter.rb', line 9 def headers @headers end |
#icons ⇒ Object
108 109 110 |
# File 'app/presenters/has_helpers/resource/list_presenter.rb', line 108 def icons @icons || [] end |
#is_dropdown ⇒ Object
Returns the value of attribute is_dropdown.
9 10 11 |
# File 'app/presenters/has_helpers/resource/list_presenter.rb', line 9 def is_dropdown @is_dropdown end |
#is_sublist ⇒ Object
Returns the value of attribute is_sublist.
9 10 11 |
# File 'app/presenters/has_helpers/resource/list_presenter.rb', line 9 def is_sublist @is_sublist end |
#items ⇒ Object
E.g., :rows => [ HasHelpers::Resource::RowPresenter.new(:items => [=> "Hello", => "World"]), HasHelpers::Resource::RowPresenter.new(:items => [=> "Adios"]) ] This manner of setting Row presenters explicitly offers the most flexibility and control.
30 31 32 |
# File 'app/presenters/has_helpers/resource/list_presenter.rb', line 30 def items @items end |
#rows ⇒ Object
Returns the assigned values of @rows or items converted to rows.
70 71 72 |
# File 'app/presenters/has_helpers/resource/list_presenter.rb', line 70 def rows @rows_memoized ||= @rows || items_to_rows # rubocop:disable Naming/MemoizedInstanceVariableName end |
#service ⇒ Object
Returns the value of attribute service.
9 10 11 |
# File 'app/presenters/has_helpers/resource/list_presenter.rb', line 9 def service @service end |
#skin ⇒ Object
Returns the value of attribute skin.
9 10 11 |
# File 'app/presenters/has_helpers/resource/list_presenter.rb', line 9 def skin @skin end |
#subcaption ⇒ Object
Returns the value of attribute subcaption.
9 10 11 |
# File 'app/presenters/has_helpers/resource/list_presenter.rb', line 9 def subcaption @subcaption end |
#tags ⇒ Object
Returns presenter instances for all the options passed to :tags
75 76 77 78 79 80 81 82 |
# File 'app/presenters/has_helpers/resource/list_presenter.rb', line 75 def @tags_memoized ||= (@tags || []).map do || # rubocop:disable Naming/MemoizedInstanceVariableName case when ::HasHelpers::Resource::TagPresenter then else ::HasHelpers::Resource::TagPresenter.new() end end end |
Instance Method Details
#has_rows_to_toggle ⇒ Object
Some lists may have data which should not be display in the initial (closed) state, but which should be accessible when a user toggles to an open state.
86 87 88 |
# File 'app/presenters/has_helpers/resource/list_presenter.rb', line 86 def has_rows_to_toggle rows.present? && rows.any?(&:toggle) end |
#header_details_template ⇒ Object
100 101 102 |
# File 'app/presenters/has_helpers/resource/list_presenter.rb', line 100 def header_details_template [:template] end |