Give tasks one assignee and members, and schedule template tasks to due dates

- A task now has one optional assignee (tasks.assignee_user_id), whose
  calendar row it is on and whose days its estimate books, and members
  (task_members) who see it among their own jobs and in the weekly sheet
  but get no bookings. A migration moves existing assignees over: the one
  with most booked time becomes the assignee, the others members.
- Adding tasks from a workflow template asks for each step's assignee and,
  by default, schedules tasks with a due date to end on it, booking the
  estimate backwards from the due date (not before today); what does not
  fit runs past the due date and is reported as late.
- The task calendar leaves quick sale tasks out of the unscheduled list,
  shows a bar's job details in a popover on hover and focus, and shows the
  day load on its own grid line.
- The template table stacks its cells on narrow screens to reflow at 320 px.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
2026-11-24 19:01:11 +02:00
co-authored by Claude Opus 5.5
parent b4f2f1cfaa
commit 18598cc08e
45 changed files with 1133 additions and 248 deletions
+78
View File
@@ -7,6 +7,9 @@
* grid cell under the pointer (data-calendar-day / data-calendar-user).
* Dragging is only a shortcut: every bar is a button whose dialog makes
* 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.
*/
const DRAG_THRESHOLD_PX = 5;
const DAY_MS = 24 * 60 * 60 * 1000;
@@ -35,7 +38,82 @@ export function taskCalendar(canManage) {
target: null,
dragged: false,
info: null,
infoTimer: null,
/**
* Shows the info popover of a bar next to it. Not while dragging.
*/
showInfo(bar, id) {
if (this.drag?.moved) {
return;
}
this.keepInfo();
const popover = document.getElementById(id);
if (!popover) {
return;
}
if (this.info && this.info !== popover) {
this.closeInfo();
}
if (!popover.matches(':popover-open')) {
popover.showPopover();
}
this.info = popover;
const anchor = bar.getBoundingClientRect();
const box = popover.getBoundingClientRect();
const gap = 4;
const below = anchor.bottom + gap;
const top = below + box.height <= window.innerHeight || anchor.top - gap - box.height < 0 ? below : anchor.top - gap - box.height;
const left = Math.min(Math.max(gap, anchor.left), window.innerWidth - box.width - gap);
popover.style.top = `${Math.max(gap, top)}px`;
popover.style.left = `${Math.max(gap, left)}px`;
},
/**
* Hides the popover after a moment, so that the pointer can move onto it.
*/
hideInfo(id, delay = 150) {
this.keepInfo();
this.infoTimer = setTimeout(() => {
const popover = document.getElementById(id);
if (popover?.matches(':popover-open')) {
popover.hidePopover();
}
if (this.info === popover) {
this.info = null;
}
}, delay);
},
keepInfo() {
clearTimeout(this.infoTimer);
this.infoTimer = null;
},
closeInfo() {
this.keepInfo();
if (this.info?.matches(':popover-open')) {
this.info.hidePopover();
}
this.info = null;
},
begin(event, mode, bar) {
this.closeInfo();
if (!canManage || event.button !== 0 || event.pointerType === 'touch') {
return;
}