diff --git a/app/Modules/Jobs/Presentation/Livewire/⚡calendar.blade.php b/app/Modules/Jobs/Presentation/Livewire/⚡calendar.blade.php
index a40be67..7c44ece 100644
--- a/app/Modules/Jobs/Presentation/Livewire/⚡calendar.blade.php
+++ b/app/Modules/Jobs/Presentation/Livewire/⚡calendar.blade.php
@@ -552,6 +552,7 @@ new class extends Component
x-on:pointermove.window="track($event)"
x-on:pointerup.window="drop($event)"
x-on:keydown.escape.window="cancel(); closeInfo()"
+ x-on:pointerdown.window="dismissInfo($event)"
x-on:task-calendar-place.window="begin($event.detail.event, 'place', $event.detail.bar)"
>
@@ -641,13 +642,14 @@ new class extends Component
id="bar-{{ $bar->key() }}"
wire:key="bar-{{ $bar->key() }}"
aria-label="{{ $this->barLabel($bar) }}"
- aria-describedby="bar-info-{{ $bar->key() }}"
+ aria-describedby="bar-info-{{ $bar->key() }}-details"
+ data-calendar-bar
x-on:mouseenter="showInfo($el, 'bar-info-{{ $bar->key() }}')"
x-on:mouseleave="hideInfo('bar-info-{{ $bar->key() }}')"
x-on:focus="showInfo($el, 'bar-info-{{ $bar->key() }}')"
- x-on:blur="hideInfo('bar-info-{{ $bar->key() }}', 0)"
+ x-on:blur="blurBar($event, 'bar-info-{{ $bar->key() }}')"
x-on:pointerdown="begin($event, 'move', @js(['task' => $bar->task->taskId, 'job' => $bar->task->jobId, 'user' => $bar->userId, 'from' => $bar->from, 'to' => $bar->to]))"
- x-on:click="if (! consumeDrag()) $wire.openDialog({{ $bar->task->taskId }}, {{ $bar->userId ?? 'null' }})"
+ x-on:click="clickBar($el, 'bar-info-{{ $bar->key() }}', () => $wire.openDialog({{ $bar->task->taskId }}, {{ $bar->userId ?? 'null' }}))"
@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',
'cursor-grab' => $canManage,
@@ -682,46 +684,58 @@ new class extends Component
@endif
- {{-- The job's basic details on hover and focus (WCAG 1.4.13: hoverable, Escape closes it). --}}
+ {{-- The job's basic details on hover, focus and tap (WCAG 1.4.13: hoverable, Escape closes it), with a button to the dialog for touch screens. --}}
-
{{ $bar->task->title }}
-
- - {{ __('jobs.calendar.info.job') }}
- - {{ $bar->task->jobNumber }} {{ $bar->task->jobName }}
- - {{ __('jobs.calendar.info.customer') }}
- - {{ $bar->task->customerName ?? __('jobs.not_set') }}
- - {{ __('jobs.calendar.info.job_status') }}
- - {{ $bar->task->jobStatus === null ? __('jobs.not_set') : __('jobs.statuses.'.$bar->task->jobStatus->value) }}
- - {{ __('jobs.calendar.info.job_due_on') }}
- - {{ $bar->task->jobDueOn === null ? __('jobs.not_set') : $this->shortDate($bar->task->jobDueOn) }}
- - {{ __('jobs.calendar.info.responsible') }}
- - {{ $bar->task->responsibleName ?? __('jobs.not_set') }}
- - {{ __('jobs.calendar.info.work_type') }}
- - {{ $bar->task->workTypeName ?? __('jobs.not_set') }}
- - {{ __('jobs.calendar.info.due_on') }}
- - {{ $bar->task->dueOn === null ? __('jobs.not_set') : $this->shortDate($bar->task->dueOn) }}
- - {{ __('jobs.calendar.info.schedule') }}
- -
- {{ $this->shortDate($bar->from) }}–{{ $this->shortDate($bar->to) }}@if ($bar->minutes > 0), {{ $this->hours($bar->minutes) }} h @endif
- @if ($bar->late)
-
- {{ __('jobs.late') }}
-
- @endif
-
-
- @if ($bar->task->description !== null)
-
{{ $bar->task->description }}
- @endif
+
+
{{ $bar->task->title }}
+
+ - {{ __('jobs.calendar.info.job') }}
+ - {{ $bar->task->jobNumber }} {{ $bar->task->jobName }}
+ - {{ __('jobs.calendar.info.customer') }}
+ - {{ $bar->task->customerName ?? __('jobs.not_set') }}
+ - {{ __('jobs.calendar.info.job_status') }}
+ - {{ $bar->task->jobStatus === null ? __('jobs.not_set') : __('jobs.statuses.'.$bar->task->jobStatus->value) }}
+ - {{ __('jobs.calendar.info.job_due_on') }}
+ - {{ $bar->task->jobDueOn === null ? __('jobs.not_set') : $this->shortDate($bar->task->jobDueOn) }}
+ - {{ __('jobs.calendar.info.responsible') }}
+ - {{ $bar->task->responsibleName ?? __('jobs.not_set') }}
+ - {{ __('jobs.calendar.info.work_type') }}
+ - {{ $bar->task->workTypeName ?? __('jobs.not_set') }}
+ - {{ __('jobs.calendar.info.due_on') }}
+ - {{ $bar->task->dueOn === null ? __('jobs.not_set') : $this->shortDate($bar->task->dueOn) }}
+ - {{ __('jobs.calendar.info.schedule') }}
+ -
+ {{ $this->shortDate($bar->from) }}–{{ $this->shortDate($bar->to) }}@if ($bar->minutes > 0), {{ $this->hours($bar->minutes) }} h @endif
+ @if ($bar->late)
+
+ {{ __('jobs.late') }}
+
+ @endif
+
+
+ @if ($bar->task->description !== null)
+
{{ $bar->task->description }}
+ @endif
+
+
+
+
@endforeach
diff --git a/lang/en/jobs.php b/lang/en/jobs.php
index 527ae07..d5cd724 100644
--- a/lang/en/jobs.php
+++ b/lang/en/jobs.php
@@ -235,6 +235,8 @@ return [
'work_type' => 'Work type',
'due_on' => 'Task due date',
'schedule' => 'Schedule',
+ 'open_schedule' => 'Open schedule',
+ 'open_schedule_named' => 'Open schedule: task :title',
],
'unscheduled' => 'Unscheduled tasks',
'unscheduled_intro' => 'Open tasks without a schedule. Drag a task onto the calendar or choose Schedule.',
diff --git a/lang/fi/jobs.php b/lang/fi/jobs.php
index 5b0e2aa..f346038 100644
--- a/lang/fi/jobs.php
+++ b/lang/fi/jobs.php
@@ -235,6 +235,8 @@ return [
'work_type' => 'Työtehtävä',
'due_on' => 'Tehtävän määräpäivä',
'schedule' => 'Aikataulu',
+ 'open_schedule' => 'Avaa aikataulu',
+ 'open_schedule_named' => 'Avaa aikataulu: tehtävä :title',
],
'unscheduled' => 'Aikatauluttamattomat tehtävät',
'unscheduled_intro' => 'Avoimet tehtävät ilman aikataulua. Vedä tehtävä kalenteriin tai valitse Aikatauluta.',
diff --git a/resources/js/task-calendar.js b/resources/js/task-calendar.js
index 85de564..880f0f1 100644
--- a/resources/js/task-calendar.js
+++ b/resources/js/task-calendar.js
@@ -9,7 +9,10 @@
* the same changes with the keyboard. Escape cancels a drag.
*
* Hovering or focusing a bar shows its info popover (the job's basic
- * details); the pointer may move onto it, and Escape closes it.
+ * details); the pointer may move onto it, and Escape closes it. A mouse
+ * click or Enter on a bar opens its dialog. On a touch screen a tap only
+ * opens the popover (a tap would otherwise both show it and open the
+ * dialog), and the popover's own button opens the dialog.
*/
const DRAG_THRESHOLD_PX = 5;
const DAY_MS = 24 * 60 * 60 * 1000;
@@ -40,6 +43,8 @@ export function taskCalendar(canManage) {
info: null,
infoTimer: null,
+ infoHeld: false,
+ touched: false,
/**
* Shows the info popover of a bar next to it. Not while dragging.
@@ -86,6 +91,10 @@ export function taskCalendar(canManage) {
this.infoTimer = setTimeout(() => {
const popover = document.getElementById(id);
+ if (this.infoHeld && this.info === popover) {
+ return;
+ }
+
if (popover?.matches(':popover-open')) {
popover.hidePopover();
}
@@ -103,6 +112,7 @@ export function taskCalendar(canManage) {
closeInfo() {
this.keepInfo();
+ this.infoHeld = false;
if (this.info?.matches(':popover-open')) {
this.info.hidePopover();
@@ -111,8 +121,80 @@ export function taskCalendar(canManage) {
this.info = null;
},
+ /**
+ * A tap on a popover keeps it open until something outside it is tapped.
+ */
+ holdInfo() {
+ this.keepInfo();
+ this.infoHeld = true;
+ },
+
+ /**
+ * Closes the popover when a tap or click lands outside it and its bar.
+ */
+ dismissInfo(event) {
+ if (this.info && !this.info.contains(event.target) && !event.target.closest?.('[data-calendar-bar]')) {
+ this.closeInfo();
+ }
+ },
+
+ /**
+ * Keyboard focus leaving the popover (not back to its bar) closes it.
+ */
+ leaveInfo(event, id) {
+ const next = event.relatedTarget;
+
+ if (next && (next.closest?.(`#${id}`) || next.getAttribute?.('aria-describedby') === `${id}-details`)) {
+ return;
+ }
+
+ this.hideInfo(id, 0);
+ },
+
+ /**
+ * A bar's own blur closes its popover unless focus moves into it.
+ */
+ blurBar(event, id) {
+ if (event.relatedTarget?.closest?.(`#${id}`)) {
+ return;
+ }
+
+ this.hideInfo(id, 0);
+ },
+
+ /**
+ * A mouse click or Enter opens the dialog; a tap shows the popover,
+ * whose button opens the dialog.
+ */
+ clickBar(bar, id, open) {
+ const touched = this.touched;
+ this.touched = false;
+
+ if (this.consumeDrag()) {
+ return;
+ }
+
+ if (touched) {
+ this.showInfo(bar, id);
+ this.holdInfo();
+
+ return;
+ }
+
+ open();
+ },
+
+ /**
+ * The popover's button: close it and open the dialog.
+ */
+ openFromInfo(open) {
+ this.closeInfo();
+ open();
+ },
+
begin(event, mode, bar) {
this.closeInfo();
+ this.touched = event.pointerType === 'touch' || event.pointerType === 'pen';
if (!canManage || event.button !== 0 || event.pointerType === 'touch') {
return;
diff --git a/tests/Browser/TaskCalendarAccessibilityTest.php b/tests/Browser/TaskCalendarAccessibilityTest.php
index 4490667..f9c9b8b 100644
--- a/tests/Browser/TaskCalendarAccessibilityTest.php
+++ b/tests/Browser/TaskCalendarAccessibilityTest.php
@@ -97,6 +97,30 @@ it('shows the job details of a bar on hover and focus, and closes them with Esca
->assertNoJavaScriptErrors();
})->with(['light', 'dark']);
+it('opens only the popover on a tap, and the dialog from its button', function () {
+ $key = $this->task->id.'-'.$this->user->id;
+ $open = "document.getElementById('bar-info-{$key}').matches(':popover-open')";
+ $tap = <<
{
+ const bar = document.getElementById('bar-{$key}');
+ const options = { bubbles: true, pointerType: 'touch', isPrimary: true, button: 0 };
+ bar.dispatchEvent(new PointerEvent('pointerdown', options));
+ bar.dispatchEvent(new PointerEvent('pointerup', options));
+ bar.dispatchEvent(new MouseEvent('mouseenter'));
+ bar.click();
+ })()
+ JS;
+
+ $visit = visit(route('jobs.calendar'))->on()->desktop();
+ $visit->script($tap);
+ $visit->assertScript($open, true)
+ ->assertScript("document.getElementById('task-schedule-dialog').open", false)
+ ->click('#bar-info-'.$key.'-open')
+ ->assertSee('Tehtävän aikataulu')
+ ->assertScript("document.getElementById('task-schedule-dialog').open", true)
+ ->assertScript($open, false);
+});
+
it('moves a task to another person by dragging its bar', function () {
// The bar (today – today + 2) is grabbed at its middle day, so dropping it
// on today + 4 moves it three days later.
diff --git a/tests/Feature/Modules/Jobs/TaskCalendarTest.php b/tests/Feature/Modules/Jobs/TaskCalendarTest.php
index 123b09e..84b7e61 100644
--- a/tests/Feature/Modules/Jobs/TaskCalendarTest.php
+++ b/tests/Feature/Modules/Jobs/TaskCalendarTest.php
@@ -179,7 +179,8 @@ it('shows the job details in the info popover of a bar', function () {
$task = TaskModel::query()->sole();
Livewire::test('jobs::calendar')
- ->assertSee('aria-describedby="bar-info-'.$task->id.'-'.$this->other->id.'"', escape: false)
+ ->assertSee('aria-describedby="bar-info-'.$task->id.'-'.$this->other->id.'-details"', escape: false)
+ ->assertSee('Avaa aikataulu: tehtävä Mainoskuvat')
->assertSeeInOrder([
'Työ', $this->job->number, 'Kampanja',
'Asiakas', CustomerModel::query()->findOrFail($this->job->customer_id)->name,