Give tasks one assignee and members, and schedule template tasks to due dates

- A task now has one optional assignee (tasks.assignee_user_id), whose
  calendar row it is on and whose days its estimate books, and members
  (task_members) who see it among their own jobs and in the weekly sheet
  but get no bookings. A migration moves existing assignees over: the one
  with most booked time becomes the assignee, the others members.
- Adding tasks from a workflow template asks for each step's assignee and,
  by default, schedules tasks with a due date to end on it, booking the
  estimate backwards from the due date (not before today); what does not
  fit runs past the due date and is reported as late.
- The task calendar leaves quick sale tasks out of the unscheduled list,
  shows a bar's job details in a popover on hover and focus, and shows the
  day load on its own grid line.
- The template table stacks its cells on narrow screens to reflow at 320 px.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
2026-11-24 19:01:11 +02:00
co-authored by Claude Opus 5.5
parent b4f2f1cfaa
commit 18598cc08e
45 changed files with 1133 additions and 248 deletions
@@ -83,27 +83,28 @@ it('allows tasks from a quote request on, not before and not when archived', fun
});
it('adds a task with a work type of the job or a shared one', function () {
$taskId = $this->addTask->execute($this->jobId, new TaskData('Mainoskuvat', 11, 'waiting', dueOn: '2026-05-20', estimatedHours: '3,5', assigneeUserIds: [10]), 10);
$taskId = $this->addTask->execute($this->jobId, new TaskData('Mainoskuvat', 11, 'waiting', dueOn: '2026-05-20', estimatedHours: '3,5', assigneeUserId: 10), 10);
$this->addTask->execute($this->jobId, new TaskData('Suunnittelupalaveri', 91, 'waiting'), 10);
$task = $this->tasks->findForJob($this->jobId, $taskId);
expect($task?->dueOn()?->format('Y-m-d'))->toBe('2026-05-20')
->and($task?->estimatedHours()?->format())->toBe('3.5')
->and($task?->assigneeUserIds())->toBe([10])
->and($task?->assigneeUserId())->toBe(10)
->and($this->tasks->tasks)->toHaveCount(2);
});
it('rejects a work type of another unit and an inactive assignee', function (int $workTypeId, array $assignees, string $field) {
it('rejects a work type of another unit and an inactive assignee or member', function (int $workTypeId, ?int $assignee, array $members, string $field) {
try {
$this->addTask->execute($this->jobId, new TaskData('Työ', $workTypeId, 'waiting', assigneeUserIds: $assignees), 10);
$this->addTask->execute($this->jobId, new TaskData('Työ', $workTypeId, 'waiting', assigneeUserId: $assignee, memberUserIds: $members), 10);
$this->fail('No exception');
} catch (InvalidTaskReference $exception) {
expect($exception->field)->toBe($field);
}
})->with([
'work type of another unit' => [21, [], 'work_type'],
'inactive assignee' => [11, [12], 'assignees'],
'work type of another unit' => [21, null, [], 'work_type'],
'inactive assignee' => [11, 12, [], 'assignee'],
'inactive member' => [11, 10, [12], 'members'],
]);
it('changes, moves through statuses and removes a task', function () {
@@ -150,8 +151,8 @@ it('does not remove a task with time entries', function () {
});
it('books a scheduled task evenly from the working days of its period', function () {
$taskId = $this->addTask->execute($this->jobId, new TaskData('Taitto', 11, 'waiting', estimatedHours: '12', assigneeUserIds: [10], plannedFrom: '2026-12-04', plannedTo: '2026-12-07'), 10);
$oneDayId = $this->addTask->execute($this->jobId, new TaskData('Palaveri', 91, 'waiting', assigneeUserIds: [10], plannedFrom: '2026-12-08'), 10);
$taskId = $this->addTask->execute($this->jobId, new TaskData('Taitto', 11, 'waiting', estimatedHours: '12', assigneeUserId: 10, plannedFrom: '2026-12-04', plannedTo: '2026-12-07'), 10);
$oneDayId = $this->addTask->execute($this->jobId, new TaskData('Palaveri', 91, 'waiting', assigneeUserId: 10, plannedFrom: '2026-12-08'), 10);
expect($this->bookings->of($taskId, 10))->toBe(['2026-12-04' => 360, '2026-12-07' => 360])
->and($this->tasks->findForJob($this->jobId, $oneDayId)?->plannedTo()?->format('Y-m-d'))->toBe('2026-12-08')
@@ -159,8 +160,8 @@ it('books a scheduled task evenly from the working days of its period', function
});
it('moves what does not fit in a full day to the next working day', function () {
$this->addTask->execute($this->jobId, new TaskData('Kuvaus', 11, 'waiting', estimatedHours: '6', assigneeUserIds: [10], plannedFrom: '2026-12-04'), 10);
$taskId = $this->addTask->execute($this->jobId, new TaskData('Taitto', 11, 'waiting', estimatedHours: '4', assigneeUserIds: [10]), 10);
$this->addTask->execute($this->jobId, new TaskData('Kuvaus', 11, 'waiting', estimatedHours: '6', assigneeUserId: 10, plannedFrom: '2026-12-04'), 10);
$taskId = $this->addTask->execute($this->jobId, new TaskData('Taitto', 11, 'waiting', estimatedHours: '4', assigneeUserId: 10), 10);
$result = $this->scheduleTask->execute($this->jobId, $taskId, 10, 10, '2026-12-04', '2026-12-04');
@@ -170,20 +171,20 @@ it('moves what does not fit in a full day to the next working day', function ()
});
it('does not count done tasks in the day load', function () {
$doneId = $this->addTask->execute($this->jobId, new TaskData('Kuvaus', 11, 'waiting', estimatedHours: '8', assigneeUserIds: [10], plannedFrom: '2026-12-04'), 10);
$doneId = $this->addTask->execute($this->jobId, new TaskData('Kuvaus', 11, 'waiting', estimatedHours: '8', assigneeUserId: 10, plannedFrom: '2026-12-04'), 10);
$this->changeTaskStatus->execute($this->jobId, $doneId, TaskStatus::Done);
$taskId = $this->addTask->execute($this->jobId, new TaskData('Taitto', 11, 'waiting', estimatedHours: '8', assigneeUserIds: [10], plannedFrom: '2026-12-04'), 10);
$taskId = $this->addTask->execute($this->jobId, new TaskData('Taitto', 11, 'waiting', estimatedHours: '8', assigneeUserId: 10, plannedFrom: '2026-12-04'), 10);
expect($this->bookings->of($taskId, 10))->toBe(['2026-12-04' => 480]);
});
it('moves a task to another person and gives it the days its estimate needs', function () {
$this->users->addUser(11, 'Aino');
$taskId = $this->addTask->execute($this->jobId, new TaskData('Taitto', 11, 'waiting', estimatedHours: '20', assigneeUserIds: [10], plannedFrom: '2026-12-01'), 10);
$taskId = $this->addTask->execute($this->jobId, new TaskData('Taitto', 11, 'waiting', estimatedHours: '20', assigneeUserId: 10, plannedFrom: '2026-12-01'), 10);
$result = $this->scheduleTask->execute($this->jobId, $taskId, 10, 11, '2026-12-11', null);
expect($this->tasks->findForJob($this->jobId, $taskId)?->assigneeUserIds())->toBe([11])
expect($this->tasks->findForJob($this->jobId, $taskId)?->assigneeUserId())->toBe(11)
->and($result->plannedFrom)->toBe('2026-12-11')
->and($result->plannedTo)->toBe('2026-12-15')
->and($result->extended)->toBeFalse()
@@ -192,17 +193,48 @@ it('moves a task to another person and gives it the days its estimate needs', fu
});
it('rejects moving a task to an inactive person or ending it before it starts', function () {
$taskId = $this->addTask->execute($this->jobId, new TaskData('Taitto', 11, 'waiting', assigneeUserIds: [10]), 10);
$taskId = $this->addTask->execute($this->jobId, new TaskData('Taitto', 11, 'waiting', assigneeUserId: 10), 10);
expect(fn () => $this->scheduleTask->execute($this->jobId, $taskId, 10, 12, '2026-12-07', '2026-12-07'))->toThrow(InvalidTaskReference::class)
->and(fn () => $this->scheduleTask->execute($this->jobId, $taskId, 10, 10, '2026-12-07', '2026-12-04'))->toThrow(PlanEndsBeforeStart::class);
});
it('takes a task out of the calendar', function () {
$taskId = $this->addTask->execute($this->jobId, new TaskData('Taitto', 11, 'waiting', estimatedHours: '4', assigneeUserIds: [10], plannedFrom: '2026-12-07'), 10);
$taskId = $this->addTask->execute($this->jobId, new TaskData('Taitto', 11, 'waiting', estimatedHours: '4', assigneeUserId: 10, plannedFrom: '2026-12-07'), 10);
$this->clearSchedule->execute($this->jobId, $taskId);
expect($this->tasks->findForJob($this->jobId, $taskId)?->isScheduled())->toBeFalse()
->and($this->bookings->of($taskId, 10))->toBe([]);
});
it('books only the assignee, not the members, and keeps the assignee out of the members', function () {
$this->users->addUser(11, 'Aino');
$taskId = $this->addTask->execute($this->jobId, new TaskData('Taitto', 11, 'waiting', estimatedHours: '4', assigneeUserId: 10, memberUserIds: [11, 10], plannedFrom: '2026-12-07'), 10);
$task = $this->tasks->findForJob($this->jobId, $taskId);
expect($task?->memberUserIds())->toBe([11])
->and($this->bookings->of($taskId, 10))->toBe(['2026-12-07' => 240])
->and($this->bookings->of($taskId, 11))->toBe([]);
});
it('moves a task to a member, who then is the assignee and no longer a member', function () {
$this->users->addUser(11, 'Aino');
$this->users->addUser(13, 'Ville');
$taskId = $this->addTask->execute($this->jobId, new TaskData('Taitto', 11, 'waiting', estimatedHours: '4', assigneeUserId: 10, memberUserIds: [11, 13], plannedFrom: '2026-12-07'), 10);
$this->scheduleTask->execute($this->jobId, $taskId, 10, 11, '2026-12-07', '2026-12-07');
$task = $this->tasks->findForJob($this->jobId, $taskId);
expect($task?->assigneeUserId())->toBe(11)
->and($task?->memberUserIds())->toBe([13])
->and($this->bookings->of($taskId, 10))->toBe([])
->and($this->bookings->of($taskId, 11))->toBe(['2026-12-07' => 240]);
});
it('books nothing for a task without an assignee', function () {
$taskId = $this->addTask->execute($this->jobId, new TaskData('Taitto', 11, 'waiting', estimatedHours: '4', memberUserIds: [10], plannedFrom: '2026-12-07'), 10);
expect($this->bookings->of($taskId, 10))->toBe([])
->and($this->tasks->findForJob($this->jobId, $taskId)?->plannedTo()?->format('Y-m-d'))->toBe('2026-12-07');
});