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
@@ -55,7 +55,7 @@ it('adds the steps of a template as tasks of the job', function () {
['Kuvat', $this->graphic->id, 'waiting', null],
['Julkaisu', $this->graphic->id, 'waiting', null],
])
->and(DB::table('task_assignees')->pluck('user_id')->unique()->values()->all())->toBe([$this->employee->id]);
->and($tasks->pluck('assignee_user_id')->unique()->values()->all())->toBe([$this->employee->id]);
$this->get(route('jobs.show', $this->job->id))->assertSee('Lisättiin 3 tehtävää pohjasta Somekampanja (graafinen työ).');
});
@@ -103,13 +103,16 @@ it('shows a table of the chosen template tasks and saves their due dates and est
Livewire::test('jobs::tasks-from-template', ['job' => $this->job->id])
->assertDontSee('Pohjan Somekampanja tehtävät')
->set('templateId', (string) $this->campaign)
->assertSet('rows', array_fill(0, 3, ['due_on' => '', 'estimated_hours' => '']))
->assertSet('rows', array_fill(0, 3, ['due_on' => '', 'estimated_hours' => '', 'assignee_user_id' => (string) $this->employee->id]))
->assertSet('scheduleToDueDates', true)
->assertSee('Tekijä: Kuvat')
->assertSee('Pohjan Somekampanja tehtävät')
->assertSee('Määräpäivä: Kuvat')
->assertSee('Arvioitu aika (h): Julkaisu')
->set('rows.0.due_on', '2026-06-01')
->set('rows.0.estimated_hours', '1,5')
->set('rows.2.estimated_hours', '2')
->set('scheduleToDueDates', false)
->call('add')
->assertHasNoErrors();
@@ -143,3 +146,31 @@ it('empties the rows when another template is chosen', function () {
->set('templateId', (string) $this->campaign)
->assertSet('rows.0.estimated_hours', '');
});
it('schedules the tasks to their due dates for the chosen assignees, backwards from the due date', function () {
$this->travelTo(new DateTimeImmutable('2026-06-01 09:00'));
$colleague = User::factory()->create(['name' => 'Aino Ahkera']);
Livewire::test('jobs::tasks-from-template', ['job' => $this->job->id])
->set('templateId', (string) $this->campaign)
->set('rows.0.due_on', '2026-06-10')
->set('rows.0.estimated_hours', '12')
->set('rows.0.assignee_user_id', (string) $colleague->id)
->set('rows.1.due_on', '2026-06-10')
->set('rows.1.estimated_hours', '4')
->set('rows.1.assignee_user_id', '')
->call('add')
->assertHasNoErrors();
$tasks = TaskModel::query()->orderBy('id')->get();
expect($tasks->map(fn ($task) => [$task->assignee_user_id, $task->planned_from?->format('Y-m-d'), $task->planned_to?->format('Y-m-d')])->all())->toBe([
[$colleague->id, '2026-06-09', '2026-06-10'],
[null, '2026-06-10', '2026-06-10'],
[$this->employee->id, null, null],
])
->and(DB::table('task_bookings')->where('task_id', $tasks[0]->id)->orderBy('day')->pluck('minutes', 'day')->all())->toBe(['2026-06-09' => 240, '2026-06-10' => 480])
->and(DB::table('task_bookings')->where('task_id', '!=', $tasks[0]->id)->count())->toBe(0);
$this->get(route('jobs.show', $this->job->id))->assertSee('2 tehtävää aikataulutettiin määräpäivilleen.');
});