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:
@@ -13,14 +13,16 @@ use App\Modules\Jobs\Domain\ValueObjects\TaskTitle;
|
||||
use DateTimeImmutable;
|
||||
|
||||
/**
|
||||
* A task (tehtävä) of a customer job: one step of the work, done by its
|
||||
* assignees under one work type. Time entries are recorded on tasks.
|
||||
* Its planned schedule (planned from–to) places it in the task calendar.
|
||||
* A task (tehtävä) of a customer job: one step of the work under one work
|
||||
* type. Its assignee (tekijä) does it: the planned schedule (planned
|
||||
* from–to) places it on the assignee's row of the task calendar and books
|
||||
* the estimate from their days. Members (jäsenet) see the task among their
|
||||
* own but get no bookings. Time entries are recorded on tasks.
|
||||
*/
|
||||
final class Task
|
||||
{
|
||||
/**
|
||||
* @param list<int> $assigneeUserIds
|
||||
* @param list<int> $memberUserIds
|
||||
*/
|
||||
private function __construct(
|
||||
private ?int $id,
|
||||
@@ -31,17 +33,18 @@ final class Task
|
||||
private TaskStatus $status,
|
||||
private ?DateTimeImmutable $dueOn,
|
||||
private ?EstimatedHours $estimatedHours,
|
||||
private array $assigneeUserIds,
|
||||
private ?int $assigneeUserId,
|
||||
private array $memberUserIds,
|
||||
private int $createdBy,
|
||||
private ?DateTimeImmutable $plannedFrom = null,
|
||||
private ?DateTimeImmutable $plannedTo = null,
|
||||
) {
|
||||
$this->assigneeUserIds = self::normaliseIds($assigneeUserIds);
|
||||
$this->memberUserIds = self::members($memberUserIds, $assigneeUserId);
|
||||
self::checkPlan($plannedFrom, $plannedTo);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param list<int> $assigneeUserIds
|
||||
* @param list<int> $memberUserIds
|
||||
*
|
||||
* @throws TasksNotAllowedYet
|
||||
* @throws PlanEndsBeforeStart
|
||||
@@ -55,7 +58,8 @@ final class Task
|
||||
TaskStatus $status,
|
||||
?DateTimeImmutable $dueOn,
|
||||
?EstimatedHours $estimatedHours,
|
||||
array $assigneeUserIds,
|
||||
?int $assigneeUserId,
|
||||
array $memberUserIds,
|
||||
int $createdBy,
|
||||
?DateTimeImmutable $plannedFrom = null,
|
||||
?DateTimeImmutable $plannedTo = null,
|
||||
@@ -64,11 +68,11 @@ final class Task
|
||||
throw new TasksNotAllowedYet;
|
||||
}
|
||||
|
||||
return new self(null, $jobId, $workTypeId, $title, self::text($description), $status, $dueOn, $estimatedHours, $assigneeUserIds, $createdBy, ...self::plan($plannedFrom, $plannedTo));
|
||||
return new self(null, $jobId, $workTypeId, $title, self::text($description), $status, $dueOn, $estimatedHours, $assigneeUserId, $memberUserIds, $createdBy, ...self::plan($plannedFrom, $plannedTo));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param list<int> $assigneeUserIds
|
||||
* @param list<int> $memberUserIds
|
||||
*/
|
||||
public static function reconstitute(
|
||||
int $id,
|
||||
@@ -79,16 +83,17 @@ final class Task
|
||||
TaskStatus $status,
|
||||
?DateTimeImmutable $dueOn,
|
||||
?EstimatedHours $estimatedHours,
|
||||
array $assigneeUserIds,
|
||||
?int $assigneeUserId,
|
||||
array $memberUserIds,
|
||||
int $createdBy,
|
||||
?DateTimeImmutable $plannedFrom = null,
|
||||
?DateTimeImmutable $plannedTo = null,
|
||||
): self {
|
||||
return new self($id, $jobId, $workTypeId, $title, $description, $status, $dueOn, $estimatedHours, $assigneeUserIds, $createdBy, $plannedFrom, $plannedTo);
|
||||
return new self($id, $jobId, $workTypeId, $title, $description, $status, $dueOn, $estimatedHours, $assigneeUserId, $memberUserIds, $createdBy, $plannedFrom, $plannedTo);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param list<int> $assigneeUserIds
|
||||
* @param list<int> $memberUserIds
|
||||
*/
|
||||
public function changeDetails(
|
||||
int $workTypeId,
|
||||
@@ -97,7 +102,8 @@ final class Task
|
||||
TaskStatus $status,
|
||||
?DateTimeImmutable $dueOn,
|
||||
?EstimatedHours $estimatedHours,
|
||||
array $assigneeUserIds,
|
||||
?int $assigneeUserId,
|
||||
array $memberUserIds,
|
||||
): void {
|
||||
$this->workTypeId = $workTypeId;
|
||||
$this->title = $title;
|
||||
@@ -105,7 +111,8 @@ final class Task
|
||||
$this->status = $status;
|
||||
$this->dueOn = $dueOn;
|
||||
$this->estimatedHours = $estimatedHours;
|
||||
$this->assigneeUserIds = self::normaliseIds($assigneeUserIds);
|
||||
$this->assigneeUserId = $assigneeUserId;
|
||||
$this->memberUserIds = self::members($memberUserIds, $assigneeUserId);
|
||||
}
|
||||
|
||||
public function changeStatus(TaskStatus $status): void
|
||||
@@ -125,11 +132,13 @@ final class Task
|
||||
}
|
||||
|
||||
/**
|
||||
* @param list<int> $assigneeUserIds
|
||||
* Makes the user the assignee (null: no assignee). A member who becomes
|
||||
* the assignee is no longer a member; the earlier assignee is dropped.
|
||||
*/
|
||||
public function changeAssignees(array $assigneeUserIds): void
|
||||
public function assignTo(?int $userId): void
|
||||
{
|
||||
$this->assigneeUserIds = self::normaliseIds($assigneeUserIds);
|
||||
$this->assigneeUserId = $userId;
|
||||
$this->memberUserIds = self::members($this->memberUserIds, $userId);
|
||||
}
|
||||
|
||||
public function id(): ?int
|
||||
@@ -187,12 +196,17 @@ final class Task
|
||||
return $this->plannedFrom !== null;
|
||||
}
|
||||
|
||||
public function assigneeUserId(): ?int
|
||||
{
|
||||
return $this->assigneeUserId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return list<int>
|
||||
*/
|
||||
public function assigneeUserIds(): array
|
||||
public function memberUserIds(): array
|
||||
{
|
||||
return $this->assigneeUserIds;
|
||||
return $this->memberUserIds;
|
||||
}
|
||||
|
||||
public function createdBy(): int
|
||||
@@ -201,12 +215,14 @@ final class Task
|
||||
}
|
||||
|
||||
/**
|
||||
* The members sorted, without duplicates and without the assignee.
|
||||
*
|
||||
* @param list<int> $ids
|
||||
* @return list<int>
|
||||
*/
|
||||
private static function normaliseIds(array $ids): array
|
||||
private static function members(array $ids, ?int $assigneeUserId): array
|
||||
{
|
||||
$ids = array_values(array_unique($ids));
|
||||
$ids = array_values(array_unique(array_filter($ids, fn (int $id): bool => $id !== $assigneeUserId)));
|
||||
sort($ids);
|
||||
|
||||
return $ids;
|
||||
|
||||
Reference in New Issue
Block a user