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

+20 -1
View File
@@ -4,6 +4,21 @@
<%= error_messages_for @appointment %>
<div class="box tabular">
<%= f.hidden_field :event_type %>
<% if @appointment.call_out? %>
<%# An employee off work: no customer, vehicle, estimate, hours or status %>
<p>
<label for="customer_appointment_user_id"><%= l(:label_employee) %> <span class="required">*</span></label>
<%= f.collection_select :user_id, User.active.sorted, :id, :name, { include_blank: true }, { label: false } %>
</p>
<p>
<%= f.text_field :subject, style: "width: 95%;", placeholder: l(:text_call_out_subject_placeholder) %>
</p>
<p><%= f.datetime_local_field :date %></p>
<p><%= f.number_field :duration, step: 1, size: 6, label: :label_duration %></p>
<% else %>
<p><%= f.text_field :subject, required: true, style: "width: 95%;" %></p>
<p>
@@ -33,7 +48,11 @@
<p><%= f.number_field :estimated_hours, step: 1, size: 6 %></p>
<p><%= f.number_field :duration, step: 1, size: 6, label: :label_duration %></p>
<p><%= f.select :status, CustomerAppointment::STATUSES, label: :field_status %></p>
<%# The statuses set up in the plugin settings, plus a removed one this appointment still has %>
<% status_options = CustomerAppointment.status_options %>
<% status_options += [[@appointment.status_record.name, @appointment.status]] if @appointment.status.present? && !@appointment.status_record.known? %>
<p><%= f.select :status, status_options, label: :field_status %></p>
<% end %>
<p>
<%= f.text_area :description,