From 3ebe3505caea08e517fcef16e904de00a4003018 Mon Sep 17 00:00:00 2001 From: Rick Barrette Date: Mon, 9 Nov 2026 19:54:44 -0500 Subject: [PATCH] Weekday in appointment header; monthly totals on the calendar - Appointment view: show the day of the week on the start and end dates, and lay the header out as a flex row so it no longer wraps under the action links - Calendar: month total of estimated hours and appointments in the toolbar, counting only the shown month's days (hidden past weeks included) Co-Authored-By: Claude Opus 5.5 --- app/views/common/_calendar.html.erb | 27 ++++++++++++++-- app/views/customer_appointments/show.html.erb | 18 ++++++----- assets/stylesheets/customer_appointments.css | 32 +++++++++++++++++++ config/locales/en.yml | 1 + 4 files changed, 68 insertions(+), 10 deletions(-) diff --git a/app/views/common/_calendar.html.erb b/app/views/common/_calendar.html.erb index 882088a..70698d0 100644 --- a/app/views/common/_calendar.html.erb +++ b/app/views/common/_calendar.html.erb @@ -65,6 +65,18 @@ days.each { |d| issue_hours_by_day[d] += issue.estimated_hours.to_f / days.size } end end + + # A day's estimated hours: its share of issues plus its appointments + day_hours = lambda do |day| + issue_hours_by_day[day] + appointments_by_day.fetch(day, []).sum { |appointment, number| appointment_hours.call(appointment, number) } + end + + # Month totals: only the shown month's own days (not the neighbouring months' days that fill out the + # first and last weeks), and including weeks hidden by "Hide Past Weeks" + month_days = (calendar.startdt..calendar.enddt).select { |d| d.month == calendar.month } + monthly_total_hours = month_days.sum { |d| day_hours.call(d) } + monthly_appointment_count = month_days.flat_map { |d| appointments_by_day.fetch(d, []).map(&:first) } + .uniq.count { |a| !a.call_out? && a.counts_toward_hours? } %> <%# Calendar Status Legend Key: the statuses set up in the plugin settings, then call-outs %> @@ -88,7 +100,18 @@ <% end %> -
+
+ + <%# Month totals, on the left; cancelled appointments and call-outs aren't counted %> +
+ <%= l(:label_month_total, month: month_name(calendar.month), default: "#{month_name(calendar.month)} total") %>: + + <%= monthly_total_hours.round(1) %>h + + + <%= monthly_appointment_count %> <%= l(:label_appointments).downcase %> + +
<% if is_current_month %>
-

+

<% if @appointment.date %>
<%= @appointment.date.strftime('%b').upcase %>
@@ -41,16 +41,18 @@
<% end %> - <%= @appointment.subject %> +
+ <%= @appointment.subject %> - <% if @appointment.date %> - (<%= format_date(@appointment.date) %> <%= l(:label_at, default: 'at') %> <%= @appointment.date.strftime('%I:%M %p') %> - <% if @appointment.respond_to?(:due_date) && @appointment.due_date.present? && @appointment.duration.to_i > 1 %> - - <%= format_date(@appointment.due_date) %> - <% end %>) + + <%= day_name(@appointment.date.wday) %>, <%= format_date(@appointment.date) %> <%= l(:label_at, default: 'at') %> <%= @appointment.date.strftime('%I:%M %p') %> + <% if @appointment.respond_to?(:due_date) && @appointment.due_date.present? && @appointment.duration.to_i > 1 %> + – <%= day_name(@appointment.due_date.wday) %>, <%= format_date(@appointment.due_date) %> + <% end %> + <% end %> - +

<%# Quick status buttons; call-outs have no status %> diff --git a/assets/stylesheets/customer_appointments.css b/assets/stylesheets/customer_appointments.css index fea5112..6661d00 100644 --- a/assets/stylesheets/customer_appointments.css +++ b/assets/stylesheets/customer_appointments.css @@ -268,6 +268,38 @@ h2 .appointment-title { vertical-align: middle; } +/* Show view header: a flex box sits beside the floated .contextual links instead of + wrapping under them; the dates get their own line below the title */ +h2.appointment-header { + display: flex; + align-items: center; + gap: 10px; +} + +h2.appointment-header .calendar-badge { + flex-shrink: 0; + margin-right: 0; +} + +.appointment-heading { + min-width: 0; +} + +.appointment-heading .appointment-title { + display: block; + overflow-wrap: anywhere; +} + +.appointment-heading .appointment-dates { + display: block; + margin-left: 0; + margin-top: 2px; +} + +.appointment-heading .appointment-date { + white-space: nowrap; +} + /* ========================================================================== Status colours: each status's colour (set in the plugin settings) arrives as --status-color ========================================================================== */ diff --git a/config/locales/en.yml b/config/locales/en.yml index 1542870..f1a60b0 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -57,6 +57,7 @@ en: label_estimated_hours: Estimated Time label_event: Event label_hide_past_weeks: "Hide Past Weeks" + label_month_total: "%{month} total" label_holiday_edit: Edit Holiday label_holiday_new: New Holiday label_holiday_plural: Holidays