feat: Add TargetType form and migration for plan targets

- Implemented TargetType form for managing target details including name, type, priority, stages, estimated size, profile criteria, pain points, value proposition, and preferred channels.
- Created migration scripts for adding type and priority columns to plan objectives and tasks.
- Added migration for creating plan targets and plan target stages tables, including foreign key constraints.
- Introduced stakeholder management with forms and views for creating, editing, and listing stakeholders.
- Enhanced UI with read more functionality for long text descriptions and filtering options in plan tab tables.
This commit is contained in:
Alexandre Gain committed 2026-11-08 11:54:25 +01:00
1 parent 8c8d7a6f95
commit 8696acd01c
52 files changed
+3178 -125

No files matched your search

+185 -1
View File
@@ -4,9 +4,29 @@
* - Plan form: editable, sortable rows (objectives, description items, allocation items), the selected
* item type's description, and tab error markers. Started by Mautic.planOnLoad(), which Mautic calls after
* it loads any page whose mauticContent is "plan", including pages loaded through Ajax.
* - Task form (mauticContent "planTask", started by Mautic.planTaskOnLoad()): the selected type's
* description and pictogram, next to the type dropdown.
* - Settings > Configuration > Plan: adding and removing item types (delegated handlers,
* because that page isn't a "plan" page).
*/
Mautic.planTaskOnLoad = function (container) {
// The task form isn't a plan-collection; the type dropdown works the same way as in the plan form.
mQuery(container).find('select.plan-item-type').each(function () {
var $select = mQuery(this);
if ($select.data('planTaskInitialized')) {
return;
}
$select.data('planTaskInitialized', true);
$select.on('change', function () {
var $option = $select.find('option:selected');
var $scope = $select.closest('form');
$scope.find('.plan-item-type-help').first().text($option.attr('data-description') || '');
$scope.find('.plan-item-type-icon').first().attr('class', 'plan-item-type-icon ' + ($option.attr('data-icon') || ''));
});
});
};
Mautic.planOnLoad = function (container) {
mQuery(container).find('.plan-collection').each(function () {
Mautic.planInitCollection(mQuery(this));
@@ -14,6 +34,170 @@ Mautic.planOnLoad = function (container) {
mQuery(container).find('.plan-tabs').each(function () {
Mautic.planInitTabs(mQuery(this), mQuery(container));
});
// Detail page: the four tab tables (description items, objectives, allocation items, tasks).
mQuery(container).find('table[data-plan-tab-table]').each(function () {
Mautic.planInitTabTable(mQuery(this));
});
// Detail page: long description item texts, clamped to 10 lines with a read-more toggle.
mQuery(container).find('.plan-read-more').each(function () {
Mautic.planInitReadMore(mQuery(this));
});
};
/**
* A text clamped to a few lines with a "Read more" / "Show less" toggle. The clamping is done by CSS
* (line-clamp, see the include template); a toggle appears only when the text really overflows, because
* a button under a short text would only state the obvious.
*
* The overflow is measured when the tab pane is visible: a tab pane that is hidden on page load
* (Mautic reopens the tab last used) has no layout, so its scrollHeight is 0. The wrapper is rechecked
* on every tab activation until the measurement could run.
*/
Mautic.planInitReadMore = function ($wrapper) {
if ($wrapper.data('planReadMoreInitialized')) {
return;
}
$wrapper.data('planReadMoreInitialized', true);
var $text = $wrapper.find('.plan-read-more-text').first();
var $toggle = $wrapper.find('.plan-read-more-toggle').first();
var clampLines = 10;
var measure = function () {
if (!$text[0] || !$wrapper.is(':visible')) {
return false; // Still hidden: try again on the next tab activation.
}
var lineHeight = parseFloat($text.css('line-height')) || 20;
var clampHeight = clampLines * lineHeight;
if ($text[0].scrollHeight > clampHeight + 2) {
$toggle.show();
}
return true;
};
$toggle.on('click', function () {
var open = 'false' === $toggle.attr('aria-expanded');
$toggle.attr('aria-expanded', open ? 'true' : 'false');
$text.css('-webkit-line-clamp', open ? 'none' : clampLines);
// The texts come from the button's data attributes (rendered translated by Twig): the JS
// translation catalog only holds core strings, not the plugin's.
$toggle.html(
(open ? $toggle.attr('data-less-text') : $toggle.attr('data-more-text')) +
' <i class="ri-arrow-' + (open ? 'up' : 'down') + '-s-line"></i>'
);
});
if (!measure()) {
// The pane holding this text is hidden: recheck each time a tab of this page is shown.
mQuery(document).on('shown.bs.tab.plan-read-more', function () {
if (measure()) {
mQuery(document).off('shown.bs.tab.plan-read-more');
}
});
}
};
/**
* A plan detail page tab table: one filter box filtering every column (case-insensitive substring),
* and every column header sorting the rows asc/desc on click. Filtering and sorting are done on the
* client, instantly: these tables hold one plan's items, never many.
*
* Rows keep their order attribute, so the drag handles and the tree indentation of tasks stay right.
* Sorting the tree by another column can interleave a sub-task before its parent; the depth marker
* stays attached to its own row, so it just indents wherever it lands.
*/
Mautic.planInitTabTable = function ($table) {
if ($table.data('planTabTableInitialized')) {
return;
}
$table.data('planTabTableInitialized', true);
var $panes = $table.closest('.tab-pane');
var $filterBox = $panes.find('.plan-tab-table-filter').first();
var $input = $filterBox.find('.plan-tab-table-filter-input');
var $noMatch = $panes.find('.plan-tab-table-nomatch').first();
var $rows = $table.find('tbody tr');
var apply = function () {
var needle = mQuery.trim($input.val() || '').toLowerCase();
var visible = 0;
$rows.each(function () {
var text = mQuery(this).text().toLowerCase().replace(/\s+/g, ' ');
var show = '' === needle || -1 !== text.indexOf(needle);
mQuery(this).toggleClass('hide', !show);
if (show) {
visible++;
}
});
$noMatch.toggleClass('hide', visible > 0);
};
$input.on('input', apply);
$input.on('change', apply);
// Click-to-sort: first click ascending, then toggling. The footer row (allocation total) stays put.
$table.find('thead th').each(function (index) {
var $th = mQuery(this);
$th.css('cursor', 'pointer').attr('title', $table.attr('data-sort-hint') || '');
$th.on('click', function () {
var direction = $th.hasClass('plan-sorted-asc') ? -1 : 1;
var cells = [];
$rows.each(function () {
cells.push({
text: mQuery(this).find('td').eq(index).text().replace(/\s+/g, ' ').trim(),
$row: mQuery(this)
});
});
cells.sort(function (a, b) {
var va = a.text.toLowerCase();
var vb = b.text.toLowerCase();
var result;
// Amounts like "18,500.00 EUR" and numbers sort numerically when both hold one.
var na = Mautic.planParseNumber(va);
var nb = Mautic.planParseNumber(vb);
if (null !== na && null !== nb) {
result = na - nb;
} else {
result = va < vb ? -1 : (va > vb ? 1 : 0);
}
return result * direction;
});
mQuery.each(cells, function () {
this.$row.appendTo($table.find('tbody'));
});
$table.find('thead th').removeClass('plan-sorted-asc plan-sorted-desc');
$th.addClass(direction > 0 ? 'plan-sorted-asc' : 'plan-sorted-desc');
$rows = $table.find('tbody tr');
});
});
};
/**
* A cell "18,500.00 EUR" or "12" as a number for the tab table sort, or null when it holds no number
* (text, dates as words). The last number in the cell wins, so a name like "Q1 2027" sorts by 2027.
*/
Mautic.planParseNumber = function (text) {
var match = String(text).match(/-?\d[\d,\s]*\.?\d*/g);
if (!match) {
return null;
}
var value = parseFloat(match[match.length - 1].replace(/[\s,]/g, ''));
return isNaN(value) ? null : value;
};
/**
@@ -160,7 +344,7 @@ Mautic.planInitCollection = function ($editor) {
});
// Typed items (description, allocation): show the selected type's description under the dropdown, and
// its pictogram next to it.
// its pictogram next to it. Works within a plan-collection row.
$editor.on('change', 'select.plan-item-type', function () {
var $option = mQuery(this).find('option:selected');
var $row = mQuery(this).closest('.plan-collection-row');
+25 -3
View File
@@ -5,7 +5,7 @@ declare(strict_types=1);
return [
'name' => 'Plan',
'description' => 'Plan plugin for Mautic.',
'version' => '0.8.0',
'version' => '0.12.0',
'author' => 'Experiential',
'routes' => [
@@ -28,6 +28,15 @@ return [
'path' => '/plan-tasks/{objectAction}/{objectId}',
'controller' => 'MauticPlugin\PlanBundle\Controller\TaskController::executeAction',
],
'plan_stakeholder_index' => [
'path' => '/plan-stakeholders/{page}',
'controller' => 'MauticPlugin\PlanBundle\Controller\StakeholderController::indexAction',
],
// objectAction: new, edit, delete, batchDelete.
'plan_stakeholder_action' => [
'path' => '/plan-stakeholders/{objectAction}/{objectId}',
'controller' => 'MauticPlugin\PlanBundle\Controller\StakeholderController::executeAction',
],
],
],
@@ -37,7 +46,7 @@ return [
'mautic.plan.menu.root' => [
'id' => 'plan_root',
'iconClass' => 'ri-calendar-line',
'access' => ['plan:plans:viewown', 'plan:plans:viewother', 'plan:tasks:viewown', 'plan:tasks:viewother'],
'access' => ['plan:plans:viewown', 'plan:plans:viewother', 'plan:tasks:viewown', 'plan:tasks:viewother', 'plan:stakeholders:viewown', 'plan:stakeholders:viewother'],
'priority' => 5,
'children' => [
'mautic.plan.menu.index' => [
@@ -52,6 +61,12 @@ return [
'access' => ['plan:tasks:viewown', 'plan:tasks:viewother'],
'priority' => 90,
],
'mautic.plan.stakeholder.menu.index' => [
'id' => 'plan_stakeholder_index',
'route' => 'plan_stakeholder_index',
'access' => ['plan:stakeholders:viewown', 'plan:stakeholders:viewother'],
'priority' => 80,
],
],
],
],
@@ -90,8 +105,15 @@ return [
// Item types, edited in Settings > Configuration > Plan Settings. Read them through ItemTypeProvider.
// Each is a list of ['key' => …, 'names' => [locale => …], 'descriptions' => [locale => …]],
// plus 'icon' => a Remix Icon class for description and allocation item types.
// plus 'icon' => a Remix Icon class for description, allocation, objective, task and stakeholder types.
'plan_description_item_types' => [],
'plan_allocation_item_types' => [],
'plan_objective_types' => [],
'plan_task_types' => [],
'plan_stakeholder_types' => [],
// Default region (ISO 3166-1 alpha-2, e.g. FR) used to parse stakeholder phone numbers typed
// without a country prefix, on save. Read through StakeholderModel.
'plan_stakeholder_phone_region' => 'FR',
],
];
+2
View File
@@ -27,4 +27,6 @@ return function (ContainerConfigurator $configurator): void {
$services->alias('mautic.plan.model.plan', MauticPlugin\PlanBundle\Model\PlanModel::class);
// getModel('plan.task').
$services->alias('mautic.plan.model.task', MauticPlugin\PlanBundle\Model\TaskModel::class);
// getModel('plan.stakeholder').
$services->alias('mautic.plan.model.stakeholder', MauticPlugin\PlanBundle\Model\StakeholderModel::class);
};
+1 -1
View File
@@ -53,7 +53,7 @@ class PlanController extends AbstractStandardFormController
}
/**
* The plan detail page (tabs: Details, Description, Objectives, Allocation, Targets, Tasks).
* The plan detail page (tabs: Details, Description, Objectives, Allocations, Targets, Tasks).
*
* Core's viewStandard() isn't used: for users who aren't administrators it checks an
* "<entity>:export:enable" permission, which plans don't have.
+83
View File
@@ -0,0 +1,83 @@
<?php
declare(strict_types=1);
namespace MauticPlugin\PlanBundle\Controller;
use Mautic\CoreBundle\Controller\AbstractStandardFormController;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
/**
* List, create, edit and delete stakeholders (Planning > Stakeholders), the global directory, using
* core's standard CRUD flow. Stakeholders are independent of plans; plans link to them from their
* Stakeholders tab.
*
* Model plan.stakeholder (mautic.plan.model.stakeholder), permission base plan:stakeholders,
* translation base mautic.plan.stakeholder.
*/
class StakeholderController extends AbstractStandardFormController
{
public const ROUTE_INDEX = 'plan_stakeholder_index';
public const ROUTE_ACTION = 'plan_stakeholder_action';
protected function getModelName(): string
{
return 'plan.stakeholder';
}
protected function getTemplateBase(): string
{
return '@Plan/Stakeholder';
}
protected function getIndexRoute(): string
{
return self::ROUTE_INDEX;
}
protected function getActionRoute(): string
{
return self::ROUTE_ACTION;
}
protected function getJsLoadMethodPrefix(): string
{
return 'planStakeholder';
}
/**
* @param int $page
*/
public function indexAction(Request $request, $page = 1): Response
{
return $this->indexStandard($request, $page);
}
public function newAction(Request $request): Response
{
return $this->newStandard($request);
}
/**
* @param int $objectId
* @param bool $ignorePost
*/
public function editAction(Request $request, $objectId, $ignorePost = false): Response
{
return $this->editStandard($request, $objectId, $ignorePost);
}
/**
* @param int $objectId
*/
public function deleteAction(Request $request, $objectId): Response
{
return $this->deleteStandard($request, $objectId);
}
public function batchDeleteAction(Request $request): Response
{
return $this->batchDeleteStandard($request);
}
}
+10 -3
View File
@@ -5,12 +5,15 @@ declare(strict_types=1);
namespace MauticPlugin\PlanBundle\Entity;
/**
* For repositories of typed plan items (description items, allocation items).
* For repositories of typed plan items (description items, allocation items, objectives, tasks).
*/
trait CountsItemsByTypeTrait
{
/**
* Number of items per type key, for the types that are in use.
* Number of items per type key, for the types that are in use. Rows without a type (legacy
* rows created before their kind got types) are skipped: they don't reference any configured
* type, so they must not block any save of the configuration; validation asks for a type on
* the next save of each of those items.
*
* @return array<string, int>
*/
@@ -25,7 +28,11 @@ trait CountsItemsByTypeTrait
$counts = [];
foreach ($rows as $row) {
$counts[(string) $row['type']] = (int) $row['total'];
$key = $row['type'];
if (null === $key || '' === trim((string) $key)) {
continue;
}
$counts[(string) $key] = (int) $row['total'];
}
return $counts;
+130 -7
View File
@@ -47,13 +47,29 @@ class Plan extends FormEntity implements DateRangeInterface
private Collection $descriptionItems;
/**
* The cost lines of the Allocation tab. Each item has a type set up by the admin in
* The cost lines of the Allocations tab. Each item has a type set up by the admin in
* Settings > Configuration > Plan.
*
* @var Collection<int, PlanAllocationItem>
*/
private Collection $allocationItems;
/**
* The audiences of the Targets tab. Each target has a fixed type (persona, ICP, …), not an
* admin-configured one.
*
* @var Collection<int, Target>
*/
private Collection $targets;
/**
* The links to the stakeholders of the global directory (Planning > Stakeholders), each with the
* stakeholder's role in this plan. See PlanStakeholder.
*
* @var Collection<int, PlanStakeholder>
*/
private Collection $stakeholders;
/**
* Tasks are managed on their own pages (TaskController). Read-only from the plan: deleting a plan
* deletes its tasks through the database (ON DELETE CASCADE).
@@ -90,6 +106,8 @@ class Plan extends FormEntity implements DateRangeInterface
$this->objectives = new ArrayCollection();
$this->descriptionItems = new ArrayCollection();
$this->allocationItems = new ArrayCollection();
$this->targets = new ArrayCollection();
$this->stakeholders = new ArrayCollection();
$this->tasks = new ArrayCollection();
}
@@ -118,6 +136,20 @@ class Plan extends FormEntity implements DateRangeInterface
$this->addAllocationItem(clone $allocationItem);
}
// A clone gets its own copies of the targets. The stages are shared (ManyToMany), not cloned.
$targets = $this->targets;
$this->targets = new ArrayCollection();
foreach ($targets as $target) {
$this->addTarget(clone $target);
}
// A clone keeps the same stakeholders (directory entries), with fresh links.
$stakeholders = $this->stakeholders;
$this->stakeholders = new ArrayCollection();
foreach ($stakeholders as $stakeholder) {
$this->addStakeholder(clone $stakeholder);
}
parent::__clone();
}
@@ -190,6 +222,24 @@ class Plan extends FormEntity implements DateRangeInterface
->fetchExtraLazy()
->build();
$builder->createOneToMany('targets', Target::class)
->mappedBy('plan')
->cascadePersist()
->cascadeRemove()
->orphanRemoval()
->setOrderBy(['position' => 'ASC'])
->fetchExtraLazy()
->build();
$builder->createOneToMany('stakeholders', PlanStakeholder::class)
->mappedBy('plan')
->cascadePersist()
->cascadeRemove()
->orphanRemoval()
->setOrderBy(['position' => 'ASC'])
->fetchExtraLazy()
->build();
$builder->createOneToMany('tasks', Task::class)
->mappedBy('plan')
->setOrderBy(['name' => 'ASC'])
@@ -208,6 +258,8 @@ class Plan extends FormEntity implements DateRangeInterface
$metadata->addPropertyConstraint('objectives', new Valid());
$metadata->addPropertyConstraint('descriptionItems', new Valid());
$metadata->addPropertyConstraint('allocationItems', new Valid());
$metadata->addPropertyConstraint('targets', new Valid());
$metadata->addPropertyConstraint('stakeholders', new Valid());
$metadata->addPropertyConstraint('name', new NotBlank(message: 'mautic.core.name.required'));
$metadata->addPropertyConstraint('owner', new NotBlank(message: 'mautic.plan.owner.required'));
$metadata->addConstraint(new EndDateAfterStartDate());
@@ -235,7 +287,8 @@ class Plan extends FormEntity implements DateRangeInterface
}
/**
* The objectives sorted by position, as a new collection (Doctrine itself reads the property).
* The objectives sorted by priority (1 first), then by position for ties, as a new collection
* (Doctrine itself reads the property).
*
* Sorted here, not only by the mapping's orderBy: after a reorder, positions change in memory while the
* loaded collection keeps its old order, and the page shown right after saving uses that collection.
@@ -244,7 +297,16 @@ class Plan extends FormEntity implements DateRangeInterface
*/
public function getObjectives(): Collection
{
return self::sortedByPosition($this->objectives);
$objectives = self::sortedByPosition($this->objectives)->toArray();
usort($objectives, function (PlanObjective $a, PlanObjective $b): int {
// An objective without a priority yet sorts last; ties keep the position order.
$pa = $a->getPriority() ?? PHP_INT_MAX;
$pb = $b->getPriority() ?? PHP_INT_MAX;
return $pa === $pb ? 0 : ($pa < $pb ? -1 : 1);
});
return new ArrayCollection($objectives);
}
/**
@@ -255,6 +317,67 @@ class Plan extends FormEntity implements DateRangeInterface
return $this->tasks;
}
/**
* The targets sorted by position, as a new collection; see getObjectives().
*
* @return Collection<int, Target>
*/
public function getTargets(): Collection
{
return self::sortedByPosition($this->targets);
}
public function addTarget(Target $target): static
{
if (!$this->targets->contains($target)) {
$target->setPlan($this);
$this->targets->add($target);
}
return $this;
}
/**
* Removing a target from the plan deletes it (orphanRemoval).
*/
public function removeTarget(Target $target): static
{
$this->targets->removeElement($target);
return $this;
}
/**
* The stakeholder links sorted by position, as a new collection; see getObjectives().
*
* @return Collection<int, PlanStakeholder>
*/
public function getStakeholders(): Collection
{
return self::sortedByPosition($this->stakeholders);
}
public function addStakeholder(PlanStakeholder $stakeholder): static
{
if (!$this->stakeholders->contains($stakeholder)) {
$stakeholder->setPlan($this);
$this->stakeholders->add($stakeholder);
}
return $this;
}
/**
* Removing a stakeholder link from the plan deletes it (orphanRemoval). The stakeholder itself
* stays in the global directory.
*/
public function removeStakeholder(PlanStakeholder $stakeholder): static
{
$this->stakeholders->removeElement($stakeholder);
return $this;
}
public function addObjective(PlanObjective $objective): static
{
if (!$this->objectives->contains($objective)) {
@@ -342,7 +465,7 @@ class Plan extends FormEntity implements DateRangeInterface
}
/**
* @template T of PlanObjective|PlanDescriptionItem|PlanAllocationItem
* @template T of PlanObjective|PlanDescriptionItem|PlanAllocationItem|Target|PlanStakeholder
*
* @param Collection<int, T> $collection
*
@@ -377,12 +500,12 @@ class Plan extends FormEntity implements DateRangeInterface
}
/**
* Renumbers objective, description item and allocation item positions 0..n-1 following their current positions,
* so that the order stays contiguous after rows are added, removed or moved.
* Renumbers objective, description item, allocation item and target positions 0..n-1 following their
* current positions, so that the order stays contiguous after rows are added, removed or moved.
*/
public function normalizePositions(): void
{
foreach ([$this->objectives, $this->descriptionItems, $this->allocationItems] as $collection) {
foreach ([$this->objectives, $this->descriptionItems, $this->allocationItems, $this->targets, $this->stakeholders] as $collection) {
$rows = $collection->toArray();
usort($rows, fn ($a, $b): int => $a->getPosition() <=> $b->getPosition());
+3 -3
View File
@@ -12,9 +12,9 @@ use Symfony\Component\Validator\Constraints\NotBlank;
use Symfony\Component\Validator\Mapping\ClassMetadata;
/**
* One item of a plan's Allocation tab: a typed cost line with a planned and a real cost, both in the
* general currency (CurrencyProvider). Plan::$allocationItems owns the lifecycle: items are saved and
* deleted with their plan, and are ordered by position.
* One item of a plan's Allocations tab: a typed cost line with a planned and a real cost, both in
* the general currency (CurrencyProvider). Plan::$allocationItems owns the lifecycle: items are saved
* and deleted with their plan, and are ordered by position.
*
* The type is the key of an allocation item type set up in Settings > Configuration > Plan Settings
* (parameter plan_allocation_item_types); see ItemTypeProvider.
+59
View File
@@ -9,6 +9,8 @@ use Doctrine\ORM\Mapping\ClassMetadata as OrmClassMetadata;
use Mautic\CoreBundle\Doctrine\Mapping\ClassMetadataBuilder;
use Symfony\Component\Validator\Constraints\Length;
use Symfony\Component\Validator\Constraints\NotBlank;
use Symfony\Component\Validator\Constraints\NotNull;
use Symfony\Component\Validator\Constraints\Range;
use Symfony\Component\Validator\Mapping\ClassMetadata;
/**
@@ -19,10 +21,17 @@ class PlanObjective
{
public const TABLE_NAME = 'plan_objectives';
public const TYPE_MAX_LENGTH = 64;
public const PRIORITY_MIN = 1;
public const PRIORITY_MAX = 99;
private ?int $id = null;
private ?Plan $plan = null;
private ?string $type = null;
private ?string $title = null;
private ?string $description = null;
@@ -32,6 +41,11 @@ class PlanObjective
*/
private int $position = 0;
/**
* Importance of the objective, from 1 (highest) to 99 (lowest). Edited by hand.
*/
private ?int $priority = null;
/**
* Toggled by hand for now.
*/
@@ -57,6 +71,11 @@ class PlanObjective
->addJoinColumn('plan_id', 'id', false, false, 'CASCADE')
->build();
$builder->createField('type', Types::STRING)
->length(self::TYPE_MAX_LENGTH)
->nullable()
->build();
$builder->createField('title', Types::STRING)
->length(255)
->build();
@@ -73,12 +92,24 @@ class PlanObjective
->columnName('is_achieved')
->option('default', false)
->build();
$builder->createField('priority', Types::INTEGER)
->option('default', self::PRIORITY_MIN)
->build();
}
public static function loadValidatorMetadata(ClassMetadata $metadata): void
{
$metadata->addPropertyConstraint('title', new NotBlank(message: 'mautic.plan.objective.title.required'));
$metadata->addPropertyConstraint('title', new Length(max: 255));
$metadata->addPropertyConstraint('type', new NotBlank(message: 'mautic.plan.objective.type.required'));
$metadata->addPropertyConstraint('type', new Length(max: self::TYPE_MAX_LENGTH));
$metadata->addPropertyConstraint('priority', new NotNull(message: 'mautic.plan.objective.priority.range'));
$metadata->addPropertyConstraint('priority', new Range(
notInRangeMessage: 'mautic.plan.objective.priority.range',
min: self::PRIORITY_MIN,
max: self::PRIORITY_MAX,
));
}
public function getId(): ?int
@@ -98,6 +129,18 @@ class PlanObjective
return $this;
}
public function getType(): ?string
{
return $this->type;
}
public function setType(?string $type): static
{
$this->type = $type;
return $this;
}
public function getTitle(): ?string
{
return $this->title;
@@ -134,6 +177,22 @@ class PlanObjective
return $this;
}
public function getPriority(): ?int
{
return $this->priority;
}
/**
* An objective without a priority yet (column added by Version_0_10_1) becomes
* self::PRIORITY_MIN once set. Null is refused by validation.
*/
public function setPriority(?int $priority): static
{
$this->priority = $priority;
return $this;
}
public function isAchieved(): bool
{
return $this->isAchieved;
+2
View File
@@ -11,6 +11,8 @@ use Mautic\CoreBundle\Entity\CommonRepository;
*/
class PlanObjectiveRepository extends CommonRepository
{
use CountsItemsByTypeTrait;
public function getTableAlias(): string
{
return 'po';
+134
View File
@@ -0,0 +1,134 @@
<?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;
use Symfony\Component\Validator\Constraints\Length;
use Symfony\Component\Validator\Mapping\ClassMetadata;
/**
* The link between a plan and a stakeholder of the global directory, with the stakeholder's role in
* that plan ("Approves budget", "Media buyer"): free text, because the same person can have a
* different role on each plan.
*
* Plan::$stakeholders owns the lifecycle: links are saved and deleted with their plan. Deleting a
* stakeholder deletes its links (ON DELETE CASCADE on both sides).
*/
class PlanStakeholder
{
public const TABLE_NAME = 'plan_stakeholders_plan';
private ?int $id = null;
private ?Plan $plan = null;
private ?Stakeholder $stakeholder = null;
/**
* The stakeholder's role in this plan, free text.
*/
private ?string $roleInPlan = null;
/**
* Display order within the plan, from 0. Set by drag and drop in the form.
*/
private int $position = 0;
public function __clone()
{
$this->id = null;
$this->plan = null;
}
public static function loadMetadata(OrmClassMetadata $metadata): void
{
$builder = new ClassMetadataBuilder($metadata);
$builder->setTable(self::TABLE_NAME)
->setCustomRepositoryClass(PlanStakeholderRepository::class);
$builder->addId();
$builder->createManyToOne('plan', Plan::class)
->inversedBy('stakeholders')
->addJoinColumn('plan_id', 'id', false, false, 'CASCADE')
->build();
$builder->createManyToOne('stakeholder', Stakeholder::class)
->addJoinColumn('stakeholder_id', 'id', false, false, 'CASCADE')
->build();
$builder->createField('roleInPlan', Types::STRING)
->columnName('role_in_plan')
->length(191)
->nullable()
->build();
$builder->createField('position', Types::INTEGER)
->option('default', 0)
->build();
}
public static function loadValidatorMetadata(ClassMetadata $metadata): void
{
$metadata->addPropertyConstraint('stakeholder', new \Symfony\Component\Validator\Constraints\NotBlank(message: 'mautic.plan.stakeholder_link.stakeholder.required'));
$metadata->addPropertyConstraint('roleInPlan', new Length(max: 191));
}
public function getId(): ?int
{
return $this->id;
}
public function getPlan(): ?Plan
{
return $this->plan;
}
public function setPlan(?Plan $plan): static
{
$this->plan = $plan;
return $this;
}
public function getStakeholder(): ?Stakeholder
{
return $this->stakeholder;
}
public function setStakeholder(?Stakeholder $stakeholder): static
{
$this->stakeholder = $stakeholder;
return $this;
}
public function getRoleInPlan(): ?string
{
return $this->roleInPlan;
}
public function setRoleInPlan(?string $roleInPlan): static
{
$this->roleInPlan = $roleInPlan;
return $this;
}
public function getPosition(): int
{
return $this->position;
}
public function setPosition(?int $position): static
{
$this->position = $position ?? 0;
return $this;
}
}
+18
View File
@@ -0,0 +1,18 @@
<?php
declare(strict_types=1);
namespace MauticPlugin\PlanBundle\Entity;
use Mautic\CoreBundle\Entity\CommonRepository;
/**
* @extends CommonRepository<PlanStakeholder>
*/
class PlanStakeholderRepository extends CommonRepository
{
public function getTableAlias(): string
{
return 'psh';
}
}
+197
View File
@@ -0,0 +1,197 @@
<?php
declare(strict_types=1);
namespace MauticPlugin\PlanBundle\Entity;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping\ClassMetadata as OrmClassMetadata;
use Mautic\CoreBundle\Doctrine\Mapping\ClassMetadataBuilder;
use Mautic\CoreBundle\Entity\FormEntity;
use Symfony\Component\Validator\Constraints\Email;
use Symfony\Component\Validator\Constraints\Length;
use Symfony\Component\Validator\Constraints\NotBlank;
use Symfony\Component\Validator\Mapping\ClassMetadata;
/**
* A stakeholder of the planning: a person, a company or a team involved in the plans ("Agency XYZ",
* "Exec committee"). Stakeholders are a global directory (Planning > Stakeholders), independent of
* plans; a plan links to them through PlanStakeholder, which carries the stakeholder's role in that
* plan.
*
* The type is the key of a stakeholder type set up in Settings > Configuration > Plan Settings
* (parameter plan_stakeholder_types); see ItemTypeProvider (kind "stakeholder").
*
* isPublished (from FormEntity) means "active": an unpublished stakeholder is hidden from the plan
* form's stakeholder picker, but keeps its history on the plans it is already linked to.
*/
class Stakeholder extends FormEntity
{
public const TABLE_NAME = 'plan_stakeholders';
public const TYPE_MAX_LENGTH = 64;
private ?int $id = null;
private ?string $name = null;
private ?string $email = null;
/**
* Free input, normalized to E.164 on save when it parses (StakeholderModel); the raw input is
* kept when it doesn't.
*/
private ?string $phone = null;
private ?string $role = null;
private ?string $type = null;
/**
* The links to the plans this stakeholder is assigned to. Inverse side, read-only from here: the
* links are managed from the plans (Plan::addStakeholder/removeStakeholder).
*
* @var Collection<int, PlanStakeholder>
*/
private Collection $planLinks;
public function __construct()
{
$this->planLinks = new ArrayCollection();
}
public static function loadMetadata(OrmClassMetadata $metadata): void
{
$builder = new ClassMetadataBuilder($metadata);
$builder->setTable(self::TABLE_NAME)
->setCustomRepositoryClass(StakeholderRepository::class);
$builder->addId();
$builder->createField('name', Types::STRING)
->length(191)
->build();
$builder->createField('email', Types::STRING)
->length(191)
->nullable()
->build();
// Indexed for duplicate detection.
$builder->createField('phone', Types::STRING)
->length(50)
->nullable()
->build();
$builder->createField('role', Types::STRING)
->length(191)
->nullable()
->build();
$builder->createField('type', Types::STRING)
->length(self::TYPE_MAX_LENGTH)
->nullable()
->build();
$builder->createOneToMany('planLinks', PlanStakeholder::class)
->mappedBy('stakeholder')
->fetchExtraLazy()
->build();
$builder->addIndex(['email'], 'plan_stakeholder_email');
}
public static function loadValidatorMetadata(ClassMetadata $metadata): void
{
$metadata->addPropertyConstraint('name', new NotBlank(message: 'mautic.core.name.required'));
$metadata->addPropertyConstraint('name', new Length(max: 191));
$metadata->addPropertyConstraint('email', new Email(mode: Email::VALIDATION_MODE_HTML5, message: 'mautic.plan.stakeholder.email.invalid'));
$metadata->addPropertyConstraint('email', new Length(max: 191));
$metadata->addPropertyConstraint('phone', new Length(max: 50));
$metadata->addPropertyConstraint('role', new Length(max: 191));
$metadata->addPropertyConstraint('type', new Length(max: self::TYPE_MAX_LENGTH));
}
public function getId(): ?int
{
return $this->id;
}
public function getName(): ?string
{
return $this->name;
}
public function setName(?string $name): static
{
$this->isChanged('name', $name);
$this->name = $name;
return $this;
}
public function getEmail(): ?string
{
return $this->email;
}
public function setEmail(?string $email): static
{
$this->isChanged('email', $email);
$this->email = $email;
return $this;
}
public function getPhone(): ?string
{
return $this->phone;
}
public function setPhone(?string $phone): static
{
$this->isChanged('phone', $phone);
$this->phone = $phone;
return $this;
}
public function getRole(): ?string
{
return $this->role;
}
public function setRole(?string $role): static
{
$this->isChanged('role', $role);
$this->role = $role;
return $this;
}
public function getType(): ?string
{
return $this->type;
}
/**
* The links to the plans this stakeholder is assigned to, each with its role in that plan.
*
* @return Collection<int, PlanStakeholder>
*/
public function getPlanLinks(): Collection
{
return $this->planLinks;
}
public function setType(?string $type): static
{
$this->isChanged('type', $type);
$this->type = $type;
return $this;
}
}
+47
View File
@@ -0,0 +1,47 @@
<?php
declare(strict_types=1);
namespace MauticPlugin\PlanBundle\Entity;
use Mautic\CoreBundle\Entity\CommonRepository;
/**
* @extends CommonRepository<Stakeholder>
*/
class StakeholderRepository extends CommonRepository
{
use CountsItemsByTypeTrait;
public function getTableAlias(): string
{
return 'ps';
}
/**
* The list's search box matches the name, email, role and type.
*
* @param array<int, mixed> $filter
*
* @return array<int, mixed>
*/
protected function addCatchAllWhereClause($q, $filter): array
{
return $this->addStandardCatchAllWhereClause($q, $filter, [
$this->getTableAlias().'.name',
$this->getTableAlias().'.email',
$this->getTableAlias().'.role',
$this->getTableAlias().'.type',
]);
}
/**
* @return array<array{0: string, 1: string}>
*/
protected function getDefaultOrder(): array
{
return [
[$this->getTableAlias().'.name', 'ASC'],
];
}
}
+333
View File
@@ -0,0 +1,333 @@
<?php
declare(strict_types=1);
namespace MauticPlugin\PlanBundle\Entity;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping\ClassMetadata as OrmClassMetadata;
use Mautic\CoreBundle\Doctrine\Mapping\ClassMetadataBuilder;
use Mautic\StageBundle\Entity\Stage;
use Symfony\Component\Validator\Constraints\Length;
use Symfony\Component\Validator\Constraints\NotBlank;
use Symfony\Component\Validator\Constraints\PositiveOrZero;
use Symfony\Component\Validator\Mapping\ClassMetadata;
/**
* One audience of a plan's Targets tab: who the plan is aimed at, and how. Plan::$targets owns the
* lifecycle: targets are saved and deleted with their plan, and are ordered by position.
*
* The stages are the Mautic stages (Settings > Stages) this target maps to; a target can have any
* number of them, or none. Deleting a stage removes the link (join table row), not the target.
*/
class Target
{
public const TABLE_NAME = 'plan_targets';
/**
* Keys offered for preferredChannels, in display order.
*/
public const CHANNELS = [
'email' => 'mautic.plan.target.channel.email',
'sms' => 'mautic.plan.target.channel.sms',
'web' => 'mautic.plan.target.channel.web',
'social_organic' => 'mautic.plan.target.channel.social_organic',
'paid_social' => 'mautic.plan.target.channel.paid_social',
'paid_search' => 'mautic.plan.target.channel.paid_search',
'events_webinar' => 'mautic.plan.target.channel.events_webinar',
'outbound_sales' => 'mautic.plan.target.channel.outbound_sales',
'partners' => 'mautic.plan.target.channel.partners',
];
private ?int $id = null;
private ?Plan $plan = null;
private ?string $name = null;
private TargetType $targetType = TargetType::Persona;
private TargetPriority $priority = TargetPriority::Primary;
/**
* @var Collection<int, Stage>
*/
private Collection $stages;
/**
* Estimated number of people or accounts, or null when unknown.
*/
private ?int $estimatedSize = null;
/**
* Demographics, firmographics, job titles, geography.
*/
private ?string $profileCriteria = null;
/**
* Problems, triggers, motivations.
*/
private ?string $painPoints = null;
/**
* Key message / hook for this target in this plan.
*/
private ?string $valueProposition = null;
/**
* Keys of self::CHANNELS the plan means to use for this target.
*
* @var list<string>|null
*/
private ?array $preferredChannels = null;
/**
* Display order within the plan, from 0. Set by drag and drop in the form.
*/
private int $position = 0;
public function __construct()
{
$this->stages = new ArrayCollection();
}
public function __clone()
{
$this->id = null;
$this->plan = null;
$this->stages = new ArrayCollection();
}
public static function loadMetadata(OrmClassMetadata $metadata): void
{
$builder = new ClassMetadataBuilder($metadata);
$builder->setTable(self::TABLE_NAME)
->setCustomRepositoryClass(TargetRepository::class);
$builder->addId();
$builder->createManyToOne('plan', Plan::class)
->inversedBy('targets')
->addJoinColumn('plan_id', 'id', false, false, 'CASCADE')
->build();
// Mapped on the raw metadata: ClassMetadataBuilder::addField() forces every string to VARCHAR(191).
$metadata->mapField([
'fieldName' => 'name',
'type' => Types::STRING,
'length' => 191,
]);
$metadata->mapField([
'fieldName' => 'targetType',
'columnName' => 'target_type',
'type' => Types::STRING,
'length' => 30,
'enumType' => TargetType::class,
'options' => ['default' => TargetType::Persona->value],
]);
$metadata->mapField([
'fieldName' => 'priority',
'type' => Types::STRING,
'length' => 20,
'enumType' => TargetPriority::class,
'options' => ['default' => TargetPriority::Primary->value],
]);
foreach (['profileCriteria' => 'profile_criteria', 'painPoints' => 'pain_points', 'valueProposition' => 'value_proposition'] as $field => $column) {
$metadata->mapField([
'fieldName' => $field,
'columnName' => $column,
'type' => Types::TEXT,
'nullable' => true,
]);
}
$builder->createManyToMany('stages', Stage::class)
->setJoinTable('plan_target_stages')
->addJoinColumn('target_id', 'id', false, false, 'CASCADE')
->addInverseJoinColumn('stage_id', 'id', false, false, 'CASCADE')
->build();
$builder->createField('estimatedSize', Types::INTEGER)
->columnName('estimated_size')
->nullable()
->option('unsigned', true)
->build();
$builder->createField('preferredChannels', Types::JSON)
->columnName('preferred_channels')
->nullable()
->build();
$builder->createField('position', Types::INTEGER)
->option('default', 0)
->build();
}
public static function loadValidatorMetadata(ClassMetadata $metadata): void
{
$metadata->addPropertyConstraint('name', new NotBlank(message: 'mautic.plan.target.name.required'));
$metadata->addPropertyConstraint('name', new Length(max: 191));
$metadata->addPropertyConstraint('estimatedSize', new PositiveOrZero(message: 'mautic.plan.target.estimated_size.invalid'));
}
public function getId(): ?int
{
return $this->id;
}
public function getPlan(): ?Plan
{
return $this->plan;
}
public function setPlan(?Plan $plan): static
{
$this->plan = $plan;
return $this;
}
public function getName(): ?string
{
return $this->name;
}
public function setName(?string $name): static
{
$this->name = $name;
return $this;
}
public function getTargetType(): TargetType
{
return $this->targetType;
}
public function setTargetType(TargetType $targetType): static
{
$this->targetType = $targetType;
return $this;
}
public function getPriority(): TargetPriority
{
return $this->priority;
}
public function setPriority(TargetPriority $priority): static
{
$this->priority = $priority;
return $this;
}
/**
* @return Collection<int, Stage>
*/
public function getStages(): Collection
{
return $this->stages;
}
public function addStage(Stage $stage): static
{
if (!$this->stages->contains($stage)) {
$this->stages->add($stage);
}
return $this;
}
public function removeStage(Stage $stage): static
{
$this->stages->removeElement($stage);
return $this;
}
public function getEstimatedSize(): ?int
{
return $this->estimatedSize;
}
public function setEstimatedSize(?int $estimatedSize): static
{
$this->estimatedSize = $estimatedSize;
return $this;
}
public function getProfileCriteria(): ?string
{
return $this->profileCriteria;
}
public function setProfileCriteria(?string $profileCriteria): static
{
$this->profileCriteria = $profileCriteria;
return $this;
}
public function getPainPoints(): ?string
{
return $this->painPoints;
}
public function setPainPoints(?string $painPoints): static
{
$this->painPoints = $painPoints;
return $this;
}
public function getValueProposition(): ?string
{
return $this->valueProposition;
}
public function setValueProposition(?string $valueProposition): static
{
$this->valueProposition = $valueProposition;
return $this;
}
/**
* @return list<string>|null
*/
public function getPreferredChannels(): ?array
{
return $this->preferredChannels;
}
/**
* @param list<string>|null $preferredChannels
*/
public function setPreferredChannels(?array $preferredChannels): static
{
$this->preferredChannels = $preferredChannels;
return $this;
}
public function getPosition(): int
{
return $this->position;
}
public function setPosition(?int $position): static
{
$this->position = $position ?? 0;
return $this;
}
}
+29
View File
@@ -0,0 +1,29 @@
<?php
declare(strict_types=1);
namespace MauticPlugin\PlanBundle\Entity;
/**
* How important a plan's target is to the plan. The order of the cases is the order of the dropdown.
*/
enum TargetPriority: string
{
case Primary = 'primary';
case Secondary = 'secondary';
case Exclusion = 'exclusion';
public function getLabelKey(): string
{
return 'mautic.plan.target.priority.'.$this->value;
}
public function getLabelClass(): string
{
return match ($this) {
self::Primary => 'label-success',
self::Secondary => 'label-info',
self::Exclusion => 'label-danger',
};
}
}
+18
View File
@@ -0,0 +1,18 @@
<?php
declare(strict_types=1);
namespace MauticPlugin\PlanBundle\Entity;
use Mautic\CoreBundle\Entity\CommonRepository;
/**
* @extends CommonRepository<Target>
*/
class TargetRepository extends CommonRepository
{
public function getTableAlias(): string
{
return 'pt';
}
}
+37
View File
@@ -0,0 +1,37 @@
<?php
declare(strict_types=1);
namespace MauticPlugin\PlanBundle\Entity;
/**
* The kind of audience a plan's target describes. The order of the cases is the order of the dropdown.
*/
enum TargetType: string
{
case Persona = 'persona';
case Icp = 'icp';
case BroadAudience = 'broad_audience';
case LifecycleCohort = 'lifecycle_cohort';
case PartnerInfluencer = 'partner_influencer';
public function getLabelKey(): string
{
return 'mautic.plan.target.type.'.$this->value;
}
/**
* A fixed pictogram per type, for the unlabeled first column of the Targets tab (like the other
* tabs' pictograms, from the Remix Icon set Mautic ships).
*/
public function getIcon(): string
{
return match ($this) {
self::Persona => 'ri-user-heart-line',
self::Icp => 'ri-building-line',
self::BroadAudience => 'ri-group-line',
self::LifecycleCohort => 'ri-time-line',
self::PartnerInfluencer => 'ri-hand-heart-line',
};
}
}
+30
View File
@@ -26,10 +26,18 @@ class Task extends FormEntity implements DateRangeInterface
{
public const TABLE_NAME = 'plan_tasks';
public const TYPE_MAX_LENGTH = 64;
private ?int $id = null;
private ?Plan $plan = null;
/**
* Key of a task type set up in Settings > Configuration > Plan Settings (parameter plan_task_types);
* see ItemTypeProvider (kind "task") for its name, description and pictogram.
*/
private ?string $type = null;
private ?string $name = null;
private ?string $description = null;
@@ -74,6 +82,11 @@ class Task extends FormEntity implements DateRangeInterface
->addJoinColumn('plan_id', 'id', false, false, 'CASCADE')
->build();
$builder->createField('type', Types::STRING)
->length(self::TYPE_MAX_LENGTH)
->nullable()
->build();
$builder->createField('name', Types::STRING)
->length(255)
->build();
@@ -112,6 +125,8 @@ class Task extends FormEntity implements DateRangeInterface
$metadata->addPropertyConstraint('name', new NotBlank(message: 'mautic.core.name.required'));
$metadata->addPropertyConstraint('name', new Length(max: 255));
$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 Length(max: self::TYPE_MAX_LENGTH));
$metadata->addConstraint(new ValidTaskParent());
$metadata->addConstraint(new EndDateAfterStartDate());
}
@@ -134,6 +149,21 @@ class Task extends FormEntity implements DateRangeInterface
return $this;
}
public function getType(): ?string
{
return $this->type;
}
public function setType(?string $type): static
{
// FormEntity logs changes for the audit log; enums aren't stringable, plain strings are fine.
$this->isChanged('type', $type);
$this->type = $type;
return $this;
}
public function getName(): ?string
{
return $this->name;
+2
View File
@@ -11,6 +11,8 @@ use Mautic\CoreBundle\Entity\CommonRepository;
*/
class TaskRepository extends CommonRepository
{
use CountsItemsByTypeTrait;
public function getTableAlias(): string
{
return 't';
+11 -2
View File
@@ -9,19 +9,25 @@ use Mautic\ConfigBundle\Event\ConfigBuilderEvent;
use Mautic\ConfigBundle\Event\ConfigEvent;
use MauticPlugin\PlanBundle\Entity\PlanAllocationItemRepository;
use MauticPlugin\PlanBundle\Entity\PlanDescriptionItemRepository;
use MauticPlugin\PlanBundle\Entity\PlanObjectiveRepository;
use MauticPlugin\PlanBundle\Entity\StakeholderRepository;
use MauticPlugin\PlanBundle\Entity\TaskRepository;
use MauticPlugin\PlanBundle\Form\Type\ConfigType;
use MauticPlugin\PlanBundle\Service\ItemTypeProvider;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
/**
* Adds the "Plan" tab to Settings > Configuration (description and allocation item types), and refuses
* to save it when a type that items still use has been removed.
* Adds the "Plan" tab to Settings > Configuration (description, allocation, objective and task item
* types), and refuses to save it when a type that items still use has been removed.
*/
class ConfigSubscriber implements EventSubscriberInterface
{
public function __construct(
private PlanDescriptionItemRepository $descriptionItemRepository,
private PlanAllocationItemRepository $allocationItemRepository,
private PlanObjectiveRepository $objectiveRepository,
private TaskRepository $taskRepository,
private StakeholderRepository $stakeholderRepository,
private ItemTypeProvider $typeProvider,
) {
}
@@ -56,6 +62,9 @@ class ConfigSubscriber implements EventSubscriberInterface
$usage = [
ItemTypeProvider::KIND_DESCRIPTION => $this->descriptionItemRepository->countByType(),
ItemTypeProvider::KIND_ALLOCATION => $this->allocationItemRepository->countByType(),
ItemTypeProvider::KIND_OBJECTIVE => $this->objectiveRepository->countByType(),
ItemTypeProvider::KIND_TASK => $this->taskRepository->countByType(),
ItemTypeProvider::KIND_STAKEHOLDER => $this->stakeholderRepository->countByType(),
];
foreach ($usage as $kind => $counts) {
+16 -1
View File
@@ -4,19 +4,23 @@ declare(strict_types=1);
namespace MauticPlugin\PlanBundle\Form\Type;
use MauticPlugin\PlanBundle\Model\StakeholderModel;
use MauticPlugin\PlanBundle\Service\CurrencyProvider;
use MauticPlugin\PlanBundle\Service\ItemTypeProvider;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\CallbackTransformer;
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
use Symfony\Component\Form\Extension\Core\Type\CollectionType;
use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\Validator\Constraints\NotBlank;
/**
* The "Plan Settings" tab of Settings > Configuration. Each child is a local.php parameter:
* - plan_currency: the currency of every amount in the plugin (general setting);
* - one list of item types per kind (description items, allocation items), each with a pictogram.
* - plan_stakeholder_phone_region: default region for stakeholder phone numbers typed without a prefix;
* - one list of item types per kind (description, allocation, objective, task, stakeholder), each with
* a pictogram.
*
* @extends AbstractType<array<string, mixed>>
*/
@@ -42,6 +46,17 @@ class ConfigType extends AbstractType
'empty_data' => CurrencyProvider::DEFAULT_CURRENCY,
]);
// Default region for stakeholder phone numbers typed without a country prefix (ISO 3166-1
// alpha-2, e.g. FR). Read by StakeholderModel on save.
$builder->add(StakeholderModel::PHONE_REGION_PARAMETER, TextType::class, [
'label' => 'mautic.plan.config.stakeholder_phone_region',
'label_attr' => ['class' => 'control-label'],
'attr' => ['class' => 'form-control', 'tooltip' => 'mautic.plan.config.stakeholder_phone_region.tooltip', 'maxlength' => 2],
'required' => true,
'constraints' => [new NotBlank()],
'empty_data' => StakeholderModel::DEFAULT_PHONE_REGION,
]);
foreach (ItemTypeProvider::PARAMETERS as $kind => $parameter) {
$builder->add($parameter, CollectionType::class, [
'label' => false,
+39 -2
View File
@@ -5,30 +5,67 @@ declare(strict_types=1);
namespace MauticPlugin\PlanBundle\Form\Type;
use MauticPlugin\PlanBundle\Entity\PlanObjective;
use MauticPlugin\PlanBundle\Service\ItemTypeProvider;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
use Symfony\Component\Form\Extension\Core\Type\HiddenType;
use Symfony\Component\Form\Extension\Core\Type\IntegerType;
use Symfony\Component\Form\Extension\Core\Type\TextareaType;
use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
/**
* One row of the objectives collection in PlanType. The position field is hidden and kept in
* display order by Assets/js/plan.js.
* One row of the objectives collection in PlanType: type, title, priority, description and the achieved
* flag. Works like PlanDescriptionItemType (type description shown under the dropdown and its pictogram
* next to it, hidden position kept in display order by Assets/js/plan.js).
*
* @extends AbstractType<PlanObjective>
*/
class PlanObjectiveType extends AbstractType
{
public function __construct(
private ItemTypeProvider $typeProvider,
) {
}
public function buildForm(FormBuilderInterface $builder, array $options): void
{
$kind = ItemTypeProvider::KIND_OBJECTIVE;
$builder->add('type', ChoiceType::class, [
'label' => 'mautic.plan.objective.field.type',
'label_attr' => ['class' => 'control-label'],
'attr' => ['class' => 'form-control plan-item-type'],
'choices' => $this->typeProvider->getChoices($kind),
// The type's description and pictogram, shown next to the dropdown by plan.js.
'choice_attr' => fn (?string $key): array => [
'data-description' => (string) $this->typeProvider->getDescription($kind, $key),
'data-icon' => (string) $this->typeProvider->getIcon($kind, $key),
],
'placeholder' => 'mautic.core.form.chooseone',
'required' => true,
]);
$builder->add('title', TextType::class, [
'label' => 'mautic.plan.objective.field.title',
'label_attr' => ['class' => 'control-label'],
'attr' => ['class' => 'form-control', 'maxlength' => 255],
]);
$builder->add('priority', IntegerType::class, [
'label' => 'mautic.plan.objective.field.priority',
'label_attr' => ['class' => 'control-label'],
'invalid_message' => 'mautic.plan.objective.priority.range',
'attr' => [
'class' => 'form-control',
'min' => PlanObjective::PRIORITY_MIN,
'max' => PlanObjective::PRIORITY_MAX,
'step' => 1,
],
]);
$builder->add('description', TextareaType::class, [
'label' => 'mautic.plan.objective.field.description',
'label_attr' => ['class' => 'control-label'],
+65
View File
@@ -0,0 +1,65 @@
<?php
declare(strict_types=1);
namespace MauticPlugin\PlanBundle\Form\Type;
use Doctrine\ORM\EntityRepository;
use MauticPlugin\PlanBundle\Entity\PlanStakeholder;
use MauticPlugin\PlanBundle\Entity\Stakeholder;
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\HiddenType;
use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
/**
* One row of the stakeholders collection in PlanType: a stakeholder of the global directory (only the
* active ones are offered) and the stakeholder's role in this plan. The position field is hidden and
* kept in display order by Assets/js/plan.js.
*
* @extends AbstractType<PlanStakeholder>
*/
class PlanStakeholderType extends AbstractType
{
public function buildForm(FormBuilderInterface $builder, array $options): void
{
$builder->add('stakeholder', EntityType::class, [
'label' => 'mautic.plan.stakeholder.field.name',
'label_attr' => ['class' => 'control-label'],
'attr' => ['class' => 'form-control'],
'class' => Stakeholder::class,
'choice_label' => 'name',
'query_builder' => fn (EntityRepository $er) => $er->createQueryBuilder('s')
->orderBy('s.name', 'ASC')
->andWhere('s.isPublished = :published')
->setParameter('published', true),
'placeholder' => 'mautic.core.form.chooseone',
'required' => true,
]);
$builder->add('roleInPlan', TextType::class, [
'label' => 'mautic.plan.stakeholder.field.role_in_plan',
'label_attr' => ['class' => 'control-label'],
'attr' => ['class' => 'form-control', 'maxlength' => 191],
'required' => false,
]);
$builder->add('position', HiddenType::class, [
'attr' => ['class' => 'plan-row-position'],
]);
}
public function configureOptions(OptionsResolver $resolver): void
{
$resolver->setDefaults([
'data_class' => PlanStakeholder::class,
]);
}
public function getBlockPrefix(): string
{
return 'plan_plan_stakeholder';
}
}
+30 -1
View File
@@ -16,6 +16,8 @@ use Mautic\UserBundle\Form\Type\UserListType;
use MauticPlugin\PlanBundle\Entity\Plan;
use MauticPlugin\PlanBundle\Entity\PlanStatus;
use MauticPlugin\PlanBundle\Service\CurrencyProvider;
use MauticPlugin\PlanBundle\Form\Type\TargetType as PlanTargetType;
use MauticPlugin\PlanBundle\Form\Type\PlanStakeholderType;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\CollectionType;
use Symfony\Component\Form\Extension\Core\Type\EnumType;
@@ -63,7 +65,7 @@ class PlanType extends AbstractType
'required' => false,
]);
// The Allocation tab's cost lines, in the general currency.
// The Allocations tab's cost lines, in the general currency.
$builder->add('allocationItems', CollectionType::class, [
'label' => 'mautic.plan.field.allocation_items',
'entry_type' => PlanAllocationItemType::class,
@@ -76,6 +78,33 @@ class PlanType extends AbstractType
'required' => false,
]);
// The Targets tab's audiences. by_reference false: Symfony calls Plan::addTarget()/removeTarget().
$builder->add('targets', CollectionType::class, [
'label' => 'mautic.plan.field.targets',
'entry_type' => PlanTargetType::class,
'entry_options' => ['label' => false],
'allow_add' => true,
'allow_delete' => true,
'by_reference' => false,
'prototype' => true,
'prototype_name' => '__target__',
'required' => false,
]);
// The Stakeholders tab's links to the global directory. by_reference false: Symfony calls
// Plan::addStakeholder()/removeStakeholder().
$builder->add('stakeholders', CollectionType::class, [
'label' => 'mautic.plan.field.stakeholders',
'entry_type' => PlanStakeholderType::class,
'entry_options' => ['label' => false],
'allow_add' => true,
'allow_delete' => true,
'by_reference' => false,
'prototype' => true,
'prototype_name' => '__stakeholder__',
'required' => false,
]);
$builder->add('version', IntegerType::class, [
'label' => 'mautic.plan.field.version',
'label_attr' => ['class' => 'control-label'],
+98
View File
@@ -0,0 +1,98 @@
<?php
declare(strict_types=1);
namespace MauticPlugin\PlanBundle\Form\Type;
use MauticPlugin\PlanBundle\Entity\Stakeholder;
use MauticPlugin\PlanBundle\Service\ItemTypeProvider;
use Mautic\CoreBundle\Form\Type\FormButtonsType;
use Mautic\CoreBundle\Form\Type\YesNoButtonGroupType;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
use Symfony\Component\Form\Extension\Core\Type\EmailType;
use Symfony\Component\Form\Extension\Core\Type\TelType;
use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
/**
* The create and edit form of a stakeholder of the global directory (Planning > Stakeholders).
*
* @extends AbstractType<Stakeholder>
*/
class StakeholderType extends AbstractType
{
public function __construct(
private ItemTypeProvider $typeProvider,
) {
}
public function buildForm(FormBuilderInterface $builder, array $options): void
{
$kind = ItemTypeProvider::KIND_STAKEHOLDER;
$builder->add('name', TextType::class, [
'label' => 'mautic.plan.stakeholder.field.name',
'label_attr' => ['class' => 'control-label'],
'attr' => ['class' => 'form-control', 'maxlength' => 191],
]);
$builder->add('email', EmailType::class, [
'label' => 'mautic.plan.stakeholder.field.email',
'label_attr' => ['class' => 'control-label'],
'attr' => ['class' => 'form-control', 'maxlength' => 191],
'required' => false,
]);
$builder->add('phone', TelType::class, [
'label' => 'mautic.plan.stakeholder.field.phone',
'label_attr' => ['class' => 'control-label'],
'attr' => ['class' => 'form-control', 'maxlength' => 50],
'required' => false,
]);
$builder->add('role', TextType::class, [
'label' => 'mautic.plan.stakeholder.field.role',
'label_attr' => ['class' => 'control-label'],
'attr' => ['class' => 'form-control', 'maxlength' => 191],
'required' => false,
]);
$builder->add('type', ChoiceType::class, [
'label' => 'mautic.plan.stakeholder.field.type',
'label_attr' => ['class' => 'control-label'],
'attr' => ['class' => 'form-control plan-item-type'],
'choices' => $this->typeProvider->getChoices($kind),
// The type's description and pictogram, shown next to the dropdown by plan.js.
'choice_attr' => fn (?string $key): array => [
'data-description' => (string) $this->typeProvider->getDescription($kind, $key),
'data-icon' => (string) $this->typeProvider->getIcon($kind, $key),
],
'placeholder' => 'mautic.core.form.chooseone',
'required' => false,
]);
$builder->add('isPublished', YesNoButtonGroupType::class, [
'label' => 'mautic.plan.stakeholder.field.active',
]);
$builder->add('buttons', FormButtonsType::class);
if (!empty($options['action'])) {
$builder->setAction($options['action']);
}
}
public function configureOptions(OptionsResolver $resolver): void
{
$resolver->setDefaults([
'data_class' => Stakeholder::class,
]);
}
public function getBlockPrefix(): string
{
return 'plan_stakeholder';
}
}
+126
View File
@@ -0,0 +1,126 @@
<?php
declare(strict_types=1);
namespace MauticPlugin\PlanBundle\Form\Type;
use Doctrine\ORM\EntityRepository;
use Mautic\StageBundle\Entity\Stage;
use MauticPlugin\PlanBundle\Entity\Target;
use MauticPlugin\PlanBundle\Entity\TargetPriority;
use MauticPlugin\PlanBundle\Entity\TargetType as TargetTypeEnum;
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
use Symfony\Component\Form\Extension\Core\Type\EnumType;
use Symfony\Component\Form\Extension\Core\Type\HiddenType;
use Symfony\Component\Form\Extension\Core\Type\IntegerType;
use Symfony\Component\Form\Extension\Core\Type\TextareaType;
use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
/**
* One row of the targets collection in PlanType: name, type, priority, stages, estimated size, the
* three texts, the preferred channels, and the hidden position kept in display order by
* Assets/js/plan.js.
*
* @extends AbstractType<Target>
*/
class TargetType extends AbstractType
{
public function buildForm(FormBuilderInterface $builder, array $options): void
{
$builder->add('name', TextType::class, [
'label' => 'mautic.plan.target.field.name',
'label_attr' => ['class' => 'control-label'],
'attr' => ['class' => 'form-control', 'maxlength' => 191],
]);
// Dropdown in the order of the TargetType cases.
$builder->add('targetType', EnumType::class, [
'label' => 'mautic.plan.target.field.type',
'label_attr' => ['class' => 'control-label'],
'attr' => ['class' => 'form-control'],
'class' => TargetTypeEnum::class,
'choice_label' => fn (TargetTypeEnum $type): string => $type->getLabelKey(),
]);
// Dropdown in the order of the TargetPriority cases.
$builder->add('priority', EnumType::class, [
'label' => 'mautic.plan.target.field.priority',
'label_attr' => ['class' => 'control-label'],
'attr' => ['class' => 'form-control'],
'class' => TargetPriority::class,
'choice_label' => fn (TargetPriority $priority): string => $priority->getLabelKey(),
]);
// The Mautic stages this target maps to; any number, or none.
$builder->add('stages', EntityType::class, [
'label' => 'mautic.plan.target.field.stages',
'label_attr' => ['class' => 'control-label'],
'attr' => ['class' => 'form-control'],
'class' => Stage::class,
'choice_label' => 'name',
'query_builder' => fn (EntityRepository $er) => $er->createQueryBuilder('s')->orderBy('s.name', 'ASC'),
'multiple' => true,
'expanded' => false,
'required' => false,
]);
$builder->add('estimatedSize', IntegerType::class, [
'label' => 'mautic.plan.target.field.estimated_size',
'label_attr' => ['class' => 'control-label'],
'attr' => ['class' => 'form-control', 'min' => 0, 'step' => 1],
'required' => false,
]);
$builder->add('profileCriteria', TextareaType::class, [
'label' => 'mautic.plan.target.field.profile_criteria',
'label_attr' => ['class' => 'control-label'],
'attr' => ['class' => 'form-control', 'rows' => 2],
'required' => false,
]);
$builder->add('painPoints', TextareaType::class, [
'label' => 'mautic.plan.target.field.pain_points',
'label_attr' => ['class' => 'control-label'],
'attr' => ['class' => 'form-control', 'rows' => 2],
'required' => false,
]);
$builder->add('valueProposition', TextareaType::class, [
'label' => 'mautic.plan.target.field.value_proposition',
'label_attr' => ['class' => 'control-label'],
'attr' => ['class' => 'form-control', 'rows' => 2],
'required' => false,
]);
// One checkbox per channel, in the order of Target::CHANNELS. The choice values are the channel
// keys; the labels are translated by the trans_choices mechanism of the choice_label.
$builder->add('preferredChannels', ChoiceType::class, [
'label' => 'mautic.plan.target.field.preferred_channels',
'label_attr' => ['class' => 'control-label'],
'choices' => array_flip(Target::CHANNELS),
'expanded' => true,
'multiple' => true,
'required' => false,
]);
$builder->add('position', HiddenType::class, [
'attr' => ['class' => 'plan-row-position'],
]);
}
public function configureOptions(OptionsResolver $resolver): void
{
$resolver->setDefaults([
'data_class' => Target::class,
]);
}
public function getBlockPrefix(): string
{
return 'plan_target';
}
}
+23
View File
@@ -11,8 +11,10 @@ use Mautic\CoreBundle\Form\Type\FormButtonsType;
use MauticPlugin\PlanBundle\Entity\Plan;
use MauticPlugin\PlanBundle\Entity\Task;
use MauticPlugin\PlanBundle\Entity\TaskStatus;
use MauticPlugin\PlanBundle\Service\ItemTypeProvider;
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
use Symfony\Component\Form\Extension\Core\Type\EnumType;
use Symfony\Component\Form\Extension\Core\Type\TextareaType;
use Symfony\Component\Form\Extension\Core\Type\TextType;
@@ -24,6 +26,11 @@ use Symfony\Component\OptionsResolver\OptionsResolver;
*/
class TaskType extends AbstractType
{
public function __construct(
private ItemTypeProvider $typeProvider,
) {
}
public function buildForm(FormBuilderInterface $builder, array $options): void
{
$builder->addEventSubscriber(new CleanFormSubscriber(['description' => 'strict_html']));
@@ -32,6 +39,22 @@ class TaskType extends AbstractType
$task = $options['data'];
$plan = $task->getPlan();
$kind = ItemTypeProvider::KIND_TASK;
$builder->add('type', ChoiceType::class, [
'label' => 'mautic.plan.task.field.type',
'label_attr' => ['class' => 'control-label'],
'attr' => ['class' => 'form-control plan-item-type'],
'choices' => $this->typeProvider->getChoices($kind),
// The type's description and pictogram, shown next to the dropdown by plan.js.
'choice_attr' => fn (?string $key): array => [
'data-description' => (string) $this->typeProvider->getDescription($kind, $key),
'data-icon' => (string) $this->typeProvider->getIcon($kind, $key),
],
'placeholder' => 'mautic.core.form.chooseone',
'required' => true,
]);
$builder->add('name', TextType::class, [
'label' => 'mautic.plan.task.field.name',
'label_attr' => ['class' => 'control-label'],
+40
View File
@@ -0,0 +1,40 @@
<?php
declare(strict_types=1);
namespace MauticPlugin\PlanBundle\Migrations;
use Doctrine\DBAL\Schema\Schema;
use Mautic\IntegrationsBundle\Migration\AbstractMigration;
use MauticPlugin\PlanBundle\Entity\PlanObjective;
/**
* Since 0.10.0 objectives have a type, the key of an objective type set up in Settings >
* Configuration > Plan Settings (parameter plan_objective_types). Adds plan_objectives.type for
* installs created before 0.10.0. The column is nullable: existing objectives have no type yet, and
* each one must be given a type before the plan can be saved again (validation requires it). Runs only
* when the column is missing.
*/
class Version_0_10_0 extends AbstractMigration
{
protected function isApplicable(Schema $schema): bool
{
$objectives = $this->concatPrefix(PlanObjective::TABLE_NAME);
if (!$schema->hasTable($objectives)) {
return false;
}
return !$schema->getTable($objectives)->hasColumn('type');
}
protected function up(): void
{
$objectives = $this->concatPrefix(PlanObjective::TABLE_NAME);
$table = $this->entityManager->getConnection()->createSchemaManager()->introspectTable($objectives);
if (!$table->hasColumn('type')) {
$this->addSql(sprintf('ALTER TABLE %s ADD type VARCHAR(%d) DEFAULT NULL', $objectives, PlanObjective::TYPE_MAX_LENGTH));
}
}
}
+42
View File
@@ -0,0 +1,42 @@
<?php
declare(strict_types=1);
namespace MauticPlugin\PlanBundle\Migrations;
use Doctrine\DBAL\Schema\Schema;
use Mautic\IntegrationsBundle\Migration\AbstractMigration;
use MauticPlugin\PlanBundle\Entity\PlanObjective;
/**
* Since 0.10.1 objectives have a priority, a whole number from 1 (highest) to 99 (lowest). Adds
* plan_objectives.priority for installs created before 0.10.1: NOT NULL with the default 1, and the
* existing objectives get that default. Runs only when the column is missing.
*/
class Version_0_10_1 extends AbstractMigration
{
protected function isApplicable(Schema $schema): bool
{
$objectives = $this->concatPrefix(PlanObjective::TABLE_NAME);
if (!$schema->hasTable($objectives)) {
return false;
}
return !$schema->getTable($objectives)->hasColumn('priority');
}
protected function up(): void
{
$objectives = $this->concatPrefix(PlanObjective::TABLE_NAME);
$table = $this->entityManager->getConnection()->createSchemaManager()->introspectTable($objectives);
if (!$table->hasColumn('priority')) {
$this->addSql(sprintf(
"ALTER TABLE %s ADD priority INT NOT NULL DEFAULT %d",
$objectives,
PlanObjective::PRIORITY_MIN
));
}
}
}
+149
View File
@@ -0,0 +1,149 @@
<?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\Plan;
use MauticPlugin\PlanBundle\Entity\Target;
use MauticPlugin\PlanBundle\Entity\TargetType as TargetTypeEnum;
/**
* Since 0.11.0 a plan has targets (table plan_targets) with any number of Mautic stages (join table
* plan_target_stages). Creates both tables for installs created before 0.11.0, and repairs the ones the
* plugin installer created without foreign keys (it drops foreign keys that point to core tables, such
* as stages) or with camelCase column names (an early version of the mapping). Each step runs only if
* needed.
*/
class Version_0_11_0 extends AbstractMigration
{
/**
* Field name => column name, for the columns an early version of the mapping left in camelCase.
*/
private const COLUMNS = [
'targetType' => 'target_type',
'profileCriteria' => 'profile_criteria',
'painPoints' => 'pain_points',
'valueProposition' => 'value_proposition',
];
protected function isApplicable(Schema $schema): bool
{
if (!$schema->hasTable($this->concatPrefix(Plan::TABLE_NAME))) {
return false;
}
if (!$schema->hasTable($this->concatPrefix(Target::TABLE_NAME))
|| !$schema->hasTable($this->concatPrefix('plan_target_stages'))) {
return true;
}
// Repair mode: missing foreign keys or camelCase columns.
return [] !== $this->getColumnsToRename($schema) || !$this->hasForeignKeys($schema);
}
protected function up(): void
{
$schema = $this->entityManager->getConnection()->createSchemaManager()->introspectSchema();
if (!$schema->hasTable($this->concatPrefix(Target::TABLE_NAME))) {
$this->addSql($this->getCreateTableSql(Target::TABLE_NAME));
}
if (!$schema->hasTable($this->concatPrefix('plan_target_stages'))) {
$this->addSql($this->getCreateTableSql('plan_target_stages'));
}
foreach ($this->getColumnsToRename($schema) as $field => $column) {
$this->addSql(sprintf(
'ALTER TABLE %s CHANGE %s %s',
$this->concatPrefix(Target::TABLE_NAME),
$field,
$this->getColumnDefinition($field, $column)
));
}
if (!$this->hasForeignKeys($schema)) {
$this->addSql($this->generateAlterTableForeignKeyStatement(
Target::TABLE_NAME,
['plan_id'],
Plan::TABLE_NAME,
['id'],
'ON DELETE CASCADE'
));
}
}
/**
* @return array<string, string> field name => column name, for the camelCase columns still present
*/
private function getColumnsToRename(Schema $schema): array
{
if (!$schema->hasTable($this->concatPrefix(Target::TABLE_NAME))) {
return [];
}
$table = $schema->getTable($this->concatPrefix(Target::TABLE_NAME));
$rename = [];
foreach (self::COLUMNS as $field => $column) {
if ($table->hasColumn($field) && !$table->hasColumn($column)) {
$rename[$field] = $column;
}
}
return $rename;
}
private function hasForeignKeys(Schema $schema): bool
{
$targets = $this->concatPrefix(Target::TABLE_NAME);
if (!$schema->hasTable($targets)) {
return false;
}
foreach ($schema->getTable($targets)->getForeignKeys() as $foreignKey) {
if (in_array('plan_id', $foreignKey->getLocalColumns(), true)) {
return true;
}
}
return false;
}
/**
* The MySQL column definition matching the entity mapping, for a CHANGE that renames the column.
*/
private function getColumnDefinition(string $field, string $column): string
{
$definitions = [
'targetType' => sprintf("%s VARCHAR(30) NOT NULL DEFAULT '%s'", $column, TargetTypeEnum::Persona->value),
'profileCriteria' => $column.' LONGTEXT DEFAULT NULL',
'painPoints' => $column.' LONGTEXT DEFAULT NULL',
'valueProposition' => $column.' LONGTEXT DEFAULT NULL',
];
return $definitions[$field] ?? $column;
}
/**
* The CREATE TABLE statement for one of this migration's tables, from Doctrine's SchemaTool.
*/
private function getCreateTableSql(string $table): string
{
$schemaTool = new SchemaTool($this->entityManager);
$prefix = 'CREATE TABLE '.$this->concatPrefix($table).' ';
foreach ($schemaTool->getCreateSchemaSql([$this->entityManager->getClassMetadata(Target::class)]) as $sql) {
if (str_starts_with($sql, $prefix)) {
return $sql;
}
}
throw new \RuntimeException('SchemaTool returned no CREATE TABLE statement for '.$table.'.');
}
}
+104
View File
@@ -0,0 +1,104 @@
<?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\Plan;
use MauticPlugin\PlanBundle\Entity\PlanStakeholder;
use MauticPlugin\PlanBundle\Entity\Stakeholder;
/**
* Since 0.12.0 planning has a global stakeholder directory (table plan_stakeholders), and each plan
* links to its stakeholders through plan_stakeholders_plan, which carries the stakeholder's role in
* the plan. Creates both tables for installs created before 0.12.0, and repairs the ones the plugin
* installer created without foreign keys (it drops foreign keys that point to core tables). Each step
* runs only if needed.
*/
class Version_0_12_0 extends AbstractMigration
{
protected function isApplicable(Schema $schema): bool
{
if (!$schema->hasTable($this->concatPrefix(Plan::TABLE_NAME))) {
return false;
}
if (!$schema->hasTable($this->concatPrefix(Stakeholder::TABLE_NAME))
|| !$schema->hasTable($this->concatPrefix(PlanStakeholder::TABLE_NAME))) {
return true;
}
return !$this->hasForeignKeys($schema);
}
protected function up(): void
{
$schema = $this->entityManager->getConnection()->createSchemaManager()->introspectSchema();
if (!$schema->hasTable($this->concatPrefix(Stakeholder::TABLE_NAME))) {
$this->addSql($this->getCreateTableSql(Stakeholder::class, Stakeholder::TABLE_NAME));
}
if (!$schema->hasTable($this->concatPrefix(PlanStakeholder::TABLE_NAME))) {
$this->addSql($this->getCreateTableSql(PlanStakeholder::class, PlanStakeholder::TABLE_NAME));
}
if (!$this->hasForeignKeys($schema)) {
$this->addSql($this->generateAlterTableForeignKeyStatement(
PlanStakeholder::TABLE_NAME,
['plan_id'],
Plan::TABLE_NAME,
['id'],
'ON DELETE CASCADE'
));
$this->addSql($this->generateAlterTableForeignKeyStatement(
PlanStakeholder::TABLE_NAME,
['stakeholder_id'],
Stakeholder::TABLE_NAME,
['id'],
'ON DELETE CASCADE'
));
}
}
/**
* True when both foreign keys of the link table exist (plan_id, stakeholder_id).
*/
private function hasForeignKeys(Schema $schema): bool
{
$links = $this->concatPrefix(PlanStakeholder::TABLE_NAME);
if (!$schema->hasTable($links)) {
return false;
}
$columns = [];
foreach ($schema->getTable($links)->getForeignKeys() as $foreignKey) {
$columns = array_merge($columns, $foreignKey->getLocalColumns());
}
return in_array('plan_id', $columns, true) && in_array('stakeholder_id', $columns, true);
}
/**
* The CREATE TABLE statement for one of this migration's tables, from Doctrine's SchemaTool.
*
* @param class-string $entityClass
*/
private function getCreateTableSql(string $entityClass, string $table): string
{
$schemaTool = new SchemaTool($this->entityManager);
$prefix = 'CREATE TABLE '.$this->concatPrefix($table).' ';
foreach ($schemaTool->getCreateSchemaSql([$this->entityManager->getClassMetadata($entityClass)]) as $sql) {
if (str_starts_with($sql, $prefix)) {
return $sql;
}
}
throw new \RuntimeException('SchemaTool returned no CREATE TABLE statement for '.$table.'.');
}
}
+39
View File
@@ -0,0 +1,39 @@
<?php
declare(strict_types=1);
namespace MauticPlugin\PlanBundle\Migrations;
use Doctrine\DBAL\Schema\Schema;
use Mautic\IntegrationsBundle\Migration\AbstractMigration;
use MauticPlugin\PlanBundle\Entity\Task;
/**
* Since 0.9.0 tasks have a type, the key of a task type set up in Settings > Configuration > Plan
* Settings (parameter plan_task_types). Adds plan_tasks.type for installs created before 0.9.0. The
* column is nullable: existing tasks have no type yet, and each one must be given one before it can be
* saved again (validation requires it). Runs only when the column is missing.
*/
class Version_0_9_0 extends AbstractMigration
{
protected function isApplicable(Schema $schema): bool
{
$tasks = $this->concatPrefix(Task::TABLE_NAME);
if (!$schema->hasTable($tasks)) {
return false;
}
return !$schema->getTable($tasks)->hasColumn('type');
}
protected function up(): void
{
$tasks = $this->concatPrefix(Task::TABLE_NAME);
$table = $this->entityManager->getConnection()->createSchemaManager()->introspectTable($tasks);
if (!$table->hasColumn('type')) {
$this->addSql(sprintf('ALTER TABLE %s ADD type VARCHAR(%d) DEFAULT NULL', $tasks, Task::TYPE_MAX_LENGTH));
}
}
}
+111
View File
@@ -0,0 +1,111 @@
<?php
declare(strict_types=1);
namespace MauticPlugin\PlanBundle\Model;
use libphonenumber\NumberParseException;
use libphonenumber\PhoneNumberFormat;
use libphonenumber\PhoneNumberUtil;
use Mautic\CoreBundle\Model\FormModel;
use MauticPlugin\PlanBundle\Entity\Stakeholder;
use MauticPlugin\PlanBundle\Entity\StakeholderRepository;
use MauticPlugin\PlanBundle\Form\Type\StakeholderType;
use Symfony\Component\Form\FormFactoryInterface;
use Symfony\Component\Form\FormInterface;
use Symfony\Component\HttpKernel\Exception\MethodNotAllowedHttpException;
/**
* Available as mautic.plan.model.stakeholder, or getModel('plan.stakeholder').
*
* On save, the phone number is normalized to E.164 using the default region from Settings >
* Configuration > Plan Settings (parameter plan_stakeholder_phone_region, FR by default). A number that
* doesn't parse (free input, extensions…) is kept exactly as typed: the save is never blocked.
*/
class StakeholderModel extends FormModel
{
/**
* local.php parameter: default region for phone numbers typed without a country prefix.
*/
public const PHONE_REGION_PARAMETER = 'plan_stakeholder_phone_region';
public const DEFAULT_PHONE_REGION = 'FR';
public function getRepository(): StakeholderRepository
{
$repository = $this->em->getRepository(Stakeholder::class);
\assert($repository instanceof StakeholderRepository);
return $repository;
}
public function getPermissionBase(): string
{
return 'plan:stakeholders';
}
public function getEntity($id = null): ?Stakeholder
{
if (null === $id) {
return new Stakeholder();
}
$stakeholder = parent::getEntity($id);
return $stakeholder instanceof Stakeholder ? $stakeholder : null;
}
/**
* Normalizes the phone number to E.164 before saving; keeps the raw input when it doesn't parse.
*/
public function saveEntity($entity, $unlock = true): void
{
if ($entity instanceof Stakeholder && null !== $entity->getPhone() && '' !== trim($entity->getPhone())) {
$entity->setPhone($this->normalizePhone($entity->getPhone()));
}
parent::saveEntity($entity, $unlock);
}
/**
* @param array<string, mixed> $options
*/
public function createForm($entity, FormFactoryInterface $formFactory, $action = null, $options = []): FormInterface
{
if (!$entity instanceof Stakeholder) {
throw new MethodNotAllowedHttpException(['Stakeholder']);
}
if (!empty($action)) {
$options['action'] = $action;
}
return $formFactory->create(StakeholderType::class, $entity, $options);
}
/**
* The number as E.164 when it parses with the default region, or the raw input as typed when it
* doesn't ("+33 6 … ext. 12" stays as typed).
*/
public function normalizePhone(string $phone): string
{
try {
$number = PhoneNumberUtil::getInstance()->parse(trim($phone), $this->getDefaultPhoneRegion());
if (PhoneNumberUtil::getInstance()->isValidNumber($number)) {
return PhoneNumberUtil::getInstance()->format($number, PhoneNumberFormat::E164);
}
} catch (NumberParseException) {
// Not a parseable number: keep the raw input.
}
return $phone;
}
public function getDefaultPhoneRegion(): string
{
$region = $this->coreParametersHelper->get(self::PHONE_REGION_PARAMETER);
return is_string($region) && '' !== trim($region) ? strtoupper(trim($region)) : self::DEFAULT_PHONE_REGION;
}
}
@@ -1,7 +1,8 @@
{#
# Settings > Configuration > Plan Settings: the general currency, the description item types and the
# allocation item types, each with a pictogram. Adding and removing types, and the pictogram preview,
# are handled by Assets/js/plan.js (delegated handlers on .plan-config-types).
# Settings > Configuration > Plan Settings: the general currency, then one section per kind of plan
# item (description, allocation, objectives, tasks), each with a pictogram. Adding and removing
# types, and the pictogram preview, are handled by Assets/js/plan.js (delegated handlers on
# .plan-config-types).
#}
{% macro type_row(type) %}
@@ -83,6 +84,7 @@
<h4 class="fw-sb mb-xs">{{ 'mautic.plan.config.section.general'|trans }}</h4>
<div class="row">
<div class="col-md-6">{{ form_row(form.children.plan_currency) }}</div>
<div class="col-md-6">{{ form_row(form.children.plan_stakeholder_phone_region) }}</div>
</div>
<p class="text-muted small">{{ 'mautic.plan.config.currency.help'|trans }}</p>
@@ -93,4 +95,16 @@
{{ plan.type_section(form.children.plan_allocation_item_types,
'mautic.plan.config.section.allocation_item_types',
'mautic.plan.config.section.allocation_item_types.help') }}
{{ plan.type_section(form.children.plan_objective_types,
'mautic.plan.config.section.objective_types',
'mautic.plan.config.section.objective_types.help') }}
{{ plan.type_section(form.children.plan_task_types,
'mautic.plan.config.section.task_types',
'mautic.plan.config.section.task_types.help') }}
{{ plan.type_section(form.children.plan_stakeholder_types,
'mautic.plan.config.section.stakeholder_types',
'mautic.plan.config.section.stakeholder_types.help') }}
{% endblock %}
@@ -0,0 +1,24 @@
{#
# A long text clamped to 10 lines with a "Read more" toggle: the first rows of a tab table stay
# readable at a glance, and nothing is lost. Pure CSS does the clamping (line-clamp works on <p> with
# display:-webkit-box); the button only toggles the class, so it also works without JS.
#
# Parameters:
# text: the text to show (may contain line breaks; URLs in it become links, see plan_linkify)
# id: unique element id for this instance
# lines: number of lines to clamp to (default 10)
#}
{% set lines = lines|default(10) %}
{% if text|trim is not empty %}
<div class="plan-read-more" id="{{ id }}">
<div class="plan-read-more-text" style="display: -webkit-box; -webkit-line-clamp: {{ lines }}; -webkit-box-orient: vertical; overflow: hidden; white-space: pre-wrap;">{{ text|plan_linkify }}</div>
<button type="button" class="btn btn-link btn-xs p-0 plan-read-more-toggle"
data-target="{{ id }}"
data-more-text="{{ 'mautic.plan.read_more.more'|trans }}"
data-less-text="{{ 'mautic.plan.read_more.less'|trans }}"
style="display: none; padding-left: 0;"
aria-expanded="false">
{{ 'mautic.plan.read_more.more'|trans }} <i class="ri-arrow-down-s-line"></i>
</button>
</div>
{% endif %}
@@ -0,0 +1,11 @@
{#
# The filter box of a plan tab table (Description, Objectives, Allocation, Tasks) and the switch that
# shows the "no match" message. Filtering and sorting are handled by Assets/js/plan.js
# (Mautic.planInitTabTable), on any table with the data-plan-tab-table attribute.
#}
<div class="plan-tab-table-filter input-group input-group-sm mb-xs" style="max-width: 300px;">
<span class="input-group-addon"><i class="ri-search-line"></i></span>
<input type="text" class="form-control plan-tab-table-filter-input"
placeholder="{{ 'mautic.plan.filter.placeholder'|trans }}" aria-label="{{ 'mautic.plan.filter.placeholder'|trans }}">
</div>
<p class="text-muted plan-tab-table-nomatch hide">{{ 'mautic.plan.filter.no_match'|trans }}</p>
+2 -1
View File
@@ -13,8 +13,9 @@
'details': 'mautic.plan.tab.details',
'description': 'mautic.plan.tab.description',
'objectives': 'mautic.plan.tab.objectives',
'allocation': 'mautic.plan.tab.allocation',
'allocation': 'mautic.plan.tab.allocations',
'targets': 'mautic.plan.tab.targets',
'stakeholders': 'mautic.plan.tab.stakeholders',
'tasks': 'mautic.plan.tab.tasks',
} %}
<ul class="nav nav-tabs nav-tabs-contained tabs-horizontal plan-tabs" role="tablist" data-plan-id="{{ planId|default('') }}">
+33 -19
View File
@@ -1,12 +1,12 @@
{#
# The plan's tasks, for the Tasks tab of the plan detail page and form. Same columns as the task list
# (Planning > Tasks): ID, Name, Description, Start date, End date, Status. Rows are in tree order:
# each task is followed by its sub-tasks, indented under it.
# The plan's tasks, for the Tasks tab of the plan detail page and form. Same harmonized columns as the
# other tabs: Pictogram (no label), Type, Name, Description, Start date, End date, Status (last). No ID
# column. Rows are in tree order: each task is followed by its sub-tasks, indented under it.
#
# Parameters:
# plan: the Plan
# taskTree: rows from TaskModel::getTaskTree(): {task, depth}, in display order
# readOnly: true on the plan form: no links, so that following one can't drop unsaved changes
# readOnly: true on the plan form: no links, no filter, so that following one can't drop unsaved changes
# taskPermissions: plan:tasks:* permissions (create, editown, editother), when not read-only
#
# Links carry returnTo=plan, so that Save and Cancel on the task form come back to this plan
@@ -29,16 +29,21 @@
{% elseif taskTree is empty %}
<p class="text-muted">{{ 'mautic.plan.task.empty'|trans }}</p>
{% else %}
{% if not readOnly %}
{# Filter + click-to-sort on the detail page (plan.js). The form's read-only copy stays plain. #}
{{ include('@Plan/Plan/_tab_table_filter.html.twig') }}
{% endif %}
<div class="table-responsive">
<table class="table table-hover plan-task-table">
<table class="table table-hover plan-tab-table plan-task-table{% if not readOnly %}" data-plan-tab-table data-empty-text="{{ 'mautic.plan.filter.no_match'|trans }}" data-sort-hint="{{ 'mautic.plan.filter.sort_hint'|trans }}{% endif %}">
<thead>
<tr>
<th class="col-plan-task-id">{{ 'mautic.core.id'|trans }}</th>
<th class="col-plan-task-name">{{ 'mautic.plan.task.field.name'|trans }}</th>
<th class="visible-md visible-lg col-plan-task-description">{{ 'mautic.plan.task.field.description'|trans }}</th>
<th class="col-plan-task-start">{{ 'mautic.plan.task.field.start_date'|trans }}</th>
<th class="col-plan-task-end">{{ 'mautic.plan.task.field.end_date'|trans }}</th>
<th class="col-plan-task-status">{{ 'mautic.plan.task.field.status'|trans }}</th>
<th class="plan-col-pictogram" aria-label="{{ 'mautic.plan.task.field.pictogram'|trans }}"></th>
<th class="plan-col-type">{{ 'mautic.plan.task.field.type'|trans }}</th>
<th class="plan-col-name">{{ 'mautic.plan.task.field.name'|trans }}</th>
<th class="plan-col-description">{{ 'mautic.plan.task.field.description'|trans }}</th>
<th class="plan-col-date">{{ 'mautic.plan.task.field.start_date'|trans }}</th>
<th class="plan-col-date">{{ 'mautic.plan.task.field.end_date'|trans }}</th>
<th class="plan-col-status">{{ 'mautic.plan.task.field.status'|trans }}</th>
</tr>
</thead>
<tbody>
@@ -47,8 +52,14 @@
{% 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 }}" data-depth="{{ row.depth }}">
<td>{{ task.id }}</td>
<td>
<td class="plan-col-pictogram text-center">
{% 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 %}
</td>
<td class="plan-col-type"{% if plan_item_type_description('task', task.type) %} title="{{ plan_item_type_description('task', task.type) }}" data-toggle="tooltip"{% endif %}>
{{ plan_item_type_name('task', task.type) ?? 'mautic.plan.description_item.type.unknown'|trans({'%key%': task.type}) }}
</td>
<td class="plan-col-name">
<span style="display: inline-block; padding-left: {{ row.depth * 24 }}px;">
{% if row.depth > 0 %}
<i class="ri-corner-down-right-line text-muted" title="{{ 'mautic.plan.task.subtask_of'|trans({'%parent%': task.parent.name}) }}"></i>
@@ -63,13 +74,16 @@
{% endif %}
</span>
</td>
<td class="visible-md visible-lg text-muted">
{% set description = task.description|default('')|striptags|trim %}
{{ description|length > 120 ? description|slice(0, 120) ~ '…' : description }}
<td class="plan-col-description text-muted">
{# Same 10-line clamp and read-more as the Description tab; URLs become links. #}
{{ include('@Plan/Plan/_description_read_more.html.twig', {
'text': task.description|default('')|striptags,
'id': 'plan-task-desc-' ~ task.id,
}) }}
</td>
<td>{{ task.startDate ? dateToFull(task.startDate) : '' }}</td>
<td>{{ task.endDate ? dateToFull(task.endDate) : '' }}</td>
<td><span class="label {{ task.status.labelClass }}">{{ task.status.labelKey|trans }}</span></td>
<td class="plan-col-date">{{ task.startDate ? dateToFull(task.startDate) : '' }}</td>
<td class="plan-col-date">{{ task.endDate ? dateToFull(task.endDate) : '' }}</td>
<td class="plan-col-status"><span class="label {{ task.status.labelClass }}">{{ task.status.labelKey|trans }}</span></td>
</tr>
{% endfor %}
</tbody>
+194 -43
View File
@@ -86,6 +86,8 @@
'description': descriptionItems|length,
'objectives': objectives|length,
'allocation': allocationItems|length,
'targets': item.targets|length,
'stakeholders': item.stakeholders|length,
'tasks': taskTree|length,
}}) }}
@@ -151,14 +153,17 @@
{% if descriptionItems is empty %}
<p class="text-muted">{{ 'mautic.plan.description_item.empty'|trans }}</p>
{% else %}
{# Three columns: the type's pictogram, the type, the description. #}
{# Harmonized columns: Pictogram (no label), Type, Description. Description items have no
name of their own, so the Name column is left out here. Filter + click-to-sort (plan.js). #}
{{ include('@Plan/Plan/_tab_table_filter.html.twig') }}
<div class="table-responsive">
<table class="table table-hover plan-description-items-view">
<table class="table table-hover plan-tab-table plan-description-items-view"
data-plan-tab-table data-empty-text="{{ 'mautic.plan.filter.no_match'|trans }}" data-sort-hint="{{ 'mautic.plan.filter.sort_hint'|trans }}">
<thead>
<tr>
<th class="text-center" style="width: 1%;">{{ 'mautic.plan.description_item.field.pictogram'|trans }}</th>
<th class="col-md-3">{{ 'mautic.plan.description_item.field.type'|trans }}</th>
<th>{{ 'mautic.plan.description_item.field.description'|trans }}</th>
<th class="plan-col-pictogram" aria-label="{{ 'mautic.plan.description_item.field.pictogram'|trans }}"></th>
<th class="plan-col-type">{{ 'mautic.plan.description_item.field.type'|trans }}</th>
<th class="plan-col-description">{{ 'mautic.plan.description_item.field.description'|trans }}</th>
</tr>
</thead>
<tbody>
@@ -167,15 +172,18 @@
{% set typeDescription = plan_item_type_description('description', descriptionItem.type) %}
{% set typeIcon = plan_item_type_icon('description', descriptionItem.type) %}
<tr>
<td class="text-center">
<td class="plan-col-pictogram text-center">
{% if typeIcon %}<i class="{{ typeIcon }} plan-item-type-icon" style="font-size: 24px;" aria-hidden="true"></i>{% endif %}
</td>
<td>
<strong{% if typeDescription %} title="{{ typeDescription }}" data-toggle="tooltip"{% endif %}>
{{ typeName ?? 'mautic.plan.description_item.type.unknown'|trans({'%key%': descriptionItem.type}) }}
</strong>
<td class="plan-col-type"{% if typeDescription %} title="{{ typeDescription }}" data-toggle="tooltip"{% endif %}>
{{ typeName ?? 'mautic.plan.description_item.type.unknown'|trans({'%key%': descriptionItem.type}) }}
</td>
<td class="plan-col-description">
{{ include('@Plan/Plan/_description_read_more.html.twig', {
'text': descriptionItem.description,
'id': 'plan-desc-item-' ~ descriptionItem.id,
}) }}
</td>
<td style="white-space: pre-wrap;">{{ descriptionItem.description }}</td>
</tr>
{% endfor %}
</tbody>
@@ -192,21 +200,49 @@
<p class="text-muted plan-objectives-progress">
{{ 'mautic.plan.objective.progress'|trans({'%achieved%': achievedCount, '%total%': objectives|length}) }}
</p>
<ol class="list-group plan-objectives-view">
{% for objective in objectives %}
<li class="list-group-item">
{% if objective.achieved %}
<i class="ri-checkbox-circle-fill text-success" title="{{ 'mautic.plan.objective.achieved'|trans }}"></i>
{% else %}
<i class="ri-checkbox-blank-circle-line text-muted" title="{{ 'mautic.plan.objective.not_achieved'|trans }}"></i>
{% endif %}
<strong>{{ objective.title }}</strong>
{% if objective.description is not empty %}
<div class="text-muted mt-xs" style="white-space: pre-wrap;">{{ objective.description }}</div>
{% endif %}
</li>
{% endfor %}
</ol>
{# Harmonized columns: Pictogram (no label), Type, Name (title), Description, Priority,
Status (achieved). Filter + click-to-sort (plan.js). #}
{{ include('@Plan/Plan/_tab_table_filter.html.twig') }}
<div class="table-responsive">
<table class="table table-hover plan-tab-table plan-objectives-view"
data-plan-tab-table data-empty-text="{{ 'mautic.plan.filter.no_match'|trans }}" data-sort-hint="{{ 'mautic.plan.filter.sort_hint'|trans }}">
<thead>
<tr>
<th class="plan-col-pictogram" aria-label="{{ 'mautic.plan.objective.field.pictogram'|trans }}"></th>
<th class="plan-col-type">{{ 'mautic.plan.objective.field.type'|trans }}</th>
<th class="plan-col-name">{{ 'mautic.plan.objective.field.name'|trans }}</th>
<th class="plan-col-description">{{ 'mautic.plan.objective.field.description'|trans }}</th>
<th class="plan-col-priority">{{ 'mautic.plan.objective.field.priority'|trans }}</th>
<th class="plan-col-status">{{ 'mautic.plan.objective.field.is_achieved'|trans }}</th>
</tr>
</thead>
<tbody>
{% for objective in objectives %}
{% set typeName = plan_item_type_name('objective', objective.type) %}
{% set typeDescription = plan_item_type_description('objective', objective.type) %}
{% set typeIcon = plan_item_type_icon('objective', objective.type) %}
<tr>
<td class="plan-col-pictogram text-center">
{% if typeIcon %}<i class="{{ typeIcon }} plan-item-type-icon" style="font-size: 24px;" aria-hidden="true"></i>{% endif %}
</td>
<td class="plan-col-type"{% if typeDescription %} title="{{ typeDescription }}" data-toggle="tooltip"{% endif %}>
{{ typeName ?? 'mautic.plan.description_item.type.unknown'|trans({'%key%': objective.type}) }}
</td>
<td class="plan-col-name">{{ objective.title }}</td>
<td class="plan-col-description text-muted" style="white-space: pre-wrap;">{{ objective.description|plan_linkify }}</td>
<td class="plan-col-priority">{{ objective.priority ?? '—' }}</td>
<td class="plan-col-status">
{% if objective.achieved %}
<span class="label label-success"><i class="ri-checkbox-circle-fill" title="{{ 'mautic.plan.objective.achieved'|trans }}"></i> {{ 'mautic.plan.objective.achieved'|trans }}</span>
{% else %}
<span class="label label-default"><i class="ri-checkbox-blank-circle-line" title="{{ 'mautic.plan.objective.not_achieved'|trans }}"></i> {{ 'mautic.plan.objective.not_achieved'|trans }}</span>
{% endif %}
</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
{% endif %}
</div>
@@ -231,16 +267,20 @@
{% if allocationItems is empty %}
<p class="text-muted">{{ 'mautic.plan.allocation_item.empty'|trans }}</p>
{% else %}
{# Harmonized columns: Pictogram (no label), Type, Name, Description, then the costs.
Filter + click-to-sort (plan.js). #}
{{ include('@Plan/Plan/_tab_table_filter.html.twig') }}
<div class="table-responsive">
<table class="table table-hover plan-allocation-items-view">
<table class="table table-hover plan-tab-table plan-allocation-items-view"
data-plan-tab-table data-empty-text="{{ 'mautic.plan.filter.no_match'|trans }}" data-sort-hint="{{ 'mautic.plan.filter.sort_hint'|trans }}">
<thead>
<tr>
<th class="text-center" style="width: 1%;">{{ 'mautic.plan.allocation_item.field.pictogram'|trans }}</th>
<th>{{ 'mautic.plan.allocation_item.field.type'|trans }}</th>
<th>{{ 'mautic.plan.allocation_item.field.name'|trans }}</th>
<th class="visible-md visible-lg">{{ 'mautic.plan.allocation_item.field.description'|trans }}</th>
<th class="text-right">{{ 'mautic.plan.allocation_item.field.planned_cost'|trans }}</th>
<th class="text-right">{{ 'mautic.plan.allocation_item.field.real_cost'|trans }}</th>
<th class="plan-col-pictogram" aria-label="{{ 'mautic.plan.allocation_item.field.pictogram'|trans }}"></th>
<th class="plan-col-type">{{ 'mautic.plan.allocation_item.field.type'|trans }}</th>
<th class="plan-col-name">{{ 'mautic.plan.allocation_item.field.name'|trans }}</th>
<th class="plan-col-description">{{ 'mautic.plan.allocation_item.field.description'|trans }}</th>
<th class="plan-col-cost text-right">{{ 'mautic.plan.allocation_item.field.planned_cost'|trans }}</th>
<th class="plan-col-cost text-right">{{ 'mautic.plan.allocation_item.field.real_cost'|trans }}</th>
</tr>
</thead>
<tbody>
@@ -249,18 +289,18 @@
{% set typeDescription = plan_item_type_description('allocation', allocationItem.type) %}
{% set typeIcon = plan_item_type_icon('allocation', allocationItem.type) %}
<tr>
<td class="text-center">
<td class="plan-col-pictogram text-center">
{% if typeIcon %}<i class="{{ typeIcon }} plan-item-type-icon" style="font-size: 24px;" aria-hidden="true"></i>{% endif %}
</td>
<td{% if typeDescription %} title="{{ typeDescription }}"{% endif %}>
<td class="plan-col-type"{% if typeDescription %} title="{{ typeDescription }}" data-toggle="tooltip"{% endif %}>
{{ typeName ?? 'mautic.plan.description_item.type.unknown'|trans({'%key%': allocationItem.type}) }}
</td>
<td>{{ allocationItem.name }}</td>
<td class="visible-md visible-lg text-muted" style="white-space: pre-wrap;">{{ allocationItem.description }}</td>
<td class="text-right text-nowrap">
<td class="plan-col-name">{{ allocationItem.name }}</td>
<td class="plan-col-description text-muted" style="white-space: pre-wrap;">{{ allocationItem.description|plan_linkify }}</td>
<td class="plan-col-cost text-right text-nowrap">
{% if allocationItem.plannedCost is not null %}{{ plan_money(allocationItem.plannedCost) }} {{ plan_currency() }}{% endif %}
</td>
<td class="text-right text-nowrap">
<td class="plan-col-cost text-right text-nowrap">
{% if allocationItem.realCost is not null %}{{ plan_money(allocationItem.realCost) }} {{ plan_currency() }}{% endif %}
</td>
</tr>
@@ -269,10 +309,10 @@
<tfoot>
<tr class="plan-allocation-total">
<th colspan="4">{{ 'mautic.plan.allocation.total'|trans }}</th>
<th class="text-right text-nowrap">
<th class="plan-col-cost text-right text-nowrap">
{% if allocationTotals.planned is not null %}{{ plan_money(allocationTotals.planned) }} {{ plan_currency() }}{% endif %}
</th>
<th class="text-right text-nowrap">
<th class="plan-col-cost text-right text-nowrap">
{% if allocationTotals.real is not null %}{{ plan_money(allocationTotals.real) }} {{ plan_currency() }}{% endif %}
</th>
</tr>
@@ -282,9 +322,120 @@
{% endif %}
</div>
{# Targets #}
{# Stakeholders: the plan's links to the global directory, harmonized like the other tabs. #}
<div class="tab-pane bdr-w-0" id="plan-tab-stakeholders" role="tabpanel">
{% set stakeholders = item.stakeholders %}
{% if stakeholders is empty %}
<p class="text-muted">{{ 'mautic.plan.stakeholder.empty'|trans }}</p>
{% else %}
{# Harmonized columns: Pictogram (no label), Type, Name, then the link's own fields.
Filter + click-to-sort (plan.js). #}
{{ include('@Plan/Plan/_tab_table_filter.html.twig') }}
<div class="table-responsive">
<table class="table table-hover plan-tab-table plan-stakeholders-view"
data-plan-tab-table data-empty-text="{{ 'mautic.plan.filter.no_match'|trans }}" data-sort-hint="{{ 'mautic.plan.filter.sort_hint'|trans }}">
<thead>
<tr>
<th class="plan-col-pictogram" aria-label="{{ 'mautic.plan.stakeholder.field.pictogram'|trans }}"></th>
<th class="plan-col-type">{{ 'mautic.plan.stakeholder.field.type'|trans }}</th>
<th class="plan-col-name">{{ 'mautic.plan.stakeholder.field.name'|trans }}</th>
<th class="plan-col-role">{{ 'mautic.plan.stakeholder.field.role_in_plan'|trans }}</th>
<th class="plan-col-role">{{ 'mautic.plan.stakeholder.field.role'|trans }}</th>
<th class="plan-col-email">{{ 'mautic.plan.stakeholder.field.email'|trans }}</th>
<th class="plan-col-phone">{{ 'mautic.plan.stakeholder.field.phone'|trans }}</th>
<th class="plan-col-active">{{ 'mautic.plan.stakeholder.field.active'|trans }}</th>
</tr>
</thead>
<tbody>
{% for link in stakeholders %}
{% set stakeholder = link.stakeholder %}
<tr>
<td class="plan-col-pictogram text-center">
{% set typeIcon = plan_item_type_icon('stakeholder', stakeholder.type) %}
{% if typeIcon %}<i class="{{ typeIcon }} plan-item-type-icon" style="font-size: 24px;" aria-hidden="true"></i>{% endif %}
</td>
<td class="plan-col-type"{% if plan_item_type_description('stakeholder', stakeholder.type) %} title="{{ plan_item_type_description('stakeholder', stakeholder.type) }}" data-toggle="tooltip"{% endif %}>
{{ plan_item_type_name('stakeholder', stakeholder.type) ?? 'mautic.plan.description_item.type.unknown'|trans({'%key%': stakeholder.type}) }}
</td>
<td class="plan-col-name">
<a href="{{ path('plan_stakeholder_action', {'objectAction': 'view', 'objectId': stakeholder.id}) }}" data-toggle="ajax">{{ stakeholder.name }}</a>
</td>
<td class="plan-col-role">{{ link.roleInPlan }}</td>
<td class="plan-col-role text-muted">{{ stakeholder.role }}</td>
<td class="plan-col-email">
{% if stakeholder.email %}<a href="mailto:{{ stakeholder.email }}">{{ stakeholder.email }}</a>{% endif %}
</td>
<td class="plan-col-phone text-nowrap">
{% if stakeholder.phone %}<a href="tel:{{ stakeholder.phone|replace({' ': ''}) }}">{{ stakeholder.phone }}</a>{% endif %}
</td>
<td class="plan-col-active">
<span class="label {{ stakeholder.isPublished ? 'label-success' : 'label-gray' }}">
{{ (stakeholder.isPublished ? 'mautic.plan.stakeholder.active' : 'mautic.plan.stakeholder.inactive')|trans }}
</span>
</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
{% endif %}
</div>
{# Targets: the plan's audiences, harmonized like the other tabs. #}
<div class="tab-pane bdr-w-0" id="plan-tab-targets" role="tabpanel">
<p class="text-muted">{{ 'mautic.plan.target.empty'|trans }}</p>
{% set targets = item.targets %}
{% if targets is empty %}
<p class="text-muted">{{ 'mautic.plan.target.empty'|trans }}</p>
{% else %}
{# Harmonized columns: Pictogram (no label, fixed per target type), Type, Name, then the
target's own fields. Filter + click-to-sort (plan.js). #}
{{ include('@Plan/Plan/_tab_table_filter.html.twig') }}
<div class="table-responsive">
<table class="table table-hover plan-tab-table plan-targets-view"
data-plan-tab-table data-empty-text="{{ 'mautic.plan.filter.no_match'|trans }}" data-sort-hint="{{ 'mautic.plan.filter.sort_hint'|trans }}">
<thead>
<tr>
<th class="plan-col-pictogram" aria-label="{{ 'mautic.plan.target.field.pictogram'|trans }}"></th>
<th class="plan-col-type">{{ 'mautic.plan.target.field.type'|trans }}</th>
<th class="plan-col-name">{{ 'mautic.plan.target.field.name'|trans }}</th>
<th class="plan-col-priority">{{ 'mautic.plan.target.field.priority'|trans }}</th>
<th class="plan-col-stages">{{ 'mautic.plan.target.field.stages'|trans }}</th>
<th class="plan-col-size text-right">{{ 'mautic.plan.target.field.estimated_size'|trans }}</th>
<th class="plan-col-description">{{ 'mautic.plan.target.field.profile_criteria'|trans }}</th>
<th class="plan-col-description">{{ 'mautic.plan.target.field.pain_points'|trans }}</th>
<th class="plan-col-description">{{ 'mautic.plan.target.field.value_proposition'|trans }}</th>
<th class="plan-col-channels">{{ 'mautic.plan.target.field.preferred_channels'|trans }}</th>
</tr>
</thead>
<tbody>
{% for target in targets %}
<tr>
<td class="plan-col-pictogram text-center">
<i class="{{ target.targetType.icon }} plan-item-type-icon" style="font-size: 24px;" aria-hidden="true"></i>
</td>
<td class="plan-col-type">{{ target.targetType.labelKey|trans }}</td>
<td class="plan-col-name">{{ target.name }}</td>
<td class="plan-col-priority">
<span class="label {{ target.priority.labelClass }}">{{ target.priority.labelKey|trans }}</span>
</td>
<td class="plan-col-stages text-muted">
{{ target.stages|map(stage => stage.name)|join(', ') }}
</td>
<td class="plan-col-size text-right text-nowrap">{{ target.estimatedSize }}</td>
<td class="plan-col-description text-muted" style="white-space: pre-wrap;">{{ target.profileCriteria }}</td>
<td class="plan-col-description text-muted" style="white-space: pre-wrap;">{{ target.painPoints }}</td>
<td class="plan-col-description text-muted" style="white-space: pre-wrap;">{{ target.valueProposition }}</td>
<td class="plan-col-channels">
{% for channel in target.preferredChannels ?? [] %}
<span class="label label-default">{{ plan_target_channel_label(channel)|trans }}</span>
{% endfor %}
</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
{% endif %}
</div>
{# Tasks: same columns as Planning > Tasks, in tree order. #}
+90 -6
View File
@@ -39,9 +39,23 @@
{% macro objective_row(objective) %}
{{ _self.row_start('mautic.plan.objective.drag') }}
<div class="row">
{# The selected type's pictogram; updated by plan.js when the type changes. #}
<div class="col-xs-1 text-center pt-lg">
<i class="plan-item-type-icon {{ plan_item_type_icon('objective', objective.type.vars.value) }}" style="font-size: 28px;" aria-hidden="true"></i>
</div>
<div class="col-xs-11">
{{ form_row(objective.type) }}
{# Filled with the selected type's description by plan.js. #}
<p class="help-block plan-item-type-help">{{ plan_item_type_description('objective', objective.type.vars.value) }}</p>
</div>
</div>
{{ form_row(objective.title) }}
<div class="row">
<div class="col-md-6">{{ form_row(objective.priority) }}</div>
<div class="col-md-6">{{ form_row(objective.isAchieved) }}</div>
</div>
{{ form_row(objective.description) }}
{{ form_row(objective.isAchieved) }}
{{ form_widget(objective.position) }}
{{ _self.row_end('mautic.plan.objective.remove') }}
{% endmacro %}
@@ -64,6 +78,33 @@
{{ _self.row_end('mautic.plan.description_item.remove') }}
{% endmacro %}
{% macro stakeholder_row(link) %}
{{ _self.row_start('mautic.plan.stakeholder.drag') }}
<div class="row">
<div class="col-md-6">{{ form_row(link.stakeholder) }}</div>
<div class="col-md-6">{{ form_row(link.roleInPlan) }}</div>
</div>
{{ form_widget(link.position) }}
{{ _self.row_end('mautic.plan.stakeholder.remove') }}
{% endmacro %}
{% macro target_row(target) %}
{{ _self.row_start('mautic.plan.target.drag') }}
{{ form_row(target.name) }}
<div class="row">
<div class="col-md-4">{{ form_row(target.targetType) }}</div>
<div class="col-md-4">{{ form_row(target.priority) }}</div>
<div class="col-md-4">{{ form_row(target.estimatedSize) }}</div>
</div>
{{ form_row(target.stages) }}
{{ form_row(target.profileCriteria) }}
{{ form_row(target.painPoints) }}
{{ form_row(target.valueProposition) }}
{{ form_row(target.preferredChannels) }}
{{ form_widget(target.position) }}
{{ _self.row_end('mautic.plan.target.remove') }}
{% endmacro %}
{% macro allocation_item_row(item) %}
{{ _self.row_start('mautic.plan.allocation_item.drag') }}
<div class="row">
@@ -152,10 +193,14 @@
{# Objectives #}
<div class="tab-pane bdr-w-0" id="plan-tab-objectives" role="tabpanel">
{% set hasObjectiveTypes = form.objectives.vars.prototype.type.vars.choices is not empty %}
<div class="plan-collection plan-objectives"
data-prototype="{{ _self.objective_row(form.objectives.vars.prototype)|e('html_attr') }}"
data-prototype-name="__objective__">
{{ form_errors(form.objectives) }}
{% if not hasObjectiveTypes %}
<div class="alert alert-info">{{ 'mautic.plan.objective.no_types'|trans }}</div>
{% endif %}
<p class="text-muted plan-collection-empty{% if form.objectives|length > 0 %} hide{% endif %}">
{{ 'mautic.plan.objective.empty'|trans }}
</p>
@@ -164,9 +209,11 @@
{{ _self.objective_row(objective) }}
{% endfor %}
</ul>
<button type="button" class="btn btn-ghost plan-collection-add">
<i class="ri-add-line"></i> {{ 'mautic.plan.objective.add'|trans }}
</button>
{% if hasObjectiveTypes %}
<button type="button" class="btn btn-ghost plan-collection-add">
<i class="ri-add-line"></i> {{ 'mautic.plan.objective.add'|trans }}
</button>
{% endif %}
</div>
{% do form.objectives.setRendered %}
</div>
@@ -203,9 +250,46 @@
{% do form.allocationItems.setRendered %}
</div>
{# Targets #}
{# Stakeholders: links to the global directory (Planning > Stakeholders). #}
<div class="tab-pane bdr-w-0" id="plan-tab-stakeholders" role="tabpanel">
<div class="plan-collection plan-stakeholders"
data-prototype="{{ _self.stakeholder_row(form.stakeholders.vars.prototype)|e('html_attr') }}"
data-prototype-name="__stakeholder__">
{{ form_errors(form.stakeholders) }}
<p class="text-muted plan-collection-empty{% if form.stakeholders|length > 0 %} hide{% endif %}">
{{ 'mautic.plan.stakeholder.empty'|trans }}
</p>
<ul class="list-group plan-collection-list">
{% for link in form.stakeholders %}
{{ _self.stakeholder_row(link) }}
{% endfor %}
</ul>
<button type="button" class="btn btn-ghost plan-collection-add">
<i class="ri-add-line"></i> {{ 'mautic.plan.stakeholder.add'|trans }}
</button>
</div>
{% do form.stakeholders.setRendered %}
</div>
{# Targets: the plan's audiences. #}
<div class="tab-pane bdr-w-0" id="plan-tab-targets" role="tabpanel">
<p class="text-muted">{{ 'mautic.plan.target.empty'|trans }}</p>
<div class="plan-collection plan-targets"
data-prototype="{{ _self.target_row(form.targets.vars.prototype)|e('html_attr') }}"
data-prototype-name="__target__">
{{ form_errors(form.targets) }}
<p class="text-muted plan-collection-empty{% if form.targets|length > 0 %} hide{% endif %}">
{{ 'mautic.plan.target.empty'|trans }}
</p>
<ul class="list-group plan-collection-list">
{% for target in form.targets %}
{{ _self.target_row(target) }}
{% endfor %}
</ul>
<button type="button" class="btn btn-ghost plan-collection-add">
<i class="ri-add-line"></i> {{ 'mautic.plan.target.add'|trans }}
</button>
</div>
{% do form.targets.setRendered %}
</div>
{# Tasks: read-only here, so that following a link doesn't drop unsaved changes to the plan. #}
@@ -0,0 +1,99 @@
{% extends '@MauticCore/Default/content.html.twig' %}
{% block mauticContent %}planStakeholder{% endblock %}
{% block preHeader %}
{{- include('@MauticCore/Helper/page_actions.html.twig', {
'item': item,
'templateButtons': {
'close': true,
},
'closeUrl': path('plan_stakeholder_index'),
'targetLabel': 'mautic.plan.stakeholder.header.index'|trans,
}) -}}
{% endblock %}
{% block headerTitle %}{{ item.name }}{% endblock %}
{% block publishStatus %}
{% include '@MauticCore/Helper/_tag.html.twig' with { tags: [{
color: item.isPublished ? 'green' : 'cool-gray',
label: (item.isPublished ? 'mautic.plan.stakeholder.active' : 'mautic.plan.stakeholder.inactive')|trans,
icon: item.isPublished ? 'ri-checkbox-circle-line' : 'ri-time-line',
attributes: {'class': 'plan-stakeholder-status-tag'},
}] } %}
{% endblock %}
{% block actions %}
{{- include('@MauticCore/Helper/page_actions.html.twig', {
'item': item,
'templateButtons': {
'edit': securityHasEntityAccess(permissions['plan:stakeholders:editown'], permissions['plan:stakeholders:editother'], item.createdBy),
'delete': securityHasEntityAccess(permissions['plan:stakeholders:deleteown'], permissions['plan:stakeholders:deleteother'], item.createdBy),
},
'langVar': 'plan.stakeholder',
}) -}}
{% endblock %}
{% block content %}
<div class="pa-md">
<table class="table table-hover mb-md plan-stakeholder-details">
<tbody>
<tr>
<td class="col-md-3 text-muted">{{ 'mautic.plan.stakeholder.field.type'|trans }}</td>
<td>
{% set typeIcon = plan_item_type_icon('stakeholder', item.type) %}
{% if typeIcon %}<i class="{{ typeIcon }} plan-item-type-icon" style="font-size: 24px;" aria-hidden="true"></i> {% endif %}
{{ plan_item_type_name('stakeholder', item.type) ?? 'mautic.plan.description_item.type.unknown'|trans({'%key%': item.type}) }}
</td>
</tr>
<tr>
<td class="text-muted">{{ 'mautic.plan.stakeholder.field.role'|trans }}</td>
<td>{{ item.role|default('mautic.plan.value.none'|trans) }}</td>
</tr>
<tr>
<td class="text-muted">{{ 'mautic.plan.stakeholder.field.email'|trans }}</td>
<td>{% if item.email %}<a href="mailto:{{ item.email }}">{{ item.email }}</a>{% else %}{{ 'mautic.plan.value.none'|trans }}{% endif %}</td>
</tr>
<tr>
<td class="text-muted">{{ 'mautic.plan.stakeholder.field.phone'|trans }}</td>
<td>{% if item.phone %}<a href="tel:{{ item.phone|replace({' ': ''}) }}">{{ item.phone }}</a>{% else %}{{ 'mautic.plan.value.none'|trans }}{% endif %}</td>
</tr>
<tr>
<td class="text-muted">{{ 'mautic.core.created'|trans }}</td>
<td>{{ item.dateAdded ? dateToFull(item.dateAdded) : '' }}{% if item.createdByUser %} ({{ item.createdByUser }}){% endif %}</td>
</tr>
<tr>
<td class="text-muted">{{ 'mautic.core.id'|trans }}</td>
<td>{{ item.id }}</td>
</tr>
</tbody>
</table>
<h4 class="mb-sm">{{ 'mautic.plan.stakeholder.field.plans'|trans }}</h4>
{% if item.planLinks is empty %}
<p class="text-muted">{{ 'mautic.plan.stakeholder.no_plans'|trans }}</p>
{% else %}
<div class="table-responsive">
<table class="table table-hover plan-stakeholder-plans-view">
<thead>
<tr>
<th>{{ 'mautic.plan.field.name'|trans }}</th>
<th>{{ 'mautic.plan.stakeholder.field.role_in_plan'|trans }}</th>
<th>{{ 'mautic.plan.field.status'|trans }}</th>
</tr>
</thead>
<tbody>
{% for link in item.planLinks %}
<tr>
<td><a href="{{ path('plan_action', {'objectAction': 'view', 'objectId': link.plan.id}) }}" data-toggle="ajax">{{ link.plan.name }}</a></td>
<td class="text-muted">{{ link.roleInPlan|default('—') }}</td>
<td><span class="label {{ link.plan.status.labelClass }}">{{ link.plan.status.labelKey|trans }}</span></td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
{% endif %}
</div>
{% endblock %}
@@ -0,0 +1,43 @@
{% extends '@MauticCore/Default/content.html.twig' %}
{% block mauticContent %}planStakeholder{% endblock %}
{% block headerTitle %}
{% if entity.id %}
{{ 'mautic.plan.stakeholder.header.edit'|trans({'%name%': entity.name}) }}
{% else %}
{{ 'mautic.plan.stakeholder.header.new'|trans }}
{% endif %}
{% endblock %}
{% block content %}
{{ form_start(form) }}
<div class="box-layout">
<div class="col-md-9 height-auto bdr-r">
<div class="pa-md">
{{ form_row(form.name) }}
<div class="row">
{# The selected type's pictogram; updated by plan.js when the type changes. #}
<div class="col-xs-1 text-center pt-lg">
<i class="plan-item-type-icon {{ plan_item_type_icon('stakeholder', form.type.vars.value) }}" style="font-size: 28px;" aria-hidden="true"></i>
</div>
<div class="col-xs-11">
{{ form_row(form.type) }}
{# Filled with the selected type's description by plan.js. #}
<p class="help-block plan-item-type-help">{{ plan_item_type_description('stakeholder', form.type.vars.value) }}</p>
</div>
</div>
{{ form_row(form.role) }}
</div>
</div>
<div class="col-md-3 height-auto">
<div class="pr-lg pl-lg pt-md pb-md">
{{ form_row(form.isPublished) }}
{{ form_row(form.email) }}
{{ form_row(form.phone) }}
<p class="text-muted small">{{ 'mautic.plan.stakeholder.phone.help'|trans }}</p>
</div>
</div>
</div>
{{ form_end(form) }}
{% endblock %}
+169
View File
@@ -0,0 +1,169 @@
{% set isIndex = 'index' == tmpl ? true : false %}
{% set tmpl = 'list' %}
{% extends isIndex ? '@MauticCore/Default/content.html.twig' : '@MauticCore/Default/raw_output.html.twig' %}
{% block mauticContent %}planStakeholder{% endblock %}
{% block headerTitle %}{{ 'mautic.plan.stakeholder.header.index'|trans }}{% endblock %}
{% block content %}
<div id="page-list-wrapper" class="{% if items|length > 0 or searchValue is not empty %}panel {% endif %}panel-default">
{{- include('@MauticCore/Helper/list_toolbar.html.twig', {
'searchValue': searchValue,
'action': currentRoute,
'page_actions': {
'templateButtons': {
'new': permissions['plan:stakeholders:create'],
},
'langVar': 'plan.stakeholder',
},
'bulk_actions': {
'langVar': 'plan.stakeholder',
'templateButtons': {
'delete': permissions['plan:stakeholders:deleteown'] or permissions['plan:stakeholders:deleteother'],
},
},
}) -}}
<div class="page-list">
{% if items is defined and items is not empty %}
<div class="table-responsive">
<table class="table table-hover" id="planStakeholderTable">
<thead>
<tr>
{{ include('@MauticCore/Helper/tableheader.html.twig', {
'checkall': 'true',
'target': '#planStakeholderTable',
}) }}
{# Columns: ID, Pictogram, Type, Name, Role, Email, Phone, Active, Assigned plans. #}
{{ include('@MauticCore/Helper/tableheader.html.twig', {
'sessionVar': 'plan.stakeholder',
'orderBy': 's.id',
'text': 'mautic.core.id',
'class': 'col-plan-stakeholder-id',
}) }}
{{ include('@MauticCore/Helper/tableheader.html.twig', {
'sessionVar': 'plan.stakeholder',
'text': 'mautic.plan.stakeholder.field.pictogram',
'class': 'col-plan-stakeholder-pictogram',
}) }}
{{ include('@MauticCore/Helper/tableheader.html.twig', {
'sessionVar': 'plan.stakeholder',
'orderBy': 's.type',
'text': 'mautic.plan.stakeholder.field.type',
'class': 'col-plan-stakeholder-type',
}) }}
{{ include('@MauticCore/Helper/tableheader.html.twig', {
'sessionVar': 'plan.stakeholder',
'orderBy': 's.name',
'text': 'mautic.plan.stakeholder.field.name',
'class': 'col-plan-stakeholder-name',
'default': true,
}) }}
{{ include('@MauticCore/Helper/tableheader.html.twig', {
'sessionVar': 'plan.stakeholder',
'orderBy': 's.role',
'text': 'mautic.plan.stakeholder.field.role',
'class': 'visible-md visible-lg col-plan-stakeholder-role',
}) }}
{{ include('@MauticCore/Helper/tableheader.html.twig', {
'sessionVar': 'plan.stakeholder',
'orderBy': 's.email',
'text': 'mautic.plan.stakeholder.field.email',
'class': 'col-plan-stakeholder-email',
}) }}
{{ include('@MauticCore/Helper/tableheader.html.twig', {
'sessionVar': 'plan.stakeholder',
'text': 'mautic.plan.stakeholder.field.phone',
'class': 'col-plan-stakeholder-phone',
}) }}
{{ include('@MauticCore/Helper/tableheader.html.twig', {
'sessionVar': 'plan.stakeholder',
'orderBy': 's.isPublished',
'text': 'mautic.plan.stakeholder.field.active',
'class': 'col-plan-stakeholder-active',
}) }}
{{ include('@MauticCore/Helper/tableheader.html.twig', {
'sessionVar': 'plan.stakeholder',
'text': 'mautic.plan.stakeholder.field.plans',
'class': 'visible-md visible-lg col-plan-stakeholder-plans',
}) }}
</tr>
</thead>
<tbody>
{% for item in items %}
{% set canEdit = securityHasEntityAccess(permissions['plan:stakeholders:editown'], permissions['plan:stakeholders:editother'], item.createdBy) %}
<tr>
<td>
{{- include('@MauticCore/Helper/list_actions.html.twig', {
'item': item,
'templateButtons': {
'edit': canEdit,
'delete': securityHasEntityAccess(permissions['plan:stakeholders:deleteown'], permissions['plan:stakeholders:deleteother'], item.createdBy),
},
'langVar': 'plan.stakeholder',
}) -}}
</td>
<td>{{ item.id }}</td>
<td class="text-center">
{% set typeIcon = plan_item_type_icon('stakeholder', item.type) %}
{% if typeIcon %}<i class="{{ typeIcon }} plan-item-type-icon" style="font-size: 24px;" aria-hidden="true"></i>{% endif %}
</td>
<td{% if plan_item_type_description('stakeholder', item.type) %} title="{{ plan_item_type_description('stakeholder', item.type) }}"{% endif %}>
{{ plan_item_type_name('stakeholder', item.type) ?? 'mautic.plan.description_item.type.unknown'|trans({'%key%': item.type}) }}
</td>
<td>
{% if canEdit %}
<a href="{{ path('plan_stakeholder_action', {'objectAction': 'edit', 'objectId': item.id}) }}" data-toggle="ajax">{{ item.name }}</a>
{% else %}
{{ item.name }}
{% endif %}
</td>
<td class="visible-md visible-lg text-muted">{{ item.role }}</td>
<td>
{% if item.email %}<a href="mailto:{{ item.email }}">{{ item.email }}</a>{% endif %}
</td>
<td class="text-nowrap">
{% if item.phone %}<a href="tel:{{ item.phone|replace({' ': ''}) }}">{{ item.phone }}</a>{% endif %}
</td>
<td>
<span class="label {{ item.isPublished ? 'label-success' : 'label-gray' }}">
{{ (item.isPublished ? 'mautic.plan.stakeholder.active' : 'mautic.plan.stakeholder.inactive')|trans }}
</span>
</td>
<td class="visible-md visible-lg">
{# The plans this stakeholder is assigned to, through their Stakeholders tab. #}
{% set plans = item.planLinks|default([]) %}
{% for link in plans %}
<a href="{{ path('plan_action', {'objectAction': 'view', 'objectId': link.plan.id}) }}" data-toggle="ajax">{{ link.plan.name }}</a>{% if link.roleInPlan %} <span class="text-muted small">({{ link.roleInPlan }})</span>{% endif %}{% if not loop.last %}, {% endif %}
{% else %}
<span class="text-muted">{{ 'mautic.plan.stakeholder.no_plans'|trans }}</span>
{% endfor %}
</td>
</tr>
{% endfor %}
</tbody>
</table>
<div class="panel-footer">
{{- include('@MauticCore/Helper/pagination.html.twig', {
'totalItems': totalItems,
'page': page,
'limit': limit,
'baseUrl': path('plan_stakeholder_index'),
'sessionVar': 'plan.stakeholder',
}) -}}
</div>
</div>
{% elseif searchValue is not empty %}
{{ include('@MauticCore/Helper/noresults.html.twig') }}
{% else %}
<div class="mt-80 col-md-offset-2 col-lg-offset-3 col-md-8 col-lg-5 height-auto">
{{ include('@MauticCore/Components/content-block.html.twig', {
'heading': 'mautic.plan.stakeholder.onboarding.heading',
'subheading': 'mautic.plan.stakeholder.onboarding.subheading',
'copy': 'mautic.plan.stakeholder.onboarding.copy',
}) }}
</div>
{% endif %}
</div>
</div>
{% endblock %}
+11
View File
@@ -16,6 +16,17 @@
<div class="col-md-9 height-auto bdr-r">
<div class="pa-md">
{{ form_row(form.name) }}
<div class="row">
{# The selected type's pictogram; updated by plan.js when the type changes. #}
<div class="col-xs-1 text-center pt-lg">
<i class="plan-item-type-icon {{ plan_item_type_icon('task', form.type.vars.value) }}" style="font-size: 28px;" aria-hidden="true"></i>
</div>
<div class="col-xs-11">
{{ form_row(form.type) }}
{# Filled with the selected type's description by plan.js. #}
<p class="help-block plan-item-type-help">{{ plan_item_type_description('task', form.type.vars.value) }}</p>
</div>
</div>
{{ form_row(form.description) }}
</div>
</div>
+20 -2
View File
@@ -34,13 +34,24 @@
'checkall': 'true',
'target': '#planTaskTable',
}) }}
{# Columns: ID, Name, Description, Start date, End date, Status. #}
{# Columns: ID, Pictogram, Type, Name, Description, Start date, End date, Status. #}
{{ include('@MauticCore/Helper/tableheader.html.twig', {
'sessionVar': 'plan.task',
'orderBy': 't.id',
'text': 'mautic.core.id',
'class': 'col-plan-task-id',
}) }}
{{ include('@MauticCore/Helper/tableheader.html.twig', {
'sessionVar': 'plan.task',
'text': 'mautic.plan.task.field.pictogram',
'class': 'col-plan-task-pictogram',
}) }}
{{ include('@MauticCore/Helper/tableheader.html.twig', {
'sessionVar': 'plan.task',
'orderBy': 't.type',
'text': 'mautic.plan.task.field.type',
'class': 'col-plan-task-type',
}) }}
{{ include('@MauticCore/Helper/tableheader.html.twig', {
'sessionVar': 'plan.task',
'orderBy': 't.name',
@@ -88,6 +99,13 @@
}) -}}
</td>
<td>{{ item.id }}</td>
<td class="text-center">
{% set typeIcon = plan_item_type_icon('task', item.type) %}
{% if typeIcon %}<i class="{{ typeIcon }} plan-item-type-icon" style="font-size: 24px;" aria-hidden="true"></i>{% endif %}
</td>
<td{% if plan_item_type_description('task', item.type) %} title="{{ plan_item_type_description('task', item.type) }}"{% endif %}>
{{ plan_item_type_name('task', item.type) ?? 'mautic.plan.description_item.type.unknown'|trans({'%key%': item.type}) }}
</td>
<td>
{% if canEdit %}
<a href="{{ path('plan_task_action', {'objectAction': 'edit', 'objectId': item.id}) }}" data-toggle="ajax">{{ item.name }}</a>
@@ -97,7 +115,7 @@
</td>
<td class="visible-md visible-lg text-muted">
{% set description = item.description|default('')|striptags|trim %}
{{ description|length > 120 ? description|slice(0, 120) ~ '…' : description }}
{{ (description|length > 120 ? description|slice(0, 120) ~ '…' : description)|plan_linkify }}
</td>
<td>{{ item.startDate ? dateToFull(item.startDate) : '' }}</td>
<td>{{ item.endDate ? dateToFull(item.endDate) : '' }}</td>
+4 -2
View File
@@ -8,8 +8,8 @@ use Mautic\CoreBundle\Security\Permissions\AbstractPermissions;
use Symfony\Component\Form\FormBuilderInterface;
/**
* Permission keys: plan:plans:* and plan:tasks:* (view/edit/delete/publish own and other, create, full),
* and plan:categories:* (managing the "plan" category type).
* Permission keys: plan:plans:*, plan:tasks:* and plan:stakeholders:* (view/edit/delete/publish own and
* other, create, full), and plan:categories:* (managing the "plan" category type).
*
* Shown under Settings > Roles. Core discovers this class from Security/Permissions/.
*/
@@ -25,6 +25,7 @@ class PlanPermissions extends AbstractPermissions
$this->addStandardPermissions('categories');
$this->addExtendedPermissions('plans');
$this->addExtendedPermissions('tasks');
$this->addExtendedPermissions('stakeholders');
}
public function getName(): string
@@ -41,5 +42,6 @@ class PlanPermissions extends AbstractPermissions
$this->addStandardFormFields('plan', 'categories', $builder, $data);
$this->addExtendedFormFields('plan', 'plans', $builder, $data);
$this->addExtendedFormFields('plan', 'tasks', $builder, $data);
$this->addExtendedFormFields('plan', 'stakeholders', $builder, $data);
}
}
+11 -3
View File
@@ -9,10 +9,12 @@ use Mautic\CoreBundle\Helper\LanguageHelper;
use Symfony\Contracts\Translation\TranslatorInterface;
/**
* Reads the item types set up in Settings > Configuration > Plan. There is one list of types per kind of
* plan item:
* Reads the item types set up in Settings > Configuration > Plan. There is one list of types per kind:
* - KIND_DESCRIPTION: types of description items (Description tab), parameter plan_description_item_types;
* - KIND_ALLOCATION: types of allocation items (Allocation tab), parameter plan_allocation_item_types.
* - KIND_ALLOCATION: types of allocation items (Allocation tab), parameter plan_allocation_item_types;
* - KIND_OBJECTIVE: types of objectives (Objectives tab), parameter plan_objective_types;
* - KIND_TASK: types of tasks (Planning > Tasks and the plan's Tasks tab), parameter plan_task_types;
* - KIND_STAKEHOLDER: types of stakeholders (Planning > Stakeholders), parameter plan_stakeholder_types.
*
* Each list is stored in local.php, in display order:
*
@@ -30,6 +32,9 @@ class ItemTypeProvider
{
public const KIND_DESCRIPTION = 'description';
public const KIND_ALLOCATION = 'allocation';
public const KIND_OBJECTIVE = 'objective';
public const KIND_TASK = 'task';
public const KIND_STAKEHOLDER = 'stakeholder';
/**
* Kind => local.php parameter.
@@ -37,6 +42,9 @@ class ItemTypeProvider
public const PARAMETERS = [
self::KIND_DESCRIPTION => 'plan_description_item_types',
self::KIND_ALLOCATION => 'plan_allocation_item_types',
self::KIND_OBJECTIVE => 'plan_objective_types',
self::KIND_TASK => 'plan_task_types',
self::KIND_STAKEHOLDER => 'plan_stakeholder_types',
];
public function __construct(
+97 -3
View File
@@ -5,14 +5,93 @@ mautic.plan.menu.index="Plans"
mautic.plan.tab.details="Details"
mautic.plan.tab.description="Description"
mautic.plan.tab.objectives="Objectives"
mautic.plan.tab.allocation="Allocation"
mautic.plan.tab.allocations="Allocations"
mautic.plan.tab.targets="Targets"
mautic.plan.tab.stakeholders="Stakeholders"
mautic.plan.tab.tasks="Tasks"
mautic.plan.value.none="None"
mautic.plan.target.empty="No targets yet."
mautic.plan.task.empty="No tasks yet."
; Stakeholders (the global directory, Planning > Stakeholders, and the plan's Stakeholders tab).
mautic.plan.field.stakeholders="Stakeholders"
mautic.plan.stakeholder.menu.index="Stakeholders"
mautic.plan.stakeholder.header.index="Stakeholders"
mautic.plan.stakeholder.header.new="New stakeholder"
mautic.plan.stakeholder.header.edit="Edit stakeholder - %name%"
mautic.plan.stakeholder.error.notfound="No stakeholder with the ID %id% was found."
mautic.plan.stakeholder.form.confirmdelete="Delete the stakeholder, %name%? Its links to the plans are deleted too."
mautic.plan.stakeholder.form.confirmbatchdelete="Delete the selected stakeholders? Their links to the plans are deleted too."
mautic.plan.stakeholder.onboarding.heading="No stakeholders yet"
mautic.plan.stakeholder.onboarding.subheading="Stakeholders are the people, companies and teams involved in your plans."
mautic.plan.stakeholder.onboarding.copy="Use the New button above to add a stakeholder to the directory. Then assign it to a plan from the plan's Stakeholders tab, with its role in that plan."
mautic.plan.stakeholder.field.pictogram="Pictogram"
mautic.plan.stakeholder.field.name="Name"
mautic.plan.stakeholder.field.email="Email"
mautic.plan.stakeholder.field.phone="Phone"
mautic.plan.stakeholder.field.role="Role"
mautic.plan.stakeholder.field.type="Type"
mautic.plan.stakeholder.field.active="Active"
mautic.plan.stakeholder.field.role_in_plan="Role in the plan"
mautic.plan.stakeholder.field.plans="Assigned plans"
mautic.plan.stakeholder.active="Active"
mautic.plan.stakeholder.inactive="Inactive"
mautic.plan.stakeholder.no_plans="Not assigned to any plan"
mautic.plan.stakeholder.add="Add stakeholder"
mautic.plan.stakeholder.remove="Remove stakeholder"
mautic.plan.stakeholder.drag="Drag to reorder"
mautic.plan.stakeholder.empty="No stakeholders assigned to this plan yet."
mautic.plan.stakeholder.phone.help="Typed without a country prefix, the number is read with the default region from Settings > Configuration > Plan Settings."
; Stakeholder types (Settings > Configuration > Plan Settings).
mautic.plan.config.section.stakeholder_types="Stakeholder types"
mautic.plan.config.section.stakeholder_types.help="The types offered for the stakeholders of the directory (Planning > Stakeholders), 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.stakeholder_phone_region="Default phone region"
mautic.plan.config.stakeholder_phone_region.tooltip="ISO country code (e.g. FR) used to read stakeholder phone numbers typed without a country prefix."
; Targets (the plan's Targets tab).
mautic.plan.field.targets="Targets"
mautic.plan.target.field.pictogram="Pictogram"
mautic.plan.target.field.name="Name"
mautic.plan.target.field.type="Type"
mautic.plan.target.field.priority="Priority"
mautic.plan.target.field.stages="Stages"
mautic.plan.target.field.estimated_size="Estimated size"
mautic.plan.target.field.profile_criteria="Profile criteria"
mautic.plan.target.field.pain_points="Pain points"
mautic.plan.target.field.value_proposition="Value proposition"
mautic.plan.target.field.preferred_channels="Preferred channels"
mautic.plan.target.add="Add target"
mautic.plan.target.remove="Remove target"
mautic.plan.target.drag="Drag to reorder"
mautic.plan.target.type.persona="Buyer Persona"
mautic.plan.target.type.icp="Account / ICP"
mautic.plan.target.type.broad_audience="Broad / Ad Audience"
mautic.plan.target.type.lifecycle_cohort="Lifecycle Cohort"
mautic.plan.target.type.partner_influencer="Partner / Influencer"
mautic.plan.target.priority.primary="Primary Target"
mautic.plan.target.priority.secondary="Secondary Target"
mautic.plan.target.priority.exclusion="Exclusion / Anti-Persona"
mautic.plan.target.channel.email="Email"
mautic.plan.target.channel.sms="SMS"
mautic.plan.target.channel.web="Web"
mautic.plan.target.channel.social_organic="Social organic"
mautic.plan.target.channel.paid_social="Paid social"
mautic.plan.target.channel.paid_search="Paid search"
mautic.plan.target.channel.events_webinar="Events / webinar"
mautic.plan.target.channel.outbound_sales="Outbound sales"
mautic.plan.target.channel.partners="Partners"
; Plan tab tables (detail page): filter box and click-to-sort headers.
mautic.plan.filter.placeholder="Filter…"
mautic.plan.filter.no_match="No rows match the filter."
mautic.plan.filter.sort_hint="Click to sort"
; Long description item texts, clamped to 10 lines (Description tab, detail page).
mautic.plan.read_more.more="Read more"
mautic.plan.read_more.less="Show less"
mautic.plan.header.index="Plans"
mautic.plan.header.new="New plan"
mautic.plan.header.edit="Edit plan - %name%"
@@ -46,6 +125,8 @@ 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.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.field.name="Name"
mautic.plan.task.field.type="Type"
mautic.plan.task.field.pictogram="Pictogram"
mautic.plan.task.field.description="Description"
mautic.plan.task.field.plan="Plan"
mautic.plan.task.field.parent="Parent task"
@@ -75,12 +156,17 @@ mautic.plan.field.description_items="Description items"
mautic.plan.field.allocation_items="Allocation items"
mautic.plan.objective.field.title="Title"
mautic.plan.objective.field.type="Type"
mautic.plan.objective.field.pictogram="Pictogram"
mautic.plan.objective.field.name="Name"
mautic.plan.objective.field.priority="Priority"
mautic.plan.objective.field.description="Description"
mautic.plan.objective.field.is_achieved="Achieved"
mautic.plan.objective.add="Add objective"
mautic.plan.objective.remove="Remove objective"
mautic.plan.objective.drag="Drag to reorder"
mautic.plan.objective.empty="No objectives yet."
mautic.plan.objective.no_types="No objective types are set up yet. An administrator can add them in Settings > Configuration > Plan Settings."
mautic.plan.objective.progress="%achieved% of %total% achieved"
mautic.plan.objective.achieved="Achieved"
mautic.plan.objective.not_achieved="Not achieved"
@@ -116,7 +202,7 @@ mautic.plan.config.type.language="Language"
mautic.plan.config.type.name="Name"
mautic.plan.config.type.description="Description"
; Allocation items (the plan's Allocation tab).
; Allocation items (the plan's Allocations tab).
mautic.plan.allocation_item.field.type="Type"
mautic.plan.allocation_item.field.pictogram="Pictogram"
mautic.plan.allocation_item.field.name="Name"
@@ -141,7 +227,15 @@ mautic.plan.task.subtask_of="Sub-task of %parent%"
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.help="The types offered for the cost lines of a plan's Allocation 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."
; Objective types (Settings > Configuration > Plan Settings).
mautic.plan.config.section.objective_types="Objective types"
mautic.plan.config.section.objective_types.help="The types offered for the objectives of a plan's Objectives 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."
; Task types (Settings > Configuration > Plan Settings).
mautic.plan.config.section.task_types="Task types"
mautic.plan.config.section.task_types.help="The types offered for tasks, 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.description_item.field.pictogram="Pictogram"
mautic.plan.config.section.general="General"
+8 -1
View File
@@ -2,10 +2,17 @@ mautic.plan.owner.required="An owner is required."
mautic.plan.end_date.before_start_date="The end date must be on or after the start date."
mautic.plan.version.range="The version must be a whole number from 1 to 99."
mautic.plan.objective.title.required="An objective needs a title."
mautic.plan.objective.type.required="Choose a type."
mautic.plan.objective.priority.range="The priority must be a whole number from 1 to 99."
mautic.plan.target.name.required="A target needs a name."
mautic.plan.target.estimated_size.invalid="The estimated size must be 0 or more."
mautic.plan.stakeholder.email.invalid="This email address is not valid."
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.type.required="Choose a type."
mautic.plan.task.parent.other_plan="The parent task must be in the same plan."
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.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.in_use="These types are used by description items and can't be removed: %types%. Change those items 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."
mautic.plan.allocation_item.type.required="Choose a type."
+73 -1
View File
@@ -4,18 +4,24 @@ declare(strict_types=1);
namespace MauticPlugin\PlanBundle\Twig;
use MauticPlugin\PlanBundle\Entity\Target;
use MauticPlugin\PlanBundle\Service\CurrencyProvider;
use MauticPlugin\PlanBundle\Service\ItemTypeProvider;
use Twig\Extension\AbstractExtension;
use Twig\TwigFilter;
use Twig\TwigFunction;
/**
* Twig functions for the plan templates (kind: "description" or "allocation"):
* Twig functions for the plan templates (kind: "description", "allocation", "objective" or "task"):
* plan_item_type_name(kind, key) localized type name, or null for an unknown key
* plan_item_type_description(kind, key) localized type description ('' when none)
* plan_item_type_icon(kind, key) the type's pictogram (Remix Icon class), or null
* plan_currency() the general currency code, e.g. EUR
* plan_money(amount) an amount with 2 decimals, e.g. 12,500.00
* plan_target_channel_label(key) the label key of a target channel, e.g. "Email"
*
* Filter:
* plan_linkify(text) plain text as HTML, with the URLs in it as links opening in a new tab
*/
class PlanExtension extends AbstractExtension
{
@@ -25,6 +31,14 @@ class PlanExtension extends AbstractExtension
) {
}
public function getFilters(): array
{
return [
// The filter escapes everything itself, so its output is safe for templates.
new TwigFilter('plan_linkify', fn (?string $text): string => self::linkify($text), ['is_safe' => ['html']]),
];
}
public function getFunctions(): array
{
return [
@@ -33,6 +47,64 @@ class PlanExtension extends AbstractExtension
new TwigFunction('plan_item_type_icon', fn (string $kind, ?string $key): ?string => $this->typeProvider->getIcon($kind, $key)),
new TwigFunction('plan_currency', fn (): string => $this->currencyProvider->getCurrency()),
new TwigFunction('plan_money', fn ($amount): string => number_format((float) $amount, 2)),
new TwigFunction('plan_target_channel_label', fn (string $key): string => Target::CHANNELS[$key] ?? $key),
new TwigFunction('plan_target_channel_label', fn (string $key): string => Target::CHANNELS[$key] ?? $key),
];
}
/**
* Plain text as HTML, with the URLs in it (https://… and www.…) turned into links that open in a
* new tab. For the description fields of plans and tasks, which stay plain text: typing or pasting
* a URL is enough, no editor needed. Everything is escaped here, so no HTML can be injected.
*/
public static function linkify(?string $text): string
{
if (null === $text || '' === $text) {
return '';
}
// One capture group: preg_split then alternates plain text (even) and URLs (odd).
$parts = preg_split('~((?:https?://|(?<![\w.])www\.)[^\s<>"\']+)~i', $text, -1, PREG_SPLIT_DELIM_CAPTURE);
$html = '';
foreach ($parts as $i => $part) {
$html .= $i % 2 ? self::urlAnchor($part) : htmlspecialchars($part, ENT_QUOTES, 'UTF-8');
}
return $html;
}
/**
* One URL as a link. Sentence punctuation that follows the URL (".", ")", "!", …) stays outside
* the link, and a bare "www." address gets the https:// prefix.
*/
private static function urlAnchor(string $url): string
{
$after = '';
while ('' !== $url && str_contains('.,;:!?', substr($url, -1))) {
$after = substr($url, -1).$after;
$url = substr($url, 0, -1);
}
// An unbalanced closing parenthesis belongs to the sentence, not the URL.
if (str_ends_with($url, ')') && !str_contains($url, '(')) {
$after = ')'.$after;
$url = substr($url, 0, -1);
}
// Only a prefix is left ("www.", "https://"): not a link after all.
if ('' === $url || 'www.' === $url || 'http://' === $url || 'https://' === $url) {
return htmlspecialchars($url.$after, ENT_QUOTES, 'UTF-8');
}
$href = preg_match('~^https?://~i', $url) ? $url : 'https://'.$url;
return sprintf(
'<a href="%s" target="_blank" rel="noopener noreferrer">%s</a>%s',
htmlspecialchars($href, ENT_QUOTES, 'UTF-8'),
htmlspecialchars($url, ENT_QUOTES, 'UTF-8'),
htmlspecialchars($after, ENT_QUOTES, 'UTF-8')
);
}
}
+34 -17
View File
@@ -10,15 +10,15 @@ This repository holds only the plugin source. The bundle files are at the reposi
2. Clear the cache and register the plugin:
```bash
php bin/console cache:clear
column
php bin/console mautic:plugins:reload
```
3. In Mautic, go to **Settings > Plugins**, open **Plan** and publish it.
Plans are listed under **Planning > Plans** in the main menu (URL `/s/plans`), and tasks under **Planning > Tasks** (URL `/s/plan-tasks`). Users who aren't administrators need a role with the **Plan Permissions** set in **Settings > Roles**.
Plans are listed under **Planning > Plans** in the main menu (URL `/s/plans`), tasks under **Planning > Tasks** (URL `/s/plan-tasks`), and the stakeholder directory under **Planning > Stakeholders** (URL `/s/plan-stakeholders`). Users who aren't administrators need a role with the **Plan Permissions** set in **Settings > Roles**.
Before using the items of a plan's **Description** and **Allocation** tabs, an administrator sets up their types in **Settings > Configuration > Plan Settings**.
Before using the items of a plan's **Description**, **Objectives**, **Allocations** and **Tasks** tabs, an administrator sets up their types in **Settings > Configuration > Plan Settings**.
## Development
@@ -62,8 +62,8 @@ The plugin uses the IntegrationsBundle conventions:
- `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/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**, **Allocation** (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 same columns as **Planning > Tasks** (ID, Name, Description, Start date, End date, Status), 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 and links to each task. On the plan form it is read-only, so that following a link doesn't drop unsaved changes.
- `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.
- `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()`.
@@ -79,7 +79,7 @@ Which tab opens on a plan's detail page and form (`Mautic.planInitTabs`):
The main menu has a top-level **Planning** entry, with **Plans** and **Tasks** as its items. Add future planning pages as more children of `mautic.plan.menu.root` in `Config/config.php`.
The **Targets** tab only shows an empty state for now.
The **Targets** tab lists the plan's audiences, harmonized like the other tabs: pictogram (fixed per target type), Type, Name, Priority, Stages, Estimated size, Profile criteria, Pain points, Value proposition, Preferred channels.
| Route | URL | Purpose |
| --- | --- | --- |
@@ -87,12 +87,14 @@ The **Targets** tab only shows an empty state for now.
| `plan_action` | `/s/plans/{objectAction}/{objectId}` | `view`, `new`, `edit`, `delete`, `batchDelete` |
| `plan_task_index` | `/s/plan-tasks/{page}` | Task list, with search on name and description |
| `plan_task_action` | `/s/plan-tasks/{objectAction}/{objectId}` | `new` (optional `?plan=ID`), `edit`, `delete`, `batchDelete` |
| `plan_stakeholder_index` | `/s/plan-stakeholders/{page}` | Stakeholder directory, with search on name, email, role and type |
| `plan_stakeholder_action` | `/s/plan-stakeholders/{objectAction}/{objectId}` | `new`, `edit`, `delete`, `batchDelete` |
The plan templates don't pass `routeBase` to core's button helpers (`page_actions`, `list_actions`) when a "close" button is involved: from `routeBase`, core builds `mautic_<routeBase>_*` route names, which don't exist in this plugin. The other buttons use the `actionRoute` (`plan_action`) that the controller passes to the template.
Permission keys:
- `plan:plans:*` and `plan:tasks:*`: `viewown`, `viewother`, `editown`, `editother`, `create`, `deleteown`, `deleteother`, `publishown`, `publishother`, `full`. "Own" means items the user created (`createdBy`), as in core objects.
- `plan:plans:*`, `plan:tasks:*` and `plan:stakeholders:*`: `viewown`, `viewother`, `editown`, `editother`, `create`, `deleteown`, `deleteother`, `publishown`, `publishother`, `full`. "Own" means items the user created (`createdBy`), as in core objects.
- `plan:categories:*`: managing the `plan` category type.
### The Plan object
@@ -100,7 +102,8 @@ Permission keys:
- `Entity/Plan.php`: the entity (table `plans`), with its Doctrine mapping and validation rules
- `Entity/PlanStatus.php`: the status enum (`draft`, `planned`, `active`, `paused`, `completed`, `archived`)
- `Entity/PlanRepository.php`: the repository
- `Entity/PlanObjective.php` and `PlanObjectiveRepository.php`: a plan's objectives (table `plan_objectives`): title, description, position and an "achieved" flag
- `Entity/PlanObjective.php` and `PlanObjectiveRepository.php`: a plan's objectives (table `plan_objectives`): type (with its pictogram), title, description, position and an "achieved" flag
- `Entity/Target.php`, `TargetType.php`, `TargetPriority.php` and `TargetRepository.php`: a plan's targets (table `plan_targets`), the audiences of the Targets tab: name, a fixed type (persona, ICP, broad audience, lifecycle cohort, partner/influencer — each with its own pictogram), a priority (primary, secondary, exclusion), any number of Mautic stages (join table `plan_target_stages`), an estimated size, profile criteria, pain points, a value proposition, preferred channels (checkboxes: email, SMS, web, social organic, paid social, paid search, events/webinar, outbound sales, partners) and a position. Targets are edited inside the plan form like objectives, and shown in the harmonized table of the Targets tab
- `Model/PlanModel.php`: the model, available as `mautic.plan.model.plan` or with `getModel('plan')`. A new plan from `getEntity()` has the current user as owner.
- `Entity/PlanDescriptionItem.php` and `PlanDescriptionItemRepository.php`: a plan's description items (table `plan_description_items`): type, description and position. They make up the Description tab and replace the former `description` field.
- `Form/Type/PlanType.php`, `PlanObjectiveType.php` and `PlanDescriptionItemType.php`: the create and edit form, with the objectives and the description items as collections
@@ -117,14 +120,18 @@ Behaviour to know about:
- `getObjectives()` and `getDescriptionItems()` return the rows sorted by position, as a new collection. The mapping's `orderBy` isn't enough: after a reorder, the page shown right after saving uses the collection already loaded, in its old order.
- Text typed in the plan form, including in objectives and description items, is kept as typed: line breaks, `&` and quotes are preserved, and HTML tags are removed. This depends on `PlanType` passing a mask array to `CleanFormSubscriber`. Without one, core HTML-encodes every value, again on each save.
### Typed items: description items and allocation items
### Typed items: description items, allocation items and tasks
- A **description item** (Description tab, `Entity/PlanDescriptionItem.php`) has a type and a description. More fields are planned.
- An **allocation item** (Allocation tab, `Entity/PlanAllocationItem.php`, table `plan_allocation_items`) is a cost line: type (with its pictogram), name (optional), description, planned cost and real cost. Costs are `DECIMAL(12,2)`, in the general currency.
- Both kinds are edited inside the plan form, like objectives: add, remove, drag to reorder. They're saved and deleted with the plan.
- An administrator sets up each kind's types in **Settings > Configuration > Plan Settings**, in two sections. Each type has a name and a description for each language installed in Mautic, and the default language (the `locale` parameter) requires a name. Each type also has a pictogram. Users see their own language, or the default language when theirs is empty. The order of the types is the order of the dropdown.
- The types are stored in `config/local.php`, in the `plan_description_item_types` and `plan_allocation_item_types` parameters. Read them with `Service/ItemTypeProvider.php`, passing the kind (`description` or `allocation`). In templates, use the Twig functions `plan_item_type_name(kind, key)`, `plan_item_type_description(kind, key)` and `plan_item_type_icon(kind, key)`, plus `plan_currency()` and `plan_money(amount)` (`Twig/PlanExtension.php`).
- **Every item type has a pictogram**, chosen by the administrator from a list of Remix Icons that Mautic ships (`Service/Pictograms.php`, each checked against Mautic 7's icon stylesheet), with a live preview. It's stored as `icon` in the type. On the plan form it appears next to the type dropdown when a type is chosen. On the detail page, the Description tab is a table with three columns: Pictogram, Type, Description. The Allocation tab's cost lines list has the same Pictogram column, before Type.
- An **objective** (`Entity/PlanObjective.php`) has a type too (with its pictogram), a title, a priority (a whole number from 1, the most important, to 99), a description and the achieved flag. The plan's Objectives tab lists them by priority; ties keep the manual order. The priority is required.
- A **task** (`Entity/Task.php`) has a type too (with its pictogram): see *The Task object* above.
- Description items, allocation items and objectives are edited inside the plan form, like objectives: add, remove, drag to reorder. They're saved and deleted with the plan. Tasks are edited on their own form, where the type's pictogram and description appear around the type dropdown.
- An administrator sets up each kind's types in **Settings > Configuration > Plan Settings**, in four sections. Each type has a name and a description for each language installed in Mautic, and the default language (the `locale` parameter) requires a name. Each type also has a pictogram. Users see their own language, or the default language when theirs is empty. The order of the types is the order of the dropdown.
- The types are stored in `config/local.php`, in the `plan_description_item_types`, `plan_allocation_item_types`, `plan_objective_types` and `plan_task_types` parameters. Read them with `Service/ItemTypeProvider.php`, passing the kind (`description`, `allocation`, `objective` or `task`). In templates, use the Twig functions `plan_item_type_name(kind, key)`, `plan_item_type_description(kind, key)` and `plan_item_type_icon(kind, key)`, plus `plan_currency()` and `plan_money(amount)` (`Twig/PlanExtension.php`).
- **Every item type has a pictogram**, chosen by the administrator from a list of Remix Icons that Mautic ships (`Service/Pictograms.php`, each checked against Mautic 7's icon stylesheet), with a live preview. It's stored as `icon` in the type. On the plan form and the task form it appears next to the type dropdown when a type is chosen.
- **The four item tabs of a plan's detail page are harmonized** (`Resources/views/Plan/details.html.twig`, `_task_table.html.twig`, `_tab_table_filter.html.twig`): every column starts with the pictogram (its header stays empty — no "Pictogram" label), then Type, Name, Description, and the kind's other fields; objectives show their Priority after Description, and tasks end with Status. The plan's Tasks tab doesn't show task IDs (`data-task-id` still carries them). Each tab has one filter box that matches every column, and every column header sorts the rows asc/desc on click (`Mautic.planInitTabTable` in `Assets/js/plan.js`, client-side). The objective's achieved flag is the Status column of its table.
- A description item's long description is **clamped to 10 lines** in the Description tab, with a *Read more* / *Show less* toggle (`_description_read_more.html.twig`, `Mautic.planInitReadMore`). The toggle appears only when the text really overflows: the pane is hidden on page load, so the measurement waits for the tab to be shown.
- Each type has a hidden key, generated when it's created and never changed. Items store that key, so renaming a type renames it everywhere.
- A type that items use can't be removed: the configuration isn't saved, and the error lists the types and how many items use them (`EventListener/ConfigSubscriber.php`, on `CONFIG_PRE_SAVE`).
- On the plan form, the selected type's description is shown under the type dropdown. When no types are set up, the tab says where to set them up.
@@ -134,12 +141,21 @@ Behaviour to know about:
- `Plan::getAllocationTotals()` adds up the allocation items' planned and real costs, in the general currency. The sums are done in cents, as integers.
- The plan detail page shows them under the title, after the plan status, as on an email's page (`publishStatus` block): a "Planned" tag and a "Real" tag. A real total above the planned total is red, otherwise green.
- The Allocation tab of the detail page lists the cost lines, followed by a total row.
- The Allocations tab of the detail page lists the cost lines, followed by a total row.
- `isAchieved` is toggled by hand on the form for now.
### The Stakeholder object
- `Entity/Stakeholder.php` and `StakeholderRepository.php`: a stakeholder (table `plan_stakeholders`), the global directory of the people, companies and teams involved in the plans: name, email (validated, indexed for duplicate detection), phone, role, type and the active flag (`isPublished`). Independent of plans.
- `Entity/PlanStakeholder.php` and `PlanStakeholderRepository.php`: the link between a plan and a stakeholder (table `plan_stakeholders_plan`), with the stakeholder's role in that plan (free text) and a position. Deleting the plan or the stakeholder deletes the link (ON DELETE CASCADE both sides).
- `Model/StakeholderModel.php`: the model, available as `mautic.plan.model.stakeholder` or with `getModel('plan.stakeholder')`. On save, the phone number is normalized to E.164 using the default region from **Settings > Configuration > Plan Settings** (parameter `plan_stakeholder_phone_region`, `FR` by default); a number that doesn't parse is kept exactly as typed, and the save is never blocked.
- `Controller/StakeholderController.php` and `Resources/views/Stakeholder/`: the directory (**Planning > Stakeholders**), with the columns ID, Pictogram, Type, Name, Role, Email (mailto link), Phone (tel link), Active, and **Assigned plans** — the plans the stakeholder is linked to, each with its role in that plan. The detail page lists those plans too.
- The stakeholder's type is the key of a stakeholder type set up in **Settings > Configuration > Plan Settings** (parameter `plan_stakeholder_types`), same pattern as the other item types, pictogram included.
- A plan's **Stakeholders tab** links the directory to the plan: each row picks an active stakeholder and gives its role in the plan. The tab shows the harmonized table (pictogram, Type, Name, Role in the plan, Role, Email, Phone, Active). Unpublished stakeholders are not offered in the picker, but keep their links.
### The Task object
- `Entity/Task.php` and `TaskRepository.php`: a task (table `plan_tasks`): 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, optional parent task, optional start and end dates, and status
- `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.
- `Form/Type/TaskType.php`: the create and edit form
@@ -149,7 +165,8 @@ Behaviour to know about:
- A task must belong to a plan. A plan can have any number of tasks, including none.
- A task's end date must be on or after its start date, when both are set.
- The task list (**Planning > Tasks**) shows these columns, in this order: ID, Name, Description (first 120 characters), Start date, End date, Status. Every column except 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.
- 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`).
- Tasks are edited on their own pages, not inside the plan form: a task can only be picked as a parent once it exists.
@@ -160,7 +177,7 @@ After you change `Assets/js/plan.js`, run `php bin/console mautic:assets:generat
Mautic creates the `plans` table from the entity mapping when it installs the plugin. However, the installer drops foreign keys that point to core tables (`users`, `categories`). `Migrations/Version_0_2_0.php` adds them and only runs when they are missing. Core runs plugin migrations when the plugin version changes, and `EventListener/PluginInstallSubscriber.php` also runs them right after a fresh install.
`Migrations/Version_0_3_0.php` adds `plans.version` and the `plan_objectives` table to installs created before 0.3.0. `Migrations/Version_0_4_0.php` adds the `plan_tasks` table and its two foreign keys, and adds the foreign keys to an existing `plan_tasks` table that lacks them. `Migrations/Version_0_5_0.php` adds the tasks' `start_date`, `end_date` and `status` columns, and existing tasks get the status `new`. `Migrations/Version_0_6_0.php` creates `plan_description_items` with its foreign key to `plans` (`ON DELETE CASCADE`), and drops `plans.description`, deleting its content. `Migrations/Version_0_7_0.php` creates `plan_allocation_items` with its foreign key to `plans` (`ON DELETE CASCADE`). `Migrations/Version_0_8_0.php` drops the currency columns (`plans.currency`, `plan_allocation_items.planned_currency` and `real_currency`), since every amount is now in the general currency. Every migration checks the schema first, so it's safe to run again.
`Migrations/Version_0_3_0.php` adds `plans.version` and the `plan_objectives` table to installs created before 0.3.0. `Migrations/Version_0_4_0.php` adds the `plan_tasks` table and its two foreign keys, and adds the foreign keys to an existing `plan_tasks` table that lacks them. `Migrations/Version_0_5_0.php` adds the tasks' `start_date`, `end_date` and `status` columns, and existing tasks get the status `new`. `Migrations/Version_0_6_0.php` creates `plan_description_items` with its foreign key to `plans` (`ON DELETE CASCADE`), and drops `plans.description`, deleting its content. `Migrations/Version_0_7_0.php` creates `plan_allocation_items` with its foreign key to `plans` (`ON DELETE CASCADE`). `Migrations/Version_0_8_0.php` drops the currency columns (`plans.currency`, `plan_allocation_items.planned_currency` and `real_currency`), since every amount is now in the general currency. `Migrations/Version_0_9_0.php` adds `plan_tasks.type` (nullable; tasks existed before types, so each existing task must be given a type before it can be saved again). `Migrations/Version_0_10_0.php` adds `plan_objectives.type` (nullable; existing objectives must be given a type before the plan can be saved again). `Migrations/Version_0_10_1.php` adds `plan_objectives.priority` (`INT NOT NULL`, default 1; existing objectives get 1). `Migrations/Version_0_11_0.php` creates `plan_targets` and the `plan_target_stages` join table. `Migrations/Version_0_12_0.php` creates `plan_stakeholders` and `plan_stakeholders_plan`, with their foreign keys. Every migration checks the schema first, so it's safe to run again.
If a migration builds its `CREATE TABLE` with Doctrine's `SchemaTool`, keep only the statement for its own table. `SchemaTool` also returns statements for other tables, such as Symfony Messenger's `messenger_messages`. Those fail on an existing install, and the migration engine then reports "There is no active transaction" instead of the real error.