@activecollab/components 2.0.577 → 2.0.578
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/presentation/myWork/MyWorkTasks.js +83 -30
- package/dist/cjs/presentation/myWork/MyWorkTasks.js.map +1 -1
- package/dist/cjs/presentation/myWork/agendaGrid.js +1095 -0
- package/dist/cjs/presentation/myWork/agendaGrid.js.map +1 -0
- package/dist/cjs/presentation/shared/settings.js +6 -2
- package/dist/cjs/presentation/shared/settings.js.map +1 -1
- package/dist/cjs/presentation/shared/tokens.js +8 -1
- package/dist/cjs/presentation/shared/tokens.js.map +1 -1
- package/dist/cjs/presentation/timeboxes/AdjustmentList.js +31 -0
- package/dist/cjs/presentation/timeboxes/AdjustmentList.js.map +1 -0
- package/dist/cjs/presentation/timeboxes/AgendaDayView.js +1722 -0
- package/dist/cjs/presentation/timeboxes/AgendaDayView.js.map +1 -0
- package/dist/cjs/presentation/timeboxes/CapacityBar.js +54 -0
- package/dist/cjs/presentation/timeboxes/CapacityBar.js.map +1 -0
- package/dist/cjs/presentation/timeboxes/SimulationCard.js +47 -0
- package/dist/cjs/presentation/timeboxes/SimulationCard.js.map +1 -0
- package/dist/cjs/presentation/timeboxes/SimulationPanel.js +319 -0
- package/dist/cjs/presentation/timeboxes/SimulationPanel.js.map +1 -0
- package/dist/cjs/presentation/timeboxes/TimeRecordsSection.js +206 -0
- package/dist/cjs/presentation/timeboxes/TimeRecordsSection.js.map +1 -0
- package/dist/cjs/presentation/timeboxes/WorkloadView.js +887 -0
- package/dist/cjs/presentation/timeboxes/WorkloadView.js.map +1 -0
- package/dist/cjs/presentation/timeboxes/__tests__/timeboxes.test.js +699 -0
- package/dist/cjs/presentation/timeboxes/__tests__/timeboxes.test.js.map +1 -0
- package/dist/cjs/presentation/timeboxes/changes.js +293 -0
- package/dist/cjs/presentation/timeboxes/changes.js.map +1 -0
- package/dist/cjs/presentation/timeboxes/mockData.js +320 -0
- package/dist/cjs/presentation/timeboxes/mockData.js.map +1 -0
- package/dist/cjs/presentation/timeboxes/model.js +186 -0
- package/dist/cjs/presentation/timeboxes/model.js.map +1 -0
- package/dist/cjs/presentation/timeboxes/pillLook.js +72 -0
- package/dist/cjs/presentation/timeboxes/pillLook.js.map +1 -0
- package/dist/cjs/presentation/timeboxes/plan.js +181 -0
- package/dist/cjs/presentation/timeboxes/plan.js.map +1 -0
- package/dist/cjs/presentation/timeboxes/reducer.js +763 -0
- package/dist/cjs/presentation/timeboxes/reducer.js.map +1 -0
- package/dist/cjs/presentation/timeboxes/scheduler.js +147 -0
- package/dist/cjs/presentation/timeboxes/scheduler.js.map +1 -0
- package/dist/cjs/presentation/timeboxes/store.js +65 -0
- package/dist/cjs/presentation/timeboxes/store.js.map +1 -0
- package/dist/cjs/presentation/timeboxes/timeBlocks.js +1931 -0
- package/dist/cjs/presentation/timeboxes/timeBlocks.js.map +1 -0
- package/dist/cjs/presentation/timeboxes/timeboxSettings.js +369 -0
- package/dist/cjs/presentation/timeboxes/timeboxSettings.js.map +1 -0
- package/dist/cjs/presentation/timeboxes/tracked.js +189 -0
- package/dist/cjs/presentation/timeboxes/tracked.js.map +1 -0
- package/dist/esm/presentation/myWork/MyWorkTasks.d.ts +81 -1
- package/dist/esm/presentation/myWork/MyWorkTasks.d.ts.map +1 -1
- package/dist/esm/presentation/myWork/MyWorkTasks.js +76 -23
- package/dist/esm/presentation/myWork/MyWorkTasks.js.map +1 -1
- package/dist/esm/presentation/myWork/agendaGrid.d.ts +341 -0
- package/dist/esm/presentation/myWork/agendaGrid.d.ts.map +1 -0
- package/dist/esm/presentation/myWork/agendaGrid.js +1001 -0
- package/dist/esm/presentation/myWork/agendaGrid.js.map +1 -0
- package/dist/esm/presentation/shared/settings.d.ts +2 -0
- package/dist/esm/presentation/shared/settings.d.ts.map +1 -1
- package/dist/esm/presentation/shared/settings.js +5 -1
- package/dist/esm/presentation/shared/settings.js.map +1 -1
- package/dist/esm/presentation/shared/tokens.d.ts +6 -0
- package/dist/esm/presentation/shared/tokens.d.ts.map +1 -1
- package/dist/esm/presentation/shared/tokens.js +7 -0
- package/dist/esm/presentation/shared/tokens.js.map +1 -1
- package/dist/esm/presentation/timeboxes/AdjustmentList.d.ts +11 -0
- package/dist/esm/presentation/timeboxes/AdjustmentList.d.ts.map +1 -0
- package/dist/esm/presentation/timeboxes/AdjustmentList.js +22 -0
- package/dist/esm/presentation/timeboxes/AdjustmentList.js.map +1 -0
- package/dist/esm/presentation/timeboxes/AgendaDayView.d.ts +15 -0
- package/dist/esm/presentation/timeboxes/AgendaDayView.d.ts.map +1 -0
- package/dist/esm/presentation/timeboxes/AgendaDayView.js +1524 -0
- package/dist/esm/presentation/timeboxes/AgendaDayView.js.map +1 -0
- package/dist/esm/presentation/timeboxes/CapacityBar.d.ts +15 -0
- package/dist/esm/presentation/timeboxes/CapacityBar.d.ts.map +1 -0
- package/dist/esm/presentation/timeboxes/CapacityBar.js +48 -0
- package/dist/esm/presentation/timeboxes/CapacityBar.js.map +1 -0
- package/dist/esm/presentation/timeboxes/SimulationCard.d.ts +13 -0
- package/dist/esm/presentation/timeboxes/SimulationCard.d.ts.map +1 -0
- package/dist/esm/presentation/timeboxes/SimulationCard.js +41 -0
- package/dist/esm/presentation/timeboxes/SimulationCard.js.map +1 -0
- package/dist/esm/presentation/timeboxes/SimulationPanel.d.ts +18 -0
- package/dist/esm/presentation/timeboxes/SimulationPanel.d.ts.map +1 -0
- package/dist/esm/presentation/timeboxes/SimulationPanel.js +267 -0
- package/dist/esm/presentation/timeboxes/SimulationPanel.js.map +1 -0
- package/dist/esm/presentation/timeboxes/TimeRecordsSection.d.ts +14 -0
- package/dist/esm/presentation/timeboxes/TimeRecordsSection.d.ts.map +1 -0
- package/dist/esm/presentation/timeboxes/TimeRecordsSection.js +159 -0
- package/dist/esm/presentation/timeboxes/TimeRecordsSection.js.map +1 -0
- package/dist/esm/presentation/timeboxes/WorkloadView.d.ts +9 -0
- package/dist/esm/presentation/timeboxes/WorkloadView.d.ts.map +1 -0
- package/dist/esm/presentation/timeboxes/WorkloadView.js +761 -0
- package/dist/esm/presentation/timeboxes/WorkloadView.js.map +1 -0
- package/dist/esm/presentation/timeboxes/__tests__/timeboxes.test.d.ts +2 -0
- package/dist/esm/presentation/timeboxes/__tests__/timeboxes.test.d.ts.map +1 -0
- package/dist/esm/presentation/timeboxes/__tests__/timeboxes.test.js +640 -0
- package/dist/esm/presentation/timeboxes/__tests__/timeboxes.test.js.map +1 -0
- package/dist/esm/presentation/timeboxes/changes.d.ts +72 -0
- package/dist/esm/presentation/timeboxes/changes.d.ts.map +1 -0
- package/dist/esm/presentation/timeboxes/changes.js +224 -0
- package/dist/esm/presentation/timeboxes/changes.js.map +1 -0
- package/dist/esm/presentation/timeboxes/mockData.d.ts +16 -0
- package/dist/esm/presentation/timeboxes/mockData.d.ts.map +1 -0
- package/dist/esm/presentation/timeboxes/mockData.js +297 -0
- package/dist/esm/presentation/timeboxes/mockData.js.map +1 -0
- package/dist/esm/presentation/timeboxes/model.d.ts +136 -0
- package/dist/esm/presentation/timeboxes/model.d.ts.map +1 -0
- package/dist/esm/presentation/timeboxes/model.js +129 -0
- package/dist/esm/presentation/timeboxes/model.js.map +1 -0
- package/dist/esm/presentation/timeboxes/pillLook.d.ts +40 -0
- package/dist/esm/presentation/timeboxes/pillLook.d.ts.map +1 -0
- package/dist/esm/presentation/timeboxes/pillLook.js +65 -0
- package/dist/esm/presentation/timeboxes/pillLook.js.map +1 -0
- package/dist/esm/presentation/timeboxes/plan.d.ts +62 -0
- package/dist/esm/presentation/timeboxes/plan.d.ts.map +1 -0
- package/dist/esm/presentation/timeboxes/plan.js +116 -0
- package/dist/esm/presentation/timeboxes/plan.js.map +1 -0
- package/dist/esm/presentation/timeboxes/reducer.d.ts +203 -0
- package/dist/esm/presentation/timeboxes/reducer.d.ts.map +1 -0
- package/dist/esm/presentation/timeboxes/reducer.js +616 -0
- package/dist/esm/presentation/timeboxes/reducer.js.map +1 -0
- package/dist/esm/presentation/timeboxes/scheduler.d.ts +63 -0
- package/dist/esm/presentation/timeboxes/scheduler.d.ts.map +1 -0
- package/dist/esm/presentation/timeboxes/scheduler.js +120 -0
- package/dist/esm/presentation/timeboxes/scheduler.js.map +1 -0
- package/dist/esm/presentation/timeboxes/store.d.ts +23 -0
- package/dist/esm/presentation/timeboxes/store.d.ts.map +1 -0
- package/dist/esm/presentation/timeboxes/store.js +46 -0
- package/dist/esm/presentation/timeboxes/store.js.map +1 -0
- package/dist/esm/presentation/timeboxes/timeBlocks.d.ts +10 -0
- package/dist/esm/presentation/timeboxes/timeBlocks.d.ts.map +1 -0
- package/dist/esm/presentation/timeboxes/timeBlocks.js +1767 -0
- package/dist/esm/presentation/timeboxes/timeBlocks.js.map +1 -0
- package/dist/esm/presentation/timeboxes/timeboxSettings.d.ts +71 -0
- package/dist/esm/presentation/timeboxes/timeboxSettings.d.ts.map +1 -0
- package/dist/esm/presentation/timeboxes/timeboxSettings.js +302 -0
- package/dist/esm/presentation/timeboxes/timeboxSettings.js.map +1 -0
- package/dist/esm/presentation/timeboxes/tracked.d.ts +51 -0
- package/dist/esm/presentation/timeboxes/tracked.d.ts.map +1 -0
- package/dist/esm/presentation/timeboxes/tracked.js +136 -0
- package/dist/esm/presentation/timeboxes/tracked.js.map +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"reducer.js","names":["describeChange","MINUTES_PER_DAY","SNAP_MINUTES","allocationOn","availableDays","clockToMinutes","evenSpread","formatMinutes","isSplit","isTimebox","minutesToClock","partsOf","pinnedOn","rangeOf","snap","snapDown","timeboxesOn","untimedOn","untimedPartOn","lastAvailableDay","taskById","userOf","ok","state","validMinutes","minutes","Number","isInteger","MINUTES_ERROR","fail","error","newPartId","nextId","_extends","setUntimed","taskId","date","existing","parts","filter","part","map","durationMinutes","_newPartId","id","next","startsOnTime","addTimebox","start","_newPartId2","updateTask","patch","tasks","task","partById","partId","find","ensureSplit","context","estimate","spread","forEach","blockingTimeboxes","_state$tasks$find","item","assigneeId","sameTaskTimeboxes","exceptPartId","touches","a","b","end","mergeTargets","range","union","rest","joined","reached","length","push","includes","reduce","all","Math","min","max","mergeTimeboxes","keepPartId","total","sum","runs","runEnd","run","every","_run$find","keep","dayValueRange","_task$estimate","_lastAvailableDay","user","days","before","day","locked","dayValueError","fitTimeboxes","excess","latestFirst","reverse","settings","minGapMinutes","editDayValue","_task$estimate2","totals","set","previewDayValue","result","type","timeboxes","kind","draggableMinutes","planDrop","dropAt","others","own","some","nextPinned","first","available","planMove","previousEnd","last","nextStart","planResize","_days","reason","minLength","newStart","newEnd","_mergeTargets","merges","growth","untimed","allocation","stopAt","limit","allowed","to","_dayValueRange","from","increaseConfirmText","name","unsplitConfirmText","pinned","pin","_untimedPartOn$durati","_untimedPartOn","joins","action","suggestions","plan","allowIncrease","_untimedPartOn$durati2","_untimedPartOn2","_spread$get","get","isCompleted","completed","subtasks","subtask","subtaskId","event","endsOnTime","undefined","events","_action$userId","timeRecords","userId","recordDate","record"],"sources":["../../../../src/presentation/timeboxes/reducer.ts"],"sourcesContent":["import { TimeboxChange, describeChange } from \"./changes\";\nimport {\n DateKey,\n MINUTES_PER_DAY,\n SNAP_MINUTES,\n TbEvent,\n TbPart,\n TbSettings,\n TbState,\n TbTask,\n TimeRange,\n allocationOn,\n availableDays,\n clockToMinutes,\n evenSpread,\n formatMinutes,\n isSplit,\n isTimebox,\n minutesToClock,\n partsOf,\n pinnedOn,\n rangeOf,\n snap,\n snapDown,\n timeboxesOn,\n untimedOn,\n untimedPartOn,\n} from \"./model\";\nimport { TbContext, lastAvailableDay, taskById, userOf } from \"./plan\";\n\nexport type TbAction =\n /** Pin one suggestion; splits the task first when it is not split. */\n | {\n type: \"pin\";\n taskId: number;\n date: DateKey;\n start: number;\n minutes: number;\n }\n /** Pin the day's suggestions in one go. */\n | {\n type: \"pinAll\";\n date: DateKey;\n suggestions: { taskId: number; start: number; minutes: number }[];\n }\n /** A task dropped on the grid (from the list or the All Day row). */\n | { type: \"dropTask\"; taskId: number; date: DateKey; start: number }\n | { type: \"moveTimebox\"; partId: string; start: number }\n /** New edges; allowIncrease after the user confirmed taking minutes\n from the following days. */\n | {\n type: \"resizeTimebox\";\n partId: string;\n start: number;\n end: number;\n allowIncrease?: boolean;\n }\n | { type: \"unpin\"; partId: string }\n | { type: \"editDayValue\"; taskId: number; date: DateKey; minutes: number }\n | { type: \"split\"; taskId: number }\n | { type: \"unsplit\"; taskId: number }\n | { type: \"setEstimate\"; taskId: number; minutes: number | null }\n | { type: \"setCompleted\"; taskId: number; completed: boolean }\n | { type: \"setSubtaskCompleted\"; subtaskId: number; completed: boolean }\n | { type: \"upsertEvent\"; event: Omit<TbEvent, \"id\"> & { id?: number } }\n | { type: \"removeEvent\"; id: number }\n | { type: \"updateSettings\"; settings: Partial<TbSettings> }\n /** Tracked time: whole minutes above 0; it may exceed the plan. */\n | {\n type: \"addTimeRecord\";\n taskId: number;\n recordDate: DateKey;\n minutes: number;\n /** The task's assignee when left out. */\n userId?: number;\n }\n | { type: \"updateTimeRecord\"; id: string; minutes: number }\n | { type: \"removeTimeRecord\"; id: string };\n\n/** The new state, and a message when the action was refused (state\n unchanged) or stopped short (a resize that stops at its edge). */\nexport interface TbResult {\n state: TbState;\n error?: string;\n}\n\nconst ok = (state: TbState): TbResult => ({ state });\n\nconst validMinutes = (minutes: number): boolean =>\n Number.isInteger(minutes) && minutes > 0;\nconst MINUTES_ERROR = \"Tracked time is whole minutes above 0\";\nconst fail = (state: TbState, error: string): TbResult => ({ state, error });\n\n/* ------------------------------------------------------------------ */\n/* Part helpers */\n/* ------------------------------------------------------------------ */\n\nconst newPartId = (state: TbState): [string, TbState] => [\n `p${state.nextId}`,\n { ...state, nextId: state.nextId + 1 },\n];\n\n/** Sets the day's untimed part; 0 removes it. */\nconst setUntimed = (\n state: TbState,\n taskId: number,\n date: DateKey,\n minutes: number\n): TbState => {\n const existing = untimedPartOn(state, taskId, date);\n if (minutes <= 0) {\n return existing\n ? { ...state, parts: state.parts.filter((part) => part !== existing) }\n : state;\n }\n if (existing) {\n return {\n ...state,\n parts: state.parts.map((part) =>\n part === existing ? { ...part, durationMinutes: minutes } : part\n ),\n };\n }\n const [id, next] = newPartId(state);\n return {\n ...next,\n parts: [\n ...next.parts,\n { id, taskId, date, startsOnTime: null, durationMinutes: minutes },\n ],\n };\n};\n\nconst addTimebox = (\n state: TbState,\n taskId: number,\n date: DateKey,\n start: number,\n minutes: number\n): TbState => {\n const [id, next] = newPartId(state);\n return {\n ...next,\n parts: [\n ...next.parts,\n {\n id,\n taskId,\n date,\n startsOnTime: minutesToClock(start),\n durationMinutes: minutes,\n },\n ],\n };\n};\n\nconst updateTask = (\n state: TbState,\n taskId: number,\n patch: Partial<TbTask>\n): TbState => ({\n ...state,\n tasks: state.tasks.map((task) =>\n task.id === taskId ? { ...task, ...patch } : task\n ),\n});\n\nconst partById = (state: TbState, partId: string): TbPart | undefined =>\n state.parts.find((part) => part.id === partId);\n\n/** Splits a task as the app's add(): its estimate spread evenly over the\n assignee's available days, as untimed parts. */\nexport const ensureSplit = (\n state: TbState,\n context: TbContext,\n taskId: number\n): TbState => {\n if (isSplit(state, taskId)) return state;\n const task = taskById(state, taskId);\n if (task.estimate === null) return state;\n const spread = evenSpread(\n task.estimate,\n availableDays(task, userOf(context, task))\n );\n let next = state;\n spread.forEach((minutes, date) => {\n next = setUntimed(next, taskId, date, minutes);\n });\n return next;\n};\n\n/** The timeboxes that block a task on a day: the same assignee's\n timeboxes of other tasks. Only these stop moves, resizes and drops. */\nconst blockingTimeboxes = (\n state: TbState,\n task: TbTask,\n date: DateKey\n): TimeRange[] =>\n state.parts\n .filter(\n (part) =>\n part.date === date &&\n isTimebox(part) &&\n part.taskId !== task.id &&\n state.tasks.find((item) => item.id === part.taskId)?.assigneeId ===\n task.assigneeId\n )\n .map(rangeOf);\n\n/** The task's own timeboxes on a day, except one. */\nconst sameTaskTimeboxes = (\n state: TbState,\n taskId: number,\n date: DateKey,\n exceptPartId?: string\n): TbPart[] =>\n timeboxesOn(state, taskId, date).filter((part) => part.id !== exceptPartId);\n\n/** Two ranges that touch (one ends where the other starts) or overlap. */\nconst touches = (a: TimeRange, b: TimeRange): boolean =>\n a.start <= b.end && b.start <= a.end;\n\n/**\n * The task's own timeboxes on a day a range would join, and the union with\n * them; a timebox the union reaches joins too.\n */\nexport const mergeTargets = (\n state: TbState,\n taskId: number,\n date: DateKey,\n range: TimeRange,\n exceptPartId?: string\n): { parts: TbPart[]; union: TimeRange } => {\n const parts: TbPart[] = [];\n let union = { ...range };\n let rest = sameTaskTimeboxes(state, taskId, date, exceptPartId);\n let joined = true;\n while (joined) {\n joined = false;\n const reached = rest.filter((part) => touches(union, rangeOf(part)));\n if (reached.length > 0) {\n joined = true;\n parts.push(...reached);\n rest = rest.filter((part) => !reached.includes(part));\n union = reached.reduce(\n (all, part) => ({\n start: Math.min(all.start, rangeOf(part).start),\n end: Math.max(all.end, rangeOf(part).end),\n }),\n union\n );\n }\n }\n return { parts, union };\n};\n\n/**\n * Joins the task's touching or overlapping timeboxes on a day into one, the\n * union of their ranges. The run keeps keepPartId when it is in it, else its\n * earliest timebox. The day's total does not change: the untimed part is\n * derived again (minutes an overlap loses go back to it).\n */\nexport const mergeTimeboxes = (\n state: TbState,\n taskId: number,\n date: DateKey,\n keepPartId?: string\n): TbState => {\n const total = partsOf(state, taskId)\n .filter((part) => part.date === date)\n .reduce((sum, part) => sum + part.durationMinutes, 0);\n const runs: TbPart[][] = [];\n let runEnd = -1;\n timeboxesOn(state, taskId, date).forEach((part) => {\n const range = rangeOf(part);\n const run = runs[runs.length - 1];\n if (run && range.start <= runEnd) {\n run.push(part);\n runEnd = Math.max(runEnd, range.end);\n } else {\n runs.push([part]);\n runEnd = range.end;\n }\n });\n if (runs.every((run) => run.length === 1)) return state;\n let next = state;\n runs\n .filter((run) => run.length > 1)\n .forEach((run) => {\n const keep = run.find((part) => part.id === keepPartId) ?? run[0];\n const start = Math.min(...run.map((part) => rangeOf(part).start));\n const end = Math.max(...run.map((part) => rangeOf(part).end));\n next = {\n ...next,\n parts: next.parts\n .filter((part) => part === keep || !run.includes(part))\n .map((part) =>\n part === keep\n ? {\n ...part,\n startsOnTime: minutesToClock(start),\n durationMinutes: end - start,\n }\n : part\n ),\n };\n });\n return setUntimed(next, taskId, date, total - pinnedOn(next, taskId, date));\n};\n\n/* ------------------------------------------------------------------ */\n/* Edit day value */\n/* ------------------------------------------------------------------ */\n\nexport interface DayValueRange {\n min: number;\n max: number;\n /** The last workday: its value follows from the others. */\n locked: boolean;\n}\n\n/**\n * The bounds of a day's total (EstimationsSplitsDialog's maxEstimate):\n * anything from 0 to the estimate less the days before. Timeboxes do not\n * bound it; they are fitted to the new totals (fitTimeboxes).\n */\nexport const dayValueRange = (\n state: TbState,\n context: TbContext,\n taskId: number,\n date: DateKey\n): DayValueRange => {\n const task = taskById(state, taskId);\n const user = userOf(context, task);\n const days = availableDays(task, user);\n const estimate = task.estimate ?? 0;\n const before = days\n .filter((day) => day < date)\n .reduce((total, day) => total + allocationOn(state, task, user, day), 0);\n return {\n min: 0,\n max: estimate - before,\n locked: date >= (lastAvailableDay(task, user) ?? date),\n };\n};\n\n/** The inline error for a day value, or null when it can be saved. */\nexport const dayValueError = (\n state: TbState,\n context: TbContext,\n taskId: number,\n date: DateKey,\n minutes: number\n): string | null => {\n const range = dayValueRange(state, context, taskId, date);\n if (range.locked) return \"The last workday takes what the other days leave\";\n if (minutes < range.min) return \"Enter 0 or more\";\n if (minutes > range.max) {\n return `At most ${formatMinutes(range.max)}: the estimate has no more left`;\n }\n return null;\n};\n\n/**\n * Fits a day's timeboxes into a new total. When the total still holds what\n * is pinned, the timeboxes stay and the untimed part takes the rest.\n * Otherwise the untimed part goes first, then the timeboxes from the latest\n * start back: those no longer needed are deleted, the last one kept is\n * shortened at its end (rounded down to 5 minutes, the leftover minutes\n * untimed), and deleted too when that leaves it under the min gap.\n */\nexport const fitTimeboxes = (\n state: TbState,\n taskId: number,\n date: DateKey,\n total: number\n): TbState => {\n let excess = pinnedOn(state, taskId, date) - total;\n let next = state;\n const latestFirst = [...timeboxesOn(state, taskId, date)].reverse();\n for (const part of latestFirst) {\n if (excess <= 0) break;\n if (excess >= part.durationMinutes) {\n next = {\n ...next,\n parts: next.parts.filter((item) => item.id !== part.id),\n };\n excess -= part.durationMinutes;\n } else {\n const length = snapDown(part.durationMinutes - excess);\n next = {\n ...next,\n parts:\n length < next.settings.minGapMinutes\n ? next.parts.filter((item) => item.id !== part.id)\n : next.parts.map((item) =>\n item.id === part.id\n ? { ...item, durationMinutes: length }\n : item\n ),\n };\n excess = 0;\n }\n }\n return setUntimed(next, taskId, date, total - pinnedOn(next, taskId, date));\n};\n\n/**\n * A new total for one day, as the app's edit(): earlier days stay, the day\n * takes the total, later days share the rest of the estimate evenly. Then\n * the timeboxes of every day whose total was set are fitted into it.\n */\nconst editDayValue = (\n state: TbState,\n context: TbContext,\n taskId: number,\n date: DateKey,\n minutes: number\n): TbResult => {\n const error = dayValueError(state, context, taskId, date, minutes);\n if (error) return fail(state, error);\n const task = taskById(state, taskId);\n const user = userOf(context, task);\n let next = ensureSplit(state, context, taskId);\n const days = availableDays(task, user);\n const before = days\n .filter((day) => day < date)\n .reduce((total, day) => total + allocationOn(next, task, user, day), 0);\n const totals = evenSpread(\n (task.estimate ?? 0) - before - minutes,\n days.filter((day) => day > date)\n );\n totals.set(date, minutes);\n totals.forEach((total, day) => {\n next = fitTimeboxes(next, taskId, day, total);\n });\n return ok(next);\n};\n\n/** The timeboxes an edit of a day's total would shorten or delete,\n without saving it. */\nexport const previewDayValue = (\n state: TbState,\n context: TbContext,\n taskId: number,\n date: DateKey,\n minutes: number\n): TimeboxChange[] => {\n const result = reduce(state, context, {\n type: \"editDayValue\",\n taskId,\n date,\n minutes,\n });\n if (result.error) return [];\n return describeChange(state, result.state, context).timeboxes.filter(\n (item) => item.kind === \"resized\" || item.kind === \"deleted\"\n );\n};\n\n/* ------------------------------------------------------------------ */\n/* Drop, move, resize */\n/* ------------------------------------------------------------------ */\n\n/** How many of the day's minutes a dragged row can still pin. */\nexport const draggableMinutes = (\n state: TbState,\n context: TbContext,\n taskId: number,\n date: DateKey\n): number => {\n const task = taskById(state, taskId);\n if (task.estimate === null) return 60;\n return Math.max(0, untimedOn(state, task, userOf(context, task), date));\n};\n\n/**\n * Where a dropped task lands: at the snapped drop time, as long as its\n * untimed minutes for the day, cut at the next pinned timebox (the rest\n * stays a suggestion) and at midnight. A task without an estimate gets an\n * hour.\n */\nexport const planDrop = (\n state: TbState,\n context: TbContext,\n taskId: number,\n date: DateKey,\n dropAt: number\n): { start: number; minutes: number } | { error: string } => {\n const task = taskById(state, taskId);\n const start = Math.min(snap(dropAt), MINUTES_PER_DAY - SNAP_MINUTES);\n const others = blockingTimeboxes(state, task, date);\n const own = sameTaskTimeboxes(state, taskId, date).map(rangeOf);\n if (\n [...others, ...own].some(\n (range) => range.start <= start && range.end > start\n )\n ) {\n return { error: \"That time is already pinned\" };\n }\n const nextPinned = others\n .filter((range) => range.start > start)\n .reduce((first, range) => Math.min(first, range.start), MINUTES_PER_DAY);\n const available = draggableMinutes(state, context, taskId, date);\n const minutes = snapDown(Math.min(available, nextPinned - start));\n if (minutes < SNAP_MINUTES) {\n return available < SNAP_MINUTES\n ? { error: \"All of today's allocation is scheduled\" }\n : { error: \"No room before the next pinned timebox\" };\n }\n return { start, minutes };\n};\n\n/** A timebox's new start: snapped, kept between its pinned neighbours and\n inside the day. Events may overlap it. */\nexport const planMove = (\n state: TbState,\n partId: string,\n start: number\n): number => {\n const part = partById(state, partId);\n if (!part) return start;\n const task = taskById(state, part.taskId);\n const own = rangeOf(part);\n const others = blockingTimeboxes(state, task, part.date);\n const previousEnd = others\n .filter((range) => range.end <= own.start)\n .reduce((last, range) => Math.max(last, range.end), 0);\n const nextStart = others\n .filter((range) => range.start >= own.end)\n .reduce((first, range) => Math.min(first, range.start), MINUTES_PER_DAY);\n return Math.min(\n Math.max(snap(start), previousEnd),\n nextStart - part.durationMinutes\n );\n};\n\nexport type ResizePlan =\n /** Inside the day's allocation: minutes move to or from the untimed part.\n merges: the task's own timeboxes the new edge reaches; start and end\n are then the union with them. */\n | { kind: \"free\"; start: number; end: number; merges: TbPart[] }\n /** Past the allocation: confirm, then the day's total grows. */\n | {\n kind: \"increase\";\n start: number;\n end: number;\n from: number;\n to: number;\n merges: TbPart[];\n }\n /** The edge stops here. */\n | { kind: \"blocked\"; start: number; end: number; reason: string };\n\n/**\n * A resize: snapped, kept between pinned neighbours and inside the day, at\n * least the min gap long. An edge that reaches one of the task's own\n * timeboxes joins it: the plan is the union, and its growth is the union\n * less both lengths. Growing past the day's allocation takes minutes\n * from the following days, which a one-day task or the task's last day\n * cannot.\n */\nexport const planResize = (\n state: TbState,\n context: TbContext,\n partId: string,\n start: number,\n end: number\n): ResizePlan => {\n const part = partById(state, partId);\n if (!part) return { kind: \"blocked\", start, end, reason: \"\" };\n const task = taskById(state, part.taskId);\n const user = userOf(context, task);\n const own = rangeOf(part);\n const minLength = state.settings.minGapMinutes;\n const others = blockingTimeboxes(state, task, part.date);\n const previousEnd = others\n .filter((range) => range.end <= own.start)\n .reduce((last, range) => Math.max(last, range.end), 0);\n const nextStart = others\n .filter((range) => range.start >= own.end)\n .reduce((first, range) => Math.min(first, range.start), MINUTES_PER_DAY);\n let newStart = Math.max(snap(start), previousEnd);\n let newEnd = Math.min(snap(end), nextStart);\n if (newEnd - newStart < minLength) {\n if (start !== own.start) newStart = newEnd - minLength;\n else newEnd = newStart + minLength;\n }\n\n const { parts: merges, union } = mergeTargets(\n state,\n task.id,\n part.date,\n { start: newStart, end: newEnd },\n partId\n );\n const growth =\n union.end -\n union.start -\n part.durationMinutes -\n merges.reduce((sum, item) => sum + item.durationMinutes, 0);\n const untimed = Math.max(0, untimedOn(state, task, user, part.date));\n if (growth <= untimed) {\n return { kind: \"free\", start: union.start, end: union.end, merges };\n }\n\n const allocation = allocationOn(state, task, user, part.date);\n const days = availableDays(task, user);\n const stopAt = (limit: number, reason: string): ResizePlan => {\n const allowed = part.durationMinutes + limit;\n return start !== own.start\n ? { kind: \"blocked\", start: newEnd - allowed, end: newEnd, reason }\n : { kind: \"blocked\", start: newStart, end: newStart + allowed, reason };\n };\n if (days.length <= 1 || part.date >= (days[days.length - 1] ?? part.date)) {\n return stopAt(\n untimed,\n `Today's allocation is ${formatMinutes(allocation)}`\n );\n }\n const to = allocation + growth - untimed;\n const { max } = dayValueRange(state, context, task.id, part.date);\n if (to > max) {\n return stopAt(\n untimed + max - allocation,\n `At most ${formatMinutes(max)} fits on this day`\n );\n }\n return {\n kind: \"increase\",\n start: union.start,\n end: union.end,\n from: allocation,\n to,\n merges,\n };\n};\n\n/** The confirm dialog's text for growing a day's allocation. */\nexport const increaseConfirmText = (\n task: TbTask,\n from: number,\n to: number\n): string =>\n `Increase today's allocation for ${task.name} from ${formatMinutes(\n from\n )} to ${formatMinutes(to)}? The difference is taken from the following days.`;\n\n/** The confirm dialog's text for unsplitting a task. */\nexport const unsplitConfirmText = (state: TbState, task: TbTask): string => {\n const pinned = partsOf(state, task.id).filter(isTimebox).length;\n return pinned > 0\n ? `Unsplit ${task.name} and remove ${pinned} pinned ${\n pinned === 1 ? \"timebox\" : \"timeboxes\"\n }?`\n : `Unsplit ${task.name}?`;\n};\n\n/* ------------------------------------------------------------------ */\n/* The reducer */\n/* ------------------------------------------------------------------ */\n\nconst pin = (\n state: TbState,\n context: TbContext,\n taskId: number,\n date: DateKey,\n start: number,\n minutes: number\n): TbResult => {\n const next = ensureSplit(state, context, taskId);\n const untimed = untimedPartOn(next, taskId, date)?.durationMinutes ?? 0;\n const pinned = Math.min(minutes, untimed);\n if (pinned <= 0) return fail(state, \"All of today's allocation is scheduled\");\n /* Pinned next to (or over) one of its own timeboxes, the new one joins\n that one, which keeps its id. */\n const joins = mergeTargets(next, taskId, date, {\n start,\n end: start + pinned,\n }).parts[0];\n return ok(\n mergeTimeboxes(\n addTimebox(\n setUntimed(next, taskId, date, untimed - pinned),\n taskId,\n date,\n start,\n pinned\n ),\n taskId,\n date,\n joins?.id\n )\n );\n};\n\nexport const reduce = (\n state: TbState,\n context: TbContext,\n action: TbAction\n): TbResult => {\n switch (action.type) {\n case \"pin\":\n return pin(\n state,\n context,\n action.taskId,\n action.date,\n action.start,\n action.minutes\n );\n\n case \"pinAll\":\n return ok(\n action.suggestions.reduce(\n (next, item) =>\n pin(\n next,\n context,\n item.taskId,\n action.date,\n item.start,\n item.minutes\n ).state,\n state\n )\n );\n\n case \"dropTask\": {\n const task = taskById(state, action.taskId);\n const plan = planDrop(\n state,\n context,\n action.taskId,\n action.date,\n action.start\n );\n if (\"error\" in plan) return fail(state, plan.error);\n let next = state;\n if (task.estimate === null) {\n /* An hour a day over the task's range: the drop pins today's. */\n next = updateTask(next, task.id, {\n estimate: 60 * availableDays(task, userOf(context, task)).length,\n });\n }\n const result = pin(\n next,\n context,\n task.id,\n action.date,\n plan.start,\n plan.minutes\n );\n return result.error ? fail(state, result.error) : result;\n }\n\n case \"moveTimebox\": {\n const part = partById(state, action.partId);\n if (!part) return fail(state, \"No such timebox\");\n const start = planMove(state, action.partId, action.start);\n return ok(\n mergeTimeboxes(\n {\n ...state,\n parts: state.parts.map((item) =>\n item === part\n ? { ...item, startsOnTime: minutesToClock(start) }\n : item\n ),\n },\n part.taskId,\n part.date,\n part.id\n )\n );\n }\n\n case \"resizeTimebox\": {\n const part = partById(state, action.partId);\n if (!part) return fail(state, \"No such timebox\");\n const task = taskById(state, part.taskId);\n const user = userOf(context, task);\n const plan = planResize(\n state,\n context,\n action.partId,\n action.start,\n action.end\n );\n if (plan.kind === \"increase\" && !action.allowIncrease) {\n return fail(state, increaseConfirmText(task, plan.from, plan.to));\n }\n const allocation = allocationOn(state, task, user, part.date);\n let next: TbState = {\n ...state,\n parts: state.parts.map((item) =>\n item === part\n ? {\n ...item,\n startsOnTime: minutesToClock(plan.start),\n durationMinutes: plan.end - plan.start,\n }\n : item\n ),\n };\n /* The plan is the union with any timebox it reaches: those join this\n one; the untimed part follows below. */\n next = mergeTimeboxes(next, task.id, part.date, part.id);\n if (plan.kind === \"increase\") {\n const result = editDayValue(next, context, task.id, part.date, plan.to);\n if (result.error) return fail(state, result.error);\n next = result.state;\n } else {\n next = setUntimed(\n next,\n task.id,\n part.date,\n allocation - pinnedOn(next, task.id, part.date)\n );\n }\n return plan.kind === \"blocked\" ? fail(next, plan.reason) : ok(next);\n }\n\n case \"unpin\": {\n const part = partById(state, action.partId);\n if (!part) return fail(state, \"No such timebox\");\n const untimed =\n untimedPartOn(state, part.taskId, part.date)?.durationMinutes ?? 0;\n const next = {\n ...state,\n parts: state.parts.filter((item) => item !== part),\n };\n return ok(\n setUntimed(next, part.taskId, part.date, untimed + part.durationMinutes)\n );\n }\n\n case \"editDayValue\":\n return editDayValue(\n state,\n context,\n action.taskId,\n action.date,\n action.minutes\n );\n\n case \"split\": {\n const task = taskById(state, action.taskId);\n if (task.estimate === null) return fail(state, \"Set an estimate first\");\n return ok(ensureSplit(state, context, action.taskId));\n }\n\n case \"unsplit\":\n return ok({\n ...state,\n parts: state.parts.filter((part) => part.taskId !== action.taskId),\n });\n\n case \"setEstimate\": {\n const task = taskById(state, action.taskId);\n if (!isSplit(state, task.id) || action.minutes === null) {\n const next = updateTask(state, task.id, { estimate: action.minutes });\n return ok(\n action.minutes === null\n ? {\n ...next,\n parts: next.parts.filter((part) => part.taskId !== task.id),\n }\n : next\n );\n }\n /* A split task keeps its timeboxes; the rest of the new estimate is\n spread evenly over its untimed parts. */\n const pinned = partsOf(state, task.id)\n .filter(isTimebox)\n .reduce((total, part) => total + part.durationMinutes, 0);\n if (action.minutes < pinned) {\n return fail(state, `${formatMinutes(pinned)} is pinned on this task`);\n }\n let next = updateTask(state, task.id, { estimate: action.minutes });\n const days = availableDays(task, userOf(context, task));\n const spread = evenSpread(action.minutes - pinned, days);\n days.forEach((day) => {\n next = setUntimed(next, task.id, day, spread.get(day) ?? 0);\n });\n return ok(next);\n }\n\n case \"setCompleted\":\n return ok(\n updateTask(state, action.taskId, { isCompleted: action.completed })\n );\n\n case \"setSubtaskCompleted\":\n return ok({\n ...state,\n subtasks: state.subtasks.map((subtask) =>\n subtask.id === action.subtaskId\n ? { ...subtask, isCompleted: action.completed }\n : subtask\n ),\n });\n\n case \"upsertEvent\": {\n const { event } = action;\n if (\n clockToMinutes(event.endsOnTime) <= clockToMinutes(event.startsOnTime)\n ) {\n return fail(state, \"An event ends after it starts\");\n }\n if (event.id !== undefined) {\n return ok({\n ...state,\n events: state.events.map((item) =>\n item.id === event.id ? { ...item, ...event, id: item.id } : item\n ),\n });\n }\n return ok({\n ...state,\n nextId: state.nextId + 1,\n events: [...state.events, { ...event, id: state.nextId }],\n });\n }\n\n case \"removeEvent\":\n return ok({\n ...state,\n events: state.events.filter((event) => event.id !== action.id),\n });\n\n case \"updateSettings\":\n return ok({\n ...state,\n settings: { ...state.settings, ...action.settings },\n });\n\n case \"addTimeRecord\": {\n if (!validMinutes(action.minutes)) return fail(state, MINUTES_ERROR);\n const task = taskById(state, action.taskId);\n return ok({\n ...state,\n nextId: state.nextId + 1,\n timeRecords: [\n ...state.timeRecords,\n {\n id: `t${state.nextId}`,\n taskId: task.id,\n userId: action.userId ?? task.assigneeId,\n recordDate: action.recordDate,\n minutes: action.minutes,\n },\n ],\n });\n }\n\n case \"updateTimeRecord\": {\n if (!validMinutes(action.minutes)) return fail(state, MINUTES_ERROR);\n if (!state.timeRecords.some((record) => record.id === action.id)) {\n return fail(state, \"No such time record\");\n }\n return ok({\n ...state,\n timeRecords: state.timeRecords.map((record) =>\n record.id === action.id\n ? { ...record, minutes: action.minutes }\n : record\n ),\n });\n }\n\n case \"removeTimeRecord\":\n return ok({\n ...state,\n timeRecords: state.timeRecords.filter(\n (record) => record.id !== action.id\n ),\n });\n\n default:\n return ok(state);\n }\n};\n"],"mappings":";AAAA,SAAwBA,cAAc,QAAQ,WAAW;AACzD,S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A,KACdkJ,MAAM;YAAE1J,OAAO,EAAEqI,MAAM,CAACrI;UAAO,KACpC0J,MACN;QAAC,EACF,CAAC;MACJ;IAEA,KAAK,kBAAkB;MACrB,OAAO7J,EAAE,CAAAW,QAAA,KACJV,KAAK;QACRyJ,WAAW,EAAEzJ,KAAK,CAACyJ,WAAW,CAACzI,MAAM,CAClC4I,MAAM,IAAKA,MAAM,CAACvI,EAAE,KAAKkH,MAAM,CAAClH,EACnC;MAAC,EACF,CAAC;IAEJ;MACE,OAAOtB,EAAE,CAACC,KAAK,CAAC;EACpB;AACF,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { DateKey, TimeRange } from "./model";
|
|
2
|
+
/** One task's untimed minutes on the day, with what orders it. */
|
|
3
|
+
export interface ScheduleDemand {
|
|
4
|
+
taskId: number;
|
|
5
|
+
minutes: number;
|
|
6
|
+
isImportant: boolean;
|
|
7
|
+
dueOn: DateKey;
|
|
8
|
+
/** My Work list order. */
|
|
9
|
+
position: number;
|
|
10
|
+
}
|
|
11
|
+
export interface ScheduleInput {
|
|
12
|
+
/** Minutes after midnight; the window is start + daily capacity. */
|
|
13
|
+
windowStart: number;
|
|
14
|
+
windowEnd: number;
|
|
15
|
+
/** Timed events, pinned timeboxes and the pause: never suggested over. */
|
|
16
|
+
busy: TimeRange[];
|
|
17
|
+
demands: ScheduleDemand[];
|
|
18
|
+
minGap: number;
|
|
19
|
+
}
|
|
20
|
+
export interface Suggestion {
|
|
21
|
+
taskId: number;
|
|
22
|
+
start: number;
|
|
23
|
+
end: number;
|
|
24
|
+
/** This fragment's place among the task's fragments that day ("1/3"). */
|
|
25
|
+
fragment: number;
|
|
26
|
+
fragments: number;
|
|
27
|
+
/** After the work window ends. */
|
|
28
|
+
overtime: boolean;
|
|
29
|
+
}
|
|
30
|
+
export interface ScheduleResult {
|
|
31
|
+
suggestions: Suggestion[];
|
|
32
|
+
/** What did not fit before midnight, per task. */
|
|
33
|
+
unscheduled: {
|
|
34
|
+
taskId: number;
|
|
35
|
+
minutes: number;
|
|
36
|
+
}[];
|
|
37
|
+
}
|
|
38
|
+
interface Gap extends TimeRange {
|
|
39
|
+
overtime: boolean;
|
|
40
|
+
}
|
|
41
|
+
/** Important first, then the earlier due date, then My Work order; ties
|
|
42
|
+
keep the order they came in. */
|
|
43
|
+
export declare const orderDemands: (demands: ScheduleDemand[]) => ScheduleDemand[];
|
|
44
|
+
/**
|
|
45
|
+
* Free time from the window's start to midnight: everything busy taken out,
|
|
46
|
+
* cut at the window's end so what follows is overtime. Never before the
|
|
47
|
+
* window starts.
|
|
48
|
+
*/
|
|
49
|
+
export declare const freeGaps: (windowStart: number, windowEnd: number, busy: TimeRange[]) => Gap[];
|
|
50
|
+
/**
|
|
51
|
+
* Fills the free gaps chronologically with the ordered tasks, cutting a
|
|
52
|
+
* task into fragments where a gap ends:
|
|
53
|
+
* - a gap (or what is left of one) shorter than the min gap stays empty;
|
|
54
|
+
* - a cut never leaves the task a tail shorter than the min gap, though a
|
|
55
|
+
* task's final remainder may itself be shorter;
|
|
56
|
+
* - when a task cannot be cut that way, the gap stays empty and the task
|
|
57
|
+
* waits for the next one (the order is kept).
|
|
58
|
+
*/
|
|
59
|
+
export declare const schedule: (input: ScheduleInput) => ScheduleResult;
|
|
60
|
+
/** The work window: from the start setting, as long as the capacity. */
|
|
61
|
+
export declare const workWindow: (startsAt: string, capacityMinutes: number) => TimeRange;
|
|
62
|
+
export {};
|
|
63
|
+
//# sourceMappingURL=scheduler.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scheduler.d.ts","sourceRoot":"","sources":["../../../../src/presentation/timeboxes/scheduler.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAmB,SAAS,EAAkB,MAAM,SAAS,CAAC;AAE9E,kEAAkE;AAClE,MAAM,WAAW,cAAc;IAC7B,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;IA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@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
|
+
import { MINUTES_PER_DAY, clockToMinutes } from "./model";
|
|
3
|
+
|
|
4
|
+
/** One task's untimed minutes on the day, with what orders it. */
|
|
5
|
+
|
|
6
|
+
/** Important first, then the earlier due date, then My Work order; ties
|
|
7
|
+
keep the order they came in. */
|
|
8
|
+
export const orderDemands = demands => demands.map((demand, index) => ({
|
|
9
|
+
demand,
|
|
10
|
+
index
|
|
11
|
+
})).sort((a, b) => Number(b.demand.isImportant) - Number(a.demand.isImportant) || a.demand.dueOn.localeCompare(b.demand.dueOn) || a.demand.position - b.demand.position || a.index - b.index).map(_ref => {
|
|
12
|
+
let demand = _ref.demand;
|
|
13
|
+
return demand;
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Free time from the window's start to midnight: everything busy taken out,
|
|
18
|
+
* cut at the window's end so what follows is overtime. Never before the
|
|
19
|
+
* window starts.
|
|
20
|
+
*/
|
|
21
|
+
export const freeGaps = (windowStart, windowEnd, busy) => {
|
|
22
|
+
const blocked = [...busy].filter(range => range.end > range.start).sort((a, b) => a.start - b.start);
|
|
23
|
+
const free = [];
|
|
24
|
+
let cursor = windowStart;
|
|
25
|
+
blocked.forEach(range => {
|
|
26
|
+
if (range.end <= cursor) return;
|
|
27
|
+
if (range.start > cursor) {
|
|
28
|
+
free.push({
|
|
29
|
+
start: cursor,
|
|
30
|
+
end: Math.min(range.start, MINUTES_PER_DAY)
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
cursor = Math.max(cursor, range.end);
|
|
34
|
+
});
|
|
35
|
+
if (cursor < MINUTES_PER_DAY) free.push({
|
|
36
|
+
start: cursor,
|
|
37
|
+
end: MINUTES_PER_DAY
|
|
38
|
+
});
|
|
39
|
+
return free.flatMap(range => {
|
|
40
|
+
if (range.end <= windowEnd) return [_extends({}, range, {
|
|
41
|
+
overtime: false
|
|
42
|
+
})];
|
|
43
|
+
if (range.start >= windowEnd) return [_extends({}, range, {
|
|
44
|
+
overtime: true
|
|
45
|
+
})];
|
|
46
|
+
return [{
|
|
47
|
+
start: range.start,
|
|
48
|
+
end: windowEnd,
|
|
49
|
+
overtime: false
|
|
50
|
+
}, {
|
|
51
|
+
start: windowEnd,
|
|
52
|
+
end: range.end,
|
|
53
|
+
overtime: true
|
|
54
|
+
}];
|
|
55
|
+
});
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* Fills the free gaps chronologically with the ordered tasks, cutting a
|
|
60
|
+
* task into fragments where a gap ends:
|
|
61
|
+
* - a gap (or what is left of one) shorter than the min gap stays empty;
|
|
62
|
+
* - a cut never leaves the task a tail shorter than the min gap, though a
|
|
63
|
+
* task's final remainder may itself be shorter;
|
|
64
|
+
* - when a task cannot be cut that way, the gap stays empty and the task
|
|
65
|
+
* waits for the next one (the order is kept).
|
|
66
|
+
*/
|
|
67
|
+
export const schedule = input => {
|
|
68
|
+
const minGap = input.minGap;
|
|
69
|
+
const queue = orderDemands(input.demands).filter(demand => demand.minutes > 0).map(demand => ({
|
|
70
|
+
taskId: demand.taskId,
|
|
71
|
+
remaining: demand.minutes
|
|
72
|
+
}));
|
|
73
|
+
const placed = [];
|
|
74
|
+
freeGaps(input.windowStart, input.windowEnd, input.busy).forEach(gap => {
|
|
75
|
+
let cursor = gap.start;
|
|
76
|
+
while (queue.length > 0) {
|
|
77
|
+
const space = gap.end - cursor;
|
|
78
|
+
if (space < minGap) break;
|
|
79
|
+
const task = queue[0];
|
|
80
|
+
let take = Math.min(task.remaining, space);
|
|
81
|
+
if (take < task.remaining && task.remaining - take < minGap) {
|
|
82
|
+
take = task.remaining - minGap;
|
|
83
|
+
}
|
|
84
|
+
if (take < task.remaining && take < minGap) break;
|
|
85
|
+
placed.push({
|
|
86
|
+
taskId: task.taskId,
|
|
87
|
+
start: cursor,
|
|
88
|
+
end: cursor + take,
|
|
89
|
+
overtime: gap.overtime
|
|
90
|
+
});
|
|
91
|
+
cursor += take;
|
|
92
|
+
task.remaining -= take;
|
|
93
|
+
if (task.remaining === 0) queue.shift();
|
|
94
|
+
}
|
|
95
|
+
});
|
|
96
|
+
const suggestions = placed.map(suggestion => {
|
|
97
|
+
const siblings = placed.filter(other => other.taskId === suggestion.taskId);
|
|
98
|
+
return _extends({}, suggestion, {
|
|
99
|
+
fragment: siblings.indexOf(suggestion) + 1,
|
|
100
|
+
fragments: siblings.length
|
|
101
|
+
});
|
|
102
|
+
});
|
|
103
|
+
return {
|
|
104
|
+
suggestions,
|
|
105
|
+
unscheduled: queue.map(task => ({
|
|
106
|
+
taskId: task.taskId,
|
|
107
|
+
minutes: task.remaining
|
|
108
|
+
}))
|
|
109
|
+
};
|
|
110
|
+
};
|
|
111
|
+
|
|
112
|
+
/** The work window: from the start setting, as long as the capacity. */
|
|
113
|
+
export const workWindow = (startsAt, capacityMinutes) => {
|
|
114
|
+
const start = clockToMinutes(startsAt);
|
|
115
|
+
return {
|
|
116
|
+
start,
|
|
117
|
+
end: Math.min(start + capacityMinutes, MINUTES_PER_DAY)
|
|
118
|
+
};
|
|
119
|
+
};
|
|
120
|
+
//# sourceMappingURL=scheduler.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scheduler.js","names":["MINUTES_PER_DAY","clockToMinutes","orderDemands","demands","map","demand","index","sort","a","b","Number","isImportant","dueOn","localeCompare","position","_ref","freeGaps","windowStart","windowEnd","busy","blocked","filter","range","end","start","free","cursor","forEach","push","Math","min","max","flatMap","_extends","overtime","schedule","input","minGap","queue","minutes","taskId","remaining","placed","gap","length","space","task","take","shift","suggestions","suggestion","siblings","other","fragment","indexOf","fragments","unscheduled","workWindow","startsAt","capacityMinutes"],"sources":["../../../../src/presentation/timeboxes/scheduler.ts"],"sourcesContent":["import { DateKey, MINUTES_PER_DAY, TimeRange, clockToMinutes } from \"./model\";\n\n/** One task's untimed minutes on the day, with what orders it. */\nexport interface ScheduleDemand {\n taskId: number;\n minutes: number;\n isImportant: boolean;\n dueOn: DateKey;\n /** My Work list order. */\n position: number;\n}\n\nexport interface ScheduleInput {\n /** Minutes after midnight; the window is start + daily capacity. */\n windowStart: number;\n windowEnd: number;\n /** Timed events, pinned timeboxes and the pause: never suggested over. */\n busy: TimeRange[];\n demands: ScheduleDemand[];\n minGap: number;\n}\n\nexport interface Suggestion {\n taskId: number;\n start: number;\n end: number;\n /** This fragment's place among the task's fragments that day (\"1/3\"). */\n fragment: number;\n fragments: number;\n /** After the work window ends. */\n overtime: boolean;\n}\n\nexport interface ScheduleResult {\n suggestions: Suggestion[];\n /** What did not fit before midnight, per task. */\n unscheduled: { taskId: number; minutes: number }[];\n}\n\ninterface Gap extends TimeRange {\n overtime: boolean;\n}\n\n/** Important first, then the earlier due date, then My Work order; ties\n keep the order they came in. */\nexport const orderDemands = (demands: ScheduleDemand[]): ScheduleDemand[] =>\n demands\n .map((demand, index) => ({ demand, index }))\n .sort(\n (a, b) =>\n Number(b.demand.isImportant) - Number(a.demand.isImportant) ||\n a.demand.dueOn.localeCompare(b.demand.dueOn) ||\n a.demand.position - b.demand.position ||\n a.index - b.index\n )\n .map(({ demand }) => demand);\n\n/**\n * Free time from the window's start to midnight: everything busy taken out,\n * cut at the window's end so what follows is overtime. Never before the\n * window starts.\n */\nexport const freeGaps = (\n windowStart: number,\n windowEnd: number,\n busy: TimeRange[]\n): Gap[] => {\n const blocked = [...busy]\n .filter((range) => range.end > range.start)\n .sort((a, b) => a.start - b.start);\n const free: TimeRange[] = [];\n let cursor = windowStart;\n blocked.forEach((range) => {\n if (range.end <= cursor) return;\n if (range.start > cursor) {\n free.push({ start: cursor, end: Math.min(range.start, MINUTES_PER_DAY) });\n }\n cursor = Math.max(cursor, range.end);\n });\n if (cursor < MINUTES_PER_DAY)\n free.push({ start: cursor, end: MINUTES_PER_DAY });\n\n return free.flatMap((range): Gap[] => {\n if (range.end <= windowEnd) return [{ ...range, overtime: false }];\n if (range.start >= windowEnd) return [{ ...range, overtime: true }];\n return [\n { start: range.start, end: windowEnd, overtime: false },\n { start: windowEnd, end: range.end, overtime: true },\n ];\n });\n};\n\n/**\n * Fills the free gaps chronologically with the ordered tasks, cutting a\n * task into fragments where a gap ends:\n * - a gap (or what is left of one) shorter than the min gap stays empty;\n * - a cut never leaves the task a tail shorter than the min gap, though a\n * task's final remainder may itself be shorter;\n * - when a task cannot be cut that way, the gap stays empty and the task\n * waits for the next one (the order is kept).\n */\nexport const schedule = (input: ScheduleInput): ScheduleResult => {\n const { minGap } = input;\n const queue = orderDemands(input.demands)\n .filter((demand) => demand.minutes > 0)\n .map((demand) => ({ taskId: demand.taskId, remaining: demand.minutes }));\n const placed: Omit<Suggestion, \"fragment\" | \"fragments\">[] = [];\n\n freeGaps(input.windowStart, input.windowEnd, input.busy).forEach((gap) => {\n let cursor = gap.start;\n while (queue.length > 0) {\n const space = gap.end - cursor;\n if (space < minGap) break;\n const task = queue[0];\n let take = Math.min(task.remaining, space);\n if (take < task.remaining && task.remaining - take < minGap) {\n take = task.remaining - minGap;\n }\n if (take < task.remaining && take < minGap) break;\n placed.push({\n taskId: task.taskId,\n start: cursor,\n end: cursor + take,\n overtime: gap.overtime,\n });\n cursor += take;\n task.remaining -= take;\n if (task.remaining === 0) queue.shift();\n }\n });\n\n const suggestions = placed.map((suggestion) => {\n const siblings = placed.filter(\n (other) => other.taskId === suggestion.taskId\n );\n return {\n ...suggestion,\n fragment: siblings.indexOf(suggestion) + 1,\n fragments: siblings.length,\n };\n });\n\n return {\n suggestions,\n unscheduled: queue.map((task) => ({\n taskId: task.taskId,\n minutes: task.remaining,\n })),\n };\n};\n\n/** The work window: from the start setting, as long as the capacity. */\nexport const workWindow = (\n startsAt: string,\n capacityMinutes: number\n): TimeRange => {\n const start = clockToMinutes(startsAt);\n return { start, end: Math.min(start + capacityMinutes, MINUTES_PER_DAY) };\n};\n"],"mappings":";AAAA,SAAkBA,eAAe,EAAaC,cAAc,QAAQ,SAAS;;AAE7E;;AAyCA;AAC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AU,IAAK;IAC7C,MAAMC,QAAQ,GAAGT,MAAM,CAACrB,MAAM,CAC3B+B,KAAK,IAAKA,KAAK,CAACZ,MAAM,KAAKU,UAAU,CAACV,MACzC,CAAC;IACD,OAAAP,QAAA,KACKiB,UAAU;MACbG,QAAQ,EAAEF,QAAQ,CAACG,OAAO,CAACJ,UAAU,CAAC,GAAG,CAAC;MAC1CK,SAAS,EAAEJ,QAAQ,CAACP;IAAM;EAE9B,CAAC,CAAC;EAEF,OAAO;IACLK,WAAW;IACXO,WAAW,EAAElB,KAAK,CAAClC,GAAG,CAAE0C,IAAI,KAAM;MAChCN,MAAM,EAAEM,IAAI,CAACN,MAAM;MACnBD,OAAO,EAAEO,IAAI,CAACL;IAChB,CAAC,CAAC;EACJ,CAAC;AACH,CAAC;;AAED;AACA,OAAO,MAAMgB,UAAU,GAAGA,CACxBC,QAAgB,EAChBC,eAAuB,KACT;EACd,MAAMnC,KAAK,GAAGvB,cAAc,CAACyD,QAAQ,CAAC;EACtC,OAAO;IAAElC,KAAK;IAAED,GAAG,EAAEM,IAAI,CAACC,GAAG,CAACN,KAAK,GAAGmC,eAAe,EAAE3D,eAAe;EAAE,CAAC;AAC3E,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { TbChange } from "./changes";
|
|
2
|
+
import { TbState } from "./model";
|
|
3
|
+
import { TbContext } from "./plan";
|
|
4
|
+
import { TbAction, TbResult } from "./reducer";
|
|
5
|
+
/**
|
|
6
|
+
* The simulation's state, kept at module level so the Agenda and the
|
|
7
|
+
* Workload share it: a pin in one shows in the other. The last action's
|
|
8
|
+
* change is kept beside it, for both to highlight.
|
|
9
|
+
*/
|
|
10
|
+
export declare const TB_CONTEXT: TbContext;
|
|
11
|
+
export declare const timeboxStore: {
|
|
12
|
+
getState: () => TbState;
|
|
13
|
+
subscribe: (listener: () => void) => (() => void);
|
|
14
|
+
/** Applies an action; returns the reducer's message, if any. */
|
|
15
|
+
dispatch: (action: TbAction) => TbResult;
|
|
16
|
+
/** "Reset simulation". */
|
|
17
|
+
reset: () => void;
|
|
18
|
+
getLastChange: () => TbChange | null;
|
|
19
|
+
};
|
|
20
|
+
export declare const useTimeboxState: () => TbState;
|
|
21
|
+
/** What the last action changed; null after a reset. */
|
|
22
|
+
export declare const useLastChange: () => TbChange | null;
|
|
23
|
+
//# sourceMappingURL=store.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"store.d.ts","sourceRoot":"","sources":["../../../../src/presentation/timeboxes/store.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,QAAQ,EAAkB,MAAM,WAAW,CAAC;AAErD,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAClC,OAAO,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAC;AACnC,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAU,MAAM,WAAW,CAAC;AAEvD;;;;GAIG;AACH,eAAO,MAAM,UAAU,EAAE,SAA4B,CAAC;AAQtD,eAAO,MAAM,YAAY;oBACT,OAAO;0BACC,MAAM,IAAI,KAAG,CAAC,MAAM,IAAI,CAAC;IAI/C,gEAAgE;uBAC7C,QAAQ,KAAG,QAAQ;IAStC,0BAA0B;iBACf,IAAI;yBAKI,QAAQ,GAAG,IAAI;CACnC,CAAC;AAEF,eAAO,MAAM,eAAe,QAAO,OACkC,CAAC;AAEtE,wDAAwD;AACxD,eAAO,MAAM,aAAa,QAAO,QAAQ,GAAG,IAC8B,CAAC"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { useSyncExternalStore } from "react";
|
|
2
|
+
import { describeChange } from "./changes";
|
|
3
|
+
import { USERS, initialState } from "./mockData";
|
|
4
|
+
import { reduce } from "./reducer";
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* The simulation's state, kept at module level so the Agenda and the
|
|
8
|
+
* Workload share it: a pin in one shows in the other. The last action's
|
|
9
|
+
* change is kept beside it, for both to highlight.
|
|
10
|
+
*/
|
|
11
|
+
export const TB_CONTEXT = {
|
|
12
|
+
users: USERS
|
|
13
|
+
};
|
|
14
|
+
let current = initialState();
|
|
15
|
+
let lastChange = null;
|
|
16
|
+
const listeners = new Set();
|
|
17
|
+
const emit = () => listeners.forEach(listener => listener());
|
|
18
|
+
export const timeboxStore = {
|
|
19
|
+
getState: () => current,
|
|
20
|
+
subscribe: listener => {
|
|
21
|
+
listeners.add(listener);
|
|
22
|
+
return () => listeners.delete(listener);
|
|
23
|
+
},
|
|
24
|
+
/** Applies an action; returns the reducer's message, if any. */
|
|
25
|
+
dispatch: action => {
|
|
26
|
+
const result = reduce(current, TB_CONTEXT, action);
|
|
27
|
+
if (result.state !== current) {
|
|
28
|
+
lastChange = describeChange(current, result.state, TB_CONTEXT);
|
|
29
|
+
current = result.state;
|
|
30
|
+
emit();
|
|
31
|
+
}
|
|
32
|
+
return result;
|
|
33
|
+
},
|
|
34
|
+
/** "Reset simulation". */
|
|
35
|
+
reset: () => {
|
|
36
|
+
current = initialState();
|
|
37
|
+
lastChange = null;
|
|
38
|
+
emit();
|
|
39
|
+
},
|
|
40
|
+
getLastChange: () => lastChange
|
|
41
|
+
};
|
|
42
|
+
export const useTimeboxState = () => useSyncExternalStore(timeboxStore.subscribe, timeboxStore.getState);
|
|
43
|
+
|
|
44
|
+
/** What the last action changed; null after a reset. */
|
|
45
|
+
export const useLastChange = () => useSyncExternalStore(timeboxStore.subscribe, timeboxStore.getLastChange);
|
|
46
|
+
//# sourceMappingURL=store.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"store.js","names":["useSyncExternalStore","describeChange","USERS","initialState","reduce","TB_CONTEXT","users","current","lastChange","listeners","Set","emit","forEach","listener","timeboxStore","getState","subscribe","add","delete","dispatch","action","result","state","reset","getLastChange","useTimeboxState","useLastChange"],"sources":["../../../../src/presentation/timeboxes/store.ts"],"sourcesContent":["import { useSyncExternalStore } from \"react\";\n\nimport { TbChange, describeChange } from \"./changes\";\nimport { USERS, initialState } from \"./mockData\";\nimport { TbState } from \"./model\";\nimport { TbContext } from \"./plan\";\nimport { TbAction, TbResult, reduce } from \"./reducer\";\n\n/**\n * The simulation's state, kept at module level so the Agenda and the\n * Workload share it: a pin in one shows in the other. The last action's\n * change is kept beside it, for both to highlight.\n */\nexport const TB_CONTEXT: TbContext = { users: USERS };\n\nlet current: TbState = initialState();\nlet lastChange: TbChange | null = null;\nconst listeners = new Set<() => void>();\n\nconst emit = (): void => listeners.forEach((listener) => listener());\n\nexport const timeboxStore = {\n getState: (): TbState => current,\n subscribe: (listener: () => void): (() => void) => {\n listeners.add(listener);\n return () => listeners.delete(listener);\n },\n /** Applies an action; returns the reducer's message, if any. */\n dispatch: (action: TbAction): TbResult => {\n const result = reduce(current, TB_CONTEXT, action);\n if (result.state !== current) {\n lastChange = describeChange(current, result.state, TB_CONTEXT);\n current = result.state;\n emit();\n }\n return result;\n },\n /** \"Reset simulation\". */\n reset: (): void => {\n current = initialState();\n lastChange = null;\n emit();\n },\n getLastChange: (): TbChange | null => lastChange,\n};\n\nexport const useTimeboxState = (): TbState =>\n useSyncExternalStore(timeboxStore.subscribe, timeboxStore.getState);\n\n/** What the last action changed; null after a reset. */\nexport const useLastChange = (): TbChange | null =>\n useSyncExternalStore(timeboxStore.subscribe, timeboxStore.getLastChange);\n"],"mappings":"AAAA,SAASA,oBAAoB,QAAQ,OAAO;AAE5C,SAAmBC,cAAc,QAAQ,WAAW;AACpD,SAASC,KAAK,EAAEC,YAAY,QAAQ,YAAY;AAGhD,SAA6BC,MAAM,QAAQ,WAAW;;AAEtD;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,UAAqB,GAAG;EAAEC,KAAK,EAAEJ;AAAM,CAAC;AAErD,IAAIK,OAAgB,GAAGJ,YAAY,CAAC,CAAC;AACrC,IAAIK,UAA2B,GAAG,IAAI;AACtC,MAAMC,SAAS,GAAG,IAAIC,GAAG,CAAa,CAAC;AAEvC,MAAMC,IAAI,GAAGA,CAAA,KAAYF,SAAS,CAACG,OAAO,CAAEC,QAAQ,IAAKA,QAAQ,CAAC,CAAC,CAAC;AAEpE,OAAO,MAAMC,YAAY,GAAG;EAC1BC,QAAQ,EAAEA,CAAA,KAAeR,OAAO;EAChCS,SAAS,EAAGH,QAAoB,IAAmB;IACjDJ,SAAS,CAACQ,GAAG,CAACJ,QAAQ,CAAC;IACvB,OAAO,MAAMJ,SAAS,CAACS,MAAM,CAACL,QAAQ,CAAC;EACzC,CAAC;EACD;EACAM,QAAQ,EAAGC,MAAgB,IAAe;IACxC,MAAMC,MAAM,GAAGjB,MAAM,CAACG,OAAO,EAAEF,UAAU,EAAEe,MAAM,CAAC;IAClD,IAAIC,MAAM,CAACC,KAAK,KAAKf,OAAO,EAAE;MAC5BC,UAAU,GAAGP,cAAc,CAACM,OAAO,EAAEc,MAAM,CAACC,KAAK,EAAEjB,UAAU,CAAC;MAC9DE,OAAO,GAAGc,MAAM,CAACC,KAAK;MACtBX,IAAI,CAAC,CAAC;IACR;IACA,OAAOU,MAAM;EACf,CAAC;EACD;EACAE,KAAK,EAAEA,CAAA,KAAY;IACjBhB,OAAO,GAAGJ,YAAY,CAAC,CAAC;IACxBK,UAAU,GAAG,IAAI;IACjBG,IAAI,CAAC,CAAC;EACR,CAAC;EACDa,aAAa,EAAEA,CAAA,KAAuBhB;AACxC,CAAC;AAED,OAAO,MAAMiB,eAAe,GAAGA,CAAA,KAC7BzB,oBAAoB,CAACc,YAAY,CAACE,SAAS,EAAEF,YAAY,CAACC,QAAQ,CAAC;;AAErE;AACA,OAAO,MAAMW,aAAa,GAAGA,CAAA,KAC3B1B,oBAAoB,CAACc,YAAY,CAACE,SAAS,EAAEF,YAAY,CAACU,aAAa,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { ReactElement } from "react";
|
|
2
|
+
export declare const WeekView: () => ReactElement;
|
|
3
|
+
export declare const DayView: () => ReactElement;
|
|
4
|
+
export declare const SuggestedBlockMenu: () => ReactElement;
|
|
5
|
+
export declare const PinnedBlockMenu: () => ReactElement;
|
|
6
|
+
export declare const ResizingPinnedBlock: () => ReactElement;
|
|
7
|
+
export declare const SomeoneElsesSchedule: () => ReactElement;
|
|
8
|
+
export declare const SomeoneElsesScheduleInMyTime: () => ReactElement;
|
|
9
|
+
export declare const TimezoneChanged: () => ReactElement;
|
|
10
|
+
//# sourceMappingURL=timeBlocks.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"timeBlocks.d.ts","sourceRoot":"","sources":["../../../../src/presentation/timeboxes/timeBlocks.tsx"],"names":[],"mappings":"AAAA,OAAc,EACZ,YAAY,EAMb,MAAM,OAAO,CAAC;AA63Ef,eAAO,MAAM,QAAQ,QAAO,YAQ3B,CAAC;AAEF,eAAO,MAAM,OAAO,QAAO,YAQ1B,CAAC;AAYF,eAAO,MAAM,kBAAkB,QAAO,YAWrC,CAAC;AAEF,eAAO,MAAM,eAAe,QAAO,YAWlC,CAAC;AAEF,eAAO,MAAM,mBAAmB,QAAO,YAgBtC,CAAC;AAMF,eAAO,MAAM,oBAAoB,QAAO,YAWvC,CAAC;AAEF,eAAO,MAAM,4BAA4B,QAAO,YAW/C,CAAC;AAIF,eAAO,MAAM,eAAe,QAAO,YAWlC,CAAC"}
|