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
+37
-1
@@ -10,7 +10,11 @@
|
|||||||
* because that page isn't a "plan" page).
|
* because that page isn't a "plan" page).
|
||||||
*/
|
*/
|
||||||
Mautic.planTaskOnLoad = function (container) {
|
Mautic.planTaskOnLoad = function (container) {
|
||||||
// The task form isn't a plan-collection; the type dropdown works the same way as in the plan form.
|
// The dependencies and RACI rows work like the plan form's collections.
|
||||||
|
mQuery(container).find('.plan-collection').each(function () {
|
||||||
|
Mautic.planInitCollection(mQuery(this));
|
||||||
|
});
|
||||||
|
// The type dropdown works the same way as in the plan form.
|
||||||
mQuery(container).find('select.plan-item-type').each(function () {
|
mQuery(container).find('select.plan-item-type').each(function () {
|
||||||
var $select = mQuery(this);
|
var $select = mQuery(this);
|
||||||
|
|
||||||
@@ -26,6 +30,38 @@ Mautic.planTaskOnLoad = function (container) {
|
|||||||
$scope.find('.plan-item-type-icon').first().attr('class', 'plan-item-type-icon ' + ($option.attr('data-icon') || ''));
|
$scope.find('.plan-item-type-icon').first().attr('class', 'plan-item-type-icon ' + ($option.attr('data-icon') || ''));
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Kind rules: a milestone's end date is enslaved to its start date (copied and read-only);
|
||||||
|
// a phase has no status of its own (the field is left out server-side, nothing to do here).
|
||||||
|
mQuery(container).find('select[name$="[taskKind]"]').each(function () {
|
||||||
|
var $kind = mQuery(this);
|
||||||
|
|
||||||
|
if ($kind.data('planKindInitialized')) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
$kind.data('planKindInitialized', true);
|
||||||
|
|
||||||
|
var enslave = function () {
|
||||||
|
var $form = mQuery(this).closest('form');
|
||||||
|
var $start = $form.find('input[name$="[startDate]"]').first();
|
||||||
|
var $end = $form.find('input[name$="[endDate]"]').first();
|
||||||
|
var milestone = 'milestone' === mQuery(this).val();
|
||||||
|
|
||||||
|
$end.prop('disabled', milestone);
|
||||||
|
if (milestone) {
|
||||||
|
$end.val($start.val());
|
||||||
|
// While the milestone is selected, the end follows the start.
|
||||||
|
$start.off('change.planKind').on('change.planKind', function () {
|
||||||
|
$end.val($start.val());
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
$start.off('change.planKind');
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
$kind.on('change', enslave);
|
||||||
|
enslave.call($kind.get(0));
|
||||||
|
});
|
||||||
};
|
};
|
||||||
Mautic.planOnLoad = function (container) {
|
Mautic.planOnLoad = function (container) {
|
||||||
mQuery(container).find('.plan-collection').each(function () {
|
mQuery(container).find('.plan-collection').each(function () {
|
||||||
|
|||||||
+1
-1
@@ -5,7 +5,7 @@ declare(strict_types=1);
|
|||||||
return [
|
return [
|
||||||
'name' => 'Plan',
|
'name' => 'Plan',
|
||||||
'description' => 'Plan plugin for Mautic.',
|
'description' => 'Plan plugin for Mautic.',
|
||||||
'version' => '0.12.0',
|
'version' => '0.13.0',
|
||||||
'author' => 'Experiential',
|
'author' => 'Experiential',
|
||||||
|
|
||||||
'routes' => [
|
'routes' => [
|
||||||
|
|||||||
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
@@ -0,0 +1,21 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace MauticPlugin\PlanBundle\Entity;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The type of a task dependency edge. The order of the cases is the order of the dropdown.
|
||||||
|
*/
|
||||||
|
enum DependencyType: string
|
||||||
|
{
|
||||||
|
case EndToStart = 'end_to_start';
|
||||||
|
case EndToEnd = 'end_to_end';
|
||||||
|
case StartToStart = 'start_to_start';
|
||||||
|
case StartToEnd = 'start_to_end';
|
||||||
|
|
||||||
|
public function getLabelKey(): string
|
||||||
|
{
|
||||||
|
return 'mautic.plan.task.dependency_type.'.$this->value;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,31 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace MauticPlugin\PlanBundle\Entity;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The RACI roles of a task assignment. The order of the cases is the order of the dropdown.
|
||||||
|
*/
|
||||||
|
enum RaciRole: string
|
||||||
|
{
|
||||||
|
case Responsible = 'responsible';
|
||||||
|
case Accountable = 'accountable';
|
||||||
|
case Consulted = 'consulted';
|
||||||
|
case Informed = 'informed';
|
||||||
|
|
||||||
|
public function getLabelKey(): string
|
||||||
|
{
|
||||||
|
return 'mautic.plan.task.raci_role.'.$this->value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getLabelClass(): string
|
||||||
|
{
|
||||||
|
return match ($this) {
|
||||||
|
self::Responsible => 'label-success',
|
||||||
|
self::Accountable => 'label-primary',
|
||||||
|
self::Consulted => 'label-info',
|
||||||
|
self::Informed => 'label-default',
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
+243
-65
@@ -11,16 +11,29 @@ use Doctrine\ORM\Mapping\ClassMetadata as OrmClassMetadata;
|
|||||||
use Mautic\CoreBundle\Doctrine\Mapping\ClassMetadataBuilder;
|
use Mautic\CoreBundle\Doctrine\Mapping\ClassMetadataBuilder;
|
||||||
use Mautic\CoreBundle\Entity\FormEntity;
|
use Mautic\CoreBundle\Entity\FormEntity;
|
||||||
use MauticPlugin\PlanBundle\Validator\Constraints\EndDateAfterStartDate;
|
use MauticPlugin\PlanBundle\Validator\Constraints\EndDateAfterStartDate;
|
||||||
use MauticPlugin\PlanBundle\Validator\Constraints\ValidTaskParent;
|
use MauticPlugin\PlanBundle\Validator\Constraints\TaskDates;
|
||||||
|
use MauticPlugin\PlanBundle\Validator\Constraints\ValidTaskDependency;
|
||||||
use Symfony\Component\Validator\Constraints\Length;
|
use Symfony\Component\Validator\Constraints\Length;
|
||||||
use Symfony\Component\Validator\Constraints\NotBlank;
|
use Symfony\Component\Validator\Constraints\NotBlank;
|
||||||
|
use Symfony\Component\Validator\Constraints\PositiveOrZero;
|
||||||
|
use Symfony\Component\Validator\Constraints\Range;
|
||||||
use Symfony\Component\Validator\Mapping\ClassMetadata;
|
use Symfony\Component\Validator\Mapping\ClassMetadata;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A task of a plan. Every task belongs to exactly one plan, and may have a parent task in the same plan.
|
* A task of a plan. Every task belongs to exactly one plan.
|
||||||
*
|
*
|
||||||
* Database rules: deleting the plan deletes its tasks (ON DELETE CASCADE); deleting a task makes its
|
* Kinds (taskKind): a regular task; a milestone, whose end date is enslaved to its start date; or a
|
||||||
* sub-tasks top-level (parent ON DELETE SET NULL).
|
* phase, which has no status of its own — it is a collection of tasks.
|
||||||
|
*
|
||||||
|
* Dependencies: a task may depend on other tasks (TaskDependency), with the relation type End2Start,
|
||||||
|
* End2End, Start2Start or Start2End. The former parent/child tree is replaced by this dependency
|
||||||
|
* graph.
|
||||||
|
*
|
||||||
|
* RACI: a task is assigned to the plan's stakeholders through TaskRaci rows (R/A/C/I), several
|
||||||
|
* stakeholders per role.
|
||||||
|
*
|
||||||
|
* Database rules: deleting the plan deletes its tasks (ON DELETE CASCADE); deleting a task deletes
|
||||||
|
* its dependencies and RACI rows (ON DELETE CASCADE).
|
||||||
*/
|
*/
|
||||||
class Task extends FormEntity implements DateRangeInterface
|
class Task extends FormEntity implements DateRangeInterface
|
||||||
{
|
{
|
||||||
@@ -28,6 +41,11 @@ class Task extends FormEntity implements DateRangeInterface
|
|||||||
|
|
||||||
public const TYPE_MAX_LENGTH = 64;
|
public const TYPE_MAX_LENGTH = 64;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The planned work is whole hours, capped to keep the column sane.
|
||||||
|
*/
|
||||||
|
public const PLANNED_WORK_MAX = 100000;
|
||||||
|
|
||||||
private ?int $id = null;
|
private ?int $id = null;
|
||||||
|
|
||||||
private ?Plan $plan = null;
|
private ?Plan $plan = null;
|
||||||
@@ -42,28 +60,39 @@ class Task extends FormEntity implements DateRangeInterface
|
|||||||
|
|
||||||
private ?string $description = null;
|
private ?string $description = null;
|
||||||
|
|
||||||
private ?Task $parent = null;
|
|
||||||
|
|
||||||
private ?\DateTime $startDate = null;
|
private ?\DateTime $startDate = null;
|
||||||
|
|
||||||
private ?\DateTime $endDate = null;
|
private ?\DateTime $endDate = null;
|
||||||
|
|
||||||
private TaskStatus $status = TaskStatus::New;
|
private TaskStatus $status = TaskStatus::New;
|
||||||
|
|
||||||
|
private ?TaskKind $taskKind = null;
|
||||||
|
|
||||||
|
private ?string $definitionOfDone = null;
|
||||||
|
|
||||||
|
private ?int $plannedWork = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var Collection<int, Task>
|
* @var Collection<int, TaskDependency>
|
||||||
*/
|
*/
|
||||||
private Collection $children;
|
private Collection $dependencies;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var Collection<int, TaskRaci>
|
||||||
|
*/
|
||||||
|
private Collection $raci;
|
||||||
|
|
||||||
public function __construct()
|
public function __construct()
|
||||||
{
|
{
|
||||||
$this->children = new ArrayCollection();
|
$this->dependencies = new ArrayCollection();
|
||||||
|
$this->raci = new ArrayCollection();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function __clone()
|
public function __clone()
|
||||||
{
|
{
|
||||||
$this->id = null;
|
$this->id = null;
|
||||||
$this->children = new ArrayCollection();
|
$this->dependencies = new ArrayCollection();
|
||||||
|
$this->raci = new ArrayCollection();
|
||||||
|
|
||||||
parent::__clone();
|
parent::__clone();
|
||||||
}
|
}
|
||||||
@@ -95,20 +124,6 @@ class Task extends FormEntity implements DateRangeInterface
|
|||||||
->nullable()
|
->nullable()
|
||||||
->build();
|
->build();
|
||||||
|
|
||||||
$builder->createManyToOne('parent', self::class)
|
|
||||||
->inversedBy('children')
|
|
||||||
->addJoinColumn('parent_id', 'id', true, false, 'SET NULL')
|
|
||||||
->build();
|
|
||||||
|
|
||||||
$builder->createOneToMany('children', self::class)
|
|
||||||
->mappedBy('parent')
|
|
||||||
->setOrderBy(['name' => 'ASC'])
|
|
||||||
->fetchExtraLazy()
|
|
||||||
->build();
|
|
||||||
|
|
||||||
$builder->addNamedField('startDate', Types::DATETIME_MUTABLE, 'start_date', true);
|
|
||||||
$builder->addNamedField('endDate', Types::DATETIME_MUTABLE, 'end_date', true);
|
|
||||||
|
|
||||||
// Mapped on the raw metadata: ClassMetadataBuilder::addField() forces every string to VARCHAR(191).
|
// Mapped on the raw metadata: ClassMetadataBuilder::addField() forces every string to VARCHAR(191).
|
||||||
$metadata->mapField([
|
$metadata->mapField([
|
||||||
'fieldName' => 'status',
|
'fieldName' => 'status',
|
||||||
@@ -118,6 +133,58 @@ class Task extends FormEntity implements DateRangeInterface
|
|||||||
'options' => ['default' => TaskStatus::New->value],
|
'options' => ['default' => TaskStatus::New->value],
|
||||||
]);
|
]);
|
||||||
$builder->addIndex(['status'], 'plan_task_status');
|
$builder->addIndex(['status'], 'plan_task_status');
|
||||||
|
|
||||||
|
$metadata->mapField([
|
||||||
|
'fieldName' => 'taskKind',
|
||||||
|
'columnName' => 'task_kind',
|
||||||
|
'type' => Types::STRING,
|
||||||
|
'length' => 20,
|
||||||
|
'enumType' => TaskKind::class,
|
||||||
|
'options' => ['default' => TaskKind::Task->value],
|
||||||
|
]);
|
||||||
|
|
||||||
|
// Dates are DATE (no time): tasks are planned at day granularity.
|
||||||
|
$metadata->mapField([
|
||||||
|
'fieldName' => 'startDate',
|
||||||
|
'columnName' => 'start_date',
|
||||||
|
'type' => Types::DATE_MUTABLE,
|
||||||
|
'nullable' => true,
|
||||||
|
]);
|
||||||
|
$metadata->mapField([
|
||||||
|
'fieldName' => 'endDate',
|
||||||
|
'columnName' => 'end_date',
|
||||||
|
'type' => Types::DATE_MUTABLE,
|
||||||
|
'nullable' => true,
|
||||||
|
]);
|
||||||
|
|
||||||
|
$builder->createField('definitionOfDone', Types::TEXT)
|
||||||
|
->columnName('definition_of_done')
|
||||||
|
->nullable()
|
||||||
|
->build();
|
||||||
|
|
||||||
|
$builder->createField('plannedWork', Types::INTEGER)
|
||||||
|
->columnName('planned_work')
|
||||||
|
->nullable()
|
||||||
|
->option('unsigned', true)
|
||||||
|
->build();
|
||||||
|
|
||||||
|
// Dependencies: outgoing edges (this task depends on those) and incoming edges (those depend
|
||||||
|
// on this task). Both sides are owned by the rows; deleting a task deletes its edges.
|
||||||
|
$builder->createOneToMany('dependencies', TaskDependency::class)
|
||||||
|
->mappedBy('task')
|
||||||
|
->setOrderBy(['position' => 'ASC'])
|
||||||
|
->cascadePersist()
|
||||||
|
->cascadeRemove()
|
||||||
|
->orphanRemoval()
|
||||||
|
->build();
|
||||||
|
|
||||||
|
$builder->createOneToMany('raci', TaskRaci::class)
|
||||||
|
->mappedBy('task')
|
||||||
|
->setOrderBy(['position' => 'ASC'])
|
||||||
|
->cascadePersist()
|
||||||
|
->cascadeRemove()
|
||||||
|
->orphanRemoval()
|
||||||
|
->build();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function loadValidatorMetadata(ClassMetadata $metadata): void
|
public static function loadValidatorMetadata(ClassMetadata $metadata): void
|
||||||
@@ -127,8 +194,11 @@ class Task extends FormEntity implements DateRangeInterface
|
|||||||
$metadata->addPropertyConstraint('plan', new NotBlank(message: 'mautic.plan.task.plan.required'));
|
$metadata->addPropertyConstraint('plan', new NotBlank(message: 'mautic.plan.task.plan.required'));
|
||||||
$metadata->addPropertyConstraint('type', new NotBlank(message: 'mautic.plan.task.type.required'));
|
$metadata->addPropertyConstraint('type', new NotBlank(message: 'mautic.plan.task.type.required'));
|
||||||
$metadata->addPropertyConstraint('type', new Length(max: self::TYPE_MAX_LENGTH));
|
$metadata->addPropertyConstraint('type', new Length(max: self::TYPE_MAX_LENGTH));
|
||||||
$metadata->addConstraint(new ValidTaskParent());
|
$metadata->addPropertyConstraint('plannedWork', new PositiveOrZero(message: 'mautic.plan.task.planned_work.invalid'));
|
||||||
|
$metadata->addPropertyConstraint('plannedWork', new Range(notInRangeMessage: 'mautic.plan.task.planned_work.range', min: 0, max: self::PLANNED_WORK_MAX));
|
||||||
$metadata->addConstraint(new EndDateAfterStartDate());
|
$metadata->addConstraint(new EndDateAfterStartDate());
|
||||||
|
$metadata->addConstraint(new TaskDates());
|
||||||
|
$metadata->addConstraint(new ValidTaskDependency());
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getId(): ?int
|
public function getId(): ?int
|
||||||
@@ -190,19 +260,6 @@ class Task extends FormEntity implements DateRangeInterface
|
|||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getParent(): ?Task
|
|
||||||
{
|
|
||||||
return $this->parent;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function setParent(?Task $parent): static
|
|
||||||
{
|
|
||||||
$this->isChanged('parent', $parent);
|
|
||||||
$this->parent = $parent;
|
|
||||||
|
|
||||||
return $this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getStartDate(): ?\DateTime
|
public function getStartDate(): ?\DateTime
|
||||||
{
|
{
|
||||||
return $this->startDate;
|
return $this->startDate;
|
||||||
@@ -245,37 +302,158 @@ class Task extends FormEntity implements DateRangeInterface
|
|||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public function getTaskKind(): TaskKind
|
||||||
* @return Collection<int, Task>
|
|
||||||
*/
|
|
||||||
public function getChildren(): Collection
|
|
||||||
{
|
{
|
||||||
return $this->children;
|
// Never null once stored (the column defaults to 'task'); a new entity reads as a plain task.
|
||||||
|
return $this->taskKind ?? TaskKind::Task;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public function setTaskKind(TaskKind $taskKind): static
|
||||||
* True when $task is this task or one of its ancestors.
|
|
||||||
*/
|
|
||||||
public function hasAncestorOrSelf(Task $task): bool
|
|
||||||
{
|
{
|
||||||
$seen = [];
|
if ($taskKind !== $this->taskKind) {
|
||||||
$current = $this;
|
// isChanged() can't log enums (they aren't stringable), so log the backing values.
|
||||||
|
$this->addChange('taskKind', [$this->taskKind?->value, $taskKind->value]);
|
||||||
while (null !== $current) {
|
$taskKind->enslaveDates($this);
|
||||||
if ($current === $task || (null !== $task->getId() && $current->getId() === $task->getId())) {
|
$this->taskKind = $taskKind;
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Guard against a cycle that is already stored.
|
|
||||||
$key = null !== $current->getId() ? 'id'.$current->getId() : spl_object_id($current);
|
|
||||||
if (isset($seen[$key])) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
$seen[$key] = true;
|
|
||||||
|
|
||||||
$current = $current->getParent();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getDefinitionOfDone(): ?string
|
||||||
|
{
|
||||||
|
return $this->definitionOfDone;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setDefinitionOfDone(?string $definitionOfDone): static
|
||||||
|
{
|
||||||
|
$this->isChanged('definitionOfDone', $definitionOfDone);
|
||||||
|
$this->definitionOfDone = $definitionOfDone;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getPlannedWork(): ?int
|
||||||
|
{
|
||||||
|
return $this->plannedWork;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setPlannedWork(?int $plannedWork): static
|
||||||
|
{
|
||||||
|
$this->isChanged('plannedWork', $this->plannedWork);
|
||||||
|
$this->plannedWork = $plannedWork;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return Collection<int, TaskDependency>
|
||||||
|
*/
|
||||||
|
public function getDependencies(): Collection
|
||||||
|
{
|
||||||
|
return $this->dependencies;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function addDependency(TaskDependency $dependency): static
|
||||||
|
{
|
||||||
|
if (!$this->dependencies->contains($dependency)) {
|
||||||
|
$dependency->setTask($this);
|
||||||
|
$this->dependencies->add($dependency);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function removeDependency(TaskDependency $dependency): static
|
||||||
|
{
|
||||||
|
$this->dependencies->removeElement($dependency);
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return Collection<int, TaskRaci>
|
||||||
|
*/
|
||||||
|
public function getRaci(): Collection
|
||||||
|
{
|
||||||
|
return $this->raci;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Replaces the RACI rows. The form writes the whole collection: the inflector singularizes
|
||||||
|
* "raci" to "racus", so PropertyAccess can't find addRaci/removeRaci for the collection write
|
||||||
|
* and needs this setter. The back-reference is set here, so the rows persist with their task.
|
||||||
|
*
|
||||||
|
* @param iterable<int, TaskRaci> $raci
|
||||||
|
*/
|
||||||
|
public function setRaci(iterable $raci): static
|
||||||
|
{
|
||||||
|
$this->raci = new ArrayCollection();
|
||||||
|
|
||||||
|
foreach (is_array($raci) ? $raci : iterator_to_array($raci) as $row) {
|
||||||
|
$this->addRaci($row);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function addRaci(TaskRaci $raci): static
|
||||||
|
{
|
||||||
|
if (!$this->raci->contains($raci)) {
|
||||||
|
$raci->setTask($this);
|
||||||
|
$this->raci->add($raci);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function removeRaci(TaskRaci $raci): static
|
||||||
|
{
|
||||||
|
$this->raci->removeElement($raci);
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A textual summary of the dependencies, the transitively blocked tasks and the RACI roles —
|
||||||
|
* used by the tab tables and the list. Formerly the parent/children tree, removed in 0.13.0.
|
||||||
|
*/
|
||||||
|
public function getDependencySummary(): string
|
||||||
|
{
|
||||||
|
$parts = [];
|
||||||
|
|
||||||
|
foreach ($this->dependencies as $dependency) {
|
||||||
|
if (null === $dependency->getDependsOn()) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
$parts[] = sprintf(
|
||||||
|
'%s (%s)',
|
||||||
|
$dependency->getDependsOn()->getName(),
|
||||||
|
$dependency->getDependencyType()->getLabelKey(),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return implode(', ', $parts);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A textual summary of the task's RACI rows, for the tables.
|
||||||
|
*/
|
||||||
|
public function getRaciSummary(): string
|
||||||
|
{
|
||||||
|
$parts = [];
|
||||||
|
|
||||||
|
foreach ($this->raci as $raci) {
|
||||||
|
$names = [];
|
||||||
|
foreach ($raci->getStakeholders() as $stakeholder) {
|
||||||
|
$names[] = $stakeholder->getName();
|
||||||
|
}
|
||||||
|
if ([] === $names) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
$parts[] = sprintf('%s: %s', $raci->getRole()->getLabelKey(), implode(', ', $names));
|
||||||
|
}
|
||||||
|
|
||||||
|
return implode(' · ', $parts);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,119 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace MauticPlugin\PlanBundle\Entity;
|
||||||
|
|
||||||
|
use Doctrine\DBAL\Types\Types;
|
||||||
|
use Doctrine\ORM\Mapping\ClassMetadata as OrmClassMetadata;
|
||||||
|
use Mautic\CoreBundle\Doctrine\Mapping\ClassMetadataBuilder;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* One dependency edge of the task dependency graph: this task depends on the depends-on task, with
|
||||||
|
* the relation type End2Start, End2End, Start2Start or Start2End.
|
||||||
|
*
|
||||||
|
* The edge is owned by the task it belongs to (Task::$dependencies); deleting either task deletes
|
||||||
|
* the edge (ON DELETE CASCADE both sides).
|
||||||
|
*/
|
||||||
|
class TaskDependency
|
||||||
|
{
|
||||||
|
public const TABLE_NAME = 'plan_task_dependencies';
|
||||||
|
|
||||||
|
private ?int $id = null;
|
||||||
|
|
||||||
|
private ?Task $task = null;
|
||||||
|
|
||||||
|
private ?Task $dependsOn = null;
|
||||||
|
|
||||||
|
private DependencyType $dependencyType = DependencyType::EndToStart;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Display order within the task's dependency list, from 0.
|
||||||
|
*/
|
||||||
|
private int $position = 0;
|
||||||
|
|
||||||
|
public static function loadMetadata(OrmClassMetadata $metadata): void
|
||||||
|
{
|
||||||
|
$builder = new ClassMetadataBuilder($metadata);
|
||||||
|
|
||||||
|
$builder->setTable(self::TABLE_NAME)
|
||||||
|
->setCustomRepositoryClass(TaskDependencyRepository::class);
|
||||||
|
|
||||||
|
$builder->addId();
|
||||||
|
|
||||||
|
$builder->createManyToOne('task', Task::class)
|
||||||
|
->inversedBy('dependencies')
|
||||||
|
->addJoinColumn('task_id', 'id', false, false, 'CASCADE')
|
||||||
|
->build();
|
||||||
|
|
||||||
|
$builder->createManyToOne('dependsOn', Task::class)
|
||||||
|
->addJoinColumn('depends_on_id', 'id', false, false, 'CASCADE')
|
||||||
|
->build();
|
||||||
|
|
||||||
|
$metadata->mapField([
|
||||||
|
'fieldName' => 'dependencyType',
|
||||||
|
'columnName' => 'dependency_type',
|
||||||
|
'type' => Types::STRING,
|
||||||
|
'length' => 20,
|
||||||
|
'enumType' => DependencyType::class,
|
||||||
|
'options' => ['default' => DependencyType::EndToStart->value],
|
||||||
|
]);
|
||||||
|
|
||||||
|
$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 getDependsOn(): ?Task
|
||||||
|
{
|
||||||
|
return $this->dependsOn;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setDependsOn(?Task $dependsOn): static
|
||||||
|
{
|
||||||
|
$this->dependsOn = $dependsOn;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getDependencyType(): DependencyType
|
||||||
|
{
|
||||||
|
return $this->dependencyType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setDependencyType(DependencyType $dependencyType): static
|
||||||
|
{
|
||||||
|
$this->dependencyType = $dependencyType;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getPosition(): int
|
||||||
|
{
|
||||||
|
return $this->position;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setPosition(?int $position): static
|
||||||
|
{
|
||||||
|
$this->position = $position ?? 0;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace MauticPlugin\PlanBundle\Entity;
|
||||||
|
|
||||||
|
use Mautic\CoreBundle\Entity\CommonRepository;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @extends CommonRepository<TaskDependency>
|
||||||
|
*/
|
||||||
|
class TaskDependencyRepository extends CommonRepository
|
||||||
|
{
|
||||||
|
public function getTableAlias(): string
|
||||||
|
{
|
||||||
|
return 'td';
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,40 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace MauticPlugin\PlanBundle\Entity;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The kind of a task. The order of the cases is the order of the dropdown.
|
||||||
|
*/
|
||||||
|
enum TaskKind: string
|
||||||
|
{
|
||||||
|
case Task = 'task';
|
||||||
|
case Milestone = 'milestone';
|
||||||
|
case Phase = 'phase';
|
||||||
|
|
||||||
|
public function getLabelKey(): string
|
||||||
|
{
|
||||||
|
return 'mautic.plan.task.kind.'.$this->value;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* True when this kind has no status of its own: a phase is a collection of tasks, its state comes
|
||||||
|
* from them.
|
||||||
|
*/
|
||||||
|
public function hasStatus(): bool
|
||||||
|
{
|
||||||
|
return self::Phase !== $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Applies the kind's rules to the task's dates. A milestone's end date is enslaved to its start
|
||||||
|
* date: whatever is set, the end becomes the start.
|
||||||
|
*/
|
||||||
|
public function enslaveDates(Task $task): void
|
||||||
|
{
|
||||||
|
if (self::Milestone === $this && null !== $task->getStartDate()) {
|
||||||
|
$task->setEndDate(clone $task->getStartDate());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -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;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace MauticPlugin\PlanBundle\Entity;
|
||||||
|
|
||||||
|
use Mautic\CoreBundle\Entity\CommonRepository;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @extends CommonRepository<TaskRaci>
|
||||||
|
*/
|
||||||
|
class TaskRaciRepository extends CommonRepository
|
||||||
|
{
|
||||||
|
public function getTableAlias(): string
|
||||||
|
{
|
||||||
|
return 'tr';
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -19,7 +19,8 @@ class TaskRepository extends CommonRepository
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Loads the plan and the parent with the tasks, so that the list doesn't query them one by one.
|
* Loads the plan, the dependencies (with their depends-on task) and the RACI rows (with their
|
||||||
|
* stakeholders) with the tasks, so that the list doesn't query them one by one.
|
||||||
*
|
*
|
||||||
* @param array<string, mixed> $args
|
* @param array<string, mixed> $args
|
||||||
*/
|
*/
|
||||||
@@ -28,21 +29,29 @@ class TaskRepository extends CommonRepository
|
|||||||
$alias = $this->getTableAlias();
|
$alias = $this->getTableAlias();
|
||||||
|
|
||||||
$args['qb'] = $this->createQueryBuilder($alias)
|
$args['qb'] = $this->createQueryBuilder($alias)
|
||||||
->select($alias, 'pl', 'pa')
|
->select($alias, 'pl', 'dep', 'depTask', 'raci', 'raciStakeholder')
|
||||||
->leftJoin($alias.'.plan', 'pl')
|
->leftJoin($alias.'.plan', 'pl')
|
||||||
->leftJoin($alias.'.parent', 'pa');
|
->leftJoin($alias.'.dependencies', 'dep')
|
||||||
|
->leftJoin('dep.dependsOn', 'depTask')
|
||||||
|
->leftJoin($alias.'.raci', 'raci')
|
||||||
|
->leftJoin('raci.stakeholders', 'raciStakeholder');
|
||||||
|
|
||||||
return parent::getEntities($args);
|
return parent::getEntities($args);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* All tasks of a plan, ordered by name.
|
* All tasks of a plan, ordered by name, with their dependencies and RACI rows loaded.
|
||||||
*
|
*
|
||||||
* @return Task[]
|
* @return Task[]
|
||||||
*/
|
*/
|
||||||
public function findByPlan(Plan $plan): array
|
public function findByPlan(Plan $plan): array
|
||||||
{
|
{
|
||||||
return $this->createQueryBuilder('t')
|
return $this->createQueryBuilder('t')
|
||||||
|
->select('t', 'dep', 'depTask', 'raci', 'raciStakeholder')
|
||||||
|
->leftJoin('t.dependencies', 'dep')
|
||||||
|
->leftJoin('dep.dependsOn', 'depTask')
|
||||||
|
->leftJoin('t.raci', 'raci')
|
||||||
|
->leftJoin('raci.stakeholders', 'raciStakeholder')
|
||||||
->where('t.plan = :plan')
|
->where('t.plan = :plan')
|
||||||
->setParameter('plan', $plan)
|
->setParameter('plan', $plan)
|
||||||
->orderBy('t.name', 'ASC')
|
->orderBy('t.name', 'ASC')
|
||||||
|
|||||||
@@ -0,0 +1,87 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace MauticPlugin\PlanBundle\Form\Type;
|
||||||
|
|
||||||
|
use Doctrine\ORM\EntityRepository;
|
||||||
|
use MauticPlugin\PlanBundle\Entity\DependencyType;
|
||||||
|
use MauticPlugin\PlanBundle\Entity\Plan;
|
||||||
|
use MauticPlugin\PlanBundle\Entity\Task;
|
||||||
|
use MauticPlugin\PlanBundle\Entity\TaskDependency;
|
||||||
|
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
|
||||||
|
use Symfony\Component\Form\AbstractType;
|
||||||
|
use Symfony\Component\Form\Extension\Core\Type\EnumType;
|
||||||
|
use Symfony\Component\Form\Extension\Core\Type\HiddenType;
|
||||||
|
use Symfony\Component\Form\FormBuilderInterface;
|
||||||
|
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* One row of the dependencies collection in TaskType: the task this one depends on, and the type of
|
||||||
|
* the relation. Only the tasks of the same plan are offered; cycles and self-edges are refused by
|
||||||
|
* ValidTaskDependency.
|
||||||
|
*
|
||||||
|
* @extends AbstractType<TaskDependency>
|
||||||
|
*/
|
||||||
|
class TaskDependencyType extends AbstractType
|
||||||
|
{
|
||||||
|
public function buildForm(FormBuilderInterface $builder, array $options): void
|
||||||
|
{
|
||||||
|
/** @var Plan|null $plan */
|
||||||
|
$plan = $options['plan'];
|
||||||
|
/** @var Task|null $task */
|
||||||
|
$task = $options['task'];
|
||||||
|
|
||||||
|
$builder->add('dependsOn', EntityType::class, [
|
||||||
|
'label' => 'mautic.plan.task.dependency.field.depends_on',
|
||||||
|
'label_attr' => ['class' => 'control-label'],
|
||||||
|
'attr' => ['class' => 'form-control'],
|
||||||
|
'class' => Task::class,
|
||||||
|
'choice_label' => 'name',
|
||||||
|
'query_builder' => function (EntityRepository $er) use ($plan, $task) {
|
||||||
|
$qb = $er->createQueryBuilder('t')
|
||||||
|
->orderBy('t.name', 'ASC');
|
||||||
|
|
||||||
|
if (null !== $plan) {
|
||||||
|
$qb->andWhere('t.plan = :plan')->setParameter('plan', $plan);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (null !== $task?->getId()) {
|
||||||
|
$qb->andWhere('t.id != :self')->setParameter('self', $task->getId());
|
||||||
|
}
|
||||||
|
|
||||||
|
return $qb;
|
||||||
|
},
|
||||||
|
'placeholder' => 'mautic.core.form.chooseone',
|
||||||
|
'required' => true,
|
||||||
|
]);
|
||||||
|
|
||||||
|
$builder->add('dependencyType', EnumType::class, [
|
||||||
|
'label' => 'mautic.plan.task.dependency.field.type',
|
||||||
|
'label_attr' => ['class' => 'control-label'],
|
||||||
|
'attr' => ['class' => 'form-control'],
|
||||||
|
'class' => DependencyType::class,
|
||||||
|
'choice_label' => fn (DependencyType $type): string => $type->getLabelKey(),
|
||||||
|
]);
|
||||||
|
|
||||||
|
// The row's order in the collection, rewritten by plan.js after each change.
|
||||||
|
$builder->add('position', HiddenType::class, [
|
||||||
|
'attr' => ['class' => 'plan-row-position'],
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function configureOptions(OptionsResolver $resolver): void
|
||||||
|
{
|
||||||
|
$resolver->setDefaults([
|
||||||
|
'data_class' => TaskDependency::class,
|
||||||
|
]);
|
||||||
|
$resolver->setDefined(['plan', 'task']);
|
||||||
|
$resolver->setAllowedTypes('plan', [Plan::class, 'null']);
|
||||||
|
$resolver->setAllowedTypes('task', [Task::class, 'null']);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getBlockPrefix(): string
|
||||||
|
{
|
||||||
|
return 'plan_task_dependency';
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,83 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace MauticPlugin\PlanBundle\Form\Type;
|
||||||
|
|
||||||
|
use Doctrine\ORM\EntityRepository;
|
||||||
|
use MauticPlugin\PlanBundle\Entity\Plan;
|
||||||
|
use MauticPlugin\PlanBundle\Entity\RaciRole;
|
||||||
|
use MauticPlugin\PlanBundle\Entity\Stakeholder;
|
||||||
|
use MauticPlugin\PlanBundle\Entity\TaskRaci;
|
||||||
|
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
|
||||||
|
use Symfony\Component\Form\AbstractType;
|
||||||
|
use Symfony\Component\Form\Extension\Core\Type\EnumType;
|
||||||
|
use Symfony\Component\Form\Extension\Core\Type\HiddenType;
|
||||||
|
use Symfony\Component\Form\FormBuilderInterface;
|
||||||
|
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* One row of the RACI collection in TaskType: a role (R/A/C/I) and the stakeholders carrying it.
|
||||||
|
* The stakeholders are picked from the plan's assigned stakeholders; several may share a role.
|
||||||
|
*
|
||||||
|
* @extends AbstractType<TaskRaci>
|
||||||
|
*/
|
||||||
|
class TaskRaciType extends AbstractType
|
||||||
|
{
|
||||||
|
public function buildForm(FormBuilderInterface $builder, array $options): void
|
||||||
|
{
|
||||||
|
/** @var Plan|null $plan */
|
||||||
|
$plan = $options['plan'];
|
||||||
|
|
||||||
|
$builder->add('role', EnumType::class, [
|
||||||
|
'label' => 'mautic.plan.task.raci.field.role',
|
||||||
|
'label_attr' => ['class' => 'control-label'],
|
||||||
|
'attr' => ['class' => 'form-control'],
|
||||||
|
'class' => RaciRole::class,
|
||||||
|
'choice_label' => fn (RaciRole $role): string => $role->getLabelKey(),
|
||||||
|
]);
|
||||||
|
|
||||||
|
$builder->add('stakeholders', EntityType::class, [
|
||||||
|
'label' => 'mautic.plan.task.raci.field.stakeholders',
|
||||||
|
'label_attr' => ['class' => 'control-label'],
|
||||||
|
'attr' => ['class' => 'form-control'],
|
||||||
|
'class' => Stakeholder::class,
|
||||||
|
'choice_label' => 'name',
|
||||||
|
'query_builder' => function (EntityRepository $er) use ($plan) {
|
||||||
|
$qb = $er->createQueryBuilder('s')
|
||||||
|
->orderBy('s.name', 'ASC');
|
||||||
|
|
||||||
|
// The plan's assigned stakeholders, when the plan is known.
|
||||||
|
if (null !== $plan) {
|
||||||
|
$qb->join('s.planLinks', 'l')
|
||||||
|
->andWhere('l.plan = :plan')
|
||||||
|
->setParameter('plan', $plan);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $qb;
|
||||||
|
},
|
||||||
|
'multiple' => true,
|
||||||
|
'expanded' => false,
|
||||||
|
'required' => false,
|
||||||
|
]);
|
||||||
|
|
||||||
|
// The row's order in the collection, rewritten by plan.js after each change.
|
||||||
|
$builder->add('position', HiddenType::class, [
|
||||||
|
'attr' => ['class' => 'plan-row-position'],
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function configureOptions(OptionsResolver $resolver): void
|
||||||
|
{
|
||||||
|
$resolver->setDefaults([
|
||||||
|
'data_class' => TaskRaci::class,
|
||||||
|
]);
|
||||||
|
$resolver->setDefined(['plan']);
|
||||||
|
$resolver->setAllowedTypes('plan', [Plan::class, 'null']);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getBlockPrefix(): string
|
||||||
|
{
|
||||||
|
return 'plan_task_raci';
|
||||||
|
}
|
||||||
|
}
|
||||||
+87
-40
@@ -6,22 +6,31 @@ namespace MauticPlugin\PlanBundle\Form\Type;
|
|||||||
|
|
||||||
use Doctrine\ORM\EntityRepository;
|
use Doctrine\ORM\EntityRepository;
|
||||||
use Mautic\CoreBundle\Form\EventListener\CleanFormSubscriber;
|
use Mautic\CoreBundle\Form\EventListener\CleanFormSubscriber;
|
||||||
use Mautic\CoreBundle\Form\Type\DatePickerType;
|
|
||||||
use Mautic\CoreBundle\Form\Type\FormButtonsType;
|
use Mautic\CoreBundle\Form\Type\FormButtonsType;
|
||||||
use MauticPlugin\PlanBundle\Entity\Plan;
|
use MauticPlugin\PlanBundle\Entity\Plan;
|
||||||
use MauticPlugin\PlanBundle\Entity\Task;
|
use MauticPlugin\PlanBundle\Entity\Task;
|
||||||
|
use MauticPlugin\PlanBundle\Entity\TaskKind;
|
||||||
use MauticPlugin\PlanBundle\Entity\TaskStatus;
|
use MauticPlugin\PlanBundle\Entity\TaskStatus;
|
||||||
use MauticPlugin\PlanBundle\Service\ItemTypeProvider;
|
use MauticPlugin\PlanBundle\Service\ItemTypeProvider;
|
||||||
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
|
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
|
||||||
use Symfony\Component\Form\AbstractType;
|
use Symfony\Component\Form\AbstractType;
|
||||||
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
|
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
|
||||||
|
use Symfony\Component\Form\Extension\Core\Type\CollectionType;
|
||||||
|
use Symfony\Component\Form\Extension\Core\Type\DateType;
|
||||||
use Symfony\Component\Form\Extension\Core\Type\EnumType;
|
use Symfony\Component\Form\Extension\Core\Type\EnumType;
|
||||||
|
use Symfony\Component\Form\Extension\Core\Type\IntegerType;
|
||||||
use Symfony\Component\Form\Extension\Core\Type\TextareaType;
|
use Symfony\Component\Form\Extension\Core\Type\TextareaType;
|
||||||
use Symfony\Component\Form\Extension\Core\Type\TextType;
|
use Symfony\Component\Form\Extension\Core\Type\TextType;
|
||||||
use Symfony\Component\Form\FormBuilderInterface;
|
use Symfony\Component\Form\FormBuilderInterface;
|
||||||
use Symfony\Component\OptionsResolver\OptionsResolver;
|
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* The create and edit form of a task (Planning > Tasks).
|
||||||
|
*
|
||||||
|
* Kind rules: a milestone's end date is enslaved to its start date (the entity's setTaskKind copies
|
||||||
|
* the start onto the end, and the TaskDates validator keeps it in step); a phase has no status
|
||||||
|
* field — its state comes from its tasks.
|
||||||
|
*
|
||||||
* @extends AbstractType<Task>
|
* @extends AbstractType<Task>
|
||||||
*/
|
*/
|
||||||
class TaskType extends AbstractType
|
class TaskType extends AbstractType
|
||||||
@@ -41,6 +50,17 @@ class TaskType extends AbstractType
|
|||||||
|
|
||||||
$kind = ItemTypeProvider::KIND_TASK;
|
$kind = ItemTypeProvider::KIND_TASK;
|
||||||
|
|
||||||
|
// The kind drives what the form offers: milestones enslave the end date, phases have no status.
|
||||||
|
$taskKind = $task->getTaskKind();
|
||||||
|
|
||||||
|
$builder->add('taskKind', EnumType::class, [
|
||||||
|
'label' => 'mautic.plan.task.field.kind',
|
||||||
|
'label_attr' => ['class' => 'control-label'],
|
||||||
|
'attr' => ['class' => 'form-control'],
|
||||||
|
'class' => TaskKind::class,
|
||||||
|
'choice_label' => fn (TaskKind $k): string => $k->getLabelKey(),
|
||||||
|
]);
|
||||||
|
|
||||||
$builder->add('type', ChoiceType::class, [
|
$builder->add('type', ChoiceType::class, [
|
||||||
'label' => 'mautic.plan.task.field.type',
|
'label' => 'mautic.plan.task.field.type',
|
||||||
'label_attr' => ['class' => 'control-label'],
|
'label_attr' => ['class' => 'control-label'],
|
||||||
@@ -79,51 +99,78 @@ class TaskType extends AbstractType
|
|||||||
'required' => true,
|
'required' => true,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
// Offers the tasks of the task's plan when it is known, otherwise all tasks grouped by plan.
|
// Simple dates, no time (the columns are DATE since 0.13.0).
|
||||||
// ValidTaskParent rejects a parent from another plan, and loops.
|
$builder->add('startDate', DateType::class, [
|
||||||
$builder->add('parent', EntityType::class, [
|
'label' => 'mautic.plan.task.field.start_date',
|
||||||
'label' => 'mautic.plan.task.field.parent',
|
'widget' => 'single_text',
|
||||||
'label_attr' => ['class' => 'control-label'],
|
'format' => 'yyyy-MM-dd',
|
||||||
'attr' => ['class' => 'form-control'],
|
'html5' => true,
|
||||||
'class' => Task::class,
|
'attr' => ['class' => 'form-control', 'data-toggle' => 'date'],
|
||||||
'choice_label' => 'name',
|
|
||||||
'group_by' => null === $plan ? fn (Task $t): string => (string) $t->getPlan()?->getName() : null,
|
|
||||||
'query_builder' => function (EntityRepository $er) use ($task, $plan) {
|
|
||||||
$qb = $er->createQueryBuilder('t')
|
|
||||||
->leftJoin('t.plan', 'p')
|
|
||||||
->addSelect('p')
|
|
||||||
->orderBy('p.name', 'ASC')
|
|
||||||
->addOrderBy('t.name', 'ASC');
|
|
||||||
|
|
||||||
if (null !== $plan) {
|
|
||||||
$qb->andWhere('t.plan = :plan')->setParameter('plan', $plan);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (null !== $task->getId()) {
|
|
||||||
$qb->andWhere('t.id != :self')->setParameter('self', $task->getId());
|
|
||||||
}
|
|
||||||
|
|
||||||
return $qb;
|
|
||||||
},
|
|
||||||
'placeholder' => 'mautic.plan.task.parent.none',
|
|
||||||
'required' => false,
|
|
||||||
]);
|
]);
|
||||||
|
|
||||||
// Dropdown in the order of the TaskStatus cases: New, To do, In progress, Done.
|
// End date: a milestone's is enslaved to the start date (same day), so it stays read-only.
|
||||||
$builder->add('status', EnumType::class, [
|
$isMilestone = TaskKind::Milestone === $task->getTaskKind();
|
||||||
'label' => 'mautic.plan.task.field.status',
|
$isPhase = TaskKind::Phase === $task->getTaskKind();
|
||||||
'label_attr' => ['class' => 'control-label'],
|
$builder->add('endDate', DateType::class, [
|
||||||
'attr' => ['class' => 'form-control'],
|
'label' => 'mautic.plan.task.field.end_date',
|
||||||
'class' => TaskStatus::class,
|
'widget' => 'single_text',
|
||||||
'choice_label' => fn (TaskStatus $status): string => $status->getLabelKey(),
|
'format' => 'yyyy-MM-dd',
|
||||||
|
'html5' => true,
|
||||||
|
'disabled' => $isMilestone,
|
||||||
|
'attr' => ['class' => 'form-control', 'data-toggle' => 'date'],
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$builder->add('startDate', DatePickerType::class, [
|
// Status: a phase has none of its own — it comes from its tasks.
|
||||||
'label' => 'mautic.plan.task.field.start_date',
|
if (!$isPhase) {
|
||||||
|
$builder->add('status', EnumType::class, [
|
||||||
|
'label' => 'mautic.plan.task.field.status',
|
||||||
|
'label_attr' => ['class' => 'control-label'],
|
||||||
|
'attr' => ['class' => 'form-control'],
|
||||||
|
'class' => TaskStatus::class,
|
||||||
|
'choice_label' => fn (TaskStatus $status): string => $status->getLabelKey(),
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
$builder->add('definitionOfDone', TextareaType::class, [
|
||||||
|
'label' => 'mautic.plan.task.field.definition_of_done',
|
||||||
|
'label_attr' => ['class' => 'control-label'],
|
||||||
|
'attr' => ['class' => 'form-control', 'rows' => 3],
|
||||||
|
'required' => false,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$builder->add('endDate', DatePickerType::class, [
|
$builder->add('plannedWork', IntegerType::class, [
|
||||||
'label' => 'mautic.plan.task.field.end_date',
|
'label' => 'mautic.plan.task.field.planned_work',
|
||||||
|
'label_attr' => ['class' => 'control-label'],
|
||||||
|
'attr' => ['class' => 'form-control', 'min' => 0, 'step' => 1, 'postaddon_text' => 'h'],
|
||||||
|
'required' => false,
|
||||||
|
]);
|
||||||
|
|
||||||
|
// Dependencies: several edges, each another task of the plan with the relation type. The
|
||||||
|
// rows are added and removed by the form template; cycles and self-edges are refused by
|
||||||
|
// ValidTaskDependency.
|
||||||
|
$builder->add('dependencies', CollectionType::class, [
|
||||||
|
'label' => 'mautic.plan.task.field.dependencies',
|
||||||
|
'entry_type' => TaskDependencyType::class,
|
||||||
|
'entry_options' => ['label' => false, 'plan' => $plan, 'task' => $task],
|
||||||
|
'allow_add' => true,
|
||||||
|
'allow_delete' => true,
|
||||||
|
'by_reference' => false,
|
||||||
|
'prototype' => true,
|
||||||
|
'prototype_name' => '__dependency__',
|
||||||
|
'required' => false,
|
||||||
|
]);
|
||||||
|
|
||||||
|
// RACI: one row per role, several stakeholders per role, picked from the plan's stakeholders.
|
||||||
|
$builder->add('raci', CollectionType::class, [
|
||||||
|
'label' => 'mautic.plan.task.field.raci',
|
||||||
|
'entry_type' => TaskRaciType::class,
|
||||||
|
'entry_options' => ['label' => false, 'plan' => $plan],
|
||||||
|
'allow_add' => true,
|
||||||
|
'allow_delete' => true,
|
||||||
|
'by_reference' => false,
|
||||||
|
'prototype' => true,
|
||||||
|
'prototype_name' => '__raci__',
|
||||||
|
'required' => false,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$builder->add('buttons', FormButtonsType::class);
|
$builder->add('buttons', FormButtonsType::class);
|
||||||
|
|||||||
@@ -0,0 +1,137 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace MauticPlugin\PlanBundle\Migrations;
|
||||||
|
|
||||||
|
use Doctrine\DBAL\Schema\Schema;
|
||||||
|
use Doctrine\ORM\Tools\SchemaTool;
|
||||||
|
use Mautic\IntegrationsBundle\Migration\AbstractMigration;
|
||||||
|
use MauticPlugin\PlanBundle\Entity\Task;
|
||||||
|
use MauticPlugin\PlanBundle\Entity\TaskDependency;
|
||||||
|
use MauticPlugin\PlanBundle\Entity\TaskRaci;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Since 0.13.0 tasks are reworked:
|
||||||
|
* - start_date and end_date become DATE (no time); existing values are truncated to the date;
|
||||||
|
* - new columns task_kind (default 'task'), definition_of_done, planned_work;
|
||||||
|
* - new tables plan_task_dependencies (dependency graph) and plan_task_raci with its
|
||||||
|
* plan_task_raci_stakeholders join table;
|
||||||
|
* - the parent/child tree is dropped: parent_id and its index are removed, replaced by the
|
||||||
|
* dependency graph.
|
||||||
|
*
|
||||||
|
* Each step runs only if needed.
|
||||||
|
*/
|
||||||
|
class Version_0_13_0 extends AbstractMigration
|
||||||
|
{
|
||||||
|
protected function isApplicable(Schema $schema): bool
|
||||||
|
{
|
||||||
|
$tasks = $this->concatPrefix(Task::TABLE_NAME);
|
||||||
|
|
||||||
|
if (!$schema->hasTable($tasks)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
$table = $schema->getTable($tasks);
|
||||||
|
|
||||||
|
return !$table->hasColumn('task_kind')
|
||||||
|
|| !$table->hasColumn('definition_of_done')
|
||||||
|
|| !$table->hasColumn('planned_work')
|
||||||
|
|| $table->hasColumn('parent_id')
|
||||||
|
|| !$schema->hasTable($this->concatPrefix(TaskDependency::TABLE_NAME))
|
||||||
|
|| !$schema->hasTable($this->concatPrefix(TaskRaci::TABLE_NAME))
|
||||||
|
|| !$schema->hasTable($this->concatPrefix(TaskRaci::JOIN_TABLE_NAME));
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function up(): void
|
||||||
|
{
|
||||||
|
$tasks = $this->concatPrefix(Task::TABLE_NAME);
|
||||||
|
$table = $this->entityManager->getConnection()->createSchemaManager()->introspectTable($tasks);
|
||||||
|
|
||||||
|
// New columns.
|
||||||
|
if (!$table->hasColumn('task_kind')) {
|
||||||
|
$this->addSql(sprintf(
|
||||||
|
"ALTER TABLE %s ADD task_kind VARCHAR(20) NOT NULL DEFAULT '%s'",
|
||||||
|
$tasks,
|
||||||
|
\MauticPlugin\PlanBundle\Entity\TaskKind::Task->value
|
||||||
|
));
|
||||||
|
}
|
||||||
|
if (!$table->hasColumn('definition_of_done')) {
|
||||||
|
$this->addSql("ALTER TABLE {$tasks} ADD definition_of_done LONGTEXT DEFAULT NULL");
|
||||||
|
}
|
||||||
|
if (!$table->hasColumn('planned_work')) {
|
||||||
|
$this->addSql("ALTER TABLE {$tasks} ADD planned_work INT UNSIGNED DEFAULT NULL");
|
||||||
|
}
|
||||||
|
|
||||||
|
// Dates: DATETIME -> DATE, truncating the time part.
|
||||||
|
$start = $table->getColumn('start_date');
|
||||||
|
$end = $table->getColumn('end_date');
|
||||||
|
if ('datetime' === $start->getType()->getName()) {
|
||||||
|
$this->addSql("ALTER TABLE {$tasks} MODIFY start_date DATE DEFAULT NULL");
|
||||||
|
$this->addSql("UPDATE {$tasks} SET start_date = DATE(start_date)");
|
||||||
|
}
|
||||||
|
if ('datetime' === $end->getType()->getName()) {
|
||||||
|
$this->addSql("ALTER TABLE {$tasks} MODIFY end_date DATE DEFAULT NULL");
|
||||||
|
$this->addSql("UPDATE {$tasks} SET end_date = DATE(end_date)");
|
||||||
|
}
|
||||||
|
|
||||||
|
// Drop the parent/child tree.
|
||||||
|
if ($table->hasColumn('parent_id')) {
|
||||||
|
$this->addSql("ALTER TABLE {$tasks} DROP COLUMN parent_id");
|
||||||
|
}
|
||||||
|
|
||||||
|
// New tables. Each is created when missing on its own, so a partial earlier run is repaired.
|
||||||
|
if (!$this->introspectSchema()->hasTable($this->concatPrefix(TaskDependency::TABLE_NAME))) {
|
||||||
|
foreach ($this->getCreateTableSqls(TaskDependency::class, TaskDependency::TABLE_NAME) as $sql) {
|
||||||
|
$this->addSql($sql);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!$this->introspectSchema()->hasTable($this->concatPrefix(TaskRaci::TABLE_NAME))) {
|
||||||
|
foreach ($this->getCreateTableSqls(TaskRaci::class, TaskRaci::TABLE_NAME) as $sql) {
|
||||||
|
$this->addSql($sql);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// The RACI join table comes with the TaskRaci entity's SQL (CREATE TABLE plan_task_raci_stakeholders),
|
||||||
|
// but it may be missing while plan_task_raci exists (a partial earlier run).
|
||||||
|
if (!$this->introspectSchema()->hasTable($this->concatPrefix(TaskRaci::JOIN_TABLE_NAME))) {
|
||||||
|
foreach ($this->getCreateTableSqls(TaskRaci::class, TaskRaci::JOIN_TABLE_NAME) as $sql) {
|
||||||
|
$this->addSql($sql);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private function introspectSchema(): Schema
|
||||||
|
{
|
||||||
|
return $this->entityManager->getConnection()->createSchemaManager()->introspectSchema();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The CREATE TABLE statements of one of this migration's entities, from Doctrine's SchemaTool —
|
||||||
|
* the entity's table and, for TaskRaci, its join table plan_task_raci_stakeholders too.
|
||||||
|
*
|
||||||
|
* @param class-string $entityClass
|
||||||
|
*
|
||||||
|
* @return string[]
|
||||||
|
*/
|
||||||
|
private function getCreateTableSqls(string $entityClass, string $table): array
|
||||||
|
{
|
||||||
|
$schemaTool = new SchemaTool($this->entityManager);
|
||||||
|
$prefix = 'CREATE TABLE ';
|
||||||
|
$prefixes = [$prefix.$this->concatPrefix($table).' ', $prefix.$this->concatPrefix($table).'_'];
|
||||||
|
|
||||||
|
$statements = [];
|
||||||
|
foreach ($schemaTool->getCreateSchemaSql([$this->entityManager->getClassMetadata($entityClass)]) as $sql) {
|
||||||
|
foreach ($prefixes as $candidate) {
|
||||||
|
if (str_starts_with($sql, $candidate)) {
|
||||||
|
$statements[] = $sql;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ([] === $statements) {
|
||||||
|
throw new \RuntimeException('SchemaTool returned no CREATE TABLE statement for '.$table.'.');
|
||||||
|
}
|
||||||
|
|
||||||
|
return $statements;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -26,10 +26,12 @@ class Version_0_4_0 extends AbstractMigration
|
|||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Local column => [referenced table, ON DELETE action].
|
* Local column => [referenced table, ON DELETE action].
|
||||||
|
*
|
||||||
|
* parent_id is gone since 0.13.0 (the parent/child tree was replaced by the dependency graph),
|
||||||
|
* so only plan_id is repaired here.
|
||||||
*/
|
*/
|
||||||
private const FOREIGN_KEYS = [
|
private const FOREIGN_KEYS = [
|
||||||
'plan_id' => [Plan::TABLE_NAME, 'CASCADE'],
|
'plan_id' => [Plan::TABLE_NAME, 'CASCADE'],
|
||||||
'parent_id' => [Task::TABLE_NAME, 'SET NULL'],
|
|
||||||
];
|
];
|
||||||
|
|
||||||
protected function isApplicable(Schema $schema): bool
|
protected function isApplicable(Schema $schema): bool
|
||||||
@@ -40,7 +42,9 @@ class Version_0_4_0 extends AbstractMigration
|
|||||||
|
|
||||||
$tasks = $this->concatPrefix(Task::TABLE_NAME);
|
$tasks = $this->concatPrefix(Task::TABLE_NAME);
|
||||||
|
|
||||||
return !$schema->hasTable($tasks) || [] !== $this->getMissingForeignKeys($schema->getTable($tasks));
|
$table = $schema->hasTable($tasks) ? $schema->getTable($tasks) : null;
|
||||||
|
|
||||||
|
return null === $table || [] !== $this->getMissingForeignKeys($table);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function up(): void
|
protected function up(): void
|
||||||
|
|||||||
+6
-18
@@ -45,30 +45,18 @@ class TaskModel extends FormModel
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The plan's tasks as a tree: top-level tasks first, each with its sub-tasks, ordered by name.
|
* The plan's tasks as rows for the plan's Tasks tab: the tasks ordered by name, each with its
|
||||||
|
* dependencies and RACI rows loaded. The former parent/child tree is gone; the tab lists the
|
||||||
|
* tasks flat, and the dependencies are shown per task.
|
||||||
*
|
*
|
||||||
* @return array<int, array{task: Task, depth: int}>
|
* @return array<int, array{task: Task, depth: int}>
|
||||||
*/
|
*/
|
||||||
public function getTaskTree(Plan $plan): array
|
public function getTaskTree(Plan $plan): array
|
||||||
{
|
{
|
||||||
$byParent = [];
|
|
||||||
foreach ($this->getRepository()->findByPlan($plan) as $task) {
|
|
||||||
$byParent[$task->getParent()?->getId() ?? 0][] = $task;
|
|
||||||
}
|
|
||||||
|
|
||||||
$rows = [];
|
$rows = [];
|
||||||
$seen = [];
|
foreach ($this->getRepository()->findByPlan($plan) as $task) {
|
||||||
$walk = function (int $parentId, int $depth) use (&$walk, &$rows, &$seen, $byParent): void {
|
$rows[] = ['task' => $task, 'depth' => 0];
|
||||||
foreach ($byParent[$parentId] ?? [] as $task) {
|
}
|
||||||
if (isset($seen[$task->getId()])) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
$seen[$task->getId()] = true;
|
|
||||||
$rows[] = ['task' => $task, 'depth' => $depth];
|
|
||||||
$walk((int) $task->getId(), $depth + 1);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
$walk(0, 0);
|
|
||||||
|
|
||||||
return $rows;
|
return $rows;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -50,8 +50,7 @@
|
|||||||
{% for row in taskTree %}
|
{% for row in taskTree %}
|
||||||
{% set task = row.task %}
|
{% set task = row.task %}
|
||||||
{% set canEdit = not readOnly and securityHasEntityAccess(taskPermissions['plan:tasks:editown']|default(false), taskPermissions['plan:tasks:editother']|default(false), task.createdBy) %}
|
{% set canEdit = not readOnly and securityHasEntityAccess(taskPermissions['plan:tasks:editown']|default(false), taskPermissions['plan:tasks:editother']|default(false), task.createdBy) %}
|
||||||
{% set childCount = taskTree|filter(r => r.task.parent and r.task.parent.id == task.id)|length %}
|
<tr class="plan-task" data-task-id="{{ task.id }}">
|
||||||
<tr class="plan-task" data-task-id="{{ task.id }}" data-depth="{{ row.depth }}">
|
|
||||||
<td class="plan-col-pictogram text-center">
|
<td class="plan-col-pictogram text-center">
|
||||||
{% set taskTypeIcon = plan_item_type_icon('task', task.type) %}
|
{% set taskTypeIcon = plan_item_type_icon('task', task.type) %}
|
||||||
{% if taskTypeIcon %}<i class="{{ taskTypeIcon }} plan-item-type-icon" style="font-size: 24px;" aria-hidden="true"></i>{% endif %}
|
{% if taskTypeIcon %}<i class="{{ taskTypeIcon }} plan-item-type-icon" style="font-size: 24px;" aria-hidden="true"></i>{% endif %}
|
||||||
@@ -60,19 +59,16 @@
|
|||||||
{{ plan_item_type_name('task', task.type) ?? 'mautic.plan.description_item.type.unknown'|trans({'%key%': task.type}) }}
|
{{ plan_item_type_name('task', task.type) ?? 'mautic.plan.description_item.type.unknown'|trans({'%key%': task.type}) }}
|
||||||
</td>
|
</td>
|
||||||
<td class="plan-col-name">
|
<td class="plan-col-name">
|
||||||
<span style="display: inline-block; padding-left: {{ row.depth * 24 }}px;">
|
{% if canEdit %}
|
||||||
{% if row.depth > 0 %}
|
<a href="{{ path('plan_task_action', {'objectAction': 'edit', 'objectId': task.id, 'returnTo': 'plan'}) }}" data-toggle="ajax">{{ task.name }}</a>
|
||||||
<i class="ri-corner-down-right-line text-muted" title="{{ 'mautic.plan.task.subtask_of'|trans({'%parent%': task.parent.name}) }}"></i>
|
{% else %}
|
||||||
{% endif %}
|
{{ task.name }}
|
||||||
{% if canEdit %}
|
{% endif %}
|
||||||
<a href="{{ path('plan_task_action', {'objectAction': 'edit', 'objectId': task.id, 'returnTo': 'plan'}) }}" data-toggle="ajax">{{ task.name }}</a>
|
{% if task.taskKind == constant('MauticPlugin\\PlanBundle\\Entity\\TaskKind::Milestone') %}
|
||||||
{% else %}
|
<span class="label label-success" title="{{ 'mautic.plan.task.kind.milestone'|trans }}">{{ 'mautic.plan.task.kind.milestone_short'|trans }}</span>
|
||||||
{{ task.name }}
|
{% elseif task.taskKind == constant('MauticPlugin\\PlanBundle\\Entity\\TaskKind::Phase') %}
|
||||||
{% endif %}
|
<span class="label label-primary" title="{{ 'mautic.plan.task.kind.phase'|trans }}">{{ 'mautic.plan.task.kind.phase_short'|trans }}</span>
|
||||||
{% if childCount > 0 %}
|
{% endif %}
|
||||||
<span class="text-muted small" title="{{ 'mautic.plan.task.subtasks'|trans }}">({{ childCount }})</span>
|
|
||||||
{% endif %}
|
|
||||||
</span>
|
|
||||||
</td>
|
</td>
|
||||||
<td class="plan-col-description text-muted">
|
<td class="plan-col-description text-muted">
|
||||||
{# Same 10-line clamp and read-more as the Description tab; URLs become links. #}
|
{# Same 10-line clamp and read-more as the Description tab; URLs become links. #}
|
||||||
@@ -81,9 +77,14 @@
|
|||||||
'id': 'plan-task-desc-' ~ task.id,
|
'id': 'plan-task-desc-' ~ task.id,
|
||||||
}) }}
|
}) }}
|
||||||
</td>
|
</td>
|
||||||
<td class="plan-col-date">{{ task.startDate ? dateToFull(task.startDate) : '' }}</td>
|
<td class="plan-col-date">{{ task.startDate ? task.startDate|date('Y-m-d') : '' }}</td>
|
||||||
<td class="plan-col-date">{{ task.endDate ? dateToFull(task.endDate) : '' }}</td>
|
<td class="plan-col-date">{{ task.endDate ? task.endDate|date('Y-m-d') : '' }}</td>
|
||||||
<td class="plan-col-status"><span class="label {{ task.status.labelClass }}">{{ task.status.labelKey|trans }}</span></td>
|
<td class="plan-col-status">
|
||||||
|
{# A phase has no status of its own — skip the column value. #}
|
||||||
|
{% if task.taskKind != constant('MauticPlugin\\PlanBundle\\Entity\\TaskKind::Phase') %}
|
||||||
|
<span class="label {{ task.status.labelClass }}">{{ task.status.labelKey|trans }}</span>
|
||||||
|
{% endif %}
|
||||||
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</tbody>
|
</tbody>
|
||||||
|
|||||||
@@ -10,6 +10,57 @@
|
|||||||
{% endif %}
|
{% endif %}
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
|
{# The dependencies and the RACI rows: the same editable, sortable rows as the plan form's
|
||||||
|
collections. Adding, removing and reordering is handled by Assets/js/plan.js through the
|
||||||
|
plan-collection-* classes. #}
|
||||||
|
{% macro dependency_row(dependency) %}
|
||||||
|
<li class="plan-collection-row list-group-item">
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-xs-1 text-center">
|
||||||
|
<span class="plan-collection-handle text-muted" title="{{ 'mautic.plan.task.dependency.drag'|trans }}" style="cursor: move;">
|
||||||
|
<i class="ri-draggable ri-lg"></i>
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
<div class="col-xs-10">
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-md-7">{{ form_row(dependency.dependsOn) }}</div>
|
||||||
|
<div class="col-md-5">{{ form_row(dependency.dependencyType) }}</div>
|
||||||
|
</div>
|
||||||
|
{{ form_widget(dependency.position) }}
|
||||||
|
</div>
|
||||||
|
<div class="col-xs-1 text-right">
|
||||||
|
<button type="button" class="btn btn-ghost btn-sm plan-collection-remove" title="{{ 'mautic.plan.task.dependency.remove'|trans }}">
|
||||||
|
<i class="ri-delete-bin-line"></i>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</li>
|
||||||
|
{% endmacro %}
|
||||||
|
|
||||||
|
{% macro raci_row(raci) %}
|
||||||
|
<li class="plan-collection-row list-group-item">
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-xs-1 text-center">
|
||||||
|
<span class="plan-collection-handle text-muted" title="{{ 'mautic.plan.task.raci.drag'|trans }}" style="cursor: move;">
|
||||||
|
<i class="ri-draggable ri-lg"></i>
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
<div class="col-xs-10">
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-md-4">{{ form_row(raci.role) }}</div>
|
||||||
|
<div class="col-md-8">{{ form_row(raci.stakeholders) }}</div>
|
||||||
|
</div>
|
||||||
|
{{ form_widget(raci.position) }}
|
||||||
|
</div>
|
||||||
|
<div class="col-xs-1 text-right">
|
||||||
|
<button type="button" class="btn btn-ghost btn-sm plan-collection-remove" title="{{ 'mautic.plan.task.raci.remove'|trans }}">
|
||||||
|
<i class="ri-delete-bin-line"></i>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</li>
|
||||||
|
{% endmacro %}
|
||||||
|
|
||||||
{% block content %}
|
{% block content %}
|
||||||
{{ form_start(form) }}
|
{{ form_start(form) }}
|
||||||
<div class="box-layout">
|
<div class="box-layout">
|
||||||
@@ -28,18 +79,70 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{{ form_row(form.description) }}
|
{{ form_row(form.description) }}
|
||||||
|
{{ form_row(form.definitionOfDone) }}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-md-3 height-auto">
|
<div class="col-md-3 height-auto">
|
||||||
<div class="pr-lg pl-lg pt-md pb-md">
|
<div class="pr-lg pl-lg pt-md pb-md">
|
||||||
{{ form_row(form.status) }}
|
{{ form_row(form.plan) }}
|
||||||
|
{{ form_row(form.taskKind) }}
|
||||||
{{ form_row(form.startDate) }}
|
{{ form_row(form.startDate) }}
|
||||||
{{ form_row(form.endDate) }}
|
{{ form_row(form.endDate) }}
|
||||||
{{ form_row(form.plan) }}
|
{% if form.status is defined %}
|
||||||
{{ form_row(form.parent) }}
|
{{ form_row(form.status) }}
|
||||||
<p class="text-muted small">{{ 'mautic.plan.task.parent.help'|trans }}</p>
|
{% else %}
|
||||||
|
{# A phase has no status of its own: its state comes from its tasks. #}
|
||||||
|
<p class="text-muted small">{{ 'mautic.plan.task.kind.phase_status_note'|trans }}</p>
|
||||||
|
{% endif %}
|
||||||
|
{{ form_row(form.plannedWork) }}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{{ form_end(form) }}
|
<div class="pa-md">
|
||||||
|
<div class="col-md-12">
|
||||||
|
{# Dependencies: several edges, each another task of the plan with the relation type. #}
|
||||||
|
<div class="plan-collection plan-task-dependencies"
|
||||||
|
data-prototype="{{ _self.dependency_row(form.dependencies.vars.prototype)|e('html_attr') }}"
|
||||||
|
data-prototype-name="__dependency__">
|
||||||
|
<h4 class="mt-lg mb-sm">{{ 'mautic.plan.task.field.dependencies'|trans }}</h4>
|
||||||
|
{{ form_errors(form.dependencies) }}
|
||||||
|
<p class="text-muted plan-collection-empty{% if form.dependencies|length > 0 %} hide{% endif %}">
|
||||||
|
{{ 'mautic.plan.task.dependency.empty'|trans }}
|
||||||
|
</p>
|
||||||
|
<ul class="list-group plan-collection-list">
|
||||||
|
{% for dependency in form.dependencies %}
|
||||||
|
{{ _self.dependency_row(dependency) }}
|
||||||
|
{% endfor %}
|
||||||
|
</ul>
|
||||||
|
<button type="button" class="btn btn-ghost plan-collection-add">
|
||||||
|
<i class="ri-add-line"></i> {{ 'mautic.plan.task.dependency.add'|trans }}
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
{% do form.dependencies.setRendered %}
|
||||||
|
|
||||||
|
{# RACI: one row per role, several stakeholders per role, picked from the plan's. #}
|
||||||
|
<div class="plan-collection plan-task-raci"
|
||||||
|
data-prototype="{{ _self.raci_row(form.raci.vars.prototype)|e('html_attr') }}"
|
||||||
|
data-prototype-name="__raci__">
|
||||||
|
<h4 class="mt-lg mb-sm">{{ 'mautic.plan.task.field.raci'|trans }}</h4>
|
||||||
|
{{ form_errors(form.raci) }}
|
||||||
|
<p class="text-muted plan-collection-empty{% if form.raci|length > 0 %} hide{% endif %}">
|
||||||
|
{{ 'mautic.plan.task.raci.empty'|trans }}
|
||||||
|
</p>
|
||||||
|
<ul class="list-group plan-collection-list">
|
||||||
|
{% for raci in form.raci %}
|
||||||
|
{{ _self.raci_row(raci) }}
|
||||||
|
{% endfor %}
|
||||||
|
</ul>
|
||||||
|
<button type="button" class="btn btn-ghost plan-collection-add">
|
||||||
|
<i class="ri-add-line"></i> {{ 'mautic.plan.task.raci.add'|trans }}
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
{% do form.raci.setRendered %}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{{ form_row(form.buttons) }}
|
||||||
|
{# render_rest is false, so the hidden CSRF token must be rendered explicitly. #}
|
||||||
|
{{ form_widget(form._token) }}
|
||||||
|
{{ form_end(form, {'render_rest': false}) }}
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
@@ -117,9 +117,16 @@
|
|||||||
{% set description = item.description|default('')|striptags|trim %}
|
{% set description = item.description|default('')|striptags|trim %}
|
||||||
{{ (description|length > 120 ? description|slice(0, 120) ~ '…' : description)|plan_linkify }}
|
{{ (description|length > 120 ? description|slice(0, 120) ~ '…' : description)|plan_linkify }}
|
||||||
</td>
|
</td>
|
||||||
<td>{{ item.startDate ? dateToFull(item.startDate) : '' }}</td>
|
<td>{{ item.startDate ? item.startDate|date('Y-m-d') : '' }}</td>
|
||||||
<td>{{ item.endDate ? dateToFull(item.endDate) : '' }}</td>
|
<td>{{ item.endDate ? item.endDate|date('Y-m-d') : '' }}</td>
|
||||||
<td><span class="label {{ item.status.labelClass }}">{{ item.status.labelKey|trans }}</span></td>
|
<td>
|
||||||
|
{# A phase has no status of its own: its state comes from its tasks. #}
|
||||||
|
{% if item.taskKind != constant('MauticPlugin\\PlanBundle\\Entity\\TaskKind::Phase') %}
|
||||||
|
<span class="label {{ item.status.labelClass }}">{{ item.status.labelKey|trans }}</span>
|
||||||
|
{% else %}
|
||||||
|
<span class="label label-primary">{{ 'mautic.plan.task.kind.phase_short'|trans }}</span>
|
||||||
|
{% endif %}
|
||||||
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</tbody>
|
</tbody>
|
||||||
|
|||||||
@@ -119,28 +119,58 @@ mautic.plan.task.header.index="Tasks"
|
|||||||
mautic.plan.task.header.new="New task"
|
mautic.plan.task.header.new="New task"
|
||||||
mautic.plan.task.header.edit="Edit task - %name%"
|
mautic.plan.task.header.edit="Edit task - %name%"
|
||||||
mautic.plan.task.error.notfound="No task with the ID %id% was found."
|
mautic.plan.task.error.notfound="No task with the ID %id% was found."
|
||||||
mautic.plan.task.form.confirmdelete="Delete the task, %name%? Its sub-tasks are kept and become top-level tasks."
|
mautic.plan.task.form.confirmdelete="Delete the task, %name%? Its dependencies on other tasks and its RACI assignments are removed too."
|
||||||
mautic.plan.task.form.confirmbatchdelete="Delete the selected tasks? Their sub-tasks are kept and become top-level tasks."
|
mautic.plan.task.form.confirmbatchdelete="Delete the selected tasks? Their dependencies on other tasks and their RACI assignments are removed too."
|
||||||
mautic.plan.task.onboarding.heading="No tasks yet"
|
mautic.plan.task.onboarding.heading="No tasks yet"
|
||||||
mautic.plan.task.onboarding.subheading="Tasks break a plan down into work to do."
|
mautic.plan.task.onboarding.subheading="Tasks break a plan down into work to do."
|
||||||
mautic.plan.task.onboarding.copy="Use the New button above, or Add task on a plan's Tasks tab. A task belongs to one plan and can be a sub-task of another task in the same plan."
|
mautic.plan.task.onboarding.copy="Use the New button above, or Add task on a plan's Tasks tab. A task belongs to one plan, may depend on other tasks of that plan (start to start, end to end and so on), and is assigned to the plan's stakeholders through RACI roles."
|
||||||
mautic.plan.task.field.name="Name"
|
mautic.plan.task.field.name="Name"
|
||||||
mautic.plan.task.field.type="Type"
|
mautic.plan.task.field.type="Type"
|
||||||
mautic.plan.task.field.pictogram="Pictogram"
|
mautic.plan.task.field.pictogram="Pictogram"
|
||||||
mautic.plan.task.field.description="Description"
|
mautic.plan.task.field.description="Description"
|
||||||
mautic.plan.task.field.plan="Plan"
|
mautic.plan.task.field.plan="Plan"
|
||||||
mautic.plan.task.field.parent="Parent task"
|
mautic.plan.task.field.kind="Kind"
|
||||||
mautic.plan.task.field.start_date="Start date"
|
mautic.plan.task.field.start_date="Start date"
|
||||||
mautic.plan.task.field.end_date="End date"
|
mautic.plan.task.field.end_date="End date"
|
||||||
mautic.plan.task.field.status="Status"
|
mautic.plan.task.field.status="Status"
|
||||||
|
mautic.plan.task.field.definition_of_done="Definition of Done"
|
||||||
|
mautic.plan.task.field.planned_work="Planned work"
|
||||||
|
mautic.plan.task.field.dependencies="Dependencies"
|
||||||
|
mautic.plan.task.field.raci="RACI"
|
||||||
mautic.plan.task.status.new="New"
|
mautic.plan.task.status.new="New"
|
||||||
mautic.plan.task.status.todo="To do"
|
mautic.plan.task.status.todo="To do"
|
||||||
mautic.plan.task.status.in_progress="In progress"
|
mautic.plan.task.status.in_progress="In progress"
|
||||||
mautic.plan.task.status.done="Done"
|
mautic.plan.task.status.done="Done"
|
||||||
mautic.plan.task.parent.none="None (top-level task)"
|
mautic.plan.task.kind.task="Task"
|
||||||
mautic.plan.task.parent.help="A parent task must be in the same plan."
|
mautic.plan.task.kind.milestone="Milestone"
|
||||||
|
mautic.plan.task.kind.milestone_short="M"
|
||||||
|
mautic.plan.task.kind.phase="Phase"
|
||||||
|
mautic.plan.task.kind.phase_short="P"
|
||||||
|
mautic.plan.task.kind.task_short="T"
|
||||||
|
mautic.plan.task.kind.phase_status_note="A phase has no status of its own: its state comes from its tasks."
|
||||||
|
mautic.plan.task.kind.milestone_end_note="A milestone ends on its start date: the end date is the start date."
|
||||||
|
mautic.plan.task.planned_work_unit="hours"
|
||||||
|
mautic.plan.task.dependency.add="Add dependency"
|
||||||
|
mautic.plan.task.dependency.remove="Remove dependency"
|
||||||
|
mautic.plan.task.dependency.drag="Drag to reorder"
|
||||||
|
mautic.plan.task.dependency.empty="No dependencies yet."
|
||||||
|
mautic.plan.task.dependency.field.depends_on="Depends on"
|
||||||
|
mautic.plan.task.dependency.field.type="Relation"
|
||||||
|
mautic.plan.task.dependency_type.end_to_start="End to Start"
|
||||||
|
mautic.plan.task.dependency_type.end_to_end="End to End"
|
||||||
|
mautic.plan.task.dependency_type.start_to_start="Start to Start"
|
||||||
|
mautic.plan.task.dependency_type.start_to_end="Start to End"
|
||||||
|
mautic.plan.task.raci.add="Add RACI role"
|
||||||
|
mautic.plan.task.raci.remove="Remove"
|
||||||
|
mautic.plan.task.raci.drag="Drag to reorder"
|
||||||
|
mautic.plan.task.raci.empty="No RACI assignments yet."
|
||||||
|
mautic.plan.task.raci.field.role="Role"
|
||||||
|
mautic.plan.task.raci.field.stakeholders="Stakeholders"
|
||||||
|
mautic.plan.task.raci_role.responsible="Responsible"
|
||||||
|
mautic.plan.task.raci_role.accountable="Accountable"
|
||||||
|
mautic.plan.task.raci_role.consulted="Consulted"
|
||||||
|
mautic.plan.task.raci_role.informed="Informed"
|
||||||
mautic.plan.task.add="Add task"
|
mautic.plan.task.add="Add task"
|
||||||
mautic.plan.task.save_plan_first="Save the plan first, then add tasks from its page."
|
|
||||||
mautic.plan.task.manage_from_plan_page="Add and edit tasks from the plan's page, after saving."
|
mautic.plan.task.manage_from_plan_page="Add and edit tasks from the plan's page, after saving."
|
||||||
|
|
||||||
mautic.plan.field.name="Name"
|
mautic.plan.field.name="Name"
|
||||||
@@ -223,8 +253,7 @@ mautic.plan.header.total_real="Real: %amount% %currency%"
|
|||||||
mautic.plan.header.total_real.tooltip="Total real cost of the allocation items, within the planned cost"
|
mautic.plan.header.total_real.tooltip="Total real cost of the allocation items, within the planned cost"
|
||||||
mautic.plan.header.total_real.over="Total real cost of the allocation items, above the planned cost"
|
mautic.plan.header.total_real.over="Total real cost of the allocation items, above the planned cost"
|
||||||
|
|
||||||
mautic.plan.task.subtask_of="Sub-task of %parent%"
|
mautic.plan.task.save_plan_first="Save the plan first, then add tasks from its page."
|
||||||
mautic.plan.task.subtasks="Number of sub-tasks"
|
|
||||||
|
|
||||||
mautic.plan.config.section.allocation_item_types="Allocation item types"
|
mautic.plan.config.section.allocation_item_types="Allocation item types"
|
||||||
mautic.plan.config.section.allocation_item_types.help="The types offered for the cost lines of a plan's Allocations tab, in this order. Give each type a name and a description in each language, and a pictogram; the default language is required. Users see their own language, or the default language when it's empty."
|
mautic.plan.config.section.allocation_item_types.help="The types offered for the cost lines of a plan's Allocations tab, in this order. Give each type a name and a description in each language, and a pictogram; the default language is required. Users see their own language, or the default language when it's empty."
|
||||||
|
|||||||
@@ -10,8 +10,12 @@ mautic.plan.stakeholder.email.invalid="This email address is not valid."
|
|||||||
mautic.plan.stakeholder_link.stakeholder.required="Choose a stakeholder."
|
mautic.plan.stakeholder_link.stakeholder.required="Choose a stakeholder."
|
||||||
mautic.plan.task.plan.required="A task must be assigned to a plan."
|
mautic.plan.task.plan.required="A task must be assigned to a plan."
|
||||||
mautic.plan.task.type.required="Choose a type."
|
mautic.plan.task.type.required="Choose a type."
|
||||||
mautic.plan.task.parent.other_plan="The parent task must be in the same plan."
|
mautic.plan.task.planned_work.invalid="The planned work must be a whole number of hours, 0 or more."
|
||||||
mautic.plan.task.parent.loop="A task can't be its own parent, or a sub-task of one of its sub-tasks."
|
mautic.plan.task.planned_work.range="The planned work must be a whole number of hours from 0 to %max%."
|
||||||
|
mautic.plan.task.milestone.end_enslaved="A milestone ends on its start date."
|
||||||
|
mautic.plan.task.dependency.self="A task can't depend on itself."
|
||||||
|
mautic.plan.task.dependency.cycle="A task can't depend on a task that (directly or not) depends on it."
|
||||||
|
mautic.plan.task.dependency.other_plan="A task can only depend on tasks of the same plan."
|
||||||
mautic.plan.description_item.type.required="Choose a type."
|
mautic.plan.description_item.type.required="Choose a type."
|
||||||
mautic.plan.config.type.name.required="A type needs a name in the default language."
|
mautic.plan.config.type.name.required="A type needs a name in the default language."
|
||||||
mautic.plan.config.type.in_use="These types are in use and can't be removed: %types%. Change the items or tasks that use them to another type first."
|
mautic.plan.config.type.in_use="These types are in use and can't be removed: %types%. Change the items or tasks that use them to another type first."
|
||||||
|
|||||||
@@ -0,0 +1,25 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace MauticPlugin\PlanBundle\Validator\Constraints;
|
||||||
|
|
||||||
|
use Symfony\Component\Validator\Constraint;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Applies the task kind's rules to the dates:
|
||||||
|
* - a milestone's end date is enslaved to its start date (saved as equals);
|
||||||
|
* - a phase keeps its own dates, like any task.
|
||||||
|
*
|
||||||
|
* The start-before-end rule itself is EndDateAfterStartDate, shared by plans and tasks.
|
||||||
|
*/
|
||||||
|
#[\Symfony\Component\Validator\Attribute\HasNamedArguments]
|
||||||
|
class TaskDates extends Constraint
|
||||||
|
{
|
||||||
|
public const MILESTONE_END_ENSLAVED = 'mautic.plan.task.milestone.end_enslaved';
|
||||||
|
|
||||||
|
public function getTargets(): string|array
|
||||||
|
{
|
||||||
|
return self::CLASS_CONSTRAINT;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,32 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace MauticPlugin\PlanBundle\Validator\Constraints;
|
||||||
|
|
||||||
|
use MauticPlugin\PlanBundle\Entity\Task;
|
||||||
|
use MauticPlugin\PlanBundle\Entity\TaskKind;
|
||||||
|
use Symfony\Component\Validator\Constraint;
|
||||||
|
use Symfony\Component\Validator\ConstraintValidator;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Enforces the task kind's date rules. A milestone's end date is enslaved to its start date: the
|
||||||
|
* validator copies the start date onto the end date before validation, so the saved task always
|
||||||
|
* carries start = end.
|
||||||
|
*/
|
||||||
|
class TaskDatesValidator extends ConstraintValidator
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @param Task $task
|
||||||
|
*/
|
||||||
|
public function validate($task, Constraint $constraint): void
|
||||||
|
{
|
||||||
|
if (!$task instanceof Task) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (TaskKind::Milestone === $task->getTaskKind() && null !== $task->getStartDate()) {
|
||||||
|
$task->setEndDate(clone $task->getStartDate());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,22 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace MauticPlugin\PlanBundle\Validator\Constraints;
|
||||||
|
|
||||||
|
use Symfony\Component\Validator\Constraint;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A task's dependency edges must not form a cycle, and must not point at the task itself.
|
||||||
|
*/
|
||||||
|
class ValidTaskDependency extends Constraint
|
||||||
|
{
|
||||||
|
public const SELF_REFERENCE = 'mautic.plan.task.dependency.self';
|
||||||
|
public const CYCLE = 'mautic.plan.task.dependency.cycle';
|
||||||
|
public const OTHER_PLAN = 'mautic.plan.task.dependency.other_plan';
|
||||||
|
|
||||||
|
public function getTargets(): string|array
|
||||||
|
{
|
||||||
|
return self::CLASS_CONSTRAINT;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,84 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace MauticPlugin\PlanBundle\Validator\Constraints;
|
||||||
|
|
||||||
|
use Doctrine\ORM\EntityManagerInterface;
|
||||||
|
use MauticPlugin\PlanBundle\Entity\Task;
|
||||||
|
use MauticPlugin\PlanBundle\Entity\TaskDependency;
|
||||||
|
use Symfony\Component\Validator\Constraint;
|
||||||
|
use Symfony\Component\Validator\ConstraintValidator;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Walks the task's dependency edges and refuses cycles, self-edges and edges to another plan's
|
||||||
|
* tasks. The walk follows the edges through the database (edges of other tasks are not on this
|
||||||
|
* form), so a cycle crossing other tasks is caught too.
|
||||||
|
*/
|
||||||
|
class ValidTaskDependencyValidator extends ConstraintValidator
|
||||||
|
{
|
||||||
|
public function __construct(
|
||||||
|
private EntityManagerInterface $em,
|
||||||
|
) {
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param Task $task
|
||||||
|
*/
|
||||||
|
public function validate($task, Constraint $constraint): void
|
||||||
|
{
|
||||||
|
if (!$task instanceof Task) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach ($task->getDependencies() as $dependency) {
|
||||||
|
$this->validateEdge($task, $dependency, $constraint);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private function validateEdge(Task $task, TaskDependency $dependency, Constraint $constraint): void
|
||||||
|
{
|
||||||
|
$dependsOn = $dependency->getDependsOn();
|
||||||
|
|
||||||
|
if (null === $dependsOn) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($dependsOn === $task || $dependsOn->getId() === $task->getId()) {
|
||||||
|
$this->context->buildViolation($constraint::SELF_REFERENCE)->atPath('dependencies')->addViolation();
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (null !== $task->getPlan() && null !== $dependsOn->getPlan() && $task->getPlan()->getId() !== $dependsOn->getPlan()->getId()) {
|
||||||
|
$this->context->buildViolation($constraint::OTHER_PLAN)->atPath('dependencies')->addViolation();
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Cycle check: walk the edges from the depends-on task; if we come back to this task, it's a cycle.
|
||||||
|
$seen = [];
|
||||||
|
$queue = [$dependsOn];
|
||||||
|
|
||||||
|
while (null !== ($current = array_shift($queue))) {
|
||||||
|
$key = $current->getId() ?? spl_object_id($current);
|
||||||
|
if ($key === ($task->getId() ?? spl_object_id($task))) {
|
||||||
|
$this->context->buildViolation($constraint::CYCLE)->atPath('dependencies')->addViolation();
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (isset($seen[$key])) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
$seen[$key] = true;
|
||||||
|
|
||||||
|
// Follow the edges of the current task, from the database (they may belong to other tasks).
|
||||||
|
$edges = $this->em->getRepository(TaskDependency::class)->findBy(['task' => $current]);
|
||||||
|
foreach ($edges as $edge) {
|
||||||
|
if (null !== $edge->getDependsOn()) {
|
||||||
|
$queue[] = $edge->getDependsOn();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,23 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
declare(strict_types=1);
|
|
||||||
|
|
||||||
namespace MauticPlugin\PlanBundle\Validator\Constraints;
|
|
||||||
|
|
||||||
use Symfony\Component\Validator\Constraint;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Class constraint on Task: the parent task must be in the same plan, and must not be the task itself
|
|
||||||
* or one of its sub-tasks (which would create a loop).
|
|
||||||
*/
|
|
||||||
class ValidTaskParent extends Constraint
|
|
||||||
{
|
|
||||||
public string $otherPlanMessage = 'mautic.plan.task.parent.other_plan';
|
|
||||||
|
|
||||||
public string $loopMessage = 'mautic.plan.task.parent.loop';
|
|
||||||
|
|
||||||
public function getTargets(): string
|
|
||||||
{
|
|
||||||
return self::CLASS_CONSTRAINT;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,53 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
declare(strict_types=1);
|
|
||||||
|
|
||||||
namespace MauticPlugin\PlanBundle\Validator\Constraints;
|
|
||||||
|
|
||||||
use MauticPlugin\PlanBundle\Entity\Task;
|
|
||||||
use Symfony\Component\Validator\Constraint;
|
|
||||||
use Symfony\Component\Validator\ConstraintValidator;
|
|
||||||
use Symfony\Component\Validator\Exception\UnexpectedTypeException;
|
|
||||||
use Symfony\Component\Validator\Exception\UnexpectedValueException;
|
|
||||||
|
|
||||||
class ValidTaskParentValidator extends ConstraintValidator
|
|
||||||
{
|
|
||||||
public function validate(mixed $value, Constraint $constraint): void
|
|
||||||
{
|
|
||||||
if (!$constraint instanceof ValidTaskParent) {
|
|
||||||
throw new UnexpectedTypeException($constraint, ValidTaskParent::class);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (null === $value) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!$value instanceof Task) {
|
|
||||||
throw new UnexpectedValueException($value, Task::class);
|
|
||||||
}
|
|
||||||
|
|
||||||
$parent = $value->getParent();
|
|
||||||
|
|
||||||
if (null === $parent) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// The parent's ancestors include the task itself: the task is its own parent or a sub-task's child.
|
|
||||||
if ($parent->hasAncestorOrSelf($value)) {
|
|
||||||
$this->context->buildViolation($constraint->loopMessage)
|
|
||||||
->atPath('parent')
|
|
||||||
->addViolation();
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
$plan = $value->getPlan();
|
|
||||||
$parentPlan = $parent->getPlan();
|
|
||||||
|
|
||||||
if (null !== $plan && null !== $parentPlan && $plan->getId() !== $parentPlan->getId()) {
|
|
||||||
$this->context->buildViolation($constraint->otherPlanMessage)
|
|
||||||
->atPath('parent')
|
|
||||||
->addViolation();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -63,7 +63,7 @@ The plugin uses the IntegrationsBundle conventions:
|
|||||||
- `Controller/PlanController.php`: list, detail page, create, edit and delete (single and batch), built on core's `AbstractStandardFormController`
|
- `Controller/PlanController.php`: list, detail page, create, edit and delete (single and batch), built on core's `AbstractStandardFormController`
|
||||||
- `Resources/views/Plan/list.html.twig`: the list. A plan's name opens its detail page.
|
- `Resources/views/Plan/list.html.twig`: the list. A plan's name opens its detail page.
|
||||||
- `Resources/views/Plan/form.html.twig` and `details.html.twig`: the create/edit form and the detail page. Both have the same six tabs, from `_tabs.html.twig`: **Details**, **Description** (description items), **Objectives**, **Allocations** (planned budget, currency and allocation items), **Targets** and **Tasks**.
|
- `Resources/views/Plan/form.html.twig` and `details.html.twig`: the create/edit form and the detail page. Both have the same six tabs, from `_tabs.html.twig`: **Details**, **Description** (description items), **Objectives**, **Allocations** (planned budget, currency and allocation items), **Targets** and **Tasks**.
|
||||||
- `Resources/views/Plan/_task_table.html.twig`: the plan's tasks in the Tasks tab. It has the harmonized tab columns (pictogram, Type, Name, Description, Start date, End date, Status — no ID), in tree order: each task is followed by its sub-tasks, indented, and a task's name shows its number of sub-tasks. On the detail page it has an **Add task** button, links to each task and the filter/sort of the other tabs. On the plan form it is read-only (no links, no filter), so that following a link doesn't drop unsaved changes.
|
- `Resources/views/Plan/_task_table.html.twig`: the plan's tasks in the Tasks tab. It has the harmonized tab columns (pictogram, Type, Name with kind badge for milestones and phases, Description, Start date, End date, Status — no ID), one row per task, no tree: a phase's or milestone's badge marks it in the name column. On the detail page it has an **Add task** button, links to each task and the filter/sort of the other tabs. On the plan form it is read-only (no links, no filter), so that following a link doesn't drop unsaved changes.
|
||||||
- `Controller/TaskController.php` and `Resources/views/Task/`: the task list, and the create/edit form (**Planning > Tasks**). `new?plan=ID` preselects the plan. After Save or Cancel, the user goes back to where the form was opened from. Opened from **Planning > Tasks**, that's the task list. Opened from a plan's Tasks tab, whose links carry `returnTo=plan`, that's the plan (its new plan, if the task was moved). The origin is stored in the session when the form is opened, because the form posts without the query string.
|
- `Controller/TaskController.php` and `Resources/views/Task/`: the task list, and the create/edit form (**Planning > Tasks**). `new?plan=ID` preselects the plan. After Save or Cancel, the user goes back to where the form was opened from. Opened from **Planning > Tasks**, that's the task list. Opened from a plan's Tasks tab, whose links carry `returnTo=plan`, that's the plan (its new plan, if the task was moved). The origin is stored in the session when the form is opened, because the form posts without the query string.
|
||||||
- `Assets/js/plan.js`: on the form, the objectives editor (add, remove, drag-and-drop ordering), and after a failed save, marking the tabs that contain errors with an icon and opening the first one. Started by `Mautic.planOnLoad()`.
|
- `Assets/js/plan.js`: on the form, the objectives editor (add, remove, drag-and-drop ordering), and after a failed save, marking the tabs that contain errors with an icon and opening the first one. Started by `Mautic.planOnLoad()`.
|
||||||
|
|
||||||
@@ -155,11 +155,11 @@ Behaviour to know about:
|
|||||||
|
|
||||||
### The Task object
|
### The Task object
|
||||||
|
|
||||||
- `Entity/Task.php` and `TaskRepository.php`: a task (table `plan_tasks`): type (with its pictogram), name, description, plan, optional parent task, optional start and end dates, and status
|
- `Entity/Task.php` and `TaskRepository.php`: a task (table `plan_tasks`): type (with its pictogram), name, description, plan, kind (task, milestone or phase), optional start and end dates (plain dates, no time), definition of done, planned work in whole hours, status (not for phases), dependencies (table `plan_task_dependencies`) and RACI assignments (table `plan_task_raci` with its `plan_task_raci_stakeholders` join table)
|
||||||
- `Entity/TaskStatus.php`: the status enum. The order of its cases is the order of the dropdown: `new` (New, the default), `todo` (To do), `in_progress` (In progress), `done` (Done). Stored as `VARCHAR(20)`, indexed.
|
- `Entity/TaskStatus.php`: the status enum. The order of its cases is the order of the dropdown: `new` (New, the default), `todo` (To do), `in_progress` (In progress), `done` (Done). Stored as `VARCHAR(20)`, indexed.
|
||||||
- `Model/TaskModel.php`: the model, available as `mautic.plan.model.task` or with `getModel('plan.task')`. `getTaskTree($plan)` returns a plan's tasks in tree order, with their depth.
|
- `Model/TaskModel.php`: the model, available as `mautic.plan.model.task` or with `getModel('plan.task')`. `getTaskTree($plan)` returns a plan's tasks as flat rows for the Tasks tab, ordered by name, with their dependencies and RACI rows fully loaded.
|
||||||
- `Form/Type/TaskType.php`: the create and edit form
|
- `Form/Type/TaskType.php`: the create and edit form
|
||||||
- `Validator/Constraints/ValidTaskParent.php`: the parent task must be in the same plan, and must not be the task itself or one of its sub-tasks
|
- `Validator/Constraints/ValidTaskDependency.php`: a dependency must point at another task of the same plan, and the dependency graph must not form a cycle (followed through the database, so a cycle crossing other tasks is caught too)
|
||||||
|
|
||||||
Behaviour to know about:
|
Behaviour to know about:
|
||||||
|
|
||||||
@@ -168,8 +168,10 @@ Behaviour to know about:
|
|||||||
- The task list (**Planning > Tasks**) shows these columns, in this order: ID, Pictogram, Type, Name, Description (first 120 characters), Start date, End date, Status. Every column except Pictogram and Description can be sorted.
|
- The task list (**Planning > Tasks**) shows these columns, in this order: ID, Pictogram, Type, Name, Description (first 120 characters), Start date, End date, Status. Every column except Pictogram and Description can be sorted.
|
||||||
- A task's type is required. It's the key of a task type set up in **Settings > Configuration > Plan Settings** (parameter `plan_task_types`); on the task form the type's pictogram appears next to the dropdown and its description under it. The plan's Tasks tab shows the same Pictogram and Type columns as the task list, without the ID column.
|
- A task's type is required. It's the key of a task type set up in **Settings > Configuration > Plan Settings** (parameter `plan_task_types`); on the task form the type's pictogram appears next to the dropdown and its description under it. The plan's Tasks tab shows the same Pictogram and Type columns as the task list, without the ID column.
|
||||||
- Deleting a plan deletes its tasks (`plan_id` `ON DELETE CASCADE`).
|
- Deleting a plan deletes its tasks (`plan_id` `ON DELETE CASCADE`).
|
||||||
- Deleting a task keeps its sub-tasks, which become top-level tasks (`parent_id` `ON DELETE SET NULL`).
|
- Deleting a task removes its dependency edges and RACI rows too (`ON DELETE CASCADE`).
|
||||||
- Tasks are edited on their own pages, not inside the plan form: a task can only be picked as a parent once it exists.
|
- Tasks are edited on their own pages, not inside the plan form: a task can only be picked as a dependency once it exists.
|
||||||
|
- Kinds: a **milestone**'s end date is enslaved to its start date (same day — the entity's `setTaskKind` copies it, the `TaskDates` validator keeps it in step, the form shows it disabled); a **phase** has no status of its own, it comes from its tasks (the form shows no status field).
|
||||||
|
- RACI: one row per role (Responsible, Accountable, Consulted, Informed), each with several stakeholders picked from the plan's stakeholders.
|
||||||
|
|
||||||
After you change `Assets/js/plan.js`, run `php bin/console mautic:assets:generate` (in the dev environment, `./dev.sh console mautic:assets:generate`), because production mode bundles plugin scripts into `app.js`.
|
After you change `Assets/js/plan.js`, run `php bin/console mautic:assets:generate` (in the dev environment, `./dev.sh console mautic:assets:generate`), because production mode bundles plugin scripts into `app.js`.
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user