From 3c65700b526719f682e8e509e2f01368cead0676 Mon Sep 17 00:00:00 2001 From: Rick Barrette Date: Mon, 10 Aug 2026 15:50:23 -0400 Subject: [PATCH] Add customer show hook to display upcoming appointments and refactor appointment list rendering --- .../customer_appointments/_list.html.erb | 73 ++++++++++++++++++ .../_list_simple.html.erb | 57 ++++++++++++++ .../customer_appointments/index.html.erb | 74 +------------------ lib/redmine_qbo_calendar.rb | 1 + .../hooks/customer_show_hook_listener.rb | 40 ++++++++++ 5 files changed, 172 insertions(+), 73 deletions(-) create mode 100644 app/views/customer_appointments/_list.html.erb create mode 100644 app/views/customer_appointments/_list_simple.html.erb create mode 100644 lib/redmine_qbo_calendar/hooks/customer_show_hook_listener.rb diff --git a/app/views/customer_appointments/_list.html.erb b/app/views/customer_appointments/_list.html.erb new file mode 100644 index 0000000..6bb1726 --- /dev/null +++ b/app/views/customer_appointments/_list.html.erb @@ -0,0 +1,73 @@ + + + + + + + + + + + + + + + + + + + + + + + + +<% appointments.each do |appointment| %> + + + + + + + + + + + + + + + + + +<% end %> + + + +
<%= l(:label_customer) %><%= l(:label_vehicle) %><%= l(:label_appointment) %><%= l(:label_user) %><%= l(:label_date) %><%= l(:label_status) %>
+ +<%= link_to appointment.customer unless appointment.customer.nil? %> + + + +<%= link_to appointment.vehicle unless appointment.vehicle.nil? %> + + + +<%= link_to appointment %> + + + +<%= link_to appointment.user unless appointment.user.nil? %> + + + +<%= format_date( + appointment.date + ) %> + + + +<%= appointment.status %> + +
\ No newline at end of file diff --git a/app/views/customer_appointments/_list_simple.html.erb b/app/views/customer_appointments/_list_simple.html.erb new file mode 100644 index 0000000..2cd1cc4 --- /dev/null +++ b/app/views/customer_appointments/_list_simple.html.erb @@ -0,0 +1,57 @@ + + + + + + + + + + + + + + + + + + + + +<% appointments.each do |appointment| %> + + + + + + + + + + + + + +<% end %> + + + +
<%= l(:label_appointment) %><%= l(:label_user) %><%= l(:label_date) %><%= l(:label_status) %>
+ +<%= link_to appointment %> + + + +<%= link_to appointment.user unless appointment.user.nil? %> + + + +<%= format_date( + appointment.date + ) %> + + + +<%= appointment.status %> + +
\ No newline at end of file diff --git a/app/views/customer_appointments/index.html.erb b/app/views/customer_appointments/index.html.erb index 51bbd45..733dffd 100644 --- a/app/views/customer_appointments/index.html.erb +++ b/app/views/customer_appointments/index.html.erb @@ -11,76 +11,4 @@ - - - - - - - - - - - - - - - - - - - - - - - - -<% @appointments.each do |appointment| %> - - - - - - - - - - - - - - - - - -<% end %> - - - -
<%= l(:label_customer) %><%= l(:label_vehicle) %><%= l(:label_appointment) %><%= l(:label_user) %><%= l(:label_date) %><%= l(:label_status) %>
- -<%= link_to appointment.customer unless appointment.customer.nil? %> - - - -<%= link_to appointment.vehicle unless appointment.vehicle.nil? %> - - - -<%= link_to appointment %> - - - -<%= link_to appointment.user unless appointment.user.nil? %> - - - -<%= format_date( - appointment.date - ) %> - - - -<%= appointment.status %> - -
\ No newline at end of file +<%= render partial: "list", locals: { appointments: @appointments } %> \ No newline at end of file diff --git a/lib/redmine_qbo_calendar.rb b/lib/redmine_qbo_calendar.rb index 05dba06..be3f6ab 100644 --- a/lib/redmine_qbo_calendar.rb +++ b/lib/redmine_qbo_calendar.rb @@ -18,5 +18,6 @@ module RedmineQboCalendar # Hooks RedmineQboCalendar::Hooks::ViewHookListener RedmineQboCalendar::Hooks::CustomerActionsHookListener + RedmineQboCalendar::Hooks::CustomerShowHookListener end end \ No newline at end of file diff --git a/lib/redmine_qbo_calendar/hooks/customer_show_hook_listener.rb b/lib/redmine_qbo_calendar/hooks/customer_show_hook_listener.rb new file mode 100644 index 0000000..1be002a --- /dev/null +++ b/lib/redmine_qbo_calendar/hooks/customer_show_hook_listener.rb @@ -0,0 +1,40 @@ +#The MIT License (MIT) +# +#Copyright (c) 2016 - 2026 rick barrette +# +#Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: +# +#The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. +# +#THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +module RedmineQboCalendar + module Hooks + + class CustomerShowHookListener < Redmine::Hook::ViewListener + + include IssuesHelper + + # Display vehicle information on the customer show view (right side) + def show_customer_view_right(context={}) + log "show_customer_view_right called" + + customer = context[:customer] + appointments = customer.customer_appointments.where('date >= ?', Date.today).order(date: :asc) + + return if appointments.nil? + + context[:controller].send(:render_to_string, { + partial: 'customer_appointments/list_simple', locals: { appointments: appointments } + }) + + end + + private + + def log(msg) + Rails.logger.info "[CustomerShowHookListener] #{msg}" + end + end + end +end \ No newline at end of file