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
+36 -2
View File
@@ -3,6 +3,7 @@
use App\Models\User;
use App\Modules\Catalog\Infrastructure\Persistence\Eloquent\ServiceUnitModel;
use App\Modules\Catalog\Infrastructure\Persistence\Eloquent\WorkTypeModel;
use App\Modules\Jobs\Application\Contracts\TaskQueries;
use App\Modules\Jobs\Infrastructure\Persistence\Eloquent\CustomerJobModel;
use App\Modules\Jobs\Infrastructure\Persistence\Eloquent\TaskModel;
use Illuminate\Foundation\Testing\RefreshDatabase;
@@ -29,7 +30,8 @@ it('adds a task with work types of the job and the shared ones on offer', functi
->assertDontSee('painotyö');
Livewire::test('jobs::task-form', ['job' => $this->job->id])
->assertSet('form.assignee_user_ids', [(string) $this->employee->id])
->assertSet('form.assignee_user_id', (string) $this->employee->id)
->assertSet('form.member_user_ids', [])
->set('form.title', 'Mainoskuvat')
->set('form.work_type_id', (string) $this->graphic->id)
->set('form.due_on', '2026-05-20')
@@ -39,7 +41,8 @@ it('adds a task with work types of the job and the shared ones on offer', functi
$task = TaskModel::query()->sole();
expect($task->work_type_id)->toBe($this->graphic->id)
->and(DB::table('task_assignees')->where('task_id', $task->id)->pluck('user_id')->all())->toBe([$this->employee->id]);
->and($task->assignee_user_id)->toBe($this->employee->id)
->and(DB::table('task_members')->where('task_id', $task->id)->count())->toBe(0);
$this->get(route('jobs.show', $this->job->id))
->assertSee('Mainoskuvat')
@@ -117,3 +120,34 @@ it('returns 404 for a task of another job', function () {
$this->get(route('jobs.tasks.edit', [$this->job->id, $other->id]))->assertNotFound();
});
it('saves a task assignee and members apart, and the members find the job among their own', function () {
$colleague = User::factory()->create(['name' => 'Aino Ahkera']);
$intern = User::factory()->create(['name' => 'Ville Harjoittelija']);
Livewire::test('jobs::task-form', ['job' => $this->job->id])
->set('form.title', 'Mainoskuvat')
->set('form.work_type_id', (string) $this->graphic->id)
->set('form.assignee_user_id', (string) $colleague->id)
->set('form.member_user_ids', [(string) $intern->id, (string) $colleague->id])
->call('save')
->assertHasNoErrors();
$task = TaskModel::query()->sole();
expect($task->assignee_user_id)->toBe($colleague->id)
->and(DB::table('task_members')->where('task_id', $task->id)->pluck('user_id')->all())->toBe([$intern->id]);
$this->get(route('jobs.show', $this->job->id))
->assertSeeInOrder(['Tekijä', 'Aino Ahkera', 'Jäsenet', 'Ville Harjoittelija']);
Livewire::test('jobs::task-form', ['job' => $this->job->id, 'task' => $task->id])
->assertSet('form.assignee_user_id', (string) $colleague->id)
->assertSet('form.member_user_ids', [(string) $intern->id])
->set('form.assignee_user_id', '')
->call('save')
->assertHasNoErrors();
expect($task->refresh()->assignee_user_id)->toBeNull()
->and(app(TaskQueries::class)->assignedOpenTaskIds($intern->id))->toBe([$task->id]);
});