Sha256: 7a3385e1cd5314aca6c2442d7607fa573d4c9ade03263b272f0515fdb4666cb1
Contents?: true
Size: 1.13 KB
Versions: 2
Compression:
Stored size: 1.13 KB
Contents
# frozen_string_literal: true module Renalware module Patients class MessagesComponent < ApplicationComponent include ToggleHelper include Pagy::Backend include Pagy::Frontend TITLE = "Messages" attr_reader :patient, :current_user def initialize(patient:, current_user:) @patient = patient @current_user = current_user super end def pagination load_messages unless @pagination @pagination end def messages load_messages unless @messages @messages end def title if pagination.items < pagination.count "#{TITLE} (#{pagination.items} of #{pagination.count})" else "#{TITLE} (#{pagination.count})" end end private def load_messages @pagination, @messages = pagy(scope, items: 5, link_extra: "data-remote='true'") end def messaging_patient @messaging_patient ||= Messaging.cast_patient(patient) end def scope messaging_patient.messages.where(public: true).order(created_at: :desc) end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
renalware-core-2.0.159 | app/components/renalware/patients/messages_component.rb |
renalware-core-2.0.158 | app/components/renalware/patients/messages_component.rb |