Deliverable: persist omgJobNumber through create / update / edit pre-fill
The OMG # field was registered on the form + validator but never made
it onto the prisma write — `createDeliverable` destructured a fixed
list of columns and the new field wasn't on it. Same gap on the
update path. Also the edit dialog never pre-filled the current value
when reopening.
- createDeliverable: include omgJobNumber (empty string → null).
- updateDeliverable: normalise omgJobNumber the same way before
passing to prisma.deliverable.update.
- Deliverable detail page edit dialog: defaultValues now seeds
omgJobNumber from the loaded row.
Empty-string normalisation matters because of the unique-per-org
constraint — two manual deliverables both clearing the field would
otherwise collide on `""`.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
0b0b3bfadc
commit
80a16e68e8
2 changed files with 17 additions and 1 deletions
|
|
@ -533,6 +533,7 @@ export default function DeliverableDetailPage() {
|
|||
isPending={updateDeliverable.isPending}
|
||||
defaultValues={{
|
||||
name: deliverable.name,
|
||||
omgJobNumber: deliverable.omgJobNumber ?? undefined,
|
||||
priority: deliverable.priority,
|
||||
dueDate: deliverable.dueDate
|
||||
? new Date(deliverable.dueDate).toISOString().slice(0, 10)
|
||||
|
|
|
|||
|
|
@ -130,6 +130,12 @@ export async function createDeliverable(
|
|||
const deliverable = await tx.deliverable.create({
|
||||
data: {
|
||||
name: data.name,
|
||||
// Empty string → null so the unique constraint doesn't trip
|
||||
// when two manual deliverables both leave the field blank.
|
||||
omgJobNumber:
|
||||
data.omgJobNumber && data.omgJobNumber.trim() !== ""
|
||||
? data.omgJobNumber.trim()
|
||||
: null,
|
||||
priority: data.priority,
|
||||
notes: data.notes,
|
||||
projectId,
|
||||
|
|
@ -351,9 +357,18 @@ export async function updateDeliverable(
|
|||
};
|
||||
}
|
||||
|
||||
// Normalise omgJobNumber: empty string → null so the unique-per-org
|
||||
// constraint doesn't trip when two deliverables both clear the field.
|
||||
const normalised: typeof data = { ...data };
|
||||
if (Object.prototype.hasOwnProperty.call(normalised, "omgJobNumber")) {
|
||||
const v = (normalised as any).omgJobNumber;
|
||||
(normalised as any).omgJobNumber =
|
||||
typeof v === "string" && v.trim() !== "" ? v.trim() : null;
|
||||
}
|
||||
|
||||
const deliverable = await prisma.deliverable.update({
|
||||
where: { id },
|
||||
data,
|
||||
data: normalised,
|
||||
});
|
||||
|
||||
// Regenerate embedding asynchronously (non-blocking)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue