Fix duplicate template due date being silently cleared

duplicate() blanked next_due along with location/asset, but title/
description/notes/etc. all stayed filled in — so a duplicated
template looked fully populated while due date was actually empty,
and the combined 'Title and first due date are required' error didn't
say which field was missing. Adding another room to an existing
schedule normally wants the same due date as the rest of the group
anyway, so carry it over from the source template instead of clearing
it; only location/asset genuinely need re-picking. Error messages now
name the specific missing field.
This commit is contained in:
jtricerolph 2026-08-26 11:53:54 +00:00
parent ee23cb1b16
commit 690de73172

View file

@ -124,7 +124,7 @@ export default function Recurring() {
title: t.title, description: t.description || '',
location_id: '', asset_id: '', priority: t.priority,
unusable: t.unusable, interval_value: t.interval_value, interval_unit: t.interval_unit,
next_due: '', template_notes: t.template_notes, active: true,
next_due: t.next_due.slice(0, 10), template_notes: t.template_notes, active: true,
schedule_mode: t.schedule_mode, group_name: t.group_name || '',
assignment: {
assigned_type: t.assigned_type, assigned_to: t.assigned_to,
@ -145,10 +145,9 @@ export default function Recurring() {
}
async function save() {
if (!form || !form.title.trim() || !form.next_due) {
setError('Title and first due date are required')
return
}
if (!form) return
if (!form.title.trim()) { setError('Title is required'); return }
if (!form.next_due) { setError(form.id ? 'Next due date is required' : 'First due date is required'); return }
if (form.multiLocation) {
if (!form.group_name.trim()) { setError('A group name is required when creating for multiple locations'); return }
if (form.location_ids.length === 0) { setError('Select at least one location'); return }