Class: Renalware::Events::EventListComponent
- Inherits:
-
ApplicationComponent
- Object
- ViewComponent::Base
- ApplicationComponent
- Renalware::Events::EventListComponent
- Defined in:
- app/components/renalware/events/event_list_component.rb
Overview
A generic view component for displaying a summarised list of events of a certain type - for example Biopsy events - to add to a dashboard or MDM. Once we have configurable dashboards and MDMs it should be possible to drop this component onto a dashboard and configure the event class and perhaps some other custom parameters, and at run time the dashboard is constructed and will include the requested component. In this way you could choose to add say list components which each display a different class of event. Obviously some more thought needs to go into this but as a direction of travel it has many advantages - for example a hospital can configure the default dashboards and MDMs, perhaps depending on the user’s role, but an individual user could override and build their own. Some parameters to think about when configuring an event component
-
event class or description - where does the event_type fit in?
-
the AR scope to use and whether this affects sorting
-
the title displayed above the list of events - is this i18n, derived from the event type/class, or configured when the dashboard is designed?
-
to what extent to the event partials affect display? We have these to help us build form inputs and display content in table cell/toggled cells, but is this flexible enough - e.g. is only have a Description HTML table column sufficient for displaying multiple custom event properties (defined in the event’s document) or do we need to allow partials that control table structure?
Perhaps a datavase-backed component configuration model could be passed into this component to drive the display - eg hide_if_no_data of not.
Instance Method Summary collapse
- #description_column_title ⇒ Object
- #event_count ⇒ Object
-
#events ⇒ Object
This assumes the event class has a scope called #ordered.
-
#render? ⇒ Boolean
There is the option to prevent anything from displaying if we expose the render? method and return false.
- #title ⇒ Object
- #total_event_count ⇒ Object
Methods inherited from ApplicationComponent
Instance Method Details
#description_column_title ⇒ Object
59 60 61 |
# File 'app/components/renalware/events/event_list_component.rb', line 59 def description_column_title t(:description_column_title) end |
#event_count ⇒ Object
47 48 49 |
# File 'app/components/renalware/events/event_list_component.rb', line 47 def event_count @event_count ||= events.length end |
#events ⇒ Object
This assumes the event class has a scope called #ordered
38 39 40 41 42 43 44 45 |
# File 'app/components/renalware/events/event_list_component.rb', line 38 def events @events ||= begin CollectionPresenter.new( relation.includes(:created_by).ordered.limit(limit), Events::EventPresenter ) end end |
#render? ⇒ Boolean
There is the option to prevent anything from displaying if we expose the render? method and return false
65 66 67 68 69 |
# File 'app/components/renalware/events/event_list_component.rb', line 65 def render? return true unless hide_if_no_data event_count > 0 end |
#title ⇒ Object
55 56 57 |
# File 'app/components/renalware/events/event_list_component.rb', line 55 def title t(:title) end |
#total_event_count ⇒ Object
51 52 53 |
# File 'app/components/renalware/events/event_list_component.rb', line 51 def total_event_count @total_event_count ||= relation.count end |