From 78fe22f00481d387c479b22c3d1810a560f3062d Mon Sep 17 00:00:00 2001 From: Claude Date: Wed, 28 Oct 2026 15:43:19 -0400 Subject: [PATCH] Link appointment history from customer page and calendar - Customer page list now shows a History link and a 'View all N past appointments' link; it also renders when a customer has history but nothing upcoming - Calendar toolbar gets an Appointment History button - Calendar tooltip gets a history icon next to the customer Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01BiwYMjhoQvL7XsKKfRz4pM --- app/views/common/_calendar.html.erb | 10 ++ .../_list_simple.html.erb | 101 ++++++++---------- .../customer_appointments/_tooltip.html.erb | 8 +- assets/stylesheets/customer_appointments.css | 13 +++ config/locales/en.yml | 5 + .../hooks/customer_show_hook_listener.rb | 17 ++- 6 files changed, 93 insertions(+), 61 deletions(-) diff --git a/app/views/common/_calendar.html.erb b/app/views/common/_calendar.html.erb index 950de23..8953f78 100644 --- a/app/views/common/_calendar.html.erb +++ b/app/views/common/_calendar.html.erb @@ -120,6 +120,16 @@
+ <% if User.current.allowed_to?(:view_customer_appointments, nil, global: true) %> + <%= link_to history_customer_appointments_path, + class: 'button-small', + style: 'display: inline-flex; align-items: center; gap: 5px; text-decoration: none; font-weight: 600; font-size: 0.9em; padding: 4px 10px; border-radius: 3px;', + title: l(:label_appointment_history) do %> + + <%= l(:label_appointment_history) %> + <% end %> + <% end %> + <% if is_current_month %>
diff --git a/app/views/customer_appointments/_tooltip.html.erb b/app/views/customer_appointments/_tooltip.html.erb index 2f8307a..548b14a 100644 --- a/app/views/customer_appointments/_tooltip.html.erb +++ b/app/views/customer_appointments/_tooltip.html.erb @@ -19,7 +19,13 @@ <% if appointment.customer %> <%= l(:label_customer) %> - <%= link_to appointment.customer %> + + <%= link_to appointment.customer %> + <%= link_to history_customer_appointments_path(customer_id: appointment.customer_id), + title: l(:label_appointment_history), class: 'appointment-history-icon' do %> + + <% end %> + <% end %> diff --git a/assets/stylesheets/customer_appointments.css b/assets/stylesheets/customer_appointments.css index ee280e6..ecbc41a 100644 --- a/assets/stylesheets/customer_appointments.css +++ b/assets/stylesheets/customer_appointments.css @@ -609,3 +609,16 @@ table.cal td.today { table.appointment-history td.subject { text-align: left; } + +/* Upcoming appointments on the customer page */ +.customer-appointments-simple .contextual { + margin-top: 0; +} +.customer-appointments-simple .appointment-history-link { + margin-top: 6px; + text-align: right; +} +.appointment-history-icon { + margin-left: 6px; + text-decoration: none; +} diff --git a/config/locales/en.yml b/config/locales/en.yml index 8bb4ba8..7ea280a 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -37,6 +37,11 @@ en: label_appointment_new: "New Appointment" label_appointments: Appointments label_appointment_history: Appointment History + label_upcoming_customer_appointments: Upcoming Appointments + label_no_upcoming_appointments: "No upcoming appointments" + label_view_past_appointments: + one: "View 1 past appointment" + other: "View all %{count} past appointments" label_appointment_history_for: "Appointment History: %{name}" label_all_statuses: "All statuses" label_date_from: From diff --git a/lib/redmine_qbo_calendar/hooks/customer_show_hook_listener.rb b/lib/redmine_qbo_calendar/hooks/customer_show_hook_listener.rb index 7a7f9d4..730a0f0 100644 --- a/lib/redmine_qbo_calendar/hooks/customer_show_hook_listener.rb +++ b/lib/redmine_qbo_calendar/hooks/customer_show_hook_listener.rb @@ -20,12 +20,19 @@ module RedmineQboCalendar log "show_customer_view_right called" customer = context[:customer] - appointments = customer.customer_appointments.where('date >= ?', Date.today).order(date: :asc) + return unless customer + return unless User.current.allowed_to?(:view_customer_appointments, nil, global: true) - return if appointments.empty? + cutoff = Time.zone.now.beginning_of_day + appointments = customer.customer_appointments.where('date >= ?', cutoff).order(date: :asc) + past_count = customer.customer_appointments.where('date < ?', cutoff).count - context[:controller].send(:render_to_string, { - partial: 'customer_appointments/list_simple', locals: { appointments: appointments } + # Nothing upcoming and no history: keep the customer page clean + return if appointments.empty? && past_count.zero? + + context[:controller].send(:render_to_string, { + partial: 'customer_appointments/list_simple', + locals: { appointments: appointments, customer: customer, past_count: past_count } }) end @@ -37,4 +44,4 @@ module RedmineQboCalendar end end end -end \ No newline at end of file +end \ No newline at end of file