diff --git a/app/Modules/Inventory/Presentation/Livewire/⚡task-materials.blade.php b/app/Modules/Inventory/Presentation/Livewire/⚡task-materials.blade.php index 1efe012..dafae9d 100644 --- a/app/Modules/Inventory/Presentation/Livewire/⚡task-materials.blade.php +++ b/app/Modules/Inventory/Presentation/Livewire/⚡task-materials.blade.php @@ -272,7 +272,7 @@ new class extends Component
@if (($this->context?->usesStock ?? false) || $this->movements !== []) -
+

{{ __('inventory.task.title') }}

{{ $message }}

diff --git a/app/Modules/Jobs/Presentation/Livewire/⚡show.blade.php b/app/Modules/Jobs/Presentation/Livewire/⚡show.blade.php index 8374a6f..a2d96f4 100644 --- a/app/Modules/Jobs/Presentation/Livewire/⚡show.blade.php +++ b/app/Modules/Jobs/Presentation/Livewire/⚡show.blade.php @@ -470,14 +470,6 @@ new class extends Component

{{ $task->description }}

@endif - - - - - - - -
@if ($canChangeStatus)
@@ -530,6 +522,33 @@ new class extends Component /> @endif
+ + + + + + + + + + + + {{-- The sections mark themselves data-task-section when they have something to show. --}} + + + +

{{ __('jobs.tasks.tabs.no_materials') }}

+
+
diff --git a/app/Modules/Machines/Presentation/Livewire/⚡task-machine.blade.php b/app/Modules/Machines/Presentation/Livewire/⚡task-machine.blade.php index c4496d1..2e78c3c 100644 --- a/app/Modules/Machines/Presentation/Livewire/⚡task-machine.blade.php +++ b/app/Modules/Machines/Presentation/Livewire/⚡task-machine.blade.php @@ -150,7 +150,7 @@ new class extends Component
@if ($this->canPlan() || $this->row !== null) -
+

{{ __('machines.task.title') }}

{{ $message }}

diff --git a/lang/en/jobs.php b/lang/en/jobs.php index 3e257f5..ea17276 100644 --- a/lang/en/jobs.php +++ b/lang/en/jobs.php @@ -148,6 +148,13 @@ return [ 'not_author' => 'You can edit and remove only your own comments.', ], ], + 'tabs' => [ + 'label' => 'Sections of task :title', + 'notes' => 'Checklist and comments', + 'images' => 'Images', + 'materials' => 'Materials and machines', + 'no_materials' => 'This task has no materials or machines.', + ], 'images' => [ 'title' => 'Images', 'list_of' => 'Images: :title', diff --git a/lang/fi/jobs.php b/lang/fi/jobs.php index a31fc4e..a0f5d6a 100644 --- a/lang/fi/jobs.php +++ b/lang/fi/jobs.php @@ -148,6 +148,13 @@ return [ 'not_author' => 'Voit muokata ja poistaa vain omia kommenttejasi.', ], ], + 'tabs' => [ + 'label' => 'Tehtävän :title osiot', + 'notes' => 'Tarkistuslista ja kommentit', + 'images' => 'Kuvat', + 'materials' => 'Materiaali ja koneet', + 'no_materials' => 'Tällä tehtävällä ei ole materiaaleja eikä koneita.', + ], 'images' => [ 'title' => 'Kuvat', 'list_of' => 'Kuvat: :title', diff --git a/resources/views/components/tabs.blade.php b/resources/views/components/tabs.blade.php new file mode 100644 index 0000000..c05c09e --- /dev/null +++ b/resources/views/components/tabs.blade.php @@ -0,0 +1,66 @@ +{{-- + Tabs after the WAI-ARIA tabs pattern, because TallStackUI's ties its + panels to ids that do not exist and has no arrow keys. Only the selected tab + is in the tab order; arrow keys, Home and End move between the tabs and + select them. Panels are children with the same id. + + $tabs: ['key' => 'title', ...] in display order. +--}} +@props([ + 'id', + 'label', + 'tabs', + 'selected' => null, +]) + +@php + $selected ??= array_key_first($tabs); +@endphp + +
class('space-y-3') }} + x-data="{ + selected: @js($selected), + select(key) { + this.selected = key; + this.$nextTick(() => document.getElementById(@js($id) + '-tab-' + key)?.focus()); + }, + move(event) { + const keys = @js(array_keys($tabs)); + const index = keys.indexOf(this.selected); + const next = { ArrowRight: index + 1, ArrowLeft: index - 1, Home: 0, End: keys.length - 1 }[event.key]; + if (next === undefined) { + return; + } + event.preventDefault(); + this.select(keys[(next + keys.length) % keys.length]); + }, + }" +> +
+ @foreach ($tabs as $key => $title) + + @endforeach +
+ + {{ $slot }} +
diff --git a/resources/views/components/tabs/panel.blade.php b/resources/views/components/tabs/panel.blade.php new file mode 100644 index 0000000..f0e4631 --- /dev/null +++ b/resources/views/components/tabs/panel.blade.php @@ -0,0 +1,21 @@ +{{-- + One panel of : $tabsId is the id given to , $name the key of + its tab. The panel is always rendered and only hidden, so Livewire components + in it keep their state. +--}} +@props([ + 'tabsId', + 'name', +]) + +
class('rounded-md focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-blue-700 dark:focus-visible:outline-blue-400') }} + role="tabpanel" + id="{{ $tabsId }}-panel-{{ $name }}" + aria-labelledby="{{ $tabsId }}-tab-{{ $name }}" + tabindex="0" + x-show="selected === @js($name)" + x-cloak +> + {{ $slot }} +
diff --git a/tests/Browser/InventoryAccessibilityTest.php b/tests/Browser/InventoryAccessibilityTest.php index a67a6be..8931da9 100644 --- a/tests/Browser/InventoryAccessibilityTest.php +++ b/tests/Browser/InventoryAccessibilityTest.php @@ -82,7 +82,8 @@ it('records material on a task card with the keyboard and without accessibility $visit = $device === 'mobile' ? $visit->on()->mobile() : $visit->on()->desktop(); $visit = $colorScheme === 'dark' ? $visit->inDarkMode() : $visit->inLightMode(); - $visit->assertSee(__('inventory.task.title')) + $visit->click('#task-'.$task->id.'-tabs-tab-materials') + ->assertSee(__('inventory.task.title')) ->fill('#task-'.$task->id.'-material-search', 'valoku') ->assertSee('1 osuma') ->click('[wire\:click="selectItem('.$this->item->id.')"]') diff --git a/tests/Browser/JobsAccessibilityTest.php b/tests/Browser/JobsAccessibilityTest.php index 09d9023..a2b3896 100644 --- a/tests/Browser/JobsAccessibilityTest.php +++ b/tests/Browser/JobsAccessibilityTest.php @@ -216,6 +216,42 @@ it('changes a task status and removes a task with the keyboard', function () { ->assertScript('document.activeElement.id', 'tasks-heading'); }); +it('puts the task actions above the tabs and moves between the tabs with the arrow keys', function (string $device, string $colorScheme) { + $this->job->update(['status' => 'order']); + $workType = WorkTypeModel::query()->where('name', 'videokuvaus')->sole(); + $task = TaskModel::factory() + ->create(['customer_job_id' => $this->job->id, 'work_type_id' => $workType->id, 'title' => 'Kuvauspäivä']); + $tabs = 'task-'.$task->id.'-tabs'; + + $visit = visit(route('jobs.show', $this->job->id)); + $visit = $device === 'mobile' ? $visit->on()->mobile() : $visit->on()->desktop(); + $visit = $colorScheme === 'dark' ? $visit->inDarkMode() : $visit->inLightMode(); + + $visit->click('#task-toggle-'.$task->id) + ->assertScript("!! (document.getElementById('task-status-{$task->id}').compareDocumentPosition(document.getElementById('{$tabs}-tab-notes')) & Node.DOCUMENT_POSITION_FOLLOWING)", true) + ->assertAttribute('#'.$tabs.'-tab-notes', 'aria-selected', 'true') + ->assertVisible('#checklist-new-'.$task->id) + ->assertMissing('#'.$tabs.'-panel-images') + ->keys('#'.$tabs.'-tab-notes', 'ArrowRight') + ->assertScript('document.activeElement.id', $tabs.'-tab-images') + ->assertAttribute('#'.$tabs.'-tab-images', 'aria-selected', 'true') + ->assertAttribute('#'.$tabs.'-tab-notes', 'tabindex', '-1') + ->assertVisible('#'.$tabs.'-panel-images') + ->assertMissing('#'.$tabs.'-panel-notes') + ->keys('#'.$tabs.'-tab-images', 'End') + ->assertScript('document.activeElement.id', $tabs.'-tab-materials') + ->assertSee('Tällä tehtävällä ei ole materiaaleja eikä koneita.') + ->keys('#'.$tabs.'-tab-materials', 'ArrowRight') + ->assertScript('document.activeElement.id', $tabs.'-tab-notes') + ->assertNoJavaScriptErrors() + ->assertNoAccessibilityIssues(level: 2); +})->with([ + 'desktop, light' => ['desktop', 'light'], + 'desktop, dark' => ['desktop', 'dark'], + 'mobile, light' => ['mobile', 'light'], + 'mobile, dark' => ['mobile', 'dark'], +]); + it('shows task cards collapsed, opens several at once and expands or collapses them all', function () { $this->job->update(['status' => 'order']); $workType = WorkTypeModel::query()->where('name', 'videokuvaus')->sole(); @@ -348,6 +384,7 @@ it('recaptions and removes a task image with the keyboard', function () { $page = visit(route('jobs.show', $this->job->id)) ->click('#task-toggle-'.$task->id) + ->click('#task-'.$task->id.'-tabs-tab-images') ->assertVisible('img[alt="Valot paikallaan"]') ->assertScript("document.querySelector('img[alt=\"Valot paikallaan\"]').naturalWidth > 0", true) ->assertSeeIn('#task-'.$task->id.'-title + dl', 'Kuvat:'); diff --git a/tests/Browser/MachinesAccessibilityTest.php b/tests/Browser/MachinesAccessibilityTest.php index 54a18e4..f168e26 100644 --- a/tests/Browser/MachinesAccessibilityTest.php +++ b/tests/Browser/MachinesAccessibilityTest.php @@ -53,6 +53,10 @@ it('has no accessibility issues on the machine pages', function (string $page, s $visit = $device === 'mobile' ? $visit->on()->mobile() : $visit->on()->desktop(); $visit = $colorScheme === 'dark' ? $visit->inDarkMode() : $visit->inLightMode(); + if ($page === 'job') { + $visit->click('#task-'.$this->task->id.'-tabs-tab-materials'); + } + $visit->assertSee($page === 'form' ? __('machines.form.edit_title') : 'Suurkuvatulostin') ->assertNoJavaScriptErrors() ->assertNoAccessibilityIssues(level: 2);