Appointment statuses in the plugin settings; call-outs as their own entry

Statuses (name, colour, counts toward hours, order) are set up on the plugin's settings page
instead of being hard-coded. Appointments keep a fixed key, so renaming is safe; removing a status
in use asks which status to move its appointments to (done on save by a SettingsController hook).
Colours come from the settings everywhere statuses show, which also fixes Cancelled never being
coloured (cancelled/canceled mismatch).

Call-outs (an employee off work) are their own kind of entry (event_type 'call_out') with an
employee, date, days and notes, added from a button on each calendar day. They sit at the top of
the day in red stripes and never count toward hours. Migration 004 converts Call_Out appointments.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
rickyandClaude Opus 5.5 committed 2026-11-02 20:22:52 -05:00
1 parent f2a16b1821
commit 31356ac3fb
23 files changed
+536 -252

No files matched your search

@@ -51,7 +51,12 @@ class CustomerAppointmentsController < ApplicationController
.includes(:customer, :vehicle, :user)
.where('date < ?', Time.zone.now.beginning_of_day)
scope = scope.where(customer_id: @customer.id) if @customer
scope = scope.where(status: @status) if @status
# The status filter also offers call-outs, which have no status
if @status == CustomerAppointment::CALL_OUT
scope = scope.where(event_type: CustomerAppointment::CALL_OUT)
elsif @status
scope = scope.where(status: @status).where(event_type: [nil, ''])
end
scope = scope.where('date >= ?', @from.in_time_zone.beginning_of_day) if @from
scope = scope.where('date <= ?', @to.in_time_zone.end_of_day) if @to
@@ -72,6 +77,9 @@ class CustomerAppointmentsController < ApplicationController
def new
@appointment = CustomerAppointment.new
@appointment.project = @project
# The calendar's "call-out" link makes an employee's call-out instead of a customer appointment
@appointment.event_type = CustomerAppointment::CALL_OUT if params[:event_type] == CustomerAppointment::CALL_OUT
@appointment.status = RedmineQboCalendar::AppointmentStatus.default.key unless @appointment.call_out?
@appointment.date = (params[:start_date].to_date + 9.hours) if params[:start_date].present?
@appointment.customer_id = params[:customer_id] if params[:customer_id].present?
prefill_estimate_and_vehicle
@@ -137,6 +145,7 @@ class CustomerAppointmentsController < ApplicationController
:vehicle_id,
:description,
:status,
:event_type,
:user_id,
:date,
:estimated_hours,