4 Commits
Author SHA1 Message Date
petriandClaude Opus 5.5 f3d2b3e39e Give the editor's task checklist its own toggle, comments and images their tabs
Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-30 11:05:44 +02:00
petriandClaude Opus 5.5 1d9bcefb41 Fix editor colour refresh, task row layout, dark date icons and time cell width
- The job editor redraws its customer-coloured header when the board saves
  a customer colour (customer-color-changed).
- Service units and members in the editor's sidebar are in two columns.
- Native controls follow the dark theme (color-scheme), so the date
  picker's calendar icon is light.
- Task status, assignee and due date sit side by side in the editor.
- Each task in the editor has its checklist, comments and images.
- The time sheet's time field shows five characters (00:00).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-30 11:00:53 +02:00
petriandClaude Opus 5.5 38c5b43018 Include the last day of a date range in expense and time entry queries
SQLite stores date casts as "Y-m-d 00:00:00", so a between ending at
"Y-m-d" left out the month's last day and the week's Sunday (the own
expenses test failed on the 30th). Ranges now end before the next day.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-30 10:47:01 +02:00
petriandClaude Opus 5.5 f24bd3cc35 Document the board, time sheet and colour pieces in CLAUDE.md
Also drops a redundant array_values() that Larastan flagged in MoveBoardCard.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-30 10:32:15 +02:00
16 changed files with 153 additions and 28 deletions
+2 -1
View File
File diff suppressed because one or more lines are too long
@@ -34,7 +34,10 @@ class EloquentExpenseQueries implements ExpenseQueries
return $this->summaries(ExpenseModel::query()
->where('user_id', $userId)
->whereBetween('spent_on', [$start->toDateString(), $start->copy()->endOfMonth()->toDateString()]));
// An upper bound before the next month: SQLite keeps date casts as "Y-m-d 00:00:00",
// which a between ending at the month's last "Y-m-d" would leave out.
->where('spent_on', '>=', $start->toDateString())
->where('spent_on', '<', $start->copy()->addMonth()->toDateString()));
}
public function find(int $id): ?ExpenseSummary
@@ -125,7 +125,7 @@ final class MoveBoardCard
$jobPositions = [];
$taskPositions = [];
foreach (array_values($orderedKeys) as $index => $key) {
foreach ($orderedKeys as $index => $key) {
if (preg_match('/^(job|task)-(\d+)$/', $key, $matches) !== 1) {
continue;
}
@@ -387,6 +387,7 @@ new class extends Component
}
$this->refreshBoard();
$this->dispatch('customer-color-changed', customerId: $customerId);
$this->statusMessage = __('jobs.board.customer_color_saved', ['customer' => $card->customerName ?? '']);
}
@@ -130,6 +130,23 @@ new class extends Component
return $this->jobId === null ? [] : app(TaskQueries::class)->pinnedTaskIds($this->jobId);
}
/**
* The colour picker lives on the board, so the board tells the editor
* when a customer's colour changed; the header colour is read on render.
*/
#[On('customer-color-changed')]
public function customerColorChanged(): void
{
unset($this->job);
}
#[On('task-comments-changed')]
#[On('task-images-changed')]
public function refreshTasks(): void
{
unset($this->tasks);
}
public function canEdit(): bool
{
return Gate::allows('jobs.manage');
@@ -436,6 +453,7 @@ new class extends Component
$staff = collect($this->users)->reject(fn ($user) => $user->role === Role::Subcontractor);
$headerColor = new HexColor($job?->customer->id !== null ? (app(\App\Modules\Customers\Application\Contracts\CustomerQueries::class)->headerColorsByIds([$job->customer->id])[$job->customer->id] ?? '#23476a') : '#23476a');
$fieldClass = 'w-full rounded-lg border border-neutral-400 bg-white px-2.5 py-1.5 text-xs text-neutral-900 focus-visible:outline-2 focus-visible:outline-primary-600 dark:border-[#6b7079] dark:bg-[#24262a] dark:text-white dark:focus-visible:outline-primary-300';
$controlClass = 'w-auto max-w-full rounded-lg border border-neutral-400 bg-white px-2.5 py-1.5 text-xs text-neutral-900 focus-visible:outline-2 focus-visible:outline-primary-600 dark:border-[#6b7079] dark:bg-[#24262a] dark:text-white dark:focus-visible:outline-primary-300';
$labelClass = 'mb-1 block text-[11px] font-semibold text-neutral-800 dark:text-neutral-100';
$boxClass = 'space-y-2.5 rounded-xl border border-neutral-200 bg-neutral-100 p-3.5 dark:border-[#36393f] dark:bg-[#18191b]';
$boxHeading = 'text-[10px] font-extrabold tracking-wider text-neutral-700 uppercase dark:text-neutral-200';
@@ -598,7 +616,7 @@ new class extends Component
@if (Gate::allows('jobs.manage-tasks', [$job->id]) && $this->templates !== [] && $job->status->allowsTasks())
<form wire:submit="applyTemplate" class="flex items-center gap-1.5">
<label for="job-editor-template" class="sr-only">{{ __('jobs.editor.template') }}</label>
<select id="job-editor-template" wire:model="templateId" class="{{ $fieldClass }} w-auto py-1 text-[11px]">
<select id="job-editor-template" wire:model="templateId" class="{{ $controlClass }} py-1 text-[11px]">
<option value="">{{ __('jobs.editor.template_choose') }}</option>
@foreach ($this->templates as $template)
<option value="{{ $template->id }}">{{ $template->name }}</option>
@@ -616,7 +634,7 @@ new class extends Component
<ul class="space-y-2">
@foreach ($this->tasks as $task)
@php($canManageTask = Gate::allows('jobs.manage-tasks', [$job->id]))
<li wire:key="editor-task-{{ $task->id }}" x-data="{ checklist: false }" class="space-y-2 rounded-xl border border-neutral-200 bg-white p-2.5 text-xs dark:border-[#36393f] dark:bg-[#25272b]">
<li wire:key="editor-task-{{ $task->id }}" x-data="{ checklist: false, extras: false }" class="space-y-2 rounded-xl border border-neutral-200 bg-white p-2.5 text-xs dark:border-[#36393f] dark:bg-[#25272b]">
<div class="flex flex-wrap items-center justify-between gap-2">
<div class="flex min-w-0 flex-1 items-center gap-2">
<input
@@ -646,20 +664,20 @@ new class extends Component
@if ($canManageTask)
<div class="flex flex-wrap items-center gap-1.5">
<label for="editor-task-status-{{ $task->id }}" class="sr-only">{{ __('jobs.editor.task_status', ['task' => $task->title]) }}</label>
<select id="editor-task-status-{{ $task->id }}" wire:change="updateTaskField({{ $task->id }}, 'status', $event.target.value)" class="{{ $fieldClass }} w-auto py-0.5 text-[11px]">
<select id="editor-task-status-{{ $task->id }}" wire:change="updateTaskField({{ $task->id }}, 'status', $event.target.value)" class="{{ $controlClass }} py-0.5 text-[11px]">
@foreach (TaskStatus::cases() as $taskStatus)
<option value="{{ $taskStatus->value }}" @selected($taskStatus === $task->status)>{{ __('jobs.tasks.statuses.'.$taskStatus->value) }}</option>
@endforeach
</select>
<label for="editor-task-assignee-{{ $task->id }}" class="sr-only">{{ __('jobs.editor.task_assignee', ['task' => $task->title]) }}</label>
<select id="editor-task-assignee-{{ $task->id }}" wire:change="updateTaskField({{ $task->id }}, 'assignee', $event.target.value)" class="{{ $fieldClass }} w-auto py-0.5 text-[11px]">
<select id="editor-task-assignee-{{ $task->id }}" wire:change="updateTaskField({{ $task->id }}, 'assignee', $event.target.value)" class="{{ $controlClass }} py-0.5 text-[11px]">
<option value="">{{ __('jobs.editor.no_assignee') }}</option>
@foreach ($this->users as $user)
<option value="{{ $user->id }}" @selected($user->id === $task->assignee?->id)>{{ $user->name }}</option>
@endforeach
</select>
<label for="editor-task-due-{{ $task->id }}" class="sr-only">{{ __('jobs.editor.task_due', ['task' => $task->title]) }}</label>
<input id="editor-task-due-{{ $task->id }}" type="date" value="{{ $task->dueOn }}" wire:change="updateTaskField({{ $task->id }}, 'due_on', $event.target.value)" class="{{ $fieldClass }} w-auto py-0.5 text-[11px]" />
<input id="editor-task-due-{{ $task->id }}" type="date" value="{{ $task->dueOn }}" wire:change="updateTaskField({{ $task->id }}, 'due_on', $event.target.value)" class="{{ $controlClass }} py-0.5 text-[11px]" />
@if ($job->status === JobStatus::Ongoing)
@php($pinned = $this->pinnedTasks[$task->id] ?? false)
<button
@@ -674,20 +692,49 @@ new class extends Component
</div>
@error('tasks.'.$task->id) <p class="text-xs font-semibold text-red-700 dark:text-red-200">{{ $message }}</p> @enderror
<div class="pl-6">
<button
type="button"
x-on:click="checklist = ! checklist"
x-bind:aria-expanded="checklist.toString()"
aria-controls="editor-checklist-{{ $task->id }}"
class="inline-flex min-h-6 items-center gap-1 rounded text-[11px] font-semibold text-indigo-800 hover:underline focus-visible:outline-2 focus-visible:outline-primary-600 dark:text-indigo-100 dark:focus-visible:outline-primary-300"
>
<x-icon name="chevron-right" class="size-3 transition" x-bind:class="checklist && 'rotate-90'" aria-hidden="true" />
{{ __('jobs.editor.checklist') }}
</button>
<div class="space-y-1 pl-6">
<div class="flex flex-wrap gap-3">
<button
type="button"
x-on:click="checklist = ! checklist"
x-bind:aria-expanded="checklist.toString()"
aria-controls="editor-checklist-{{ $task->id }}"
class="inline-flex min-h-6 items-center gap-1 rounded text-[11px] font-semibold text-indigo-800 hover:underline focus-visible:outline-2 focus-visible:outline-primary-600 dark:text-indigo-100 dark:focus-visible:outline-primary-300"
>
<x-icon name="chevron-right" class="size-3 transition" x-bind:class="checklist && 'rotate-90'" aria-hidden="true" />
{{ __('jobs.editor.checklist') }}
</button>
<button
type="button"
x-on:click="extras = ! extras"
x-bind:aria-expanded="extras.toString()"
aria-controls="editor-extras-{{ $task->id }}"
class="inline-flex min-h-6 items-center gap-1 rounded text-[11px] font-semibold text-indigo-800 hover:underline focus-visible:outline-2 focus-visible:outline-primary-600 dark:text-indigo-100 dark:focus-visible:outline-primary-300"
>
<x-icon name="chevron-right" class="size-3 transition" x-bind:class="extras && 'rotate-90'" aria-hidden="true" />
{{ __('jobs.editor.extras', ['comments' => $task->commentCount, 'images' => $task->imageCount]) }}
</button>
</div>
<div id="editor-checklist-{{ $task->id }}" x-show="checklist" x-cloak class="pt-1">
<livewire:jobs::task-checklist :job-id="$job->id" :task-id="$task->id" :task-title="$task->title" :wire:key="'editor-checklist-'.$task->id" />
</div>
<div id="editor-extras-{{ $task->id }}" x-show="extras" x-cloak class="pt-1">
<x-tabs
id="editor-task-{{ $task->id }}-tabs"
:label="__('jobs.tasks.tabs.label', ['title' => $task->title])"
:tabs="[
'comments' => __('jobs.editor.tab_comments', ['count' => $task->commentCount]),
'images' => __('jobs.editor.tab_images', ['count' => $task->imageCount]),
]"
>
<x-tabs.panel tabs-id="editor-task-{{ $task->id }}-tabs" name="comments">
<livewire:jobs::task-comments :job-id="$job->id" :task-id="$task->id" :task-title="$task->title" :wire:key="'editor-comments-'.$task->id" />
</x-tabs.panel>
<x-tabs.panel tabs-id="editor-task-{{ $task->id }}-tabs" name="images">
<livewire:jobs::task-images :job-id="$job->id" :task-id="$task->id" :task-title="$task->title" :wire:key="'editor-images-'.$task->id" />
</x-tabs.panel>
</x-tabs>
</div>
</div>
</li>
@endforeach
@@ -699,7 +746,7 @@ new class extends Component
<label for="job-editor-new-task" class="sr-only">{{ __('jobs.editor.new_task') }}</label>
<input id="job-editor-new-task" type="text" wire:model="newTaskTitle" maxlength="255" placeholder="{{ __('jobs.editor.new_task_placeholder') }}" class="{{ $fieldClass }} min-w-[200px] flex-1 placeholder:text-neutral-600 dark:placeholder:text-neutral-300" />
<label for="job-editor-new-task-assignee" class="sr-only">{{ __('jobs.editor.new_task_assignee') }}</label>
<select id="job-editor-new-task-assignee" wire:model="newTaskAssignee" class="{{ $fieldClass }} w-auto">
<select id="job-editor-new-task-assignee" wire:model="newTaskAssignee" class="{{ $controlClass }}">
<option value="">{{ __('jobs.editor.no_assignee') }}</option>
@foreach ($this->users as $user)
<option value="{{ $user->id }}">{{ $user->name }}</option>
@@ -809,6 +856,7 @@ new class extends Component
</div>
@endforeach
<x-checkbox-group
:columns="2"
:legend="__('jobs.fields.members')"
model="form.member_user_ids"
:options="collect($this->users)->map(fn ($user) => ['value' => $user->id, 'label' => $user->name, 'note' => $user->role === Role::Subcontractor ? __('users.roles.subcontractor') : null])->all()"
@@ -817,7 +865,7 @@ new class extends Component
<section aria-labelledby="job-editor-units-heading" class="{{ $boxClass }}">
<h3 id="job-editor-units-heading" class="{{ $boxHeading }}">{{ __('jobs.editor.units_section') }}</h3>
<x-checkbox-group :legend="__('jobs.fields.service_units')" model="form.service_unit_ids" :options="$this->serviceUnitOptions" />
<x-checkbox-group :columns="2" :legend="__('jobs.fields.service_units')" model="form.service_unit_ids" :options="$this->serviceUnitOptions" />
<div class="space-y-1.5">
<p id="editor-tags-label" class="{{ $labelClass }}">{{ __('jobs.fields.tags') }}</p>
@if ($form->tags !== [])
@@ -42,7 +42,8 @@ class EloquentTimeEntryQueries implements TimeEntryQueries
$entries = TimeEntryModel::query()
->where('user_id', $userId)
->whereBetween('worked_on', [$days[0], $days[6]])
->where('worked_on', '>=', $days[0])
->where('worked_on', '<', CarbonImmutable::parse($days[6])->addDay()->toDateString())
->get();
$pinnedIds = $this->pins->pinnedTaskIds($userId);
$scheduledIds = $this->tasks->scheduledTaskIdsFor($userId, $days[0], $days[6]);
@@ -100,7 +101,8 @@ class EloquentTimeEntryQueries implements TimeEntryQueries
$start = CarbonImmutable::createFromFormat('!Y-m', $month) ?: CarbonImmutable::now()->startOfMonth();
$entries = TimeEntryModel::query()
->where('user_id', $userId)
->whereBetween('worked_on', [$start->toDateString(), $start->endOfMonth()->toDateString()])
->where('worked_on', '>=', $start->toDateString())
->where('worked_on', '<', $start->addMonth()->toDateString())
->get();
$paymentBases = [];
@@ -135,7 +137,8 @@ class EloquentTimeEntryQueries implements TimeEntryQueries
$entries = TimeEntryModel::query()
->where('user_id', $userId)
->whereBetween('worked_on', [$days[0], $days[6]])
->where('worked_on', '>=', $days[0])
->where('worked_on', '<', CarbonImmutable::parse($days[6])->addDay()->toDateString())
->get();
$taskIds = array_values(array_unique(array_merge(
@@ -55,7 +55,9 @@ class EloquentTimeEntryRepository implements TimeEntryRepository
{
return TimeEntryModel::query()
->where('user_id', $userId)
->whereBetween('worked_on', [$from->format('Y-m-d'), $to->format('Y-m-d')])
// Exclusive upper bound: SQLite keeps date casts as "Y-m-d 00:00:00".
->where('worked_on', '>=', $from->format('Y-m-d'))
->where('worked_on', '<', $to->modify('+1 day')->format('Y-m-d'))
->orderBy('worked_on')
->get()
->map(fn (TimeEntryModel $model): TimeEntry => $this->toEntity($model))
+3
View File
@@ -308,6 +308,9 @@ return [
],
'editor' => [
'extras' => 'Comments and images (comments :comments, images :images)',
'tab_comments' => 'Comments (:count)',
'tab_images' => 'Images (:count)',
'heading' => 'Customer job :number',
'close' => 'Close the card',
'color' => 'Colour',
+3
View File
@@ -308,6 +308,9 @@ return [
],
'editor' => [
'extras' => 'Kommentit ja kuvat (kommentit :comments, kuvat :images)',
'tab_comments' => 'Kommentit (:count)',
'tab_images' => 'Kuvat (:count)',
'heading' => 'Asiakastyö :number',
'close' => 'Sulje kortti',
'color' => 'Väri',
+9
View File
@@ -60,6 +60,15 @@ html {
overflow-y: scroll;
}
/*
* Native controls (the date picker's calendar icon and popup, select arrows,
* scrollbars) follow the page theme. html.dark, not .dark: the header always
* carries .dark.
*/
html.dark {
color-scheme: dark;
}
[x-cloak] {
display: none !important;
}
@@ -10,7 +10,7 @@
'model',
'options',
'hint' => null,
'columns' => true,
'columns' => true, // true: 2 from sm and 3 from lg; 2: always two; false: one
])
@php
@@ -28,7 +28,7 @@
<p id="{{ $id }}-hint" class="text-sm text-zinc-600 dark:text-zinc-200">{{ $hint }}</p>
@endif
<div @class(['grid gap-2', 'sm:grid-cols-2 lg:grid-cols-3' => $columns])>
<div @class(['grid gap-2', 'grid-cols-2' => $columns === 2, 'sm:grid-cols-2 lg:grid-cols-3' => $columns === true])>
@foreach ($options as $option)
<label wire:key="{{ $id }}-{{ $option['value'] }}" class="flex min-h-6 cursor-pointer items-start gap-2 text-sm">
<input
@@ -254,7 +254,7 @@
wire:change="saveCell({{ $taskId }}, '{{ $day }}', $event.target.value)"
@error($errorKey) aria-invalid="true" aria-describedby="{{ $fieldId }}-error" @enderror
@class([
'h-6 w-11 rounded border text-center font-mono text-[11px] focus-visible:outline-2 focus-visible:outline-primary-600 aria-invalid:border-red-700 dark:focus-visible:outline-primary-300 dark:aria-invalid:border-red-300',
'h-6 w-12 rounded border px-0.5 text-center font-mono text-[11px] tabular-nums focus-visible:outline-2 focus-visible:outline-primary-600 aria-invalid:border-red-700 dark:focus-visible:outline-primary-300 dark:aria-invalid:border-red-300',
'border-emerald-600 bg-emerald-50 font-semibold text-emerald-900 dark:border-emerald-500/50 dark:bg-emerald-950/50 dark:text-emerald-100' => $quarters > 0,
'border-slate-400 bg-slate-50 text-slate-700 dark:border-[#5a5e66] dark:bg-[#1b1d20] dark:text-zinc-200' => $quarters === 0,
])
+3
View File
@@ -160,6 +160,9 @@ it('has no accessibility issues in the job editor and the quick intake dialog',
$visit->click('#card-job-'.$this->job->id.'-open')
->assertScript('document.getElementById("job-editor-dialog").open', true)
->assertSee('Kuvauspäivä')
->click('#job-editor-dialog [aria-controls^="editor-checklist-"]')
->click('#job-editor-dialog [aria-controls^="editor-extras-"]')
->assertSee('Kuvat (0)')
->assertNoJavaScriptErrors()
->assertNoAccessibilityIssues(level: 2)
->keys('#job-editor-name', 'Escape')
@@ -178,3 +178,15 @@ it('links the job page to its expenses and shows the own expenses by month', fun
->assertSee('Lokakuu 2026')
->assertSee('Lokakuun hankinta');
});
it('lists an expense of the month\'s last day on the own expenses page', function () {
$user = User::factory()->create();
ExpenseModel::factory()->create(['customer_job_id' => $this->job->id, 'user_id' => $user->id, 'description' => 'Helmikuun viimeinen hankinta', 'spent_on' => '2026-02-28']);
ExpenseModel::factory()->create(['customer_job_id' => $this->job->id, 'user_id' => $user->id, 'description' => 'Maaliskuun hankinta', 'spent_on' => '2026-03-01']);
$this->actingAs($user)
->get(route('expenses.mine', ['kuukausi' => '2026-02']))
->assertOk()
->assertSee('Helmikuun viimeinen hankinta')
->assertDontSee('Maaliskuun hankinta');
});
@@ -126,3 +126,30 @@ it('lets a subcontractor only look at their own job and tick its tasks', functio
expect($task->fresh()->status->value)->toBe('done');
});
it('shows a new customer colour at once when the board saves it', function () {
$editor = Livewire::test('jobs::job-editor')
->dispatch('open-job-editor', jobId: $this->job->id)
->assertSeeHtml('background-color: #23476a');
Livewire::test('jobs::board')
->call('setCustomerColor', $this->job->customer_id, '#991b1b')
->assertDispatched('customer-color-changed', customerId: $this->job->customer_id);
$editor->dispatch('customer-color-changed', customerId: $this->job->customer_id)
->assertSeeHtml('background-color: #991b1b');
});
it('has comments and images for each task', function () {
$task = TaskModel::factory()->create(['customer_job_id' => $this->job->id, 'title' => 'Vedos']);
Livewire::test('jobs::job-editor')
->dispatch('open-job-editor', jobId: $this->job->id)
->assertSee('Tarkistuslista')
->assertSee('Kommentit ja kuvat (kommentit 0, kuvat 0)')
->assertSeeLivewire('jobs::task-checklist')
->assertSeeLivewire('jobs::task-comments')
->assertSeeLivewire('jobs::task-images')
->assertSeeHtml('editor-task-'.$task->id.'-tabs-tab-comments')
->assertSeeHtml('editor-task-'.$task->id.'-tabs-tab-images');
});
@@ -166,3 +166,13 @@ it('keeps subcontractors to their own jobs and blocks removing tasks with hours'
$this->actingAs(User::factory()->subcontractor()->create());
$this->get(route('time.task', $this->task->id))->assertForbidden();
});
it('counts the hours of Sunday in the week', function () {
$sunday = now()->startOfWeek()->addDays(6)->toDateString();
TimeEntryModel::factory()->create(['task_id' => $this->task->id, 'user_id' => $this->employee->id, 'worked_on' => $sunday, 'hours' => 2]);
$sheet = Livewire::test('time::week')->instance()->sheet;
expect($sheet->totalQuarters)->toBe(8)
->and($sheet->dayTotals[$sunday])->toBe(8);
});