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:
@@ -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\Customers\Infrastructure\Persistence\Eloquent\CustomerModel;
|
||||
use App\Modules\Jobs\Infrastructure\Persistence\Eloquent\CustomerJobModel;
|
||||
use App\Modules\Jobs\Infrastructure\Persistence\Eloquent\TaskModel;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
@@ -53,7 +54,7 @@ it('moves a task to another person by dropping it and books their days', functio
|
||||
|
||||
expect($task->refresh()->planned_from?->format('Y-m-d'))->toBe('2026-12-28')
|
||||
->and($task->planned_to?->format('Y-m-d'))->toBe('2026-12-29')
|
||||
->and(DB::table('task_assignees')->where('task_id', $task->id)->pluck('user_id')->all())->toBe([$this->other->id])
|
||||
->and($task->assignee_user_id)->toBe($this->other->id)
|
||||
->and(DB::table('task_bookings')->where('task_id', $task->id)->orderBy('day')->pluck('minutes', 'day')->all())->toBe(['2026-12-28' => 360, '2026-12-29' => 360]);
|
||||
});
|
||||
|
||||
@@ -106,7 +107,7 @@ it('shows a subcontractor only their own row and lets them change only the statu
|
||||
->assertOk()
|
||||
->assertSee('Oma tehtävä')
|
||||
->assertDontSee('Toisen tehtävä')
|
||||
->assertDontSee('Eero Työntekijä')
|
||||
->assertDontSee('id="row-'.$this->employee->id.'-name"', escape: false)
|
||||
->assertDontSee('Ei tekijää');
|
||||
|
||||
Livewire::test('jobs::calendar')
|
||||
@@ -137,3 +138,43 @@ it('adds a schedule on the task form', function () {
|
||||
expect($task->planned_to?->format('Y-m-d'))->toBe('2026-12-28')
|
||||
->and(DB::table('task_bookings')->where('task_id', $task->id)->sum('minutes'))->toBe(240);
|
||||
});
|
||||
|
||||
it('shows a task only on its assignee row and books nothing for its members', function () {
|
||||
$task = TaskModel::factory()->assignedTo([$this->other->id, $this->employee->id])->create(['customer_job_id' => $this->job->id, 'work_type_id' => $this->graphic->id, 'title' => 'Mainoskuvat', 'estimated_hours' => 4]);
|
||||
|
||||
Livewire::test('jobs::calendar')->call('reschedule', $task->id, $this->job->id, $this->other->id, $this->other->id, '2026-12-22', '2026-12-22');
|
||||
|
||||
expect(DB::table('task_bookings')->where('task_id', $task->id)->pluck('user_id')->unique()->values()->all())->toBe([$this->other->id]);
|
||||
|
||||
Livewire::test('jobs::calendar')
|
||||
->set('mine', true)
|
||||
->assertDontSee('Mainoskuvat');
|
||||
});
|
||||
|
||||
it('leaves the tasks of quick sale jobs out of the unscheduled tasks', function () {
|
||||
$quickSales = CustomerJobModel::factory()->create(['name' => 'Pikamyynnit 2026', 'status' => 'in_production', 'quick_sale_year' => 2026]);
|
||||
calendarTaskModel(['customer_job_id' => $quickSales->id, 'work_type_id' => $this->graphic->id, 'title' => 'Passikuvat'], []);
|
||||
calendarTaskModel(['customer_job_id' => $this->job->id, 'work_type_id' => $this->graphic->id, 'title' => 'Mainoskuvat'], [$this->employee->id]);
|
||||
|
||||
Livewire::test('jobs::calendar')
|
||||
->assertSee('Mainoskuvat')
|
||||
->assertDontSee('Passikuvat');
|
||||
});
|
||||
|
||||
it('shows the job details in the info popover of a bar', function () {
|
||||
$this->job->update(['due_on' => '2026-12-31']);
|
||||
calendarTaskModel(['customer_job_id' => $this->job->id, 'work_type_id' => $this->graphic->id, 'title' => 'Mainoskuvat', 'description' => 'Kolme kuvaa somekanaviin', 'planned_from' => '2026-12-22', 'planned_to' => '2026-12-23'], [$this->other->id]);
|
||||
$task = TaskModel::query()->sole();
|
||||
|
||||
Livewire::test('jobs::calendar')
|
||||
->assertSee('aria-describedby="bar-info-'.$task->id.'-'.$this->other->id.'"', escape: false)
|
||||
->assertSeeInOrder([
|
||||
'Työ', $this->job->number, 'Kampanja',
|
||||
'Asiakas', CustomerModel::query()->findOrFail($this->job->customer_id)->name,
|
||||
'Työn tila', 'Tilaus',
|
||||
'Työn määräpäivä', '31.12.2026',
|
||||
'Vastuuhenkilö', 'Eero Työntekijä',
|
||||
'Työtehtävä', 'graafinen työ',
|
||||
'Kolme kuvaa somekanaviin',
|
||||
]);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user