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 <noreply@anthropic.com>
This commit is contained in:
rickyandClaude Opus 5.5 committed 2026-11-09 19:54:44 -05:00
1 parent 82d8d13a27
commit 3ebe3505ca
4 files changed
+68 -10

No files matched your search

+25 -2
View File
@@ -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 %>
<!-- 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; flex-wrap: wrap;">
<%# Month totals, on the left; cancelled appointments and call-outs aren't counted %>
<div class="monthly-totals" style="margin-right: auto; display: inline-flex; align-items: center; gap: 12px; font-size: 0.95em; color: #444;">
<strong><%= l(:label_month_total, month: month_name(calendar.month), default: "#{month_name(calendar.month)} total") %>:</strong>
<span class="monthly-hours-total" title="<%= l(:label_estimated_hours, default: 'Estimated hours') %>">
<i class="fa-regular fa-clock"></i> <strong><%= monthly_total_hours.round(1) %>h</strong>
</span>
<span class="monthly-appointments-total" title="<%= l(:label_appointments) %>">
<i class="fa-regular fa-calendar-check"></i> <strong><%= monthly_appointment_count %></strong> <%= l(:label_appointments).downcase %>
</span>
</div>
<% if is_current_month %>
<button type="button"
@@ -168,7 +191,7 @@
[call_out, time]
end
day_total_hours = issue_hours_by_day[day] + day_appointments.sum { |appointment, number| appointment_hours.call(appointment, number) }
day_total_hours = day_hours.call(day)
weekly_total_hours += day_total_hours
# Store it so we don't calculate it twice
+10 -8
View File
@@ -33,7 +33,7 @@
<% end %>
</div>
<h2>
<h2 class="appointment-header">
<% if @appointment.date %>
<div class="calendar-badge">
<div class="month"><%= @appointment.date.strftime('%b').upcase %></div>
@@ -41,16 +41,18 @@
</div>
<% end %>
<span class="appointment-title"><%= @appointment.subject %></span>
<div class="appointment-heading">
<span class="appointment-title"><%= @appointment.subject %></span>
<span class="appointment-dates">
<% 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 %>)
<span class="appointment-dates">
<span class="appointment-date"><%= day_name(@appointment.date.wday) %>, <%= format_date(@appointment.date) %> <%= l(:label_at, default: 'at') %> <%= @appointment.date.strftime('%I:%M %p') %></span>
<% if @appointment.respond_to?(:due_date) && @appointment.due_date.present? && @appointment.duration.to_i > 1 %>
&ndash; <span class="appointment-date"><%= day_name(@appointment.due_date.wday) %>, <%= format_date(@appointment.due_date) %></span>
<% end %>
</span>
<% end %>
</span>
</div>
</h2>
<%# Quick status buttons; call-outs have no status %>
@@ -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
========================================================================== */
+1
View File
@@ -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