Class: Renalware::Patients::MessagesComponent

Inherits:
ApplicationComponent show all
Includes:
Pagy::Backend, Pagy::Frontend, ToggleHelper
Defined in:
app/components/renalware/patients/messages_component.rb

Constant Summary collapse

TITLE =
"Messages"

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from ToggleHelper

#css_toggle_link_to, #row_toggler, #rows_toggler, #table_toggler, #td_toggle_row, #th_toggle_all_rows, #toggler

Methods inherited from ApplicationComponent

#policy, #renalware

Constructor Details

#initialize(patient:, current_user:) ⇒ MessagesComponent

Returns a new instance of MessagesComponent.



13
14
15
16
17
# File 'app/components/renalware/patients/messages_component.rb', line 13

def initialize(patient:, current_user:)
  @patient = patient
  @current_user = current_user
  super
end

Instance Attribute Details

#current_userObject (readonly)

Returns the value of attribute current_user.



11
12
13
# File 'app/components/renalware/patients/messages_component.rb', line 11

def current_user
  @current_user
end

#patientObject (readonly)

Returns the value of attribute patient.



11
12
13
# File 'app/components/renalware/patients/messages_component.rb', line 11

def patient
  @patient
end

Instance Method Details

#messagesObject



24
25
26
27
# File 'app/components/renalware/patients/messages_component.rb', line 24

def messages
  load_messages unless @messages
  @messages
end

#paginationObject



19
20
21
22
# File 'app/components/renalware/patients/messages_component.rb', line 19

def pagination
  load_messages unless @pagination
  @pagination
end

#titleObject



29
30
31
32
33
34
35
# File 'app/components/renalware/patients/messages_component.rb', line 29

def title
  if pagination.items < pagination.count
    "#{TITLE} (#{pagination.items} of #{pagination.count})"
  else
    "#{TITLE} (#{pagination.items})"
  end
end