- 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.
80 lines
2.1 KiB
PHP
80 lines
2.1 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace MauticPlugin\PlanBundle\Model;
|
|
|
|
use Mautic\CoreBundle\Model\FormModel;
|
|
use MauticPlugin\PlanBundle\Entity\Plan;
|
|
use MauticPlugin\PlanBundle\Entity\Task;
|
|
use MauticPlugin\PlanBundle\Entity\TaskRepository;
|
|
use MauticPlugin\PlanBundle\Form\Type\TaskType;
|
|
use Symfony\Component\Form\FormFactoryInterface;
|
|
use Symfony\Component\Form\FormInterface;
|
|
use Symfony\Component\HttpKernel\Exception\MethodNotAllowedHttpException;
|
|
|
|
/**
|
|
* Available as mautic.plan.model.task, or getModel('plan.task').
|
|
*
|
|
* @extends FormModel<Task>
|
|
*/
|
|
class TaskModel extends FormModel
|
|
{
|
|
public function getRepository(): TaskRepository
|
|
{
|
|
$repository = $this->em->getRepository(Task::class);
|
|
\assert($repository instanceof TaskRepository);
|
|
|
|
return $repository;
|
|
}
|
|
|
|
public function getPermissionBase(): string
|
|
{
|
|
return 'plan:tasks';
|
|
}
|
|
|
|
public function getEntity($id = null): ?Task
|
|
{
|
|
if (null === $id) {
|
|
return new Task();
|
|
}
|
|
|
|
$task = parent::getEntity($id);
|
|
|
|
return $task instanceof Task ? $task : null;
|
|
}
|
|
|
|
/**
|
|
* 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}>
|
|
*/
|
|
public function getTaskTree(Plan $plan): array
|
|
{
|
|
$rows = [];
|
|
foreach ($this->getRepository()->findByPlan($plan) as $task) {
|
|
$rows[] = ['task' => $task, 'depth' => 0];
|
|
}
|
|
|
|
return $rows;
|
|
}
|
|
|
|
/**
|
|
* @param array<string, mixed> $options
|
|
*/
|
|
public function createForm($entity, FormFactoryInterface $formFactory, $action = null, $options = []): FormInterface
|
|
{
|
|
if (!$entity instanceof Task) {
|
|
throw new MethodNotAllowedHttpException(['Task']);
|
|
}
|
|
|
|
if (!empty($action)) {
|
|
$options['action'] = $action;
|
|
}
|
|
|
|
return $formFactory->create(TaskType::class, $entity, $options);
|
|
}
|
|
}
|