diff --git a/scripts/setup-remote.ts b/scripts/setup-remote.ts index eeee903..97e601f 100644 --- a/scripts/setup-remote.ts +++ b/scripts/setup-remote.ts @@ -360,6 +360,31 @@ async function ensureCardNarrativeFields(pb: PocketBase): Promise { } } +async function ensureSubtaskDateFields(pb: PocketBase): Promise { + const subtasks = await pb.collections.getOne("subtasks"); + const have = new Set(subtasks.fields.map((f: { name: string }) => f.name)); + + const fields = [...(subtasks.fields as unknown[])]; + let changed = false; + + for (const field of [ + { name: "start_date", type: "date", required: false }, + { name: "target_date", type: "date", required: false }, + ]) { + if (!have.has(field.name)) { + fields.push({ ...field, presentable: false, hidden: false, system: false }); + changed = true; + } + } + + if (changed) { + await pb.collections.update(subtasks.id, { fields }); + console.log(" + subtasks fields: start_date, target_date"); + } else { + console.log(" = subtasks date fields already present"); + } +} + async function ensureCardNumbers(pb: PocketBase): Promise { const cards = await pb.collections.getOne("cards"); const have = new Set(cards.fields.map((f: { name: string }) => f.name)); @@ -505,6 +530,29 @@ async function ensureCardProposalFields(pb: PocketBase): Promise { } } +async function ensureCardAssigneeField(pb: PocketBase): Promise { + const cards = await pb.collections.getOne("cards"); + const have = new Set(cards.fields.map((f: { name: string }) => f.name)); + + if (have.has("assignee")) { + console.log(" = cards.assignee already present"); + return; + } + + const fields = [...(cards.fields as unknown[])]; + fields.push({ + name: "assignee", + type: "text", + required: false, + max: 120, + presentable: false, + hidden: false, + system: false, + }); + await pb.collections.update(cards.id, { fields }); + console.log(" + cards field: assignee"); +} + /** * Extend the activity `action` select with Plan Puzzle v1's three new values: * `column_changed`, `date_proposed`, `date_proposal_resolved`. Existing rows @@ -1525,6 +1573,11 @@ async function main(): Promise { // Add the Plan Puzzle v1 proposal fields and the partial index. await ensureCardProposalFields(pb); + // Add the Gantt plan redesign's optional assignee text and the subtask + // date fields (Phase 10). + await ensureCardAssigneeField(pb); + await ensureSubtaskDateFields(pb); + // Extend activity.action with the three new puzzle actions. await ensureActivityActionValues(pb); diff --git a/src/lib/pb/types.ts b/src/lib/pb/types.ts index fe3be3a..3549168 100644 --- a/src/lib/pb/types.ts +++ b/src/lib/pb/types.ts @@ -114,6 +114,8 @@ export interface CardRecord extends BaseRecord { proposed_target_date?: string; proposed_by?: string; proposed_at?: string; + /** Free-text label rendered above the card bar on the Gantt. Optional. */ + assignee: string; } export interface SubtaskRecord extends BaseRecord { @@ -121,6 +123,10 @@ export interface SubtaskRecord extends BaseRecord { title: string; done: boolean; position: number; + /** ISO date string, or "" when unset. Mirrors cards.start_date. */ + start_date: string; + /** ISO date string, or "" when unset. Mirrors cards.target_date. */ + target_date: string; } export interface CommentRecord extends BaseRecord {