feat: Rework task management in PlanBundle
- Introduced migration Version_0_13_0 to update task schema: - Changed start_date and end_date to DATE type, truncating time. - Added new columns: task_kind, definition_of_done, planned_work. - Removed parent_id and its index, replacing with a dependency graph. - Created new tables: plan_task_dependencies and plan_task_raci, including a join table for stakeholders. - Updated Version_0_4_0 migration to remove references to parent_id. - Refactored TaskModel to return tasks as flat rows with dependencies and RACI assignments. - Modified task table view to display tasks without hierarchical structure, adding badges for milestones and phases. - Enhanced task form to include dependencies and RACI roles, with appropriate macros for rendering. - Updated task list view to reflect new task structure and display status based on task kind. - Added new validation constraints for task dependencies and dates, ensuring no cycles or self-references. - Removed obsolete ValidTaskParent validation as parent-child relationships are no longer supported. - Updated translations to reflect changes in task management and new fields. - Revised documentation to describe new task handling and features.
This commit is contained in:
1 parent
8696acd01c
commit
8268fad886
33 files changed
+1454
-251
No files matched your search
@@ -0,0 +1,154 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace MauticPlugin\PlanBundle\Entity;
|
||||
|
||||
use Doctrine\DBAL\Types\Types;
|
||||
use Doctrine\Common\Collections\ArrayCollection;
|
||||
use Doctrine\Common\Collections\Collection;
|
||||
use Doctrine\ORM\Mapping\ClassMetadata as OrmClassMetadata;
|
||||
use Mautic\CoreBundle\Doctrine\Mapping\ClassMetadataBuilder;
|
||||
|
||||
/**
|
||||
* One RACI assignment of a task: a role (R/A/C/I) and the stakeholders carrying it. Several
|
||||
* stakeholders may share a role; each row is one role with its stakeholder list.
|
||||
*
|
||||
* The row is owned by the task it belongs to (Task::$raci); deleting the task or a stakeholder
|
||||
* deletes the row (ON DELETE CASCADE both sides).
|
||||
*/
|
||||
class TaskRaci
|
||||
{
|
||||
public const TABLE_NAME = 'plan_task_raci';
|
||||
|
||||
/**
|
||||
* The join table carrying the stakeholders of a RACI row (TaskRaci -> Stakeholder).
|
||||
*/
|
||||
public const JOIN_TABLE_NAME = 'plan_task_raci_stakeholders';
|
||||
|
||||
private ?int $id = null;
|
||||
|
||||
private ?Task $task = null;
|
||||
|
||||
private RaciRole $role = RaciRole::Responsible;
|
||||
|
||||
/**
|
||||
* @var Collection<int, Stakeholder>
|
||||
*/
|
||||
private Collection $stakeholders;
|
||||
|
||||
/**
|
||||
* Display order within the task's RACI list, from 0.
|
||||
*/
|
||||
private int $position = 0;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->stakeholders = new ArrayCollection();
|
||||
}
|
||||
|
||||
public function __clone()
|
||||
{
|
||||
$this->id = null;
|
||||
$this->task = null;
|
||||
$this->stakeholders = new ArrayCollection();
|
||||
}
|
||||
|
||||
public static function loadMetadata(OrmClassMetadata $metadata): void
|
||||
{
|
||||
$builder = new ClassMetadataBuilder($metadata);
|
||||
|
||||
$builder->setTable(self::TABLE_NAME)
|
||||
->setCustomRepositoryClass(TaskRaciRepository::class);
|
||||
|
||||
$builder->addId();
|
||||
|
||||
$builder->createManyToOne('task', Task::class)
|
||||
->inversedBy('raci')
|
||||
->addJoinColumn('task_id', 'id', false, false, 'CASCADE')
|
||||
->build();
|
||||
|
||||
$metadata->mapField([
|
||||
'fieldName' => 'role',
|
||||
'type' => Types::STRING,
|
||||
'length' => 20,
|
||||
'enumType' => RaciRole::class,
|
||||
'options' => ['default' => RaciRole::Responsible->value],
|
||||
]);
|
||||
|
||||
$builder->createManyToMany('stakeholders', Stakeholder::class)
|
||||
->setJoinTable(self::JOIN_TABLE_NAME)
|
||||
->addJoinColumn('raci_id', 'id', false, false, 'CASCADE')
|
||||
->addInverseJoinColumn('stakeholder_id', 'id', false, false, 'CASCADE')
|
||||
->build();
|
||||
|
||||
$builder->createField('position', Types::INTEGER)
|
||||
->option('default', 0)
|
||||
->build();
|
||||
}
|
||||
|
||||
public function getId(): ?int
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
public function getTask(): ?Task
|
||||
{
|
||||
return $this->task;
|
||||
}
|
||||
|
||||
public function setTask(?Task $task): static
|
||||
{
|
||||
$this->task = $task;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getRole(): RaciRole
|
||||
{
|
||||
return $this->role;
|
||||
}
|
||||
|
||||
public function setRole(RaciRole $role): static
|
||||
{
|
||||
$this->role = $role;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Collection<int, Stakeholder>
|
||||
*/
|
||||
public function getStakeholders(): Collection
|
||||
{
|
||||
return $this->stakeholders;
|
||||
}
|
||||
|
||||
public function addStakeholder(Stakeholder $stakeholder): static
|
||||
{
|
||||
if (!$this->stakeholders->contains($stakeholder)) {
|
||||
$this->stakeholders->add($stakeholder);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function removeStakeholder(Stakeholder $stakeholder): static
|
||||
{
|
||||
$this->stakeholders->removeElement($stakeholder);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getPosition(): int
|
||||
{
|
||||
return $this->position;
|
||||
}
|
||||
|
||||
public function setPosition(?int $position): static
|
||||
{
|
||||
$this->position = $position ?? 0;
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user