Rebuild the Kanban board after the prototype, with the job editor and quick intake dialog

- Toolbar: whose board (own, a person, a service line, all), pipeline
  views (daily, sales, full), urgent and late filters with a live count,
  normal and compact density, and the quick intake button.
- Columns side by side with horizontal scrolling on desktop, stacked on
  phones; each user's own column colours and order, the urgent column's
  threshold menu, and the continuing jobs column.
- Cards in customer colours: job cards with their tasks checked off inside
  the card (the status select is gone), continuing job cards with the next
  period, PIN and quick add, and pinned task cards. Dragging moves and
  orders cards; the keyboard opens the job editor from the card title.
- Job editor dialog: every job detail, tasks with checklists and
  templates, quick hours (TimeTracking) and expenses (Expenses), history.
- The quick intake form also adds a contact person, initial status and
  priority, and opens as a dialog on the board.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
2026-11-30 06:33:28 +02:00
co-authored by Claude Opus 5.5
parent f4b58f6b1d
commit 6332ff0fa9
35 changed files with 3556 additions and 494 deletions
@@ -0,0 +1,128 @@
<?php
use App\Models\User;
use App\Modules\Jobs\Infrastructure\Persistence\Eloquent\CustomerJobModel;
use App\Modules\Jobs\Infrastructure\Persistence\Eloquent\TaskModel;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Support\Facades\DB;
use Livewire\Livewire;
uses(RefreshDatabase::class);
beforeEach(function () {
$this->employee = User::factory()->create();
$this->actingAs($this->employee);
$this->job = CustomerJobModel::factory()->create(['name' => 'Kylkiteippaukset', 'status' => 'order', 'responsible_user_id' => $this->employee->id]);
});
it('opens a job from the board and saves its details without leaving the board', function () {
Livewire::test('jobs::board')
->call('openJob', $this->job->id)
->assertDispatched('open-job-editor', jobId: $this->job->id);
Livewire::test('jobs::job-editor')
->dispatch('open-job-editor', jobId: $this->job->id)
->assertSet('form.name', 'Kylkiteippaukset')
->assertSee($this->job->number)
->set('form.name', 'Pakettiauton kylkiteippaukset')
->set('form.instructions', 'Asiakkaan logo vektorina')
->call('save')
->assertHasNoErrors()
->assertDispatched('job-saved')
->assertDispatched('job-editor-saved');
expect($this->job->fresh()->name)->toBe('Pakettiauton kylkiteippaukset')
->and($this->job->fresh()->instructions)->toBe('Asiakkaan logo vektorina');
});
it('changes the status and priority at once and records them', function () {
Livewire::test('jobs::job-editor')
->dispatch('open-job-editor', jobId: $this->job->id)
->call('changeStatus', 'in_production')
->assertSee('tila: Tuotannossa')
->call('changePriority', 'urgent')
->assertSee('prioriteetti: Kiire');
expect($this->job->fresh()->status->value)->toBe('in_production')
->and($this->job->fresh()->priority->value)->toBe('urgent')
->and(DB::table('customer_job_changes')->where('customer_job_id', $this->job->id)->whereIn('field', ['status', 'priority'])->count())->toBe(2);
});
it('keeps an employee from billing statuses and from opening the lock', function () {
$this->job->update(['status' => 'done']);
Livewire::test('jobs::job-editor')
->dispatch('open-job-editor', jobId: $this->job->id)
->assertSee('tunnit ja kulut on lukittu')
->assertDontSee('Avaa lukitus (johto)')
->call('changeStatus', 'invoiced')
->assertHasErrors('form.status')
->call('changeStatus', 'in_production')
->assertHasErrors('form.status');
expect($this->job->fresh()->status->value)->toBe('done');
$this->actingAs(User::factory()->management()->create());
Livewire::test('jobs::job-editor')
->dispatch('open-job-editor', jobId: $this->job->id)
->call('unlock');
expect($this->job->fresh()->status->value)->toBe('in_production');
});
it('edits, adds and marks tasks done in the editor', function () {
$task = TaskModel::factory()->create(['customer_job_id' => $this->job->id, 'title' => 'Vedos', 'status' => 'waiting']);
$editor = Livewire::test('jobs::job-editor')
->dispatch('open-job-editor', jobId: $this->job->id)
->call('updateTaskField', $task->id, 'title', 'Vedos asiakkaalle')
->call('updateTaskField', $task->id, 'due_on', '2026-12-16')
->call('setTaskDone', $task->id, true)
->set('newTaskTitle', 'Asennus')
->call('addTask')
->assertHasNoErrors()
->assertSee('Tehtävä Asennus lisätty.');
expect($task->fresh()->title)->toBe('Vedos asiakkaalle')
->and($task->fresh()->due_on?->format('Y-m-d'))->toBe('2026-12-16')
->and($task->fresh()->status->value)->toBe('done')
->and(TaskModel::query()->where('customer_job_id', $this->job->id)->where('title', 'Asennus')->value('assignee_user_id'))->toBe($this->employee->id);
$editor->call('updateTaskField', $task->id, 'nonsense', 'x');
expect($task->fresh()->title)->toBe('Vedos asiakkaalle');
});
it('hides quote amounts without the quotes permission', function () {
$this->job->update(['quoted_amount_cents' => 123400]);
Livewire::test('jobs::job-editor')
->dispatch('open-job-editor', jobId: $this->job->id)
->assertSee('Tarjous- ja laskutussummat on piilotettu')
->assertDontSeeHtml('id="job-editor-quoted"');
$this->actingAs(User::factory()->management()->create());
Livewire::test('jobs::job-editor')
->dispatch('open-job-editor', jobId: $this->job->id)
->assertSeeHtml('id="job-editor-quoted"');
});
it('lets a subcontractor only look at their own job and tick its tasks', function () {
$subcontractor = User::factory()->subcontractor()->create();
$theirs = CustomerJobModel::factory()->withMembers([$subcontractor->id])->create(['status' => 'in_production']);
$task = TaskModel::factory()->create(['customer_job_id' => $theirs->id, 'status' => 'in_progress']);
$this->actingAs($subcontractor);
Livewire::test('jobs::job-editor')
->dispatch('open-job-editor', jobId: $this->job->id)
->assertForbidden();
Livewire::test('jobs::job-editor')
->dispatch('open-job-editor', jobId: $theirs->id)
->assertSee('Voit kuitata tehtäviä')
->call('setTaskDone', $task->id, true)
->call('save')
->assertForbidden();
expect($task->fresh()->status->value)->toBe('done');
});