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 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01BiwYMjhoQvL7XsKKfRz4pM
This commit is contained in:
Claude committed 2026-10-28 15:43:25 -04:00
1 parent a4095b947f
commit 78fe22f004
6 files changed
+93 -61

No files matched your search

+10
View File
@@ -120,6 +120,16 @@
<!-- Toggle Bar --> <!-- Toggle Bar -->
<div class="calendar-filter-toolbar" style="margin-bottom: 12px; display: flex; align-items: center; justify-content: flex-end; gap: 16px;"> <div class="calendar-filter-toolbar" style="margin-bottom: 12px; display: flex; align-items: center; justify-content: flex-end; gap: 16px;">
<% 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 %>
<i class="fa-solid fa-clock-rotate-left" aria-hidden="true"></i>
<%= l(:label_appointment_history) %>
<% end %>
<% end %>
<% if is_current_month %> <% if is_current_month %>
<button type="button" <button type="button"
onclick="scrollToToday()" onclick="scrollToToday()"
@@ -1,58 +1,49 @@
<h4><%=t(:label_appointments)%>:</h4> <div class="customer-appointments-simple">
<table class="list"> <div class="contextual">
<%= link_to history_customer_appointments_path(customer_id: customer.id), title: l(:label_appointment_history) do %>
<i class="fa-solid fa-clock-rotate-left"></i> <%= l(:label_history) %>
<% end %>
</div>
<thead> <h4><%= l(:label_upcoming_customer_appointments) %>:</h4>
<tr> <% if appointments.any? %>
<table class="list">
<thead>
<tr>
<th><%= l(:label_appointment) %></th>
<th><%= l(:label_user) %></th>
<th><%= l(:label_date) %></th>
<th><%= l(:label_status) %></th>
</tr>
</thead>
<tbody>
<% appointments.each do |appointment| %>
<tr>
<td><%= link_to appointment %></td>
<td><%= link_to appointment.user unless appointment.user.nil? %></td>
<td><%= format_date(appointment.date) %></td>
<td>
<% if appointment.status.present? %>
<span class="status-badge status-<%= appointment.status.to_s.parameterize %>">
<%= appointment.status.to_s.humanize %>
</span>
<% end %>
</td>
</tr>
<% end %>
</tbody>
</table>
<% else %>
<p class="nodata"><%= l(:label_no_upcoming_appointments) %></p>
<% end %>
<th><%= l(:label_appointment) %></th> <% if past_count.to_i > 0 %>
<p class="appointment-history-link">
<th><%= l(:label_user) %></th> <%= link_to history_customer_appointments_path(customer_id: customer.id) do %>
<i class="fa-solid fa-clock-rotate-left"></i>
<th><%= l(:label_date) %></th> <%= l(:label_view_past_appointments, count: past_count) %>
<% end %>
<th><%= l(:label_status) %></th> </p>
<% end %>
</tr> </div>
</thead>
<tbody>
<% appointments.each do |appointment| %>
<tr>
<td>
<%= link_to appointment %>
</td>
<td>
<%= link_to appointment.user unless appointment.user.nil? %>
</td>
<td>
<%= format_date(
appointment.date
) %>
</td>
<td>
<%= appointment.status %>
</td>
</tr>
<% end %>
</tbody>
</table>
@@ -19,7 +19,13 @@
<% if appointment.customer %> <% if appointment.customer %>
<tr> <tr>
<th><%= l(:label_customer) %></th> <th><%= l(:label_customer) %></th>
<td><%= link_to appointment.customer %></td> <td>
<%= 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 %>
<i class="fa-solid fa-clock-rotate-left"></i>
<% end %>
</td>
</tr> </tr>
<% end %> <% end %>
@@ -609,3 +609,16 @@ table.cal td.today {
table.appointment-history td.subject { table.appointment-history td.subject {
text-align: left; 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;
}
+5
View File
@@ -37,6 +37,11 @@ en:
label_appointment_new: "New Appointment" label_appointment_new: "New Appointment"
label_appointments: Appointments label_appointments: Appointments
label_appointment_history: Appointment History 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_appointment_history_for: "Appointment History: %{name}"
label_all_statuses: "All statuses" label_all_statuses: "All statuses"
label_date_from: From label_date_from: From
@@ -20,12 +20,19 @@ module RedmineQboCalendar
log "show_customer_view_right called" log "show_customer_view_right called"
customer = context[:customer] 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, { # Nothing upcoming and no history: keep the customer page clean
partial: 'customer_appointments/list_simple', locals: { appointments: appointments } 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 end
@@ -37,4 +44,4 @@ module RedmineQboCalendar
end end
end end
end end
end end␍