Colour overloaded days and late tasks in the task calendar
Days over the daily capacity are amber and late task bars red, next to the existing icon and text. Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
This commit is contained in:
@@ -595,6 +595,7 @@ new class extends Component
|
|||||||
|
|
||||||
@foreach ($days as $index => $day)
|
@foreach ($days as $index => $day)
|
||||||
@php($booked = $row->minutesByDay[$day] ?? 0)
|
@php($booked = $row->minutesByDay[$day] ?? 0)
|
||||||
|
@php($overloaded = $row->userId !== null && $booked > $this->capacityMinutes)
|
||||||
<div
|
<div
|
||||||
wire:key="cell-{{ $rowKey }}-{{ $day }}"
|
wire:key="cell-{{ $rowKey }}-{{ $day }}"
|
||||||
data-calendar-day="{{ $day }}"
|
data-calendar-day="{{ $day }}"
|
||||||
@@ -602,7 +603,8 @@ new class extends Component
|
|||||||
x-bind:class="isTarget('{{ $day }}', '{{ $row->userId ?? '' }}') && 'outline-2 -outline-offset-2 outline-blue-700 dark:outline-blue-300'"
|
x-bind:class="isTarget('{{ $day }}', '{{ $row->userId ?? '' }}') && 'outline-2 -outline-offset-2 outline-blue-700 dark:outline-blue-300'"
|
||||||
@class([
|
@class([
|
||||||
'min-h-12 border-l border-zinc-200 dark:border-zinc-700',
|
'min-h-12 border-l border-zinc-200 dark:border-zinc-700',
|
||||||
'bg-zinc-200 dark:bg-zinc-950' => $this->isDayOff($day),
|
'bg-amber-100 dark:bg-amber-950' => $overloaded,
|
||||||
|
'bg-zinc-200 dark:bg-zinc-950' => $this->isDayOff($day) && ! $overloaded,
|
||||||
])
|
])
|
||||||
style="grid-column: {{ $index + 2 }}; grid-row: 1 / span {{ $row->lanes + 1 }};"
|
style="grid-column: {{ $index + 2 }}; grid-row: 1 / span {{ $row->lanes + 1 }};"
|
||||||
></div>
|
></div>
|
||||||
@@ -613,7 +615,7 @@ new class extends Component
|
|||||||
wire:key="load-{{ $rowKey }}-{{ $day }}"
|
wire:key="load-{{ $rowKey }}-{{ $day }}"
|
||||||
@class([
|
@class([
|
||||||
'pointer-events-none px-1 pt-1 text-right text-xs whitespace-nowrap',
|
'pointer-events-none px-1 pt-1 text-right text-xs whitespace-nowrap',
|
||||||
'font-semibold' => $booked > $this->capacityMinutes,
|
'font-semibold text-amber-900 dark:text-amber-200' => $booked > $this->capacityMinutes,
|
||||||
'text-zinc-600 dark:text-zinc-300' => $booked === 0,
|
'text-zinc-600 dark:text-zinc-300' => $booked === 0,
|
||||||
])
|
])
|
||||||
style="grid-column: {{ $index + 2 }}; grid-row: 1;"
|
style="grid-column: {{ $index + 2 }}; grid-row: 1;"
|
||||||
@@ -644,7 +646,8 @@ new class extends Component
|
|||||||
@class([
|
@class([
|
||||||
'relative z-10 mx-0.5 my-1 flex min-w-0 touch-none flex-col justify-center overflow-hidden border px-2 text-left text-xs leading-tight select-none focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-blue-700 dark:focus-visible:outline-blue-300',
|
'relative z-10 mx-0.5 my-1 flex min-w-0 touch-none flex-col justify-center overflow-hidden border px-2 text-left text-xs leading-tight select-none focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-blue-700 dark:focus-visible:outline-blue-300',
|
||||||
'cursor-grab' => $canManage,
|
'cursor-grab' => $canManage,
|
||||||
'border-primary-300 bg-primary-100 text-primary-950 dark:border-primary-600 dark:bg-primary-900 dark:text-white' => $bar->task->status !== TaskStatus::Done,
|
'border-primary-300 bg-primary-100 text-primary-950 dark:border-primary-600 dark:bg-primary-900 dark:text-white' => $bar->task->status !== TaskStatus::Done && ! $bar->late,
|
||||||
|
'border-red-600 bg-red-100 text-red-950 dark:border-red-400 dark:bg-red-950 dark:text-white' => $bar->late,
|
||||||
'border-zinc-300 bg-zinc-100 text-zinc-800 dark:border-zinc-600 dark:bg-zinc-700 dark:text-zinc-100' => $bar->task->status === TaskStatus::Done,
|
'border-zinc-300 bg-zinc-100 text-zinc-800 dark:border-zinc-600 dark:bg-zinc-700 dark:text-zinc-100' => $bar->task->status === TaskStatus::Done,
|
||||||
'rounded-l-md' => $bar->from >= $days[0],
|
'rounded-l-md' => $bar->from >= $days[0],
|
||||||
'rounded-r-md' => $bar->to <= $days[count($days) - 1],
|
'rounded-r-md' => $bar->to <= $days[count($days) - 1],
|
||||||
@@ -705,7 +708,7 @@ new class extends Component
|
|||||||
<dd>
|
<dd>
|
||||||
{{ $this->shortDate($bar->from) }}–{{ $this->shortDate($bar->to) }}@if ($bar->minutes > 0), {{ $this->hours($bar->minutes) }} h @endif
|
{{ $this->shortDate($bar->from) }}–{{ $this->shortDate($bar->to) }}@if ($bar->minutes > 0), {{ $this->hours($bar->minutes) }} h @endif
|
||||||
@if ($bar->late)
|
@if ($bar->late)
|
||||||
<span class="inline-flex items-center gap-1 font-semibold">
|
<span class="inline-flex items-center gap-1 font-semibold text-red-700 dark:text-red-400">
|
||||||
<x-icon name="exclamation-triangle" class="size-4" aria-hidden="true" />{{ __('jobs.late') }}
|
<x-icon name="exclamation-triangle" class="size-4" aria-hidden="true" />{{ __('jobs.late') }}
|
||||||
</span>
|
</span>
|
||||||
@endif
|
@endif
|
||||||
@@ -737,7 +740,11 @@ new class extends Component
|
|||||||
type="button"
|
type="button"
|
||||||
id="agenda-bar-{{ $bar->key() }}"
|
id="agenda-bar-{{ $bar->key() }}"
|
||||||
wire:click="openDialog({{ $bar->task->taskId }}, {{ $bar->userId ?? 'null' }})"
|
wire:click="openDialog({{ $bar->task->taskId }}, {{ $bar->userId ?? 'null' }})"
|
||||||
class="flex w-full flex-col gap-1 rounded-md border border-zinc-300 p-2 text-left text-sm focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-blue-700 dark:border-zinc-600 dark:focus-visible:outline-blue-300"
|
@class([
|
||||||
|
'flex w-full flex-col gap-1 rounded-md border p-2 text-left text-sm focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-blue-700 dark:focus-visible:outline-blue-300',
|
||||||
|
'border-zinc-300 dark:border-zinc-600' => ! $bar->late,
|
||||||
|
'border-red-600 border-l-4 bg-red-50 dark:border-red-400 dark:bg-red-950' => $bar->late,
|
||||||
|
])
|
||||||
>
|
>
|
||||||
<span class="font-semibold break-words">{{ $bar->task->title }}</span>
|
<span class="font-semibold break-words">{{ $bar->task->title }}</span>
|
||||||
<span>{{ $this->shortDate($bar->from) }}–{{ $this->shortDate($bar->to) }}@if ($bar->minutes > 0), {{ $this->hours($bar->minutes) }} h @endif</span>
|
<span>{{ $this->shortDate($bar->from) }}–{{ $this->shortDate($bar->to) }}@if ($bar->minutes > 0), {{ $this->hours($bar->minutes) }} h @endif</span>
|
||||||
@@ -746,7 +753,7 @@ new class extends Component
|
|||||||
<span class="break-words">{{ __('jobs.calendar.info.customer') }}: {{ $bar->task->customerName }}</span>
|
<span class="break-words">{{ __('jobs.calendar.info.customer') }}: {{ $bar->task->customerName }}</span>
|
||||||
@endif
|
@endif
|
||||||
@if ($bar->late)
|
@if ($bar->late)
|
||||||
<span class="inline-flex items-center gap-1 font-semibold">
|
<span class="inline-flex items-center gap-1 font-semibold text-red-700 dark:text-red-300">
|
||||||
<x-icon name="exclamation-triangle" class="size-4" aria-hidden="true" />{{ __('jobs.late') }}
|
<x-icon name="exclamation-triangle" class="size-4" aria-hidden="true" />{{ __('jobs.late') }}
|
||||||
</span>
|
</span>
|
||||||
@endif
|
@endif
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ use App\Modules\Catalog\Infrastructure\Persistence\Eloquent\WorkTypeModel;
|
|||||||
use App\Modules\Jobs\Infrastructure\Persistence\Eloquent\CustomerJobModel;
|
use App\Modules\Jobs\Infrastructure\Persistence\Eloquent\CustomerJobModel;
|
||||||
use App\Modules\Jobs\Infrastructure\Persistence\Eloquent\TaskModel;
|
use App\Modules\Jobs\Infrastructure\Persistence\Eloquent\TaskModel;
|
||||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||||
|
use Illuminate\Support\Facades\DB;
|
||||||
|
|
||||||
uses(RefreshDatabase::class);
|
uses(RefreshDatabase::class);
|
||||||
|
|
||||||
@@ -28,6 +29,12 @@ beforeEach(function () {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('has no accessibility issues on the task calendar', function (string $device, string $colorScheme) {
|
it('has no accessibility issues on the task calendar', function (string $device, string $colorScheme) {
|
||||||
|
// A day over the daily capacity and a late task (Leikkaus ends after its due date) get warning colours.
|
||||||
|
DB::table('task_bookings')->insert([
|
||||||
|
['task_id' => $this->task->id, 'user_id' => $this->user->id, 'day' => now()->toDateString(), 'minutes' => 600],
|
||||||
|
['task_id' => $this->task->id, 'user_id' => $this->user->id, 'day' => now()->addDays(2)->toDateString(), 'minutes' => 60],
|
||||||
|
]);
|
||||||
|
|
||||||
$visit = visit(route('jobs.calendar'));
|
$visit = visit(route('jobs.calendar'));
|
||||||
$visit = $device === 'mobile' ? $visit->on()->mobile() : $visit->on()->desktop();
|
$visit = $device === 'mobile' ? $visit->on()->mobile() : $visit->on()->desktop();
|
||||||
$visit = $colorScheme === 'dark' ? $visit->inDarkMode() : $visit->inLightMode();
|
$visit = $colorScheme === 'dark' ? $visit->inDarkMode() : $visit->inLightMode();
|
||||||
@@ -35,7 +42,14 @@ it('has no accessibility issues on the task calendar', function (string $device,
|
|||||||
$visit->assertNoJavaScriptErrors()
|
$visit->assertNoJavaScriptErrors()
|
||||||
->assertSee('Leikkaus')
|
->assertSee('Leikkaus')
|
||||||
->assertSee('Värimäärittely')
|
->assertSee('Värimäärittely')
|
||||||
->assertNoAccessibilityIssues(level: 2);
|
->assertSee('Myöhässä');
|
||||||
|
|
||||||
|
// Phones show an agenda list without the daily load.
|
||||||
|
if ($device === 'desktop') {
|
||||||
|
$visit->assertSee('10 / 7,5 h');
|
||||||
|
}
|
||||||
|
|
||||||
|
$visit->assertNoAccessibilityIssues(level: 2);
|
||||||
})->with([
|
})->with([
|
||||||
'desktop, light' => ['desktop', 'light'],
|
'desktop, light' => ['desktop', 'light'],
|
||||||
'desktop, dark' => ['desktop', 'dark'],
|
'desktop, dark' => ['desktop', 'dark'],
|
||||||
|
|||||||
Reference in New Issue
Block a user