mirror of
https://github.com/rickbarrette/redmine_qbo_calendar.git
synced 2026-11-18 06:00:40 -05:00
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:
6 files changed
+77
-45
No files matched your search
@@ -120,6 +120,16 @@
|
||||
|
||||
<!-- Toggle Bar -->
|
||||
<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 %>
|
||||
<button type="button"
|
||||
onclick="scrollToToday()"
|
||||
|
||||
@@ -1,58 +1,49 @@
|
||||
<h4><%=t(:label_appointments)%>:</h4>
|
||||
<div class="customer-appointments-simple">
|
||||
<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>
|
||||
|
||||
<h4><%= l(:label_upcoming_customer_appointments) %>:</h4>
|
||||
|
||||
<% 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>
|
||||
|
||||
<%= link_to appointment %>
|
||||
|
||||
<% if appointment.status.present? %>
|
||||
<span class="status-badge status-<%= appointment.status.to_s.parameterize %>">
|
||||
<%= appointment.status.to_s.humanize %>
|
||||
</span>
|
||||
<% end %>
|
||||
</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>
|
||||
<% else %>
|
||||
<p class="nodata"><%= l(:label_no_upcoming_appointments) %></p>
|
||||
<% end %>
|
||||
|
||||
</tbody>
|
||||
|
||||
</table>
|
||||
<% if past_count.to_i > 0 %>
|
||||
<p class="appointment-history-link">
|
||||
<%= link_to history_customer_appointments_path(customer_id: customer.id) do %>
|
||||
<i class="fa-solid fa-clock-rotate-left"></i>
|
||||
<%= l(:label_view_past_appointments, count: past_count) %>
|
||||
<% end %>
|
||||
</p>
|
||||
<% end %>
|
||||
</div>
|
||||
@@ -19,7 +19,13 @@
|
||||
<% if appointment.customer %>
|
||||
<tr>
|
||||
<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>
|
||||
<% end %>
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
# 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 }
|
||||
partial: 'customer_appointments/list_simple',
|
||||
locals: { appointments: appointments, customer: customer, past_count: past_count }
|
||||
})
|
||||
|
||||
end
|
||||
|
||||
Reference in new issue
Block a user