refactor(plugin): rename Plan to Program and add audience/UTM routes

Rename the Plan bundle to Program across config, routes, menus, and
controllers (Plan -> Initiative), bump version to 0.16.0, and introduce
new audience and UTM taxonomy routes and permissions to support the
expanded Programs feature set.
This commit is contained in:
Alexandre Gain committed 2026-11-13 22:01:32 +01:00
1 parent 8268fad886
commit 71ff11390b
121 files changed
+4992 -2855

No files matched your search

+113 -83
View File
@@ -2,32 +2,62 @@
* Plan plugin scripts.
*
* - 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.
* item type's description, and tab error markers. Started by Mautic.programOnLoad(), which Mautic calls after
* it loads any page whose mauticContent is "initiative", including pages loaded through Ajax.
* - Task form (mauticContent "programTask", started by Mautic.programTaskOnLoad()): the dependencies and
* the RACI rows work like the initiative form's collections; the selected kind enslaves a milestone's
* end date; the selected type's description and pictogram sit next to the type dropdown.
* - Audience form (mauticContent "programAudience", started by Mautic.programAudienceOnLoad()): the selected
* type's pictogram next to the type dropdown (fixed per type, not admin-configured).
* - Settings > Configuration > Plan: adding and removing item types (delegated handlers,
* because that page isn't a "plan" page).
* because that page isn't a "initiative" page).
*/
Mautic.planTaskOnLoad = function (container) {
// The dependencies and RACI rows work like the plan form's collections.
mQuery(container).find('.plan-collection').each(function () {
Mautic.planInitCollection(mQuery(this));
});
// The type dropdown works the same way as in the plan form.
mQuery(container).find('select.plan-item-type').each(function () {
Mautic.programAudienceOnLoad = function (container) {
// The type dropdown's pictogram is fixed per type (AudienceType), not admin-configured: it is
// rendered from the value server-side (the program_audience_type_icon filter), and updated here.
mQuery(container).find('select[name$="[audienceType]"]').each(function () {
var $select = mQuery(this);
if ($select.data('planTaskInitialized')) {
if ($select.data('programAudienceInitialized')) {
return;
}
$select.data('planTaskInitialized', true);
$select.data('programAudienceInitialized', true);
// The same icons as AudienceType::getIcon().
var icons = {
persona: 'ri-user-heart-line',
icp: 'ri-building-line',
broad_audience: 'ri-group-line',
lifecycle_cohort: 'ri-time-line',
partner_influencer: 'ri-hand-heart-line'
};
$select.on('change', function () {
var icon = icons[mQuery(this).val()] || 'ri-user-heart-line';
mQuery(this).closest('form').find('.initiative-item-type-icon').first()
.attr('class', 'initiative-item-type-icon ' + icon);
});
});
};
Mautic.programTaskOnLoad = function (container) {
// The dependencies and RACI rows work like the initiative form's collections.
mQuery(container).find('.initiative-collection').each(function () {
Mautic.programInitCollection(mQuery(this));
});
// The type dropdown works the same way as in the initiative form.
mQuery(container).find('select.initiative-item-type').each(function () {
var $select = mQuery(this);
if ($select.data('programTaskInitialized')) {
return;
}
$select.data('programTaskInitialized', 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') || ''));
$scope.find('.initiative-item-type-help').first().text($option.attr('data-description') || '');
$scope.find('.initiative-item-type-icon').first().attr('class', 'initiative-item-type-icon ' + ($option.attr('data-icon') || ''));
});
});
@@ -63,20 +93,20 @@ Mautic.planTaskOnLoad = function (container) {
enslave.call($kind.get(0));
});
};
Mautic.planOnLoad = function (container) {
mQuery(container).find('.plan-collection').each(function () {
Mautic.planInitCollection(mQuery(this));
Mautic.programOnLoad = function (container) {
mQuery(container).find('.initiative-collection').each(function () {
Mautic.programInitCollection(mQuery(this));
});
mQuery(container).find('.plan-tabs').each(function () {
Mautic.planInitTabs(mQuery(this), mQuery(container));
mQuery(container).find('.initiative-tabs').each(function () {
Mautic.programInitTabs(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));
mQuery(container).find('table[data-initiative-tab-table]').each(function () {
Mautic.programInitTabTable(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));
mQuery(container).find('.initiative-read-more').each(function () {
Mautic.programInitReadMore(mQuery(this));
});
};
@@ -89,14 +119,14 @@ Mautic.planOnLoad = function (container) {
* (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) {
Mautic.programInitReadMore = 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 $text = $wrapper.find('.initiative-read-more-text').first();
var $toggle = $wrapper.find('.initiative-read-more-toggle').first();
var clampLines = 10;
var measure = function () {
@@ -128,16 +158,16 @@ Mautic.planInitReadMore = function ($wrapper) {
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 () {
mQuery(document).on('shown.bs.tab.initiative-read-more', function () {
if (measure()) {
mQuery(document).off('shown.bs.tab.plan-read-more');
mQuery(document).off('shown.bs.tab.initiative-read-more');
}
});
}
};
/**
* A plan detail page tab table: one filter box filtering every column (case-insensitive substring),
* A initiative 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.
*
@@ -145,16 +175,16 @@ Mautic.planInitReadMore = function ($wrapper) {
* 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) {
Mautic.programInitTabTable = 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 $filterBox = $panes.find('.initiative-tab-table-filter').first();
var $input = $filterBox.find('.initiative-tab-table-filter-input');
var $noMatch = $panes.find('.initiative-tab-table-nomatch').first();
var $rows = $table.find('tbody tr');
var apply = function () {
@@ -182,7 +212,7 @@ Mautic.planInitTabTable = function ($table) {
$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 direction = $th.hasClass('initiative-sorted-asc') ? -1 : 1;
var cells = [];
$rows.each(function () {
@@ -213,8 +243,8 @@ Mautic.planInitTabTable = function ($table) {
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');
$table.find('thead th').removeClass('initiative-sorted-asc initiative-sorted-desc');
$th.addClass(direction > 0 ? 'initiative-sorted-asc' : 'initiative-sorted-desc');
$rows = $table.find('tbody tr');
});
});
@@ -238,7 +268,7 @@ Mautic.planParseNumber = function (text) {
/**
* Plan tabs (detail page and form):
* - the tab last used for a plan is remembered for the browser session, and reopened when the plan's
* - the tab last used for a plan is remembered for the browser session, and reopened when the initiative's
* detail page or form loads, so that Edit, Save and Cancel keep the same tab;
* - after a failed save, the tabs whose pane has an error get an icon, and the first of them is
* opened instead.
@@ -250,18 +280,18 @@ Mautic.planParseNumber = function (text) {
* the tab under the user. The plan's tab panes have no "fade" class: with fade, two tab('show') calls
* within the 150 ms transition left two panes visible.
*/
Mautic.planInitTabs = function ($tabs, $container) {
var planId = $tabs.attr('data-plan-id');
var storageKey = planId ? 'mautic.plan.tab.' + planId : null;
Mautic.programInitTabs = function ($tabs, $container) {
var initiativeId = $tabs.attr('data-initiative-id');
var storageKey = initiativeId ? 'mautic.program.tab.' + initiativeId : null;
var $target = null;
$tabs.find('a[data-toggle="tab"]').each(function () {
var $link = mQuery(this);
var hasError = Mautic.planPaneHasError($container.find($link.attr('href')));
$link.toggleClass('text-danger', hasError);
$link.find('.plan-tab-error').remove();
$link.find('.initiative-tab-error').remove();
if (hasError) {
$link.append(' <i class="ri-error-warning-line text-danger plan-tab-error"></i>');
$link.append(' <i class="ri-error-warning-line text-danger initiative-tab-error"></i>');
if ($target === null) {
$target = $link;
}
@@ -291,26 +321,26 @@ Mautic.planInitTabs = function ($tabs, $container) {
}
if ($target !== null) {
Mautic.planPendingTab = $target;
Mautic.programPendingTab = $target;
setTimeout(Mautic.planApplyPendingTab, 0);
setTimeout(function () {
if (Mautic.planPendingTab === $target) {
Mautic.planPendingTab = null;
if (Mautic.programPendingTab === $target) {
Mautic.programPendingTab = null;
}
}, 1000);
}
};
Mautic.planPendingTab = null;
Mautic.programPendingTab = null;
Mautic.planApplyPendingTab = function () {
var $target = Mautic.planPendingTab;
var $target = Mautic.programPendingTab;
if ($target && mQuery.contains(document, $target[0])) {
$target.tab('show');
}
};
// Run after core's tab restore, so that the plan's choice wins (see Mautic.planInitTabs).
// Run after core's tab restore, so that the initiative's choice wins (see Mautic.programInitTabs).
if (typeof Mautic.rememberActiveTabs === 'function' && !Mautic.rememberActiveTabs.planWrapped) {
(function (coreRememberActiveTabs) {
Mautic.rememberActiveTabs = function () {
@@ -338,34 +368,34 @@ Mautic.planPaneHasError = function ($pane) {
/**
* An editable list of rows built from a Symfony collection:
* .plan-collection[data-prototype][data-prototype-name]
* .plan-collection-empty, .plan-collection-list > .plan-collection-row, .plan-collection-add
* in each row: .plan-collection-handle (drag), .plan-collection-remove, input.plan-row-position
* .initiative-collection[data-prototype][data-prototype-name]
* .initiative-collection-empty, .initiative-collection-list > .initiative-collection-row, .initiative-collection-add
* in each row: .initiative-collection-handle (drag), .initiative-collection-remove, input.initiative-row-position
*
* The hidden position of every row is rewritten to its display index after each change, so the saved
* order is the displayed order.
*/
Mautic.planInitCollection = function ($editor) {
if ($editor.data('planInitialized')) {
Mautic.programInitCollection = function ($editor) {
if ($editor.data('programInitialized')) {
return;
}
$editor.data('planInitialized', true);
$editor.data('programInitialized', true);
var $list = $editor.find('.plan-collection-list').first();
var $list = $editor.find('.initiative-collection-list').first();
var prototypeName = new RegExp($editor.attr('data-prototype-name'), 'g');
// New rows get indexes that were never used on this page, so they can't collide with existing ones.
var nextIndex = $list.children('.plan-collection-row').length;
var nextIndex = $list.children('.initiative-collection-row').length;
var refresh = function () {
var $rows = $list.children('.plan-collection-row');
var $rows = $list.children('.initiative-collection-row');
$rows.each(function (index) {
mQuery(this).find('input.plan-row-position').val(index);
mQuery(this).find('input.initiative-row-position').val(index);
});
$editor.find('.plan-collection-empty').first().toggleClass('hide', $rows.length > 0);
$editor.find('.initiative-collection-empty').first().toggleClass('hide', $rows.length > 0);
};
$editor.on('click', '.plan-collection-add', function (event) {
$editor.on('click', '.initiative-collection-add', function (event) {
event.preventDefault();
var $row = mQuery($editor.attr('data-prototype').replace(prototypeName, nextIndex++));
$list.append($row);
@@ -373,25 +403,25 @@ Mautic.planInitCollection = function ($editor) {
$row.find('select, input[type="text"], textarea').first().trigger('focus');
});
$editor.on('click', '.plan-collection-remove', function (event) {
$editor.on('click', '.initiative-collection-remove', function (event) {
event.preventDefault();
mQuery(this).closest('.plan-collection-row').remove();
mQuery(this).closest('.initiative-collection-row').remove();
refresh();
});
// Typed items (description, allocation): show the selected type's description under the dropdown, and
// its pictogram next to it. Works within a plan-collection row.
$editor.on('change', 'select.plan-item-type', function () {
// its pictogram next to it. Works within a initiative-collection row.
$editor.on('change', 'select.initiative-item-type', function () {
var $option = mQuery(this).find('option:selected');
var $row = mQuery(this).closest('.plan-collection-row');
$row.find('.plan-item-type-help').first().text($option.attr('data-description') || '');
$row.find('.plan-item-type-icon').first().attr('class', 'plan-item-type-icon ' + ($option.attr('data-icon') || ''));
var $row = mQuery(this).closest('.initiative-collection-row');
$row.find('.initiative-item-type-help').first().text($option.attr('data-description') || '');
$row.find('.initiative-item-type-icon').first().attr('class', 'initiative-item-type-icon ' + ($option.attr('data-icon') || ''));
});
if (typeof $list.sortable === 'function') {
$list.sortable({
items: '> .plan-collection-row',
handle: '.plan-collection-handle',
items: '> .initiative-collection-row',
handle: '.initiative-collection-handle',
axis: 'y',
update: refresh
});
@@ -405,32 +435,32 @@ Mautic.planInitCollection = function ($editor) {
*/
(function () {
var refreshTypes = function ($editor) {
var count = $editor.find('.plan-config-type').length;
$editor.find('.plan-config-types-empty').toggleClass('hide', count > 0);
var count = $editor.find('.program-config-type').length;
$editor.find('.program-config-types-empty').toggleClass('hide', count > 0);
};
mQuery(document).on('click', '.plan-config-types .plan-config-type-add', function (event) {
mQuery(document).on('click', '.program-config-types .program-config-type-add', function (event) {
event.preventDefault();
var $editor = mQuery(this).closest('.plan-config-types');
var $editor = mQuery(this).closest('.program-config-types');
// Never reuse an index: count every index ever added on this page.
var index = ($editor.data('planNextIndex') || $editor.find('.plan-config-type').length + 1000);
$editor.data('planNextIndex', index + 1);
var index = ($editor.data('programNextIndex') || $editor.find('.program-config-type').length + 1000);
$editor.data('programNextIndex', index + 1);
var $row = mQuery($editor.attr('data-prototype').replace(/__type__/g, index));
$editor.find('.plan-config-types-list').append($row);
$editor.find('.program-config-types-list').append($row);
refreshTypes($editor);
$row.find('input[type="text"]').first().trigger('focus');
});
// Pictogram of an item type (description, allocation): preview the chosen icon.
mQuery(document).on('change', '.plan-config-types select.plan-type-icon-select', function () {
mQuery(document).on('change', '.program-config-types select.initiative-type-icon-select', function () {
var icon = mQuery(this).find('option:selected').attr('data-icon') || '';
mQuery(this).closest('.plan-config-type').find('.plan-type-icon-preview').first().attr('class', 'plan-type-icon-preview ' + icon);
mQuery(this).closest('.program-config-type').find('.initiative-type-icon-preview').first().attr('class', 'initiative-type-icon-preview ' + icon);
});
mQuery(document).on('click', '.plan-config-types .plan-config-type-remove', function (event) {
mQuery(document).on('click', '.program-config-types .program-config-type-remove', function (event) {
event.preventDefault();
var $editor = mQuery(this).closest('.plan-config-types');
mQuery(this).closest('.plan-config-type').remove();
var $editor = mQuery(this).closest('.program-config-types');
mQuery(this).closest('.program-config-type').remove();
refreshTypes($editor);
});
})();
+124 -55
View File
@@ -3,70 +3,96 @@
declare(strict_types=1);
return [
'name' => 'Plan',
'description' => 'Plan plugin for Mautic.',
'version' => '0.13.0',
'name' => 'Program',
'description' => 'Program plugin for Mautic.',
'version' => '0.16.0',
'author' => 'Experiential',
'routes' => [
'main' => [
'plan_index' => [
'path' => '/plans/{page}',
'controller' => 'MauticPlugin\PlanBundle\Controller\PlanController::indexAction',
'initiative_index' => [
'path' => '/programs/{page}',
'controller' => 'MauticPlugin\ProgramBundle\Controller\InitiativeController::indexAction',
],
// objectAction: view, new, edit, delete, batchDelete.
'plan_action' => [
'path' => '/plans/{objectAction}/{objectId}',
'controller' => 'MauticPlugin\PlanBundle\Controller\PlanController::executeAction',
'initiative_action' => [
'path' => '/programs/{objectAction}/{objectId}',
'controller' => 'MauticPlugin\ProgramBundle\Controller\InitiativeController::executeAction',
],
'plan_task_index' => [
'path' => '/plan-tasks/{page}',
'controller' => 'MauticPlugin\PlanBundle\Controller\TaskController::indexAction',
'initiative_task_index' => [
'path' => '/program-tasks/{page}',
'controller' => 'MauticPlugin\ProgramBundle\Controller\TaskController::indexAction',
],
// objectAction: new (optional ?plan=ID), edit, delete, batchDelete.
'plan_task_action' => [
'path' => '/plan-tasks/{objectAction}/{objectId}',
'controller' => 'MauticPlugin\PlanBundle\Controller\TaskController::executeAction',
// objectAction: new (optional ?initiative=ID), edit, delete, batchDelete.
'initiative_task_action' => [
'path' => '/program-tasks/{objectAction}/{objectId}',
'controller' => 'MauticPlugin\ProgramBundle\Controller\TaskController::executeAction',
],
'plan_stakeholder_index' => [
'path' => '/plan-stakeholders/{page}',
'controller' => 'MauticPlugin\PlanBundle\Controller\StakeholderController::indexAction',
'initiative_stakeholder_index' => [
'path' => '/program-stakeholders/{page}',
'controller' => 'MauticPlugin\ProgramBundle\Controller\StakeholderController::indexAction',
],
// objectAction: new, edit, delete, batchDelete.
'plan_stakeholder_action' => [
'path' => '/plan-stakeholders/{objectAction}/{objectId}',
'controller' => 'MauticPlugin\PlanBundle\Controller\StakeholderController::executeAction',
'initiative_stakeholder_action' => [
'path' => '/program-stakeholders/{objectAction}/{objectId}',
'controller' => 'MauticPlugin\ProgramBundle\Controller\StakeholderController::executeAction',
],
'initiative_audience_index' => [
'path' => '/program-audiences/{page}',
'controller' => 'MauticPlugin\ProgramBundle\Controller\AudienceController::indexAction',
],
// objectAction: new, edit, delete, batchDelete.
'initiative_audience_action' => [
'path' => '/program-audiences/{objectAction}/{objectId}',
'controller' => 'MauticPlugin\ProgramBundle\Controller\AudienceController::executeAction',
],
// UTM Taxonomies: a placeholder page under Programs for now.
'program_utm_taxonomy_index' => [
'path' => '/program-utm-taxonomies/{page}',
'controller' => 'MauticPlugin\ProgramBundle\Controller\UtmTaxonomyController::indexAction',
],
],
],
// Top-level "Planning" menu. Future planning objects go in its children, after Plans.
// Top-level "Programs" menu. Future program objects go in its children, after Initiatives.
'menu' => [
'main' => [
'mautic.plan.menu.root' => [
'id' => 'plan_root',
'mautic.program.menu.root' => [
'id' => 'program_root',
'iconClass' => 'ri-calendar-line',
'access' => ['plan:plans:viewown', 'plan:plans:viewother', 'plan:tasks:viewown', 'plan:tasks:viewother', 'plan:stakeholders:viewown', 'plan:stakeholders:viewother'],
'access' => ['program:initiatives:viewown', 'program:initiatives:viewother', 'program:tasks:viewown', 'program:tasks:viewother', 'program:stakeholders:viewown', 'program:stakeholders:viewother', 'program:audiences:viewown', 'program:audiences:viewother'],
'priority' => 5,
'children' => [
'mautic.plan.menu.index' => [
'id' => 'plan_index',
'route' => 'plan_index',
'access' => ['plan:plans:viewown', 'plan:plans:viewother'],
'mautic.program.menu.index' => [
'id' => 'initiative_index',
'route' => 'initiative_index',
'access' => ['program:initiatives:viewown', 'program:initiatives:viewother'],
'priority' => 100,
],
'mautic.plan.task.menu.index' => [
'id' => 'plan_task_index',
'route' => 'plan_task_index',
'access' => ['plan:tasks:viewown', 'plan:tasks:viewother'],
'mautic.program.task.menu.index' => [
'id' => 'initiative_task_index',
'route' => 'initiative_task_index',
'access' => ['program:tasks:viewown', 'program:tasks:viewother'],
'priority' => 90,
],
'mautic.plan.stakeholder.menu.index' => [
'id' => 'plan_stakeholder_index',
'route' => 'plan_stakeholder_index',
'access' => ['plan:stakeholders:viewown', 'plan:stakeholders:viewother'],
'mautic.program.stakeholder.menu.index' => [
'id' => 'initiative_stakeholder_index',
'route' => 'initiative_stakeholder_index',
'access' => ['program:stakeholders:viewown', 'program:stakeholders:viewother'],
'priority' => 80,
],
'mautic.program.audience.menu.index' => [
'id' => 'initiative_audience_index',
'route' => 'initiative_audience_index',
'access' => ['program:audiences:viewown', 'program:audiences:viewother'],
'priority' => 70,
],
'mautic.program.utm_taxonomy.menu.index' => [
'id' => 'program_utm_taxonomy_index',
'route' => 'program_utm_taxonomy_index',
'access' => ['program:initiatives:viewown', 'program:initiatives:viewother'],
'priority' => 60,
],
],
],
],
@@ -74,15 +100,15 @@ return [
'services' => [
'integrations' => [
'mautic.plan.integration' => [
'class' => MauticPlugin\PlanBundle\Integration\PlanIntegration::class,
'mautic.program.integration' => [
'class' => MauticPlugin\ProgramBundle\Integration\ProgramIntegration::class,
'tags' => [
'mautic.integration',
'mautic.basic_integration',
],
],
'mautic.plan.integration.configuration' => [
'class' => MauticPlugin\PlanBundle\Integration\Support\ConfigSupport::class,
'mautic.program.integration.configuration' => [
'class' => MauticPlugin\ProgramBundle\Integration\Support\ProgramConfigSupport::class,
'tags' => [
'mautic.config_integration',
],
@@ -90,30 +116,73 @@ return [
],
],
// Registers "plan" as a category type (Settings > Categories), used by Plan::$category.
// Registers "initiative" as a category type (Settings > Categories), used by Initiative::$category.
'categories' => [
'plan' => [
'class' => MauticPlugin\PlanBundle\Entity\Plan::class,
'label' => 'mautic.plan.category.type',
'initiative' => [
'class' => MauticPlugin\ProgramBundle\Entity\Initiative::class,
'label' => 'mautic.program.category.type',
],
],
'parameters' => [
// The currency of every amount in the plugin (ISO 4217), edited in Settings > Configuration >
// Plan Settings. Read it through CurrencyProvider.
'plan_currency' => 'EUR',
// Program Settings. Read it through CurrencyProvider.
'program_currency' => 'EUR',
// Item types, edited in Settings > Configuration > Plan Settings. Read them through ItemTypeProvider.
// Item types, edited in Settings > Configuration > Program Settings. Read them through ItemTypeProvider.
// Each is a list of ['key' => …, 'names' => [locale => …], 'descriptions' => [locale => …]],
// 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' => [],
'program_description_item_types' => [],
'program_allocation_item_types' => [],
'program_objective_types' => [],
'program_task_types' => [],
'program_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',
'program_stakeholder_phone_region' => 'FR',
// Which audience persona attributes are offered on the audience forms, one toggle per attribute
// (Settings > Configuration > Program Settings). Read through AudienceAttributes; a parameter set
// to false turns the attribute off, and one that was never saved means enabled.
'program_audience_attribute_tagline' => true,
'program_audience_attribute_profile' => true,
'program_audience_attribute_motivations' => true,
'program_audience_attribute_barriers' => true,
'program_audience_attribute_frustrations' => true,
'program_audience_attribute_triggers' => true,
'program_audience_attribute_decision_role' => true,
'program_audience_attribute_tones' => true,
'program_audience_attribute_channels' => true,
'program_audience_attribute_stages' => true,
'program_audience_attribute_size' => true,
// The values of an audience's closed attributes, edited in Settings > Configuration > Program
// Settings. Each is a list of ['key' => …, 'names' => [locale => …]], read through
// ItemTypeProvider (kinds "audience_decision_role" and "audience_tone").
'program_audience_decision_roles' => [],
'program_audience_tones' => [],
// Which audience persona attributes are offered on the audience forms, one toggle per attribute
// (Settings > Configuration > Program Settings). The parameter names follow
// AudienceAttributes::toggleParameter(); a parameter set to false turns the attribute off.
// Defaults are handled by AudienceAttributes (enabled unless set to false).
'program_audience_attribute_tagline' => true,
'program_audience_attribute_profile' => true,
'program_audience_attribute_motivations' => true,
'program_audience_attribute_barriers' => true,
'program_audience_attribute_frustrations' => true,
'program_audience_attribute_triggers' => true,
'program_audience_attribute_decision_role' => true,
'program_audience_attribute_tones' => true,
'program_audience_attribute_channels' => true,
'program_audience_attribute_stages' => true,
'program_audience_attribute_size' => true,
// The values of an audience's closed attributes, edited in Settings > Configuration > Program
// Settings. Each is a list of ['key' => …, 'names' => [locale => …]], read through
// ItemTypeProvider (kinds "audience_decision_role" and "audience_tone").
'program_audience_decision_roles' => [],
'program_audience_tones' => [],
],
];
+10 -8
View File
@@ -16,17 +16,19 @@ return function (ContainerConfigurator $configurator): void {
'Tests',
];
$services->load('MauticPlugin\\PlanBundle\\', '../')
$services->load('MauticPlugin\\ProgramBundle\\', '../')
->exclude('../{'.implode(',', array_merge(MauticCoreExtension::DEFAULT_EXCLUDES, $excludes)).'}');
// Entity/ is excluded above; repositories must still be services for Doctrine to build them.
$services->load('MauticPlugin\\PlanBundle\\Entity\\', '../Entity/*Repository.php')
$services->load('MauticPlugin\\ProgramBundle\\Entity\\', '../Entity/*Repository.php')
->tag(Doctrine\Bundle\DoctrineBundle\DependencyInjection\Compiler\ServiceRepositoryCompilerPass::REPOSITORY_SERVICE_TAG);
// Lets core resolve the model with getModel('plan') / getModel('plan.plan').
$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);
// Lets core resolve the model with getModel('program').
$services->alias('mautic.program.model.initiative', MauticPlugin\ProgramBundle\Model\InitiativeModel::class);
// getModel('program.task').
$services->alias('mautic.program.model.task', MauticPlugin\ProgramBundle\Model\TaskModel::class);
// getModel('program.stakeholder').
$services->alias('mautic.program.model.stakeholder', MauticPlugin\ProgramBundle\Model\StakeholderModel::class);
// getModel('program.audience').
$services->alias('mautic.program.model.audience', MauticPlugin\ProgramBundle\Model\AudienceModel::class);
};
+96
View File
@@ -0,0 +1,96 @@
<?php
declare(strict_types=1);
namespace MauticPlugin\ProgramBundle\Controller;
use Mautic\CoreBundle\Controller\AbstractStandardFormController;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
/**
* List, create, edit and delete audiences (Programs > Audiences), the global directory of who the
* initiatives are aimed at, using core's standard CRUD flow. Audiences are independent of initiatives; initiatives
* link to them from their Audiences tab (InitiativeAudience carries the audience's priority in that
* initiative).
*
* Model program.audience (mautic.program.model.audience), permission base program:audiences, translation
* base mautic.program.audience.
*/
class AudienceController extends AbstractStandardFormController
{
public const ROUTE_INDEX = 'initiative_audience_index';
public const ROUTE_ACTION = 'initiative_audience_action';
protected function getModelName(): string
{
return 'program.audience';
}
protected function getTemplateBase(): string
{
return '@Program/Audience';
}
protected function getIndexRoute(): string
{
return self::ROUTE_INDEX;
}
protected function getActionRoute(): string
{
return self::ROUTE_ACTION;
}
protected function getJsLoadMethodPrefix(): string
{
return 'programAudience';
}
/**
* @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);
}
/**
* The audience's detail page (the directory entry, its persona attributes, its segments and
* the initiatives it is assigned to). The standard controller has no view action of its own, so it
* is routed here.
*
* @param int $objectId
*/
public function viewAction(Request $request, $objectId): Response
{
return $this->viewStandard($request, $objectId, 'audience', 'initiative');
}
/**
* @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);
}
}
@@ -2,37 +2,37 @@
declare(strict_types=1);
namespace MauticPlugin\PlanBundle\Controller;
namespace MauticPlugin\ProgramBundle\Controller;
use Mautic\CoreBundle\Controller\AbstractStandardFormController;
use MauticPlugin\PlanBundle\Entity\Plan;
use MauticPlugin\PlanBundle\Model\TaskModel;
use MauticPlugin\ProgramBundle\Entity\Initiative;
use MauticPlugin\ProgramBundle\Model\TaskModel;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
/**
* List, view, create, edit and delete plans, using core's standard CRUD flow.
*
* Core derives most names from the model name "plan": model mautic.plan.model.plan, permission base
* plan:plans (from PlanModel), translation base mautic.plan, session base mautic.plan.
* Core derives most names from the model name "initiative": model mautic.program.model.initiative, permission base
* program:initiatives (from InitiativeModel), translation base mautic.program, session base mautic.program.
*/
class PlanController extends AbstractStandardFormController
class InitiativeController extends AbstractStandardFormController
{
public const ROUTE_INDEX = 'plan_index';
public const ROUTE_ACTION = 'plan_action';
public const ROUTE_INDEX = 'initiative_index';
public const ROUTE_ACTION = 'initiative_action';
protected function getModelName(): string
{
return 'plan';
return 'program.initiative';
}
protected function getTemplateBase(): string
{
return '@Plan/Plan';
return '@Program/Initiative';
}
/**
* Core would build mautic_plan_index; the plugin's routes use the plan_ prefix.
* Core would build mautic_initiative_index; the plugin's routes use the plan_ prefix.
*/
protected function getIndexRoute(): string
{
@@ -53,7 +53,7 @@ class PlanController extends AbstractStandardFormController
}
/**
* The plan detail page (tabs: Details, Description, Objectives, Allocations, Targets, Tasks).
* The initiative detail page (tabs: Details, Description, Objectives, Allocations, Audiences, Stakeholders, 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.
@@ -62,13 +62,13 @@ class PlanController extends AbstractStandardFormController
*/
public function viewAction(Request $request, $objectId): Response
{
$plan = $this->getModel($this->getModelName())->getEntity((int) $objectId);
$initiative = $this->getModel($this->getModelName())->getEntity((int) $objectId);
if (!$plan instanceof Plan) {
return $this->notFound('mautic.plan.error.notfound');
if (!$initiative instanceof Initiative) {
return $this->notFound('mautic.program.error.notfound');
}
if (!$this->checkActionPermission('view', $plan)) {
if (!$this->checkActionPermission('view', $initiative)) {
return $this->accessDenied();
}
@@ -88,9 +88,9 @@ class PlanController extends AbstractStandardFormController
$taskPermissions = $this->security->isGranted(
[
'plan:tasks:create',
'plan:tasks:editown',
'plan:tasks:editother',
'program:tasks:create',
'program:tasks:editown',
'program:tasks:editother',
],
'RETURN_ARRAY',
null,
@@ -99,9 +99,9 @@ class PlanController extends AbstractStandardFormController
return $this->delegateView([
'viewParameters' => [
'item' => $plan,
'item' => $initiative,
'permissions' => $permissions,
'taskTree' => $this->getTaskModel()->getTaskTree($plan),
'taskTree' => $this->getTaskModel()->getTaskTree($initiative),
'taskPermissions' => $taskPermissions,
// Core's page_actions helper would otherwise build mautic_plan_* route names.
'indexRoute' => self::ROUTE_INDEX,
@@ -110,15 +110,15 @@ class PlanController extends AbstractStandardFormController
],
'contentTemplate' => $this->getTemplateName('details.html.twig'),
'passthroughVars' => [
'activeLink' => '#plan_index',
'activeLink' => '#initiative_index',
'mauticContent' => $this->getJsLoadMethodPrefix(),
'route' => $this->generateUrl(self::ROUTE_ACTION, ['objectAction' => 'view', 'objectId' => $plan->getId()]),
'route' => $this->generateUrl(self::ROUTE_ACTION, ['objectAction' => 'view', 'objectId' => $initiative->getId()]),
],
]);
}
/**
* Adds the plan's task tree to the form, for the read-only Tasks tab.
* Adds the initiative's task tree to the form, for the read-only Tasks tab.
*
* @param array<string, mixed> $args
* @param string $action
@@ -127,10 +127,10 @@ class PlanController extends AbstractStandardFormController
*/
protected function getViewArguments(array $args, $action): array
{
$plan = $args['viewParameters']['entity'] ?? null;
$initiative = $args['viewParameters']['entity'] ?? null;
if (in_array($action, ['new', 'edit'], true) && $plan instanceof Plan && null !== $plan->getId()) {
$args['viewParameters']['taskTree'] = $this->getTaskModel()->getTaskTree($plan);
if (in_array($action, ['new', 'edit'], true) && $initiative instanceof Initiative && null !== $initiative->getId()) {
$args['viewParameters']['taskTree'] = $this->getTaskModel()->getTaskTree($initiative);
}
return parent::getViewArguments($args, $action);
@@ -138,7 +138,7 @@ class PlanController extends AbstractStandardFormController
private function getTaskModel(): TaskModel
{
$model = $this->getModel('plan.task');
$model = $this->getModel('program.task');
\assert($model instanceof TaskModel);
return $model;
+10 -10
View File
@@ -2,33 +2,33 @@
declare(strict_types=1);
namespace MauticPlugin\PlanBundle\Controller;
namespace MauticPlugin\ProgramBundle\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
* List, create, edit and delete stakeholders (Programs > Stakeholders), the global directory, using
* core's standard CRUD flow. Stakeholders are independent of initiatives; initiatives link to them from their
* Stakeholders tab.
*
* Model plan.stakeholder (mautic.plan.model.stakeholder), permission base plan:stakeholders,
* translation base mautic.plan.stakeholder.
* Model program.stakeholder (mautic.program.model.stakeholder), permission base program:stakeholders,
* translation base mautic.program.stakeholder.
*/
class StakeholderController extends AbstractStandardFormController
{
public const ROUTE_INDEX = 'plan_stakeholder_index';
public const ROUTE_ACTION = 'plan_stakeholder_action';
public const ROUTE_INDEX = 'initiative_stakeholder_index';
public const ROUTE_ACTION = 'initiative_stakeholder_action';
protected function getModelName(): string
{
return 'plan.stakeholder';
return 'program.stakeholder';
}
protected function getTemplateBase(): string
{
return '@Plan/Stakeholder';
return '@Program/Stakeholder';
}
protected function getIndexRoute(): string
@@ -43,7 +43,7 @@ class StakeholderController extends AbstractStandardFormController
protected function getJsLoadMethodPrefix(): string
{
return 'planStakeholder';
return 'programStakeholder';
}
/**
+40 -40
View File
@@ -2,42 +2,42 @@
declare(strict_types=1);
namespace MauticPlugin\PlanBundle\Controller;
namespace MauticPlugin\ProgramBundle\Controller;
use Mautic\CoreBundle\Controller\AbstractStandardFormController;
use MauticPlugin\PlanBundle\Entity\Plan;
use MauticPlugin\PlanBundle\Entity\Task;
use MauticPlugin\ProgramBundle\Entity\Initiative;
use MauticPlugin\ProgramBundle\Entity\Task;
use Symfony\Component\Form\Form;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
/**
* List, create, edit and delete tasks (Planning > Tasks), using core's standard CRUD flow.
* List, create, edit and delete tasks (Programs > Tasks), using core's standard CRUD flow.
*
* Model plan.task (mautic.plan.model.task), permission base plan:tasks, translation base mautic.plan.task.
* Model program.task (mautic.program.model.task), permission base program:tasks, translation base mautic.program.task.
*
* Where the user lands after Save or Cancel depends on where the task form was opened from:
* - from Planning > Tasks: back to the task list (core's default);
* - from a plan's Tasks tab (links with ?returnTo=plan): back to that plan.
* - from Programs > Tasks: back to the task list (core's default);
* - from an initiative's Tasks tab (links with ?returnTo=initiative): back to that initiative.
* The origin is kept in the session when the form is opened, because the form posts to a URL
* without the query string.
*/
class TaskController extends AbstractStandardFormController
{
public const ROUTE_INDEX = 'plan_task_index';
public const ROUTE_ACTION = 'plan_task_action';
public const ROUTE_INDEX = 'initiative_task_index';
public const ROUTE_ACTION = 'initiative_task_action';
/**
* Value of the returnTo query parameter that sends the user back to the plan.
* Value of the returnTo query parameter that sends the user back to the initiative.
*/
public const RETURN_TO_PLAN = 'plan';
public const RETURN_TO_PLAN = 'initiative';
private const SESSION_RETURN_PLAN = 'mautic.plan.task.return_plan.';
private const SESSION_RETURN_PLAN = 'mautic.program.task.return_initiative.';
/**
* Plan to preselect on a new task (from ?plan=ID, used by the plan's "Add task" button).
* Initiative to preselect on a new task (from ?initiative=ID, used by the initiative's "Add task" button).
*/
private ?int $preselectedPlanId = null;
private ?int $preselectedInitiativeId = null;
/**
* The task saved during this request, if any.
@@ -45,18 +45,18 @@ class TaskController extends AbstractStandardFormController
private ?Task $savedTask = null;
/**
* Plan to go back to after Save or Cancel, or null for the task list.
* Initiative to go back to after Save or Cancel, or null for the task list.
*/
private ?int $returnPlanId = null;
private ?int $returnInitiativeId = null;
protected function getModelName(): string
{
return 'plan.task';
return 'program.task';
}
protected function getTemplateBase(): string
{
return '@Plan/Task';
return '@Program/Task';
}
protected function getIndexRoute(): string
@@ -71,7 +71,7 @@ class TaskController extends AbstractStandardFormController
protected function getJsLoadMethodPrefix(): string
{
return 'planTask';
return 'programTask';
}
/**
@@ -84,9 +84,9 @@ class TaskController extends AbstractStandardFormController
public function newAction(Request $request): Response
{
$planId = $request->query->getInt('plan');
$this->preselectedPlanId = $planId > 0 ? $planId : null;
$this->returnPlanId = $this->resolveReturnPlan($request, 'new', $this->preselectedPlanId);
$initiativeId = $request->query->getInt('initiative');
$this->preselectedInitiativeId = $initiativeId > 0 ? $initiativeId : null;
$this->returnInitiativeId = $this->resolveReturnInitiative($request, 'new', $this->preselectedInitiativeId);
return $this->newStandard($request);
}
@@ -98,24 +98,24 @@ class TaskController extends AbstractStandardFormController
public function editAction(Request $request, $objectId, $ignorePost = false): Response
{
$task = $this->getModel($this->getModelName())->getEntity((int) $objectId);
$planId = $task instanceof Task ? $task->getPlan()?->getId() : null;
$this->returnPlanId = $this->resolveReturnPlan($request, (string) (int) $objectId, $planId);
$initiativeId = $task instanceof Task ? $task->getInitiative()?->getId() : null;
$this->returnInitiativeId = $this->resolveReturnInitiative($request, (string) (int) $objectId, $initiativeId);
return $this->editStandard($request, $objectId, $ignorePost);
}
/**
* When the form is opened (GET), records whether it came from a plan (?returnTo=plan); when it is
* When the form is opened (GET), records whether it came from an initiative (?returnTo=initiative); when it is
* submitted (POST), reads that record back. Opening the same form from the task list clears it.
*/
private function resolveReturnPlan(Request $request, string $formKey, ?int $planId): ?int
private function resolveReturnInitiative(Request $request, string $formKey, ?int $initiativeId): ?int
{
$session = $request->getSession();
$key = self::SESSION_RETURN_PLAN.$formKey;
if (!$request->isMethod('POST')) {
$fromPlan = self::RETURN_TO_PLAN === $request->query->get('returnTo') && null !== $planId;
$session->set($key, $fromPlan ? $planId : null);
$fromInitiative = self::RETURN_TO_PLAN === $request->query->get('returnTo') && null !== $initiativeId;
$session->set($key, $fromInitiative ? $initiativeId : null);
}
$value = $session->get($key);
@@ -143,10 +143,10 @@ class TaskController extends AbstractStandardFormController
{
$entity = parent::getFormEntity($action, $objectId, $isClone);
if ('new' === $action && $entity instanceof Task && null === $entity->getPlan() && null !== $this->preselectedPlanId) {
$plan = $this->getModel('plan')->getEntity($this->preselectedPlanId);
if ($plan instanceof Plan) {
$entity->setPlan($plan);
if ('new' === $action && $entity instanceof Task && null === $entity->getInitiative() && null !== $this->preselectedInitiativeId) {
$initiative = $this->getModel('program.initiative')->getEntity($this->preselectedInitiativeId);
if ($initiative instanceof Initiative) {
$entity->setInitiative($initiative);
}
}
@@ -163,8 +163,8 @@ class TaskController extends AbstractStandardFormController
}
/**
* After Save or Cancel (not Apply) on a form opened from a plan, go back to that plan. If the task
* was moved to another plan, go to its new plan. Otherwise keep core's default: the task list.
* After Save or Cancel (not Apply) on a form opened from an initiative, go back to that initiative. If the task
* was moved to another initiative, go to its new initiative. Otherwise keep core's default: the task list.
*
* @param array<string, mixed> $args
*
@@ -172,13 +172,13 @@ class TaskController extends AbstractStandardFormController
*/
protected function getPostActionRedirectArguments(array $args, $action): array
{
if (in_array($action, ['new', 'edit'], true) && null !== $this->returnPlanId) {
$planId = $this->savedTask?->getPlan()?->getId() ?? $this->returnPlanId;
if (in_array($action, ['new', 'edit'], true) && null !== $this->returnInitiativeId) {
$initiativeId = $this->savedTask?->getInitiative()?->getId() ?? $this->returnInitiativeId;
$args['returnUrl'] = $this->generateUrl(PlanController::ROUTE_ACTION, ['objectAction' => 'view', 'objectId' => $planId]);
$args['contentTemplate'] = PlanController::class.'::viewAction';
$args['viewParameters'] = ['objectId' => $planId];
$args['passthroughVars'] = array_merge($args['passthroughVars'] ?? [], ['mauticContent' => 'plan']);
$args['returnUrl'] = $this->generateUrl(InitiativeController::ROUTE_ACTION, ['objectAction' => 'view', 'objectId' => $initiativeId]);
$args['contentTemplate'] = InitiativeController::class.'::viewAction';
$args['viewParameters'] = ['objectId' => $initiativeId];
$args['passthroughVars'] = array_merge($args['passthroughVars'] ?? [], ['mauticContent' => 'initiative']);
}
return parent::getPostActionRedirectArguments($args, $action);
+39
View File
@@ -0,0 +1,39 @@
<?php
declare(strict_types=1);
namespace MauticPlugin\ProgramBundle\Controller;
use Mautic\CoreBundle\Controller\CommonController;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
/**
* UTM Taxonomies (Programs > UTM Taxonomies): a placeholder for now, so the menu entry has a
* page. The content (classifying the UTM parameters of the programs' campaigns and links) comes
* later; until then the page shows an empty content block.
*/
class UtmTaxonomyController extends CommonController
{
public const ROUTE_INDEX = 'program_utm_taxonomy_index';
/**
* @param int $page
*/
public function indexAction(Request $request, $page = 1): Response
{
$tmpl = $request->isXmlHttpRequest() ? $request->get('tmpl', 'index') : 'index';
return $this->delegateView([
'viewParameters' => [
'tmpl' => $tmpl,
],
'contentTemplate' => '@Program/UtmTaxonomy/list.html.twig',
'passthroughVars' => [
'activeLink' => '#'.self::ROUTE_INDEX,
'mauticContent' => 'programUtmTaxonomy',
'route' => $this->generateUrl(self::ROUTE_INDEX),
],
]);
}
}
@@ -2,7 +2,7 @@
declare(strict_types=1);
namespace MauticPlugin\PlanBundle\DependencyInjection;
namespace MauticPlugin\ProgramBundle\DependencyInjection;
use Symfony\Component\Config\FileLocator;
use Symfony\Component\DependencyInjection\ContainerBuilder;
@@ -12,7 +12,7 @@ use Symfony\Component\DependencyInjection\Loader\PhpFileLoader;
/**
* Loads Config/services.php (Symfony finds this class by naming convention).
*/
final class PlanExtension extends Extension
final class ProgramExtension extends Extension
{
/**
* @param mixed[] $configs
+253 -107
View File
@@ -2,13 +2,15 @@
declare(strict_types=1);
namespace MauticPlugin\PlanBundle\Entity;
namespace MauticPlugin\ProgramBundle\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 Mautic\LeadBundle\Entity\LeadList;
use Mautic\StageBundle\Entity\Stage;
use Symfony\Component\Validator\Constraints\Length;
use Symfony\Component\Validator\Constraints\NotBlank;
@@ -16,50 +18,53 @@ 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.
* One audience of the global directory (Programs > Audiences): who the plan is aimed at, and how.
* Audiences are independent of plans; a plan links to them from its Audiences tab through InitiativeAudience,
* which carries the audience's priority in that plan, and possibly a initiative-specific message.
*
* 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.
* Which attributes are offered on the forms is set up by the admin in Settings > Configuration >
* Initiative Settings (per-attribute toggles, so a b2b install and a b2c install define their personas
* differently); the decision roles and the tones are lists edited there too. See AudienceAttributes.
*
* The stages are the Mautic stages (Settings > Stages) this audience maps to; an audience can have
* any number of them, or none. Deleting a stage removes the link (join table row), not the audience.
*
* The segments are the Mautic segments (LeadBundle lists) this audience maps to. They are purely
* informational: the user may assign none, one or several; the list view shows their names and
* their contact counts. Deleting a segment removes the link, not the audience.
*
* isPublished (from FormEntity) means "active": an unpublished audience is hidden from the initiative
* form's audience picker, but keeps its history on the initiatives it is already linked to.
*/
class Target
class Audience extends FormEntity
{
public const TABLE_NAME = 'plan_targets';
public const TABLE_NAME = 'initiative_audiences';
/**
* 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',
'email' => 'mautic.program.audience.channel.email',
'sms' => 'mautic.program.audience.channel.sms',
'web' => 'mautic.program.audience.channel.web',
'social_organic' => 'mautic.program.audience.channel.social_organic',
'paid_social' => 'mautic.program.audience.channel.paid_social',
'paid_search' => 'mautic.program.audience.channel.paid_search',
'events_webinar' => 'mautic.program.audience.channel.events_webinar',
'outbound_sales' => 'mautic.program.audience.channel.outbound_sales',
'partners' => 'mautic.program.audience.channel.partners',
];
private ?int $id = null;
private ?Plan $plan = null;
private ?string $name = null;
private TargetType $targetType = TargetType::Persona;
private TargetPriority $priority = TargetPriority::Primary;
private AudienceType $audienceType = AudienceType::Persona;
/**
* @var Collection<int, Stage>
* One-line positioning statement ("The busy CFO who…").
*/
private Collection $stages;
/**
* Estimated number of people or accounts, or null when unknown.
*/
private ?int $estimatedSize = null;
private ?string $tagline = null;
/**
* Demographics, firmographics, job titles, geography.
@@ -67,37 +72,88 @@ class Target
private ?string $profileCriteria = null;
/**
* Problems, triggers, motivations.
* What drives the audience.
*/
private ?string $painPoints = null;
private ?string $motivations = null;
/**
* Key message / hook for this target in this plan.
* What holds the audience back from buying.
*/
private ?string $valueProposition = null;
private ?string $barriers = null;
/**
* Keys of self::CHANNELS the plan means to use for this target.
* What annoys or blocks the audience day to day (formerly Pain points).
*/
private ?string $frustrations = null;
/**
* What makes the audience act (content, season, event…).
*/
private ?string $triggers = null;
/**
* Key of a decision role set up in Settings > Configuration > Initiative Settings
* (parameter program_audience_decision_roles), or null when the attribute is unused.
*/
private ?string $decisionRole = null;
/**
* Keys of tones set up in Settings > Configuration > Initiative Settings
* (parameter program_audience_tones), or null/[] when the attribute is unused.
*
* @var list<string>|null
*/
private ?array $preferredTones = null;
/**
* Keys of self::CHANNELS the initiative means to use for this audience.
*
* @var list<string>|null
*/
private ?array $preferredChannels = null;
/**
* Display order within the plan, from 0. Set by drag and drop in the form.
* The Mautic stages this audience maps to; any number, or none.
*
* @var Collection<int, Stage>
*/
private int $position = 0;
private Collection $stages;
/**
* The Mautic segments this audience maps to; any number, or none. Purely informational.
*
* @var Collection<int, LeadList>
*/
private Collection $segments;
/**
* Estimated number of people or accounts, or null when unknown.
*/
private ?int $estimatedSize = null;
/**
* The links to the initiatives this audience is assigned to. Inverse side, read-only from here: the
* links are managed from the plans (Initiative::addAudience/removeAudience).
*
* @var Collection<int, InitiativeAudience>
*/
private Collection $initiativeLinks;
public function __construct()
{
$this->stages = new ArrayCollection();
$this->segments = new ArrayCollection();
$this->initiativeLinks = new ArrayCollection();
}
public function __clone()
{
$this->id = null;
$this->plan = null;
$this->stages = new ArrayCollection();
$this->segments = new ArrayCollection();
$this->initiativeLinks = new ArrayCollection();
parent::__clone();
}
public static function loadMetadata(OrmClassMetadata $metadata): void
@@ -105,40 +161,32 @@ class Target
$builder = new ClassMetadataBuilder($metadata);
$builder->setTable(self::TABLE_NAME)
->setCustomRepositoryClass(TargetRepository::class);
->setCustomRepositoryClass(AudienceRepository::class);
$builder->addId();
$builder->createManyToOne('plan', Plan::class)
->inversedBy('targets')
->addJoinColumn('plan_id', 'id', false, false, 'CASCADE')
$builder->createField('name', Types::STRING)
->length(191)
->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',
'fieldName' => 'audienceType',
'columnName' => 'audience_type',
'type' => Types::STRING,
'length' => 30,
'enumType' => TargetType::class,
'options' => ['default' => TargetType::Persona->value],
'enumType' => AudienceType::class,
'options' => ['default' => AudienceType::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) {
foreach ([
'tagline' => 'tagline',
'profileCriteria' => 'profile_criteria',
'motivations' => 'motivations',
'barriers' => 'barriers',
'frustrations' => 'frustrations',
'triggers' => 'triggers',
] as $field => $column) {
$metadata->mapField([
'fieldName' => $field,
'columnName' => $column,
@@ -147,33 +195,54 @@ class Target
]);
}
// Key of a configured decision role; the attribute may be unused (null).
$builder->createField('decisionRole', Types::STRING)
->columnName('decision_role')
->length(64)
->nullable()
->build();
$builder->createField('preferredTones', Types::JSON)
->columnName('preferred_tones')
->nullable()
->build();
$builder->createField('preferredChannels', Types::JSON)
->columnName('preferred_channels')
->nullable()
->build();
$builder->createManyToMany('stages', Stage::class)
->setJoinTable('plan_target_stages')
->addJoinColumn('target_id', 'id', false, false, 'CASCADE')
->setJoinTable('initiative_audiences_stages')
->addJoinColumn('audience_id', 'id', false, false, 'CASCADE')
->addInverseJoinColumn('stage_id', 'id', false, false, 'CASCADE')
->build();
$builder->createManyToMany('segments', LeadList::class)
->setJoinTable('initiative_audiences_segments')
->addJoinColumn('audience_id', 'id', false, false, 'CASCADE')
->addInverseJoinColumn('leadlist_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)
// The links to the initiatives, managed from the initiatives.
$builder->createOneToMany('initiativeLinks', InitiativeAudience::class)
->mappedBy('audience')
->fetchExtraLazy()
->build();
}
public static function loadValidatorMetadata(ClassMetadata $metadata): void
{
$metadata->addPropertyConstraint('name', new NotBlank(message: 'mautic.plan.target.name.required'));
$metadata->addPropertyConstraint('name', new NotBlank(message: 'mautic.program.audience.name.required'));
$metadata->addPropertyConstraint('name', new Length(max: 191));
$metadata->addPropertyConstraint('estimatedSize', new PositiveOrZero(message: 'mautic.plan.target.estimated_size.invalid'));
$metadata->addPropertyConstraint('estimatedSize', new PositiveOrZero(message: 'mautic.program.audience.estimated_size.invalid'));
$metadata->addPropertyConstraint('decisionRole', new Length(max: 64));
}
public function getId(): ?int
@@ -181,18 +250,6 @@ class Target
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;
@@ -200,31 +257,37 @@ class Target
public function setName(?string $name): static
{
$this->isChanged('name', $name);
$this->name = $name;
return $this;
}
public function getTargetType(): TargetType
public function getAudienceType(): AudienceType
{
return $this->targetType;
return $this->audienceType;
}
public function setTargetType(TargetType $targetType): static
public function setAudienceType(AudienceType $audienceType): static
{
$this->targetType = $targetType;
if ($audienceType !== $this->audienceType) {
// isChanged() can't log enums (they aren't stringable), so log the backing values.
$this->addChange('audienceType', [$this->audienceType->value, $audienceType->value]);
}
$this->audienceType = $audienceType;
return $this;
}
public function getPriority(): TargetPriority
public function getTagline(): ?string
{
return $this->priority;
return $this->tagline;
}
public function setPriority(TargetPriority $priority): static
public function setTagline(?string $tagline): static
{
$this->priority = $priority;
$this->isChanged('tagline', $tagline);
$this->tagline = $tagline;
return $this;
}
@@ -253,6 +316,30 @@ class Target
return $this;
}
/**
* @return Collection<int, LeadList>
*/
public function getSegments(): Collection
{
return $this->segments;
}
public function addSegment(LeadList $segment): static
{
if (!$this->segments->contains($segment)) {
$this->segments->add($segment);
}
return $this;
}
public function removeSegment(LeadList $segment): static
{
$this->segments->removeElement($segment);
return $this;
}
public function getEstimatedSize(): ?int
{
return $this->estimatedSize;
@@ -260,6 +347,7 @@ class Target
public function setEstimatedSize(?int $estimatedSize): static
{
$this->isChanged('estimatedSize', $estimatedSize);
$this->estimatedSize = $estimatedSize;
return $this;
@@ -272,31 +360,92 @@ class Target
public function setProfileCriteria(?string $profileCriteria): static
{
$this->isChanged('profileCriteria', $profileCriteria);
$this->profileCriteria = $profileCriteria;
return $this;
}
public function getPainPoints(): ?string
public function getMotivations(): ?string
{
return $this->painPoints;
return $this->motivations;
}
public function setPainPoints(?string $painPoints): static
public function setMotivations(?string $motivations): static
{
$this->painPoints = $painPoints;
$this->isChanged('motivations', $motivations);
$this->motivations = $motivations;
return $this;
}
public function getValueProposition(): ?string
public function getBarriers(): ?string
{
return $this->valueProposition;
return $this->barriers;
}
public function setValueProposition(?string $valueProposition): static
public function setBarriers(?string $barriers): static
{
$this->valueProposition = $valueProposition;
$this->isChanged('barriers', $barriers);
$this->barriers = $barriers;
return $this;
}
public function getFrustrations(): ?string
{
return $this->frustrations;
}
public function setFrustrations(?string $frustrations): static
{
$this->isChanged('frustrations', $frustrations);
$this->frustrations = $frustrations;
return $this;
}
public function getTriggers(): ?string
{
return $this->triggers;
}
public function setTriggers(?string $triggers): static
{
$this->isChanged('triggers', $triggers);
$this->triggers = $triggers;
return $this;
}
public function getDecisionRole(): ?string
{
return $this->decisionRole;
}
public function setDecisionRole(?string $decisionRole): static
{
$this->isChanged('decisionRole', $decisionRole);
$this->decisionRole = $decisionRole;
return $this;
}
/**
* @return list<string>|null
*/
public function getPreferredTones(): ?array
{
return $this->preferredTones;
}
/**
* @param list<string>|null $preferredTones
*/
public function setPreferredTones(?array $preferredTones): static
{
$this->isChanged('preferredTones', $preferredTones);
$this->preferredTones = $preferredTones;
return $this;
}
@@ -314,20 +463,17 @@ class Target
*/
public function setPreferredChannels(?array $preferredChannels): static
{
$this->isChanged('preferredChannels', $preferredChannels);
$this->preferredChannels = $preferredChannels;
return $this;
}
public function getPosition(): int
/**
* @return Collection<int, InitiativeAudience>
*/
public function getInitiativeLinks(): Collection
{
return $this->position;
}
public function setPosition(?int $position): static
{
$this->position = $position ?? 0;
return $this;
return $this->initiativeLinks;
}
}
+4 -4
View File
@@ -2,12 +2,12 @@
declare(strict_types=1);
namespace MauticPlugin\PlanBundle\Entity;
namespace MauticPlugin\ProgramBundle\Entity;
/**
* How important a plan's target is to the plan. The order of the cases is the order of the dropdown.
* How important an initiative's audience is to the initiative. The order of the cases is the order of the dropdown.
*/
enum TargetPriority: string
enum AudiencePriority: string
{
case Primary = 'primary';
case Secondary = 'secondary';
@@ -15,7 +15,7 @@ enum TargetPriority: string
public function getLabelKey(): string
{
return 'mautic.plan.target.priority.'.$this->value;
return 'mautic.program.audience.priority.'.$this->value;
}
public function getLabelClass(): string
+76 -4
View File
@@ -2,17 +2,89 @@
declare(strict_types=1);
namespace MauticPlugin\PlanBundle\Entity;
namespace MauticPlugin\ProgramBundle\Entity;
use Doctrine\DBAL\Connection;
use Mautic\CoreBundle\Entity\CommonRepository;
/**
* @extends CommonRepository<Target>
* @extends CommonRepository<Audience>
*/
class TargetRepository extends CommonRepository
class AudienceRepository extends CommonRepository
{
public function getTableAlias(): string
{
return 'pt';
return 'pa';
}
/**
* The contact count of one segment: lead_lists_leads rows with manually_removed = 0.
*/
public function getSegmentContactCount(int $leadlistId): int
{
$count = $this->getEntityManager()->getConnection()->fetchOne(
'SELECT COUNT(ll.lead_id) FROM lead_lists_leads ll WHERE ll.leadlist_id = :leadlistId AND ll.manually_removed = 0',
['leadlistId' => $leadlistId]
);
return (int) $count;
}
/**
* Contact counts (lead_lists_leads rows with manually_removed = 0) for the segments of one
* audience, keyed by segment id. Used by the list view to show "Segment (123)".
*
* @return array<int, int> leadlist_id => contact count
*/
public function getSegmentContactCounts(int $audienceId): array
{
$rows = $this->getEntityManager()->getConnection()->fetchAllAssociative(
'SELECT s.leadlist_id, COUNT(ll.lead_id) AS cnt
FROM initiative_audiences_segments s
JOIN lead_lists_leads ll ON ll.leadlist_id = s.leadlist_id AND ll.manually_removed = 0
WHERE s.audience_id = :audienceId
GROUP BY s.leadlist_id',
['audienceId' => $audienceId]
);
$counts = [];
foreach ($rows as $row) {
$counts[(int) $row['leadlist_id']] = (int) $row['cnt'];
}
return $counts;
}
/**
* Contact counts for the segments of every audience in the list view, keyed by audience id then
* segment id. One query for the whole page.
*
* @param list<int> $audienceIds
*
* @return array<int, array<int, int>> audience_id => (leadlist_id => contact count)
*/
public function getSegmentContactCountsForAudiences(array $audienceIds): array
{
if ([] === $audienceIds) {
return [];
}
$connection = $this->getEntityManager()->getConnection();
$rows = $connection->fetchAllAssociative(
'SELECT s.audience_id, s.leadlist_id, COUNT(ll.lead_id) AS cnt
FROM initiative_audiences_segments s
JOIN lead_lists_leads ll ON ll.leadlist_id = s.leadlist_id AND ll.manually_removed = 0
WHERE s.audience_id IN (:audienceIds)
GROUP BY s.audience_id, s.leadlist_id',
['audienceIds' => $audienceIds],
['audienceIds' => Connection::PARAM_INT_ARRAY]
);
$counts = [];
foreach ($rows as $row) {
$counts[(int) $row['audience_id']][(int) $row['leadlist_id']] = (int) $row['cnt'];
}
return $counts;
}
}
+5 -5
View File
@@ -2,12 +2,12 @@
declare(strict_types=1);
namespace MauticPlugin\PlanBundle\Entity;
namespace MauticPlugin\ProgramBundle\Entity;
/**
* The kind of audience a plan's target describes. The order of the cases is the order of the dropdown.
* The kind of audience an initiative's audience entry describes. The order of the cases is the order of the dropdown.
*/
enum TargetType: string
enum AudienceType: string
{
case Persona = 'persona';
case Icp = 'icp';
@@ -17,11 +17,11 @@ enum TargetType: string
public function getLabelKey(): string
{
return 'mautic.plan.target.type.'.$this->value;
return 'mautic.program.audience.type.'.$this->value;
}
/**
* A fixed pictogram per type, for the unlabeled first column of the Targets tab (like the other
* A fixed pictogram per type, for the unlabeled first column of the Audiences tab (like the other
* tabs' pictograms, from the Remix Icon set Mautic ships).
*/
public function getIcon(): string
+2 -2
View File
@@ -2,10 +2,10 @@
declare(strict_types=1);
namespace MauticPlugin\PlanBundle\Entity;
namespace MauticPlugin\ProgramBundle\Entity;
/**
* For repositories of typed plan items (description items, allocation items, objectives, tasks).
* For repositories of typed initiative items (description items, allocation items, objectives, tasks).
*/
trait CountsItemsByTypeTrait
{
+1 -1
View File
@@ -2,7 +2,7 @@
declare(strict_types=1);
namespace MauticPlugin\PlanBundle\Entity;
namespace MauticPlugin\ProgramBundle\Entity;
/**
* An object with an optional start and end date. Checked by the EndDateAfterStartDate constraint.
+2 -2
View File
@@ -2,7 +2,7 @@
declare(strict_types=1);
namespace MauticPlugin\PlanBundle\Entity;
namespace MauticPlugin\ProgramBundle\Entity;
/**
* The type of a task dependency edge. The order of the cases is the order of the dropdown.
@@ -16,6 +16,6 @@ enum DependencyType: string
public function getLabelKey(): string
{
return 'mautic.plan.task.dependency_type.'.$this->value;
return 'mautic.program.task.dependency_type.'.$this->value;
}
}
+81 -78
View File
@@ -2,7 +2,7 @@
declare(strict_types=1);
namespace MauticPlugin\PlanBundle\Entity;
namespace MauticPlugin\ProgramBundle\Entity;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
@@ -12,16 +12,16 @@ use Mautic\CategoryBundle\Entity\Category;
use Mautic\CoreBundle\Doctrine\Mapping\ClassMetadataBuilder;
use Mautic\CoreBundle\Entity\FormEntity;
use Mautic\UserBundle\Entity\User;
use MauticPlugin\PlanBundle\Validator\Constraints\EndDateAfterStartDate;
use MauticPlugin\ProgramBundle\Validator\Constraints\EndDateAfterStartDate;
use Symfony\Component\Validator\Constraints\NotBlank;
use Symfony\Component\Validator\Constraints\NotNull;
use Symfony\Component\Validator\Constraints\Range;
use Symfony\Component\Validator\Constraints\Valid;
use Symfony\Component\Validator\Mapping\ClassMetadata;
class Plan extends FormEntity implements DateRangeInterface
class Initiative extends FormEntity implements DateRangeInterface
{
public const TABLE_NAME = 'plans';
public const TABLE_NAME = 'initiatives';
public const VERSION_MIN = 1;
public const VERSION_MAX = 99;
@@ -29,49 +29,51 @@ class Plan extends FormEntity implements DateRangeInterface
private ?int $id = null;
/**
* Plan version, 1 to 99. Edited by hand; not related to Doctrine optimistic locking.
* Initiative version, 1 to 99. Edited by hand; not related to Doctrine optimistic locking.
*/
private ?int $version = self::VERSION_MIN;
/**
* @var Collection<int, PlanObjective>
* @var Collection<int, InitiativeObjective>
*/
private Collection $objectives;
/**
* The content of the Description tab. Each item has a type set up by the admin in
* Settings > Configuration > Plan.
* Settings > Configuration > Initiative.
*
* @var Collection<int, PlanDescriptionItem>
* @var Collection<int, InitiativeDescriptionItem>
*/
private Collection $descriptionItems;
/**
* The cost lines of the Allocations tab. Each item has a type set up by the admin in
* Settings > Configuration > Plan.
* Settings > Configuration > Initiative.
*
* @var Collection<int, PlanAllocationItem>
* @var Collection<int, InitiativeAllocationItem>
*/
private Collection $allocationItems;
/**
* The audiences of the Targets tab. Each target has a fixed type (persona, ICP, …), not an
* admin-configured one.
* The audiences of the Audiences tab: links to the audiences of the global directory
* (Programs > Audiences), each with the audience's priority in this plan and possibly a
* initiative-specific message. See InitiativeAudience.
*
* @var Collection<int, Target>
* @var Collection<int, InitiativeAudience>
*/
private Collection $targets;
private Collection $audiences;
/**
* The links to the stakeholders of the global directory (Planning > Stakeholders), each with the
* stakeholder's role in this plan. See PlanStakeholder.
* The links to the stakeholders of the global directory (Programs > Stakeholders), each with the
* stakeholder's role in this plan. See InitiativeStakeholder.
*
* @var Collection<int, PlanStakeholder>
* @var Collection<int, InitiativeStakeholder>
*/
private Collection $stakeholders;
/**
* Tasks are managed on their own pages (TaskController). Read-only from the plan: deleting a plan
* Tasks are managed on their own pages (TaskController).
* Read-only from the initiative: deleting an initiative
* deletes its tasks through the database (ON DELETE CASCADE).
*
* @var Collection<int, Task>
@@ -80,7 +82,7 @@ class Plan extends FormEntity implements DateRangeInterface
private ?string $name = null;
private PlanStatus $status = PlanStatus::Draft;
private InitiativeStatus $status = InitiativeStatus::Draft;
/**
* Required in the form. The column is nullable only so that deleting the user doesn't delete the plan (SET NULL).
@@ -106,7 +108,7 @@ class Plan extends FormEntity implements DateRangeInterface
$this->objectives = new ArrayCollection();
$this->descriptionItems = new ArrayCollection();
$this->allocationItems = new ArrayCollection();
$this->targets = new ArrayCollection();
$this->audiences = new ArrayCollection();
$this->stakeholders = new ArrayCollection();
$this->tasks = new ArrayCollection();
}
@@ -136,11 +138,11 @@ 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 audiences (directory entries), with fresh links.
$audiences = $this->audiences;
$this->audiences = new ArrayCollection();
foreach ($audiences as $audience) {
$this->addAudience(clone $audience);
}
// A clone keeps the same stakeholders (directory entries), with fresh links.
@@ -158,8 +160,8 @@ class Plan extends FormEntity implements DateRangeInterface
$builder = new ClassMetadataBuilder($metadata);
$builder->setTable(self::TABLE_NAME)
->setCustomRepositoryClass(PlanRepository::class)
->addIndex(['status'], 'plan_status');
->setCustomRepositoryClass(InitiativeRepository::class)
->addIndex(['status'], 'program_status');
// id and name; no description column (replaced by description items).
$builder->addIdColumns('name', false);
@@ -169,7 +171,7 @@ class Plan extends FormEntity implements DateRangeInterface
'fieldName' => 'status',
'type' => Types::STRING,
'length' => 20,
'enumType' => PlanStatus::class,
'enumType' => InitiativeStatus::class,
]);
$builder->createManyToOne('owner', User::class)
@@ -195,8 +197,8 @@ class Plan extends FormEntity implements DateRangeInterface
->option('default', self::VERSION_MIN)
->build();
$builder->createOneToMany('objectives', PlanObjective::class)
->mappedBy('plan')
$builder->createOneToMany('objectives', InitiativeObjective::class)
->mappedBy('initiative')
->cascadePersist()
->cascadeRemove()
->orphanRemoval()
@@ -204,8 +206,8 @@ class Plan extends FormEntity implements DateRangeInterface
->fetchExtraLazy()
->build();
$builder->createOneToMany('descriptionItems', PlanDescriptionItem::class)
->mappedBy('plan')
$builder->createOneToMany('descriptionItems', InitiativeDescriptionItem::class)
->mappedBy('initiative')
->cascadePersist()
->cascadeRemove()
->orphanRemoval()
@@ -213,8 +215,8 @@ class Plan extends FormEntity implements DateRangeInterface
->fetchExtraLazy()
->build();
$builder->createOneToMany('allocationItems', PlanAllocationItem::class)
->mappedBy('plan')
$builder->createOneToMany('allocationItems', InitiativeAllocationItem::class)
->mappedBy('initiative')
->cascadePersist()
->cascadeRemove()
->orphanRemoval()
@@ -222,8 +224,8 @@ class Plan extends FormEntity implements DateRangeInterface
->fetchExtraLazy()
->build();
$builder->createOneToMany('targets', Target::class)
->mappedBy('plan')
$builder->createOneToMany('audiences', InitiativeAudience::class)
->mappedBy('initiative')
->cascadePersist()
->cascadeRemove()
->orphanRemoval()
@@ -231,8 +233,8 @@ class Plan extends FormEntity implements DateRangeInterface
->fetchExtraLazy()
->build();
$builder->createOneToMany('stakeholders', PlanStakeholder::class)
->mappedBy('plan')
$builder->createOneToMany('stakeholders', InitiativeStakeholder::class)
->mappedBy('initiative')
->cascadePersist()
->cascadeRemove()
->orphanRemoval()
@@ -241,7 +243,7 @@ class Plan extends FormEntity implements DateRangeInterface
->build();
$builder->createOneToMany('tasks', Task::class)
->mappedBy('plan')
->mappedBy('initiative')
->setOrderBy(['name' => 'ASC'])
->fetchExtraLazy()
->build();
@@ -249,19 +251,19 @@ class Plan extends FormEntity implements DateRangeInterface
public static function loadValidatorMetadata(ClassMetadata $metadata): void
{
$metadata->addPropertyConstraint('version', new NotNull(message: 'mautic.plan.version.range'));
$metadata->addPropertyConstraint('version', new NotNull(message: 'mautic.program.version.range'));
$metadata->addPropertyConstraint('version', new Range(
notInRangeMessage: 'mautic.plan.version.range',
notInRangeMessage: 'mautic.program.version.range',
min: self::VERSION_MIN,
max: self::VERSION_MAX,
));
$metadata->addPropertyConstraint('objectives', new Valid());
$metadata->addPropertyConstraint('descriptionItems', new Valid());
$metadata->addPropertyConstraint('allocationItems', new Valid());
$metadata->addPropertyConstraint('targets', new Valid());
$metadata->addPropertyConstraint('audiences', 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->addPropertyConstraint('owner', new NotBlank(message: 'mautic.program.owner.required'));
$metadata->addConstraint(new EndDateAfterStartDate());
}
@@ -293,12 +295,12 @@ class Plan extends FormEntity implements DateRangeInterface
* 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.
*
* @return Collection<int, PlanObjective>
* @return Collection<int, InitiativeObjective>
*/
public function getObjectives(): Collection
{
$objectives = self::sortedByPosition($this->objectives)->toArray();
usort($objectives, function (PlanObjective $a, PlanObjective $b): int {
usort($objectives, function (InitiativeObjective $a, InitiativeObjective $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;
@@ -318,31 +320,32 @@ class Plan extends FormEntity implements DateRangeInterface
}
/**
* The targets sorted by position, as a new collection; see getObjectives().
* The audience links sorted by position, as a new collection; see getObjectives().
*
* @return Collection<int, Target>
* @return Collection<int, InitiativeAudience>
*/
public function getTargets(): Collection
public function getAudiences(): Collection
{
return self::sortedByPosition($this->targets);
return self::sortedByPosition($this->audiences);
}
public function addTarget(Target $target): static
public function addAudience(InitiativeAudience $audience): static
{
if (!$this->targets->contains($target)) {
$target->setPlan($this);
$this->targets->add($target);
if (!$this->audiences->contains($audience)) {
$audience->setInitiative($this);
$this->audiences->add($audience);
}
return $this;
}
/**
* Removing a target from the plan deletes it (orphanRemoval).
* Removing an audience link from the plan deletes it (orphanRemoval). The audience itself stays
* in the global directory.
*/
public function removeTarget(Target $target): static
public function removeAudience(InitiativeAudience $audience): static
{
$this->targets->removeElement($target);
$this->audiences->removeElement($audience);
return $this;
}
@@ -350,17 +353,17 @@ class Plan extends FormEntity implements DateRangeInterface
/**
* The stakeholder links sorted by position, as a new collection; see getObjectives().
*
* @return Collection<int, PlanStakeholder>
* @return Collection<int, InitiativeStakeholder>
*/
public function getStakeholders(): Collection
{
return self::sortedByPosition($this->stakeholders);
}
public function addStakeholder(PlanStakeholder $stakeholder): static
public function addStakeholder(InitiativeStakeholder $stakeholder): static
{
if (!$this->stakeholders->contains($stakeholder)) {
$stakeholder->setPlan($this);
$stakeholder->setInitiative($this);
$this->stakeholders->add($stakeholder);
}
@@ -371,17 +374,17 @@ class Plan extends FormEntity implements DateRangeInterface
* Removing a stakeholder link from the plan deletes it (orphanRemoval). The stakeholder itself
* stays in the global directory.
*/
public function removeStakeholder(PlanStakeholder $stakeholder): static
public function removeStakeholder(InitiativeStakeholder $stakeholder): static
{
$this->stakeholders->removeElement($stakeholder);
return $this;
}
public function addObjective(PlanObjective $objective): static
public function addObjective(InitiativeObjective $objective): static
{
if (!$this->objectives->contains($objective)) {
$objective->setPlan($this);
$objective->setInitiative($this);
$this->objectives->add($objective);
}
@@ -391,7 +394,7 @@ class Plan extends FormEntity implements DateRangeInterface
/**
* Removing an objective from the plan deletes it (orphanRemoval).
*/
public function removeObjective(PlanObjective $objective): static
public function removeObjective(InitiativeObjective $objective): static
{
$this->objectives->removeElement($objective);
@@ -401,7 +404,7 @@ class Plan extends FormEntity implements DateRangeInterface
/**
* The description items sorted by position, as a new collection; see getObjectives().
*
* @return Collection<int, PlanDescriptionItem>
* @return Collection<int, InitiativeDescriptionItem>
*/
public function getDescriptionItems(): Collection
{
@@ -411,17 +414,17 @@ class Plan extends FormEntity implements DateRangeInterface
/**
* The allocation items sorted by position, as a new collection; see getObjectives().
*
* @return Collection<int, PlanAllocationItem>
* @return Collection<int, InitiativeAllocationItem>
*/
public function getAllocationItems(): Collection
{
return self::sortedByPosition($this->allocationItems);
}
public function addAllocationItem(PlanAllocationItem $allocationItem): static
public function addAllocationItem(InitiativeAllocationItem $allocationItem): static
{
if (!$this->allocationItems->contains($allocationItem)) {
$allocationItem->setPlan($this);
$allocationItem->setInitiative($this);
$this->allocationItems->add($allocationItem);
}
@@ -431,7 +434,7 @@ class Plan extends FormEntity implements DateRangeInterface
/**
* Removing an allocation item from the plan deletes it (orphanRemoval).
*/
public function removeAllocationItem(PlanAllocationItem $allocationItem): static
public function removeAllocationItem(InitiativeAllocationItem $allocationItem): static
{
$this->allocationItems->removeElement($allocationItem);
@@ -465,7 +468,7 @@ class Plan extends FormEntity implements DateRangeInterface
}
/**
* @template T of PlanObjective|PlanDescriptionItem|PlanAllocationItem|Target|PlanStakeholder
* @template T of InitiativeObjective|InitiativeDescriptionItem|InitiativeAllocationItem|Audience|InitiativeStakeholder
*
* @param Collection<int, T> $collection
*
@@ -479,10 +482,10 @@ class Plan extends FormEntity implements DateRangeInterface
return new ArrayCollection($rows);
}
public function addDescriptionItem(PlanDescriptionItem $descriptionItem): static
public function addDescriptionItem(InitiativeDescriptionItem $descriptionItem): static
{
if (!$this->descriptionItems->contains($descriptionItem)) {
$descriptionItem->setPlan($this);
$descriptionItem->setInitiative($this);
$this->descriptionItems->add($descriptionItem);
}
@@ -492,7 +495,7 @@ class Plan extends FormEntity implements DateRangeInterface
/**
* Removing a description item from the plan deletes it (orphanRemoval).
*/
public function removeDescriptionItem(PlanDescriptionItem $descriptionItem): static
public function removeDescriptionItem(InitiativeDescriptionItem $descriptionItem): static
{
$this->descriptionItems->removeElement($descriptionItem);
@@ -500,12 +503,12 @@ class Plan extends FormEntity implements DateRangeInterface
}
/**
* Renumbers objective, description item, allocation item and target positions 0..n-1 following their
* Renumbers objective, description item, allocation item and audience 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, $this->targets, $this->stakeholders] as $collection) {
foreach ([$this->objectives, $this->descriptionItems, $this->allocationItems, $this->audiences, $this->stakeholders] as $collection) {
$rows = $collection->toArray();
usort($rows, fn ($a, $b): int => $a->getPosition() <=> $b->getPosition());
@@ -528,7 +531,7 @@ class Plan extends FormEntity implements DateRangeInterface
return $this;
}
public function getStatus(): PlanStatus
public function getStatus(): InitiativeStatus
{
return $this->status;
}
@@ -537,7 +540,7 @@ class Plan extends FormEntity implements DateRangeInterface
* Sets completedAt when the plan moves to "completed" from another status,
* and clears it when the plan leaves "completed".
*/
public function setStatus(PlanStatus $status): static
public function setStatus(InitiativeStatus $status): static
{
if ($status === $this->status) {
return $this;
@@ -546,9 +549,9 @@ class Plan extends FormEntity implements DateRangeInterface
// isChanged() can't log enums (they aren't stringable), so log the backing values.
$this->addChange('status', [$this->status->value, $status->value]);
if (PlanStatus::Completed === $status) {
if (InitiativeStatus::Completed === $status) {
$this->setCompletedAt(new \DateTime());
} elseif (PlanStatus::Completed === $this->status) {
} elseif (InitiativeStatus::Completed === $this->status) {
$this->setCompletedAt(null);
}
@@ -2,7 +2,7 @@
declare(strict_types=1);
namespace MauticPlugin\PlanBundle\Entity;
namespace MauticPlugin\ProgramBundle\Entity;
use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping\ClassMetadata as OrmClassMetadata;
@@ -13,21 +13,21 @@ use Symfony\Component\Validator\Mapping\ClassMetadata;
/**
* 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
* the general currency (CurrencyProvider). Initiative::$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.
* The type is the key of an allocation item type set up in Settings > Configuration > Initiative Settings
* (parameter program_allocation_item_types); see ItemTypeProvider.
*/
class PlanAllocationItem
class InitiativeAllocationItem
{
public const TABLE_NAME = 'plan_allocation_items';
public const TABLE_NAME = 'initiative_allocation_items';
public const TYPE_MAX_LENGTH = 64;
private ?int $id = null;
private ?Plan $plan = null;
private ?Initiative $initiative = null;
private ?string $type = null;
@@ -50,7 +50,7 @@ class PlanAllocationItem
public function __clone()
{
$this->id = null;
$this->plan = null;
$this->initiative = null;
}
public static function loadMetadata(OrmClassMetadata $metadata): void
@@ -58,13 +58,13 @@ class PlanAllocationItem
$builder = new ClassMetadataBuilder($metadata);
$builder->setTable(self::TABLE_NAME)
->setCustomRepositoryClass(PlanAllocationItemRepository::class);
->setCustomRepositoryClass(InitiativeAllocationItemRepository::class);
$builder->addId();
$builder->createManyToOne('plan', Plan::class)
$builder->createManyToOne('initiative', Initiative::class)
->inversedBy('allocationItems')
->addJoinColumn('plan_id', 'id', false, false, 'CASCADE')
->addJoinColumn('initiative_id', 'id', false, false, 'CASCADE')
->build();
$builder->createField('type', Types::STRING)
@@ -96,7 +96,7 @@ class PlanAllocationItem
public static function loadValidatorMetadata(ClassMetadata $metadata): void
{
$metadata->addPropertyConstraint('type', new NotBlank(message: 'mautic.plan.allocation_item.type.required'));
$metadata->addPropertyConstraint('type', new NotBlank(message: 'mautic.program.allocation_item.type.required'));
$metadata->addPropertyConstraint('type', new Length(max: self::TYPE_MAX_LENGTH));
$metadata->addPropertyConstraint('name', new Length(max: 255));
}
@@ -106,14 +106,14 @@ class PlanAllocationItem
return $this->id;
}
public function getPlan(): ?Plan
public function getInitiative(): ?Initiative
{
return $this->plan;
return $this->initiative;
}
public function setPlan(?Plan $plan): static
public function setInitiative(?Initiative $initiative): static
{
$this->plan = $plan;
$this->initiative = $initiative;
return $this;
}
@@ -2,14 +2,14 @@
declare(strict_types=1);
namespace MauticPlugin\PlanBundle\Entity;
namespace MauticPlugin\ProgramBundle\Entity;
use Mautic\CoreBundle\Entity\CommonRepository;
/**
* @extends CommonRepository<PlanAllocationItem>
* @extends CommonRepository<InitiativeAllocationItem>
*/
class PlanAllocationItemRepository extends CommonRepository
class InitiativeAllocationItemRepository extends CommonRepository
{
use CountsItemsByTypeTrait;
+157
View File
@@ -0,0 +1,157 @@
<?php
declare(strict_types=1);
namespace MauticPlugin\ProgramBundle\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\Constraints\NotBlank;
use Symfony\Component\Validator\Mapping\ClassMetadata;
/**
* The link between a plan and an audience of the global directory, with the audience's priority
* in that plan and possibly a initiative-specific message ("Key message for this plan"): the same
* audience can be primary in one plan and secondary in another.
*
* Initiative::$audiences owns the lifecycle: links are saved and deleted with their plan. Deleting an
* audience deletes its links (ON DELETE CASCADE on both sides).
*/
class InitiativeAudience
{
public const TABLE_NAME = 'initiative_audiences_initiative';
private ?int $id = null;
private ?Initiative $initiative = null;
private ?Audience $audience = null;
private AudiencePriority $priority = AudiencePriority::Primary;
/**
* Key message / hook for this audience in this plan, overriding the audience's own positioning.
*/
private ?string $valueProposition = 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->initiative = null;
}
public static function loadMetadata(OrmClassMetadata $metadata): void
{
$builder = new ClassMetadataBuilder($metadata);
$builder->setTable(self::TABLE_NAME)
->setCustomRepositoryClass(InitiativeAudienceRepository::class);
$builder->addId();
$builder->createManyToOne('initiative', Initiative::class)
->inversedBy('audiences')
->addJoinColumn('initiative_id', 'id', false, false, 'CASCADE')
->build();
$builder->createManyToOne('audience', Audience::class)
->addJoinColumn('audience_id', 'id', false, false, 'CASCADE')
->build();
// Mapped on the raw metadata: ClassMetadataBuilder::addField() forces every string to VARCHAR(191).
$metadata->mapField([
'fieldName' => 'priority',
'type' => Types::STRING,
'length' => 20,
'enumType' => AudiencePriority::class,
'options' => ['default' => AudiencePriority::Primary->value],
]);
$builder->createField('valueProposition', Types::TEXT)
->columnName('value_proposition')
->nullable()
->build();
$builder->createField('position', Types::INTEGER)
->option('default', 0)
->build();
}
public static function loadValidatorMetadata(ClassMetadata $metadata): void
{
$metadata->addPropertyConstraint('audience', new NotBlank(message: 'mautic.program.audience_link.audience.required'));
$metadata->addPropertyConstraint('valueProposition', new Length(max: 1000));
}
public function getId(): ?int
{
return $this->id;
}
public function getInitiative(): ?Initiative
{
return $this->initiative;
}
public function setInitiative(?Initiative $initiative): static
{
$this->initiative = $initiative;
return $this;
}
public function getAudience(): ?Audience
{
return $this->audience;
}
public function setAudience(?Audience $audience): static
{
$this->audience = $audience;
return $this;
}
public function getPriority(): AudiencePriority
{
return $this->priority;
}
public function setPriority(AudiencePriority $priority): static
{
$this->priority = $priority;
return $this;
}
public function getValueProposition(): ?string
{
return $this->valueProposition;
}
public function setValueProposition(?string $valueProposition): static
{
$this->valueProposition = $valueProposition;
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\ProgramBundle\Entity;
use Mautic\CoreBundle\Entity\CommonRepository;
/**
* @extends CommonRepository<InitiativeAudience>
*/
class InitiativeAudienceRepository extends CommonRepository
{
public function getTableAlias(): string
{
return 'pa';
}
}
@@ -2,7 +2,7 @@
declare(strict_types=1);
namespace MauticPlugin\PlanBundle\Entity;
namespace MauticPlugin\ProgramBundle\Entity;
use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping\ClassMetadata as OrmClassMetadata;
@@ -12,21 +12,21 @@ use Symfony\Component\Validator\Constraints\NotBlank;
use Symfony\Component\Validator\Mapping\ClassMetadata;
/**
* One item of a plan's Description tab. Plan::$descriptionItems owns the lifecycle: items are saved and
* One item of a plan's Description tab. Initiative::$descriptionItems owns the lifecycle: items are saved and
* deleted with their plan, and are ordered by position.
*
* The type is the key of a type set up in Settings > Configuration > Plan (parameter
* plan_description_item_types); see ItemTypeProvider (kind "description") for its name and description.
* The type is the key of a type set up in Settings > Configuration > Initiative (parameter
* program_description_item_types); see ItemTypeProvider (kind "description") for its name and description.
*/
class PlanDescriptionItem
class InitiativeDescriptionItem
{
public const TABLE_NAME = 'plan_description_items';
public const TABLE_NAME = 'initiative_description_items';
public const TYPE_MAX_LENGTH = 64;
private ?int $id = null;
private ?Plan $plan = null;
private ?Initiative $initiative = null;
private ?string $type = null;
@@ -40,7 +40,7 @@ class PlanDescriptionItem
public function __clone()
{
$this->id = null;
$this->plan = null;
$this->initiative = null;
}
public static function loadMetadata(OrmClassMetadata $metadata): void
@@ -48,13 +48,13 @@ class PlanDescriptionItem
$builder = new ClassMetadataBuilder($metadata);
$builder->setTable(self::TABLE_NAME)
->setCustomRepositoryClass(PlanDescriptionItemRepository::class);
->setCustomRepositoryClass(InitiativeDescriptionItemRepository::class);
$builder->addId();
$builder->createManyToOne('plan', Plan::class)
$builder->createManyToOne('initiative', Initiative::class)
->inversedBy('descriptionItems')
->addJoinColumn('plan_id', 'id', false, false, 'CASCADE')
->addJoinColumn('initiative_id', 'id', false, false, 'CASCADE')
->build();
$builder->createField('type', Types::STRING)
@@ -72,7 +72,7 @@ class PlanDescriptionItem
public static function loadValidatorMetadata(ClassMetadata $metadata): void
{
$metadata->addPropertyConstraint('type', new NotBlank(message: 'mautic.plan.description_item.type.required'));
$metadata->addPropertyConstraint('type', new NotBlank(message: 'mautic.program.description_item.type.required'));
$metadata->addPropertyConstraint('type', new Length(max: self::TYPE_MAX_LENGTH));
}
@@ -81,14 +81,14 @@ class PlanDescriptionItem
return $this->id;
}
public function getPlan(): ?Plan
public function getInitiative(): ?Initiative
{
return $this->plan;
return $this->initiative;
}
public function setPlan(?Plan $plan): static
public function setInitiative(?Initiative $initiative): static
{
$this->plan = $plan;
$this->initiative = $initiative;
return $this;
}
@@ -2,14 +2,14 @@
declare(strict_types=1);
namespace MauticPlugin\PlanBundle\Entity;
namespace MauticPlugin\ProgramBundle\Entity;
use Mautic\CoreBundle\Entity\CommonRepository;
/**
* @extends CommonRepository<PlanDescriptionItem>
* @extends CommonRepository<InitiativeDescriptionItem>
*/
class PlanDescriptionItemRepository extends CommonRepository
class InitiativeDescriptionItemRepository extends CommonRepository
{
use CountsItemsByTypeTrait;
@@ -2,7 +2,7 @@
declare(strict_types=1);
namespace MauticPlugin\PlanBundle\Entity;
namespace MauticPlugin\ProgramBundle\Entity;
use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping\ClassMetadata as OrmClassMetadata;
@@ -14,12 +14,12 @@ use Symfony\Component\Validator\Constraints\Range;
use Symfony\Component\Validator\Mapping\ClassMetadata;
/**
* An objective of a plan. Plan::$objectives owns the lifecycle: objectives are saved and deleted with
* An objective of a plan. Initiative::$objectives owns the lifecycle: objectives are saved and deleted with
* their plan, and are ordered by position.
*/
class PlanObjective
class InitiativeObjective
{
public const TABLE_NAME = 'plan_objectives';
public const TABLE_NAME = 'initiative_objectives';
public const TYPE_MAX_LENGTH = 64;
@@ -28,7 +28,7 @@ class PlanObjective
private ?int $id = null;
private ?Plan $plan = null;
private ?Initiative $initiative = null;
private ?string $type = null;
@@ -54,7 +54,7 @@ class PlanObjective
public function __clone()
{
$this->id = null;
$this->plan = null;
$this->initiative = null;
}
public static function loadMetadata(OrmClassMetadata $metadata): void
@@ -62,13 +62,13 @@ class PlanObjective
$builder = new ClassMetadataBuilder($metadata);
$builder->setTable(self::TABLE_NAME)
->setCustomRepositoryClass(PlanObjectiveRepository::class);
->setCustomRepositoryClass(InitiativeObjectiveRepository::class);
$builder->addId();
$builder->createManyToOne('plan', Plan::class)
$builder->createManyToOne('initiative', Initiative::class)
->inversedBy('objectives')
->addJoinColumn('plan_id', 'id', false, false, 'CASCADE')
->addJoinColumn('initiative_id', 'id', false, false, 'CASCADE')
->build();
$builder->createField('type', Types::STRING)
@@ -100,13 +100,13 @@ class PlanObjective
public static function loadValidatorMetadata(ClassMetadata $metadata): void
{
$metadata->addPropertyConstraint('title', new NotBlank(message: 'mautic.plan.objective.title.required'));
$metadata->addPropertyConstraint('title', new NotBlank(message: 'mautic.program.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 NotBlank(message: 'mautic.program.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 NotNull(message: 'mautic.program.objective.priority.range'));
$metadata->addPropertyConstraint('priority', new Range(
notInRangeMessage: 'mautic.plan.objective.priority.range',
notInRangeMessage: 'mautic.program.objective.priority.range',
min: self::PRIORITY_MIN,
max: self::PRIORITY_MAX,
));
@@ -117,14 +117,14 @@ class PlanObjective
return $this->id;
}
public function getPlan(): ?Plan
public function getInitiative(): ?Initiative
{
return $this->plan;
return $this->initiative;
}
public function setPlan(?Plan $plan): static
public function setInitiative(?Initiative $initiative): static
{
$this->plan = $plan;
$this->initiative = $initiative;
return $this;
}
@@ -2,14 +2,14 @@
declare(strict_types=1);
namespace MauticPlugin\PlanBundle\Entity;
namespace MauticPlugin\ProgramBundle\Entity;
use Mautic\CoreBundle\Entity\CommonRepository;
/**
* @extends CommonRepository<PlanObjective>
* @extends CommonRepository<InitiativeObjective>
*/
class PlanObjectiveRepository extends CommonRepository
class InitiativeObjectiveRepository extends CommonRepository
{
use CountsItemsByTypeTrait;
@@ -2,14 +2,14 @@
declare(strict_types=1);
namespace MauticPlugin\PlanBundle\Entity;
namespace MauticPlugin\ProgramBundle\Entity;
use Mautic\CoreBundle\Entity\CommonRepository;
/**
* @extends CommonRepository<Plan>
* @extends CommonRepository<Initiative>
*/
class PlanRepository extends CommonRepository
class InitiativeRepository extends CommonRepository
{
public function getTableAlias(): string
{
@@ -2,7 +2,7 @@
declare(strict_types=1);
namespace MauticPlugin\PlanBundle\Entity;
namespace MauticPlugin\ProgramBundle\Entity;
use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping\ClassMetadata as OrmClassMetadata;
@@ -15,23 +15,23 @@ use Symfony\Component\Validator\Mapping\ClassMetadata;
* 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
* Initiative::$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
class InitiativeStakeholder
{
public const TABLE_NAME = 'plan_stakeholders_plan';
public const TABLE_NAME = 'initiative_stakeholders_initiative';
private ?int $id = null;
private ?Plan $plan = null;
private ?Initiative $initiative = null;
private ?Stakeholder $stakeholder = null;
/**
* The stakeholder's role in this plan, free text.
*/
private ?string $roleInPlan = null;
private ?string $roleInInitiative = null;
/**
* Display order within the plan, from 0. Set by drag and drop in the form.
@@ -41,7 +41,7 @@ class PlanStakeholder
public function __clone()
{
$this->id = null;
$this->plan = null;
$this->initiative = null;
}
public static function loadMetadata(OrmClassMetadata $metadata): void
@@ -49,21 +49,21 @@ class PlanStakeholder
$builder = new ClassMetadataBuilder($metadata);
$builder->setTable(self::TABLE_NAME)
->setCustomRepositoryClass(PlanStakeholderRepository::class);
->setCustomRepositoryClass(InitiativeStakeholderRepository::class);
$builder->addId();
$builder->createManyToOne('plan', Plan::class)
$builder->createManyToOne('initiative', Initiative::class)
->inversedBy('stakeholders')
->addJoinColumn('plan_id', 'id', false, false, 'CASCADE')
->addJoinColumn('initiative_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')
$builder->createField('roleInInitiative', Types::STRING)
->columnName('role_in_initiative')
->length(191)
->nullable()
->build();
@@ -75,8 +75,8 @@ class PlanStakeholder
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));
$metadata->addPropertyConstraint('stakeholder', new \Symfony\Component\Validator\Constraints\NotBlank(message: 'mautic.program.stakeholder_link.stakeholder.required'));
$metadata->addPropertyConstraint('roleInInitiative', new Length(max: 191));
}
public function getId(): ?int
@@ -84,14 +84,14 @@ class PlanStakeholder
return $this->id;
}
public function getPlan(): ?Plan
public function getInitiative(): ?Initiative
{
return $this->plan;
return $this->initiative;
}
public function setPlan(?Plan $plan): static
public function setInitiative(?Initiative $initiative): static
{
$this->plan = $plan;
$this->initiative = $initiative;
return $this;
}
@@ -108,14 +108,14 @@ class PlanStakeholder
return $this;
}
public function getRoleInPlan(): ?string
public function getRoleInInitiative(): ?string
{
return $this->roleInPlan;
return $this->roleInInitiative;
}
public function setRoleInPlan(?string $roleInPlan): static
public function setRoleInInitiative(?string $roleInInitiative): static
{
$this->roleInPlan = $roleInPlan;
$this->roleInInitiative = $roleInInitiative;
return $this;
}
@@ -2,14 +2,14 @@
declare(strict_types=1);
namespace MauticPlugin\PlanBundle\Entity;
namespace MauticPlugin\ProgramBundle\Entity;
use Mautic\CoreBundle\Entity\CommonRepository;
/**
* @extends CommonRepository<PlanStakeholder>
* @extends CommonRepository<InitiativeStakeholder>
*/
class PlanStakeholderRepository extends CommonRepository
class InitiativeStakeholderRepository extends CommonRepository
{
public function getTableAlias(): string
{
+34
View File
@@ -0,0 +1,34 @@
<?php
declare(strict_types=1);
namespace MauticPlugin\ProgramBundle\Entity;
enum InitiativeStatus: string
{
case Draft = 'draft';
case Planned = 'planned';
case Active = 'active';
case Paused = 'paused';
case Completed = 'completed';
case Archived = 'archived';
public function getLabelKey(): string
{
return 'mautic.program.status.'.$this->value;
}
/**
* The Bootstrap class of the status label in the tables (the initiative's Status column).
*/
public function getLabelClass(): string
{
return match ($this) {
self::Active => 'label-success',
self::Completed => 'label-info',
self::Paused => 'label-warning',
self::Archived => 'label-default',
self::Draft, self::Planned => 'label-primary',
};
}
}
-20
View File
@@ -1,20 +0,0 @@
<?php
declare(strict_types=1);
namespace MauticPlugin\PlanBundle\Entity;
enum PlanStatus: string
{
case Draft = 'draft';
case Planned = 'planned';
case Active = 'active';
case Paused = 'paused';
case Completed = 'completed';
case Archived = 'archived';
public function getLabelKey(): string
{
return 'mautic.plan.status.'.$this->value;
}
}
+2 -2
View File
@@ -2,7 +2,7 @@
declare(strict_types=1);
namespace MauticPlugin\PlanBundle\Entity;
namespace MauticPlugin\ProgramBundle\Entity;
/**
* The RACI roles of a task assignment. The order of the cases is the order of the dropdown.
@@ -16,7 +16,7 @@ enum RaciRole: string
public function getLabelKey(): string
{
return 'mautic.plan.task.raci_role.'.$this->value;
return 'mautic.program.task.raci_role.'.$this->value;
}
public function getLabelClass(): string
+22 -22
View File
@@ -2,7 +2,7 @@
declare(strict_types=1);
namespace MauticPlugin\PlanBundle\Entity;
namespace MauticPlugin\ProgramBundle\Entity;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
@@ -16,20 +16,20 @@ 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.
* A stakeholder of the program: a person, a company or a team involved in the initiatives ("Agency XYZ",
* "Exec committee"). Stakeholders are a global directory (Programs > Stakeholders), independent of
* initiatives; an initiative links to them through InitiativeStakeholder, which carries the stakeholder's role in that
* initiative.
*
* The type is the key of a stakeholder type set up in Settings > Configuration > Plan Settings
* (parameter plan_stakeholder_types); see ItemTypeProvider (kind "stakeholder").
* The type is the key of a stakeholder type set up in Settings > Configuration > Initiative Settings
* (parameter program_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.
* isPublished (from FormEntity) means "active": an unpublished stakeholder is hidden from the initiative
* form's stakeholder picker, but keeps its history on the initiatives it is already linked to.
*/
class Stakeholder extends FormEntity
{
public const TABLE_NAME = 'plan_stakeholders';
public const TABLE_NAME = 'initiative_stakeholders';
public const TYPE_MAX_LENGTH = 64;
@@ -50,16 +50,16 @@ class Stakeholder extends FormEntity
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).
* The links to the initiatives this stakeholder is assigned to. Inverse side, read-only from here: the
* links are managed from the plans (Initiative::addStakeholder/removeStakeholder).
*
* @var Collection<int, PlanStakeholder>
* @var Collection<int, InitiativeStakeholder>
*/
private Collection $planLinks;
private Collection $initiativeLinks;
public function __construct()
{
$this->planLinks = new ArrayCollection();
$this->initiativeLinks = new ArrayCollection();
}
public static function loadMetadata(OrmClassMetadata $metadata): void
@@ -96,19 +96,19 @@ class Stakeholder extends FormEntity
->nullable()
->build();
$builder->createOneToMany('planLinks', PlanStakeholder::class)
$builder->createOneToMany('initiativeLinks', InitiativeStakeholder::class)
->mappedBy('stakeholder')
->fetchExtraLazy()
->build();
$builder->addIndex(['email'], 'plan_stakeholder_email');
$builder->addIndex(['email'], 'program_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 Email(mode: Email::VALIDATION_MODE_HTML5, message: 'mautic.program.stakeholder.email.invalid'));
$metadata->addPropertyConstraint('email', new Length(max: 191));
$metadata->addPropertyConstraint('phone', new Length(max: 50));
$metadata->addPropertyConstraint('role', new Length(max: 191));
@@ -178,13 +178,13 @@ class Stakeholder extends FormEntity
}
/**
* The links to the plans this stakeholder is assigned to, each with its role in that plan.
* The links to the initiatives this stakeholder is assigned to, each with its role in that initiative.
*
* @return Collection<int, PlanStakeholder>
* @return Collection<int, InitiativeStakeholder>
*/
public function getPlanLinks(): Collection
public function getInitiativeLinks(): Collection
{
return $this->planLinks;
return $this->initiativeLinks;
}
public function setType(?string $type): static
+1 -1
View File
@@ -2,7 +2,7 @@
declare(strict_types=1);
namespace MauticPlugin\PlanBundle\Entity;
namespace MauticPlugin\ProgramBundle\Entity;
use Mautic\CoreBundle\Entity\CommonRepository;
+22 -22
View File
@@ -2,7 +2,7 @@
declare(strict_types=1);
namespace MauticPlugin\PlanBundle\Entity;
namespace MauticPlugin\ProgramBundle\Entity;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
@@ -10,9 +10,9 @@ use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping\ClassMetadata as OrmClassMetadata;
use Mautic\CoreBundle\Doctrine\Mapping\ClassMetadataBuilder;
use Mautic\CoreBundle\Entity\FormEntity;
use MauticPlugin\PlanBundle\Validator\Constraints\EndDateAfterStartDate;
use MauticPlugin\PlanBundle\Validator\Constraints\TaskDates;
use MauticPlugin\PlanBundle\Validator\Constraints\ValidTaskDependency;
use MauticPlugin\ProgramBundle\Validator\Constraints\EndDateAfterStartDate;
use MauticPlugin\ProgramBundle\Validator\Constraints\TaskDates;
use MauticPlugin\ProgramBundle\Validator\Constraints\ValidTaskDependency;
use Symfony\Component\Validator\Constraints\Length;
use Symfony\Component\Validator\Constraints\NotBlank;
use Symfony\Component\Validator\Constraints\PositiveOrZero;
@@ -20,7 +20,7 @@ use Symfony\Component\Validator\Constraints\Range;
use Symfony\Component\Validator\Mapping\ClassMetadata;
/**
* A task of a plan. Every task belongs to exactly one plan.
* A task of an initiative. Every task belongs to exactly one initiative.
*
* Kinds (taskKind): a regular task; a milestone, whose end date is enslaved to its start date; or a
* phase, which has no status of its own — it is a collection of tasks.
@@ -29,15 +29,15 @@ use Symfony\Component\Validator\Mapping\ClassMetadata;
* End2End, Start2Start or Start2End. The former parent/child tree is replaced by this dependency
* graph.
*
* RACI: a task is assigned to the plan's stakeholders through TaskRaci rows (R/A/C/I), several
* RACI: a task is assigned to the initiative's stakeholders through TaskRaci rows (R/A/C/I), several
* stakeholders per role.
*
* Database rules: deleting the plan deletes its tasks (ON DELETE CASCADE); deleting a task deletes
* Database rules: deleting the initiative deletes its tasks (ON DELETE CASCADE); deleting a task deletes
* its dependencies and RACI rows (ON DELETE CASCADE).
*/
class Task extends FormEntity implements DateRangeInterface
{
public const TABLE_NAME = 'plan_tasks';
public const TABLE_NAME = 'initiative_tasks';
public const TYPE_MAX_LENGTH = 64;
@@ -48,10 +48,10 @@ class Task extends FormEntity implements DateRangeInterface
private ?int $id = null;
private ?Plan $plan = null;
private ?Initiative $initiative = null;
/**
* Key of a task type set up in Settings > Configuration > Plan Settings (parameter plan_task_types);
* Key of a task type set up in Settings > Configuration > Program Settings (parameter program_task_types);
* see ItemTypeProvider (kind "task") for its name, description and pictogram.
*/
private ?string $type = null;
@@ -106,9 +106,9 @@ class Task extends FormEntity implements DateRangeInterface
$builder->addId();
$builder->createManyToOne('plan', Plan::class)
$builder->createManyToOne('initiative', Initiative::class)
->inversedBy('tasks')
->addJoinColumn('plan_id', 'id', false, false, 'CASCADE')
->addJoinColumn('initiative_id', 'id', false, false, 'CASCADE')
->build();
$builder->createField('type', Types::STRING)
@@ -132,7 +132,7 @@ class Task extends FormEntity implements DateRangeInterface
'enumType' => TaskStatus::class,
'options' => ['default' => TaskStatus::New->value],
]);
$builder->addIndex(['status'], 'plan_task_status');
$builder->addIndex(['status'], 'program_task_status');
$metadata->mapField([
'fieldName' => 'taskKind',
@@ -191,11 +191,11 @@ 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('initiative', new NotBlank(message: 'mautic.program.task.initiative.required'));
$metadata->addPropertyConstraint('type', new NotBlank(message: 'mautic.program.task.type.required'));
$metadata->addPropertyConstraint('type', new Length(max: self::TYPE_MAX_LENGTH));
$metadata->addPropertyConstraint('plannedWork', new PositiveOrZero(message: 'mautic.plan.task.planned_work.invalid'));
$metadata->addPropertyConstraint('plannedWork', new Range(notInRangeMessage: 'mautic.plan.task.planned_work.range', min: 0, max: self::PLANNED_WORK_MAX));
$metadata->addPropertyConstraint('plannedWork', new PositiveOrZero(message: 'mautic.program.task.planned_work.invalid'));
$metadata->addPropertyConstraint('plannedWork', new Range(notInRangeMessage: 'mautic.program.task.planned_work.range', min: 0, max: self::PLANNED_WORK_MAX));
$metadata->addConstraint(new EndDateAfterStartDate());
$metadata->addConstraint(new TaskDates());
$metadata->addConstraint(new ValidTaskDependency());
@@ -206,15 +206,15 @@ class Task extends FormEntity implements DateRangeInterface
return $this->id;
}
public function getPlan(): ?Plan
public function getInitiative(): ?Initiative
{
return $this->plan;
return $this->initiative;
}
public function setPlan(?Plan $plan): static
public function setInitiative(?Initiative $initiative): static
{
$this->isChanged('plan', $plan);
$this->plan = $plan;
$this->isChanged('initiative', $initiative);
$this->initiative = $initiative;
return $this;
}
+2 -2
View File
@@ -2,7 +2,7 @@
declare(strict_types=1);
namespace MauticPlugin\PlanBundle\Entity;
namespace MauticPlugin\ProgramBundle\Entity;
use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping\ClassMetadata as OrmClassMetadata;
@@ -17,7 +17,7 @@ use Mautic\CoreBundle\Doctrine\Mapping\ClassMetadataBuilder;
*/
class TaskDependency
{
public const TABLE_NAME = 'plan_task_dependencies';
public const TABLE_NAME = 'initiative_task_dependencies';
private ?int $id = null;
+1 -1
View File
@@ -2,7 +2,7 @@
declare(strict_types=1);
namespace MauticPlugin\PlanBundle\Entity;
namespace MauticPlugin\ProgramBundle\Entity;
use Mautic\CoreBundle\Entity\CommonRepository;
+2 -2
View File
@@ -2,7 +2,7 @@
declare(strict_types=1);
namespace MauticPlugin\PlanBundle\Entity;
namespace MauticPlugin\ProgramBundle\Entity;
/**
* The kind of a task. The order of the cases is the order of the dropdown.
@@ -15,7 +15,7 @@ enum TaskKind: string
public function getLabelKey(): string
{
return 'mautic.plan.task.kind.'.$this->value;
return 'mautic.program.task.kind.'.$this->value;
}
/**
+3 -3
View File
@@ -2,7 +2,7 @@
declare(strict_types=1);
namespace MauticPlugin\PlanBundle\Entity;
namespace MauticPlugin\ProgramBundle\Entity;
use Doctrine\DBAL\Types\Types;
use Doctrine\Common\Collections\ArrayCollection;
@@ -19,12 +19,12 @@ use Mautic\CoreBundle\Doctrine\Mapping\ClassMetadataBuilder;
*/
class TaskRaci
{
public const TABLE_NAME = 'plan_task_raci';
public const TABLE_NAME = 'initiative_task_raci';
/**
* The join table carrying the stakeholders of a RACI row (TaskRaci -> Stakeholder).
*/
public const JOIN_TABLE_NAME = 'plan_task_raci_stakeholders';
public const JOIN_TABLE_NAME = 'initiative_task_raci_stakeholders';
private ?int $id = null;
+1 -1
View File
@@ -2,7 +2,7 @@
declare(strict_types=1);
namespace MauticPlugin\PlanBundle\Entity;
namespace MauticPlugin\ProgramBundle\Entity;
use Mautic\CoreBundle\Entity\CommonRepository;
+8 -8
View File
@@ -2,7 +2,7 @@
declare(strict_types=1);
namespace MauticPlugin\PlanBundle\Entity;
namespace MauticPlugin\ProgramBundle\Entity;
use Mautic\CoreBundle\Entity\CommonRepository;
@@ -19,7 +19,7 @@ class TaskRepository extends CommonRepository
}
/**
* Loads the plan, the dependencies (with their depends-on task) and the RACI rows (with their
* Loads the initiative, the dependencies (with their depends-on task) and the RACI rows (with their
* stakeholders) with the tasks, so that the list doesn't query them one by one.
*
* @param array<string, mixed> $args
@@ -29,8 +29,8 @@ class TaskRepository extends CommonRepository
$alias = $this->getTableAlias();
$args['qb'] = $this->createQueryBuilder($alias)
->select($alias, 'pl', 'dep', 'depTask', 'raci', 'raciStakeholder')
->leftJoin($alias.'.plan', 'pl')
->select($alias, 'init', 'dep', 'depTask', 'raci', 'raciStakeholder')
->leftJoin($alias.'.initiative', 'init')
->leftJoin($alias.'.dependencies', 'dep')
->leftJoin('dep.dependsOn', 'depTask')
->leftJoin($alias.'.raci', 'raci')
@@ -40,11 +40,11 @@ class TaskRepository extends CommonRepository
}
/**
* All tasks of a plan, ordered by name, with their dependencies and RACI rows loaded.
* All tasks of an initiative, ordered by name, with their dependencies and RACI rows loaded.
*
* @return Task[]
*/
public function findByPlan(Plan $plan): array
public function findByInitiative(Initiative $initiative): array
{
return $this->createQueryBuilder('t')
->select('t', 'dep', 'depTask', 'raci', 'raciStakeholder')
@@ -52,8 +52,8 @@ class TaskRepository extends CommonRepository
->leftJoin('dep.dependsOn', 'depTask')
->leftJoin('t.raci', 'raci')
->leftJoin('raci.stakeholders', 'raciStakeholder')
->where('t.plan = :plan')
->setParameter('plan', $plan)
->where('t.initiative = :initiative')
->setParameter('initiative', $initiative)
->orderBy('t.name', 'ASC')
->addOrderBy('t.id', 'ASC')
->getQuery()
+2 -2
View File
@@ -2,7 +2,7 @@
declare(strict_types=1);
namespace MauticPlugin\PlanBundle\Entity;
namespace MauticPlugin\ProgramBundle\Entity;
/**
* Task status. The order of the cases is the order of the dropdown on the task form.
@@ -16,7 +16,7 @@ enum TaskStatus: string
public function getLabelKey(): string
{
return 'mautic.plan.task.status.'.$this->value;
return 'mautic.program.task.status.'.$this->value;
}
/**
+16 -16
View File
@@ -2,30 +2,30 @@
declare(strict_types=1);
namespace MauticPlugin\PlanBundle\EventListener;
namespace MauticPlugin\ProgramBundle\EventListener;
use Mautic\ConfigBundle\ConfigEvents;
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 MauticPlugin\ProgramBundle\Entity\InitiativeAllocationItemRepository;
use MauticPlugin\ProgramBundle\Entity\InitiativeDescriptionItemRepository;
use MauticPlugin\ProgramBundle\Entity\InitiativeObjectiveRepository;
use MauticPlugin\ProgramBundle\Entity\StakeholderRepository;
use MauticPlugin\ProgramBundle\Entity\TaskRepository;
use MauticPlugin\ProgramBundle\Form\Type\ConfigType;
use MauticPlugin\ProgramBundle\Service\ItemTypeProvider;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
/**
* Adds the "Plan" tab to Settings > Configuration (description, allocation, objective and task item
* Adds the "Program" 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 InitiativeDescriptionItemRepository $descriptionItemRepository,
private InitiativeAllocationItemRepository $allocationItemRepository,
private InitiativeObjectiveRepository $objectiveRepository,
private TaskRepository $taskRepository,
private StakeholderRepository $stakeholderRepository,
private ItemTypeProvider $typeProvider,
@@ -43,11 +43,11 @@ class ConfigSubscriber implements EventSubscriberInterface
public function onConfigGenerate(ConfigBuilderEvent $event): void
{
$event->addForm([
'bundle' => 'PlanBundle',
'bundle' => 'ProgramBundle',
'formAlias' => ConfigType::FORM_ALIAS,
'formType' => ConfigType::class,
'formTheme' => '@Plan/FormTheme/Config/_config_planconfig_widget.html.twig',
'parameters' => $event->getParametersFromConfig('PlanBundle'),
'formTheme' => '@Program/FormTheme/Config/_config_programconfig_widget.html.twig',
'parameters' => $event->getParametersFromConfig('ProgramBundle'),
]);
}
@@ -88,7 +88,7 @@ class ConfigSubscriber implements EventSubscriberInterface
if ([] !== $removedInUse) {
$event->setError(
'mautic.plan.config.type.in_use',
'mautic.program.config.type.in_use',
['%types%' => implode(', ', $removedInUse)],
ConfigType::FORM_ALIAS,
$parameter
+2 -2
View File
@@ -2,7 +2,7 @@
declare(strict_types=1);
namespace MauticPlugin\PlanBundle\EventListener;
namespace MauticPlugin\ProgramBundle\EventListener;
use Mautic\PluginBundle\Bundle\PluginDatabase;
use Mautic\PluginBundle\Event\PluginInstallEvent;
@@ -15,7 +15,7 @@ use Symfony\Component\EventDispatcher\EventSubscriberInterface;
*/
class PluginInstallSubscriber implements EventSubscriberInterface
{
private const BUNDLE = 'PlanBundle';
private const BUNDLE = 'ProgramBundle';
public function __construct(
private PluginDatabase $pluginDatabase,
+213
View File
@@ -0,0 +1,213 @@
<?php
declare(strict_types=1);
namespace MauticPlugin\ProgramBundle\Form\Type;
use Doctrine\ORM\EntityRepository;
use Mautic\CoreBundle\Form\Type\FormButtonsType;
use Mautic\CoreBundle\Form\Type\YesNoButtonGroupType;
use Mautic\LeadBundle\Entity\LeadList;
use Mautic\StageBundle\Entity\Stage;
use MauticPlugin\ProgramBundle\Entity\Audience;
use MauticPlugin\ProgramBundle\Entity\AudienceType as AudienceTypeEnum;
use MauticPlugin\ProgramBundle\Service\AudienceAttributes;
use MauticPlugin\ProgramBundle\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\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;
/**
* The create and edit form of an audience of the global directory (Programs > Audiences): name, a
* fixed type (persona, ICP, …), the segments (purely informational), then the persona attributes
* the admin switched on in Settings > Configuration > Initiative Settings (AudienceAttributes): one
* toggle per attribute, so a b2b install and a b2c install define their personas differently.
*
* @extends AbstractType<Audience>
*/
class AudienceType extends AbstractType
{
public function __construct(
private ItemTypeProvider $typeProvider,
private AudienceAttributes $attributes,
) {
}
public function buildForm(FormBuilderInterface $builder, array $options): void
{
$enabled = $this->attributes->getEnabled();
// Name and type are always offered; everything else is a togglable attribute.
$builder->add('name', TextType::class, [
'label' => 'mautic.program.audience.field.name',
'label_attr' => ['class' => 'control-label'],
'attr' => ['class' => 'form-control', 'maxlength' => 191],
]);
$builder->add('audienceType', EnumType::class, [
'label' => 'mautic.program.audience.field.type',
'label_attr' => ['class' => 'control-label'],
'attr' => ['class' => 'form-control'],
'class' => AudienceTypeEnum::class,
'choice_label' => fn (AudienceTypeEnum $type): string => $type->getLabelKey(),
]);
// The Mautic segments this audience maps to; any number, or none. Purely informational: the
// segments are not required, and nothing in the initiative depends on them.
$builder->add('segments', EntityType::class, [
'label' => 'mautic.program.audience.field.segments',
'label_attr' => ['class' => 'control-label'],
'attr' => ['class' => 'form-control'],
'class' => LeadList::class,
'choice_label' => 'name',
'query_builder' => fn (EntityRepository $er) => $er->createQueryBuilder('s')
->orderBy('s.name', 'ASC')
->andWhere('s.isPublished = :published')
->setParameter('published', true),
'multiple' => true,
'expanded' => false,
'required' => false,
]);
if (in_array('tagline', $enabled, true)) {
$builder->add('tagline', TextareaType::class, [
'label' => 'mautic.program.audience.field.tagline',
'label_attr' => ['class' => 'control-label'],
'attr' => ['class' => 'form-control', 'rows' => 2, 'maxlength' => 500],
'required' => false,
]);
}
if (in_array('profile', $enabled, true)) {
$builder->add('profileCriteria', TextareaType::class, [
'label' => 'mautic.program.audience.field.profile_criteria',
'label_attr' => ['class' => 'control-label'],
'attr' => ['class' => 'form-control', 'rows' => 3],
'required' => false,
]);
}
if (in_array('motivations', $enabled, true)) {
$builder->add('motivations', TextareaType::class, [
'label' => 'mautic.program.audience.field.motivations',
'label_attr' => ['class' => 'control-label'],
'attr' => ['class' => 'form-control', 'rows' => 3],
'required' => false,
]);
}
if (in_array('barriers', $enabled, true)) {
$builder->add('barriers', TextareaType::class, [
'label' => 'mautic.program.audience.field.barriers',
'label_attr' => ['class' => 'control-label'],
'attr' => ['class' => 'form-control', 'rows' => 3],
'required' => false,
]);
}
if (in_array('frustrations', $enabled, true)) {
$builder->add('frustrations', TextareaType::class, [
'label' => 'mautic.program.audience.field.frustrations',
'label_attr' => ['class' => 'control-label'],
'attr' => ['class' => 'form-control', 'rows' => 3],
'required' => false,
]);
}
if (in_array('triggers', $enabled, true)) {
$builder->add('triggers', TextareaType::class, [
'label' => 'mautic.program.audience.field.triggers',
'label_attr' => ['class' => 'control-label'],
'attr' => ['class' => 'form-control', 'rows' => 3],
'required' => false,
]);
}
if (in_array('decision_role', $enabled, true)) {
$kind = ItemTypeProvider::KIND_AUDIENCE_DECISION_ROLE;
$builder->add('decisionRole', ChoiceType::class, [
'label' => 'mautic.program.audience.field.decision_role',
'label_attr' => ['class' => 'control-label'],
'attr' => ['class' => 'form-control'],
'choices' => $this->typeProvider->getChoices($kind),
'placeholder' => 'mautic.core.form.chooseone',
'required' => false,
]);
}
if (in_array('tones', $enabled, true)) {
$kind = ItemTypeProvider::KIND_AUDIENCE_TONE;
$builder->add('preferredTones', ChoiceType::class, [
'label' => 'mautic.program.audience.field.preferred_tones',
'label_attr' => ['class' => 'control-label'],
'choices' => $this->typeProvider->getChoices($kind),
'expanded' => true,
'multiple' => true,
'required' => false,
]);
}
if (in_array('channels', $enabled, true)) {
// One checkbox per channel, in the order of Audience::CHANNELS.
$builder->add('preferredChannels', ChoiceType::class, [
'label' => 'mautic.program.audience.field.preferred_channels',
'label_attr' => ['class' => 'control-label'],
'choices' => array_flip(Audience::CHANNELS),
'expanded' => true,
'multiple' => true,
'required' => false,
]);
}
if (in_array('stages', $enabled, true)) {
$builder->add('stages', EntityType::class, [
'label' => 'mautic.program.audience.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,
]);
}
if (in_array('size', $enabled, true)) {
$builder->add('estimatedSize', IntegerType::class, [
'label' => 'mautic.program.audience.field.estimated_size',
'label_attr' => ['class' => 'control-label'],
'attr' => ['class' => 'form-control', 'min' => 0, 'step' => 1],
'required' => false,
]);
}
$builder->add('isPublished', YesNoButtonGroupType::class, [
'label' => 'mautic.program.audience.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' => Audience::class,
]);
}
public function getBlockPrefix(): string
{
return 'program_audience';
}
}
+33 -15
View File
@@ -2,43 +2,48 @@
declare(strict_types=1);
namespace MauticPlugin\PlanBundle\Form\Type;
namespace MauticPlugin\ProgramBundle\Form\Type;
use MauticPlugin\PlanBundle\Model\StakeholderModel;
use MauticPlugin\PlanBundle\Service\CurrencyProvider;
use MauticPlugin\PlanBundle\Service\ItemTypeProvider;
use MauticPlugin\ProgramBundle\Model\StakeholderModel;
use MauticPlugin\ProgramBundle\Service\CurrencyProvider;
use MauticPlugin\ProgramBundle\Service\ItemTypeProvider;
use MauticPlugin\ProgramBundle\Service\AudienceAttributes;
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 Mautic\CoreBundle\Form\Type\YesNoButtonGroupType;
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);
* - 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.
* The "Initiative Settings" tab of Settings > Configuration. Each child is a local.php parameter:
* - program_currency: the currency of every amount in the plugin (general setting);
* - program_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, and the
* values of an audience's decision roles and tones), each with a pictogram;
* - one toggle per audience persona attribute (AudienceAttributes), so each install defines its
* personas as it needs (b2b, b2c…).
*
* @extends AbstractType<array<string, mixed>>
*/
class ConfigType extends AbstractType
{
public const FORM_ALIAS = 'planconfig';
public const FORM_ALIAS = 'programconfig';
public function __construct(
private CurrencyProvider $currencyProvider,
private AudienceAttributes $audienceAttributes,
) {
}
public function buildForm(FormBuilderInterface $builder, array $options): void
{
$builder->add(CurrencyProvider::CONFIG_PARAMETER, ChoiceType::class, [
'label' => 'mautic.plan.config.currency',
'label' => 'mautic.program.config.currency',
'label_attr' => ['class' => 'control-label'],
'attr' => ['class' => 'form-control', 'tooltip' => 'mautic.plan.config.currency.tooltip'],
'attr' => ['class' => 'form-control', 'tooltip' => 'mautic.program.config.currency.tooltip'],
'choices' => $this->currencyProvider->getChoices(),
'placeholder' => false,
'required' => true,
@@ -49,19 +54,22 @@ class ConfigType extends AbstractType
// 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' => 'mautic.program.config.stakeholder_phone_region',
'label_attr' => ['class' => 'control-label'],
'attr' => ['class' => 'form-control', 'tooltip' => 'mautic.plan.config.stakeholder_phone_region.tooltip', 'maxlength' => 2],
'attr' => ['class' => 'form-control', 'tooltip' => 'mautic.program.config.stakeholder_phone_region.tooltip', 'maxlength' => 2],
'required' => true,
'constraints' => [new NotBlank()],
'empty_data' => StakeholderModel::DEFAULT_PHONE_REGION,
]);
foreach (ItemTypeProvider::PARAMETERS as $kind => $parameter) {
// The decision roles and the tones are plain value lists: no pictogram.
$withIcon = !in_array($kind, [ItemTypeProvider::KIND_AUDIENCE_DECISION_ROLE, ItemTypeProvider::KIND_AUDIENCE_TONE], true);
$builder->add($parameter, CollectionType::class, [
'label' => false,
'entry_type' => ItemTypeConfigType::class,
'entry_options' => ['label' => false, 'with_icon' => true],
'entry_options' => ['label' => false, 'with_icon' => $withIcon],
'allow_add' => true,
'allow_delete' => true,
'prototype' => true,
@@ -76,6 +84,16 @@ class ConfigType extends AbstractType
fn ($types): array => ItemTypeProvider::normalize(is_array($types) ? $types : []),
));
}
// One toggle per audience persona attribute (AudienceAttributes), defaults to enabled.
foreach (AudienceAttributes::ATTRIBUTES as $attribute => $field) {
$builder->add(AudienceAttributes::toggleParameter($attribute), YesNoButtonGroupType::class, [
'label' => 'mautic.program.audience.attribute.'.$attribute,
'label_attr' => ['class' => 'control-label'],
'data' => $this->audienceAttributes->isEnabled($attribute),
'required' => false,
]);
}
}
public function getBlockPrefix(): string
@@ -2,11 +2,11 @@
declare(strict_types=1);
namespace MauticPlugin\PlanBundle\Form\Type;
namespace MauticPlugin\ProgramBundle\Form\Type;
use MauticPlugin\PlanBundle\Entity\PlanAllocationItem;
use MauticPlugin\PlanBundle\Service\CurrencyProvider;
use MauticPlugin\PlanBundle\Service\ItemTypeProvider;
use MauticPlugin\ProgramBundle\Entity\InitiativeAllocationItem;
use MauticPlugin\ProgramBundle\Service\CurrencyProvider;
use MauticPlugin\ProgramBundle\Service\ItemTypeProvider;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
use Symfony\Component\Form\Extension\Core\Type\HiddenType;
@@ -17,14 +17,14 @@ use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
/**
* One row of the allocation items collection in PlanType: type, name, description, planned cost and
* real cost (both in the general currency). Works like PlanDescriptionItemType (type description shown
* One row of the allocation items collection in InitiativeType: type, name, description, planned cost and
* real cost (both in the general currency). Works like InitiativeDescriptionItemType (type description shown
* under the dropdown and its pictogram next to it, hidden position kept in display order by
* Assets/js/plan.js).
* Assets/js/program.js).
*
* @extends AbstractType<PlanAllocationItem>
* @extends AbstractType<InitiativeAllocationItem>
*/
class PlanAllocationItemType extends AbstractType
class InitiativeAllocationItemType extends AbstractType
{
public function __construct(
private ItemTypeProvider $typeProvider,
@@ -37,11 +37,11 @@ class PlanAllocationItemType extends AbstractType
$kind = ItemTypeProvider::KIND_ALLOCATION;
$builder->add('type', ChoiceType::class, [
'label' => 'mautic.plan.allocation_item.field.type',
'label' => 'mautic.program.allocation_item.field.type',
'label_attr' => ['class' => 'control-label'],
'attr' => ['class' => 'form-control plan-item-type'],
'attr' => ['class' => 'form-control initiative-item-type'],
'choices' => $this->typeProvider->getChoices($kind),
// The type's description and pictogram, shown next to the dropdown by plan.js.
// The type's description and pictogram, shown next to the dropdown by program.js.
'choice_attr' => fn (?string $key): array => [
'data-description' => (string) $this->typeProvider->getDescription($kind, $key),
'data-icon' => (string) $this->typeProvider->getIcon($kind, $key),
@@ -51,23 +51,23 @@ class PlanAllocationItemType extends AbstractType
]);
$builder->add('name', TextType::class, [
'label' => 'mautic.plan.allocation_item.field.name',
'label' => 'mautic.program.allocation_item.field.name',
'label_attr' => ['class' => 'control-label'],
'attr' => ['class' => 'form-control', 'maxlength' => 255],
'required' => false,
]);
$builder->add('description', TextareaType::class, [
'label' => 'mautic.plan.allocation_item.field.description',
'label' => 'mautic.program.allocation_item.field.description',
'label_attr' => ['class' => 'control-label'],
'attr' => ['class' => 'form-control', 'rows' => 3],
'required' => false,
]);
// Costs are in the general currency (Settings > Configuration > Plan Settings), shown next to the field.
// Costs are in the general currency (Settings > Configuration > Initiative Settings), shown next to the field.
foreach (['planned', 'real'] as $cost) {
$builder->add($cost.'Cost', NumberType::class, [
'label' => 'mautic.plan.allocation_item.field.'.$cost.'_cost',
'label' => 'mautic.program.allocation_item.field.'.$cost.'_cost',
'label_attr' => ['class' => 'control-label'],
'attr' => ['class' => 'form-control', 'postaddon_text' => $this->currencyProvider->getCurrency()],
'input' => 'string',
@@ -77,19 +77,19 @@ class PlanAllocationItemType extends AbstractType
}
$builder->add('position', HiddenType::class, [
'attr' => ['class' => 'plan-row-position'],
'attr' => ['class' => 'initiative-row-position'],
]);
}
public function configureOptions(OptionsResolver $resolver): void
{
$resolver->setDefaults([
'data_class' => PlanAllocationItem::class,
'data_class' => InitiativeAllocationItem::class,
]);
}
public function getBlockPrefix(): string
{
return 'plan_allocation_item';
return 'program_allocation_item';
}
}
+76
View File
@@ -0,0 +1,76 @@
<?php
declare(strict_types=1);
namespace MauticPlugin\ProgramBundle\Form\Type;
use Doctrine\ORM\EntityRepository;
use MauticPlugin\ProgramBundle\Entity\Audience;
use MauticPlugin\ProgramBundle\Entity\AudiencePriority;
use MauticPlugin\ProgramBundle\Entity\InitiativeAudience;
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\EnumType;
use Symfony\Component\Form\Extension\Core\Type\HiddenType;
use Symfony\Component\Form\Extension\Core\Type\TextareaType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
/**
* One row of the audiences collection in InitiativeType: an audience of the global directory (only the
* active ones are offered), the audience's priority in this plan, and possibly a initiative-specific
* message. The position field is hidden and kept in display order by Assets/js/program.js.
*
* @extends AbstractType<InitiativeAudience>
*/
class InitiativeAudienceType extends AbstractType
{
public function buildForm(FormBuilderInterface $builder, array $options): void
{
$builder->add('audience', EntityType::class, [
'label' => 'mautic.program.audience.field.name',
'label_attr' => ['class' => 'control-label'],
'attr' => ['class' => 'form-control'],
'class' => Audience::class,
'choice_label' => 'name',
'query_builder' => fn (EntityRepository $er) => $er->createQueryBuilder('t')
->orderBy('t.name', 'ASC')
->andWhere('t.isPublished = :published')
->setParameter('published', true),
'placeholder' => 'mautic.core.form.chooseone',
'required' => true,
]);
// Dropdown in the order of the AudiencePriority cases.
$builder->add('priority', EnumType::class, [
'label' => 'mautic.program.audience.field.priority',
'label_attr' => ['class' => 'control-label'],
'attr' => ['class' => 'form-control'],
'class' => AudiencePriority::class,
'choice_label' => fn (AudiencePriority $priority): string => $priority->getLabelKey(),
]);
$builder->add('valueProposition', TextareaType::class, [
'label' => 'mautic.program.audience.field.value_proposition',
'label_attr' => ['class' => 'control-label'],
'attr' => ['class' => 'form-control', 'rows' => 2],
'required' => false,
]);
$builder->add('position', HiddenType::class, [
'attr' => ['class' => 'initiative-row-position'],
]);
}
public function configureOptions(OptionsResolver $resolver): void
{
$resolver->setDefaults([
'data_class' => InitiativeAudience::class,
]);
}
public function getBlockPrefix(): string
{
return 'program_initiative_audience';
}
}
@@ -2,10 +2,10 @@
declare(strict_types=1);
namespace MauticPlugin\PlanBundle\Form\Type;
namespace MauticPlugin\ProgramBundle\Form\Type;
use MauticPlugin\PlanBundle\Entity\PlanDescriptionItem;
use MauticPlugin\PlanBundle\Service\ItemTypeProvider;
use MauticPlugin\ProgramBundle\Entity\InitiativeDescriptionItem;
use MauticPlugin\ProgramBundle\Service\ItemTypeProvider;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
use Symfony\Component\Form\Extension\Core\Type\HiddenType;
@@ -14,14 +14,14 @@ use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
/**
* One row of the description items collection in PlanType. The type dropdown lists the description item
* types set up in Settings > Configuration > Plan; each option carries the type's description, which
* Assets/js/plan.js shows under the dropdown. The position field is hidden and kept in display order by
* plan.js.
* One row of the description items collection in InitiativeType. The type dropdown lists the description item
* types set up in Settings > Configuration > Initiative; each option carries the type's description, which
* Assets/js/program.js shows under the dropdown. The position field is hidden and kept in display order by
* program.js.
*
* @extends AbstractType<PlanDescriptionItem>
* @extends AbstractType<InitiativeDescriptionItem>
*/
class PlanDescriptionItemType extends AbstractType
class InitiativeDescriptionItemType extends AbstractType
{
public function __construct(
private ItemTypeProvider $typeProvider,
@@ -33,11 +33,11 @@ class PlanDescriptionItemType extends AbstractType
$kind = ItemTypeProvider::KIND_DESCRIPTION;
$builder->add('type', ChoiceType::class, [
'label' => 'mautic.plan.description_item.field.type',
'label' => 'mautic.program.description_item.field.type',
'label_attr' => ['class' => 'control-label'],
'attr' => ['class' => 'form-control plan-item-type'],
'attr' => ['class' => 'form-control initiative-item-type'],
'choices' => $this->typeProvider->getChoices($kind),
// The type's description and pictogram, shown next to the dropdown by plan.js.
// The type's description and pictogram, shown next to the dropdown by program.js.
'choice_attr' => fn (?string $key): array => [
'data-description' => (string) $this->typeProvider->getDescription($kind, $key),
'data-icon' => (string) $this->typeProvider->getIcon($kind, $key),
@@ -47,26 +47,26 @@ class PlanDescriptionItemType extends AbstractType
]);
$builder->add('description', TextareaType::class, [
'label' => 'mautic.plan.description_item.field.description',
'label' => 'mautic.program.description_item.field.description',
'label_attr' => ['class' => 'control-label'],
'attr' => ['class' => 'form-control', 'rows' => 5],
'required' => false,
]);
$builder->add('position', HiddenType::class, [
'attr' => ['class' => 'plan-row-position'],
'attr' => ['class' => 'initiative-row-position'],
]);
}
public function configureOptions(OptionsResolver $resolver): void
{
$resolver->setDefaults([
'data_class' => PlanDescriptionItem::class,
'data_class' => InitiativeDescriptionItem::class,
]);
}
public function getBlockPrefix(): string
{
return 'plan_description_item';
return 'program_description_item';
}
}
@@ -2,10 +2,10 @@
declare(strict_types=1);
namespace MauticPlugin\PlanBundle\Form\Type;
namespace MauticPlugin\ProgramBundle\Form\Type;
use MauticPlugin\PlanBundle\Entity\PlanObjective;
use MauticPlugin\PlanBundle\Service\ItemTypeProvider;
use MauticPlugin\ProgramBundle\Entity\InitiativeObjective;
use MauticPlugin\ProgramBundle\Service\ItemTypeProvider;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
@@ -17,13 +17,13 @@ use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
/**
* 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).
* One row of the objectives collection in InitiativeType: type, title, priority, description and the achieved
* flag. Works like InitiativeDescriptionItemType (type description shown under the dropdown and its pictogram
* next to it, hidden position kept in display order by Assets/js/program.js).
*
* @extends AbstractType<PlanObjective>
* @extends AbstractType<InitiativeObjective>
*/
class PlanObjectiveType extends AbstractType
class InitiativeObjectiveType extends AbstractType
{
public function __construct(
private ItemTypeProvider $typeProvider,
@@ -35,11 +35,11 @@ class PlanObjectiveType extends AbstractType
$kind = ItemTypeProvider::KIND_OBJECTIVE;
$builder->add('type', ChoiceType::class, [
'label' => 'mautic.plan.objective.field.type',
'label' => 'mautic.program.objective.field.type',
'label_attr' => ['class' => 'control-label'],
'attr' => ['class' => 'form-control plan-item-type'],
'attr' => ['class' => 'form-control initiative-item-type'],
'choices' => $this->typeProvider->getChoices($kind),
// The type's description and pictogram, shown next to the dropdown by plan.js.
// The type's description and pictogram, shown next to the dropdown by program.js.
'choice_attr' => fn (?string $key): array => [
'data-description' => (string) $this->typeProvider->getDescription($kind, $key),
'data-icon' => (string) $this->typeProvider->getIcon($kind, $key),
@@ -49,36 +49,36 @@ class PlanObjectiveType extends AbstractType
]);
$builder->add('title', TextType::class, [
'label' => 'mautic.plan.objective.field.title',
'label' => 'mautic.program.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' => 'mautic.program.objective.field.priority',
'label_attr' => ['class' => 'control-label'],
'invalid_message' => 'mautic.plan.objective.priority.range',
'invalid_message' => 'mautic.program.objective.priority.range',
'attr' => [
'class' => 'form-control',
'min' => PlanObjective::PRIORITY_MIN,
'max' => PlanObjective::PRIORITY_MAX,
'min' => InitiativeObjective::PRIORITY_MIN,
'max' => InitiativeObjective::PRIORITY_MAX,
'step' => 1,
],
]);
$builder->add('description', TextareaType::class, [
'label' => 'mautic.plan.objective.field.description',
'label' => 'mautic.program.objective.field.description',
'label_attr' => ['class' => 'control-label'],
'attr' => ['class' => 'form-control', 'rows' => 2],
'required' => false,
]);
$builder->add('position', HiddenType::class, [
'attr' => ['class' => 'plan-row-position'],
'attr' => ['class' => 'initiative-row-position'],
]);
$builder->add('isAchieved', CheckboxType::class, [
'label' => 'mautic.plan.objective.field.is_achieved',
'label' => 'mautic.program.objective.field.is_achieved',
'required' => false,
]);
}
@@ -86,12 +86,12 @@ class PlanObjectiveType extends AbstractType
public function configureOptions(OptionsResolver $resolver): void
{
$resolver->setDefaults([
'data_class' => PlanObjective::class,
'data_class' => InitiativeObjective::class,
]);
}
public function getBlockPrefix(): string
{
return 'plan_objective';
return 'program_objective';
}
}
@@ -2,11 +2,11 @@
declare(strict_types=1);
namespace MauticPlugin\PlanBundle\Form\Type;
namespace MauticPlugin\ProgramBundle\Form\Type;
use Doctrine\ORM\EntityRepository;
use MauticPlugin\PlanBundle\Entity\PlanStakeholder;
use MauticPlugin\PlanBundle\Entity\Stakeholder;
use MauticPlugin\ProgramBundle\Entity\InitiativeStakeholder;
use MauticPlugin\ProgramBundle\Entity\Stakeholder;
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\HiddenType;
@@ -15,18 +15,18 @@ 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
* One row of the stakeholders collection in InitiativeType: 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.
* kept in display order by Assets/js/program.js.
*
* @extends AbstractType<PlanStakeholder>
* @extends AbstractType<InitiativeStakeholder>
*/
class PlanStakeholderType extends AbstractType
class InitiativeStakeholderType extends AbstractType
{
public function buildForm(FormBuilderInterface $builder, array $options): void
{
$builder->add('stakeholder', EntityType::class, [
'label' => 'mautic.plan.stakeholder.field.name',
'label' => 'mautic.program.stakeholder.field.name',
'label_attr' => ['class' => 'control-label'],
'attr' => ['class' => 'form-control'],
'class' => Stakeholder::class,
@@ -39,27 +39,27 @@ class PlanStakeholderType extends AbstractType
'required' => true,
]);
$builder->add('roleInPlan', TextType::class, [
'label' => 'mautic.plan.stakeholder.field.role_in_plan',
$builder->add('roleInInitiative', TextType::class, [
'label' => 'mautic.program.stakeholder.field.role_in_initiative',
'label_attr' => ['class' => 'control-label'],
'attr' => ['class' => 'form-control', 'maxlength' => 191],
'required' => false,
]);
$builder->add('position', HiddenType::class, [
'attr' => ['class' => 'plan-row-position'],
'attr' => ['class' => 'initiative-row-position'],
]);
}
public function configureOptions(OptionsResolver $resolver): void
{
$resolver->setDefaults([
'data_class' => PlanStakeholder::class,
'data_class' => InitiativeStakeholder::class,
]);
}
public function getBlockPrefix(): string
{
return 'plan_plan_stakeholder';
return 'program_initiative_stakeholder';
}
}
@@ -2,7 +2,7 @@
declare(strict_types=1);
namespace MauticPlugin\PlanBundle\Form\Type;
namespace MauticPlugin\ProgramBundle\Form\Type;
use Doctrine\ORM\EntityManagerInterface;
use Mautic\CategoryBundle\Form\Type\CategoryListType;
@@ -13,11 +13,11 @@ use Mautic\CoreBundle\Form\Type\FormButtonsType;
use Mautic\CoreBundle\Form\Type\YesNoButtonGroupType;
use Mautic\UserBundle\Entity\User;
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 MauticPlugin\ProgramBundle\Entity\Initiative;
use MauticPlugin\ProgramBundle\Entity\InitiativeStatus;
use MauticPlugin\ProgramBundle\Service\CurrencyProvider;
use MauticPlugin\ProgramBundle\Form\Type\InitiativeAudienceType;
use MauticPlugin\ProgramBundle\Form\Type\InitiativeStakeholderType;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\CollectionType;
use Symfony\Component\Form\Extension\Core\Type\EnumType;
@@ -28,9 +28,9 @@ use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
/**
* @extends AbstractType<Plan>
* @extends AbstractType<Initiative>
*/
class PlanType extends AbstractType
class InitiativeType extends AbstractType
{
public function __construct(
private CurrencyProvider $currencyProvider,
@@ -47,15 +47,15 @@ class PlanType extends AbstractType
$builder->addEventSubscriber(new CleanFormSubscriber(['name' => 'filter']));
$builder->add('name', TextType::class, [
'label' => 'mautic.plan.field.name',
'label' => 'mautic.program.field.name',
'label_attr' => ['class' => 'control-label'],
'attr' => ['class' => 'form-control'],
]);
// The Description tab. by_reference false: Symfony calls Plan::addDescriptionItem()/removeDescriptionItem().
// The Description tab. by_reference false: Symfony calls Initiative::addDescriptionItem()/removeDescriptionItem().
$builder->add('descriptionItems', CollectionType::class, [
'label' => 'mautic.plan.field.description_items',
'entry_type' => PlanDescriptionItemType::class,
'label' => 'mautic.program.field.description_items',
'entry_type' => InitiativeDescriptionItemType::class,
'entry_options' => ['label' => false],
'allow_add' => true,
'allow_delete' => true,
@@ -67,8 +67,8 @@ class PlanType extends AbstractType
// 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,
'label' => 'mautic.program.field.allocation_items',
'entry_type' => InitiativeAllocationItemType::class,
'entry_options' => ['label' => false],
'allow_add' => true,
'allow_delete' => true,
@@ -78,24 +78,25 @@ 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,
// The Audiences tab's links to the global directory. by_reference false: Symfony calls
// Initiative::addAudience()/removeAudience().
$builder->add('audiences', CollectionType::class, [
'label' => 'mautic.program.field.audiences',
'entry_type' => InitiativeAudienceType::class,
'entry_options' => ['label' => false],
'allow_add' => true,
'allow_delete' => true,
'by_reference' => false,
'prototype' => true,
'prototype_name' => '__target__',
'prototype_name' => '__audience__',
'required' => false,
]);
// The Stakeholders tab's links to the global directory. by_reference false: Symfony calls
// Plan::addStakeholder()/removeStakeholder().
// Initiative::addStakeholder()/removeStakeholder().
$builder->add('stakeholders', CollectionType::class, [
'label' => 'mautic.plan.field.stakeholders',
'entry_type' => PlanStakeholderType::class,
'label' => 'mautic.program.field.stakeholders',
'entry_type' => InitiativeStakeholderType::class,
'entry_options' => ['label' => false],
'allow_add' => true,
'allow_delete' => true,
@@ -106,21 +107,21 @@ class PlanType extends AbstractType
]);
$builder->add('version', IntegerType::class, [
'label' => 'mautic.plan.field.version',
'label' => 'mautic.program.field.version',
'label_attr' => ['class' => 'control-label'],
'invalid_message' => 'mautic.plan.version.range',
'invalid_message' => 'mautic.program.version.range',
'attr' => [
'class' => 'form-control',
'min' => Plan::VERSION_MIN,
'max' => Plan::VERSION_MAX,
'min' => Initiative::VERSION_MIN,
'max' => Initiative::VERSION_MAX,
'step' => 1,
],
]);
// by_reference false: Symfony calls Plan::addObjective()/removeObjective(), which keep both sides in sync.
// by_reference false: Symfony calls Initiative::addObjective()/removeObjective(), which keep both sides in sync.
$builder->add('objectives', CollectionType::class, [
'label' => 'mautic.plan.field.objectives',
'entry_type' => PlanObjectiveType::class,
'label' => 'mautic.program.field.objectives',
'entry_type' => InitiativeObjectiveType::class,
'entry_options' => ['label' => false],
'allow_add' => true,
'allow_delete' => true,
@@ -131,9 +132,9 @@ class PlanType extends AbstractType
]);
$builder->add('status', EnumType::class, [
'class' => PlanStatus::class,
'choice_label' => fn (PlanStatus $status): string => $status->getLabelKey(),
'label' => 'mautic.plan.field.status',
'class' => InitiativeStatus::class,
'choice_label' => fn (InitiativeStatus $status): string => $status->getLabelKey(),
'label' => 'mautic.program.field.status',
'label_attr' => ['class' => 'control-label'],
'attr' => ['class' => 'form-control'],
]);
@@ -141,7 +142,7 @@ class PlanType extends AbstractType
// Required here; the column is nullable only because of onDelete SET NULL.
$builder->add(
$builder->create('owner', UserListType::class, [
'label' => 'mautic.plan.field.owner',
'label' => 'mautic.program.field.owner',
'label_attr' => ['class' => 'control-label'],
'attr' => ['class' => 'form-control'],
'required' => true,
@@ -150,16 +151,16 @@ class PlanType extends AbstractType
);
$builder->add('startDate', DatePickerType::class, [
'label' => 'mautic.plan.field.start_date',
'label' => 'mautic.program.field.start_date',
]);
$builder->add('endDate', DatePickerType::class, [
'label' => 'mautic.plan.field.end_date',
'label' => 'mautic.program.field.end_date',
]);
// In the general currency (Settings > Configuration > Plan Settings), shown next to the field.
// In the general currency (Settings > Configuration > Initiative Settings), shown next to the field.
$builder->add('budgetPlanned', NumberType::class, [
'label' => 'mautic.plan.field.budget_planned',
'label' => 'mautic.program.field.budget_planned',
'label_attr' => ['class' => 'control-label'],
'attr' => ['class' => 'form-control', 'postaddon_text' => $this->currencyProvider->getCurrency()],
'input' => 'string',
@@ -168,7 +169,7 @@ class PlanType extends AbstractType
]);
$builder->add('category', CategoryListType::class, [
'bundle' => 'plan',
'bundle' => 'initiative',
]);
$builder->add('isPublished', YesNoButtonGroupType::class, [
@@ -185,12 +186,12 @@ class PlanType extends AbstractType
public function configureOptions(OptionsResolver $resolver): void
{
$resolver->setDefaults([
'data_class' => Plan::class,
'data_class' => Initiative::class,
]);
}
public function getBlockPrefix(): string
{
return 'plan';
return 'initiative';
}
}
+13 -13
View File
@@ -2,10 +2,10 @@
declare(strict_types=1);
namespace MauticPlugin\PlanBundle\Form\Type;
namespace MauticPlugin\ProgramBundle\Form\Type;
use MauticPlugin\PlanBundle\Service\ItemTypeProvider;
use MauticPlugin\PlanBundle\Service\Pictograms;
use MauticPlugin\ProgramBundle\Service\ItemTypeProvider;
use MauticPlugin\ProgramBundle\Service\Pictograms;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
use Symfony\Component\Form\Extension\Core\Type\FormType;
@@ -20,7 +20,7 @@ use Symfony\Component\Validator\Constraints\Length;
use Symfony\Component\Validator\Constraints\NotBlank;
/**
* One item type (description or allocation) in Settings > Configuration > Plan Settings: a name and a
* One item type (description or allocation) in Settings > Configuration > Initiative Settings: a name and a
* description per language, and a pictogram.
*
* The key is hidden. It is generated when the type is created and never changes, so that renaming a
@@ -40,7 +40,7 @@ class ItemTypeConfigType extends AbstractType
$default = $this->typeProvider->getDefaultLocale();
$builder->add('key', HiddenType::class, [
'attr' => ['class' => 'plan-type-key'],
'attr' => ['class' => 'initiative-type-key'],
]);
$names = $builder->create('names', FormType::class, ['label' => false]);
@@ -50,17 +50,17 @@ class ItemTypeConfigType extends AbstractType
$isDefault = $locale === $default;
$names->add($locale, TextType::class, [
'label' => 'mautic.plan.config.type.name',
'label' => 'mautic.program.config.type.name',
'label_attr' => ['class' => 'control-label'],
'attr' => ['class' => 'form-control', 'maxlength' => 191, 'data-locale' => $locale, 'data-language' => $language],
'required' => $isDefault,
'constraints' => $isDefault
? [new NotBlank(message: 'mautic.plan.config.type.name.required'), new Length(max: 191)]
? [new NotBlank(message: 'mautic.program.config.type.name.required'), new Length(max: 191)]
: [new Length(max: 191)],
]);
$descriptions->add($locale, TextareaType::class, [
'label' => 'mautic.plan.config.type.description',
'label' => 'mautic.program.config.type.description',
'label_attr' => ['class' => 'control-label'],
'attr' => ['class' => 'form-control', 'rows' => 2, 'data-locale' => $locale],
'required' => false,
@@ -70,15 +70,15 @@ class ItemTypeConfigType extends AbstractType
$builder->add($names);
$builder->add($descriptions);
// Pictogram; the preview next to the dropdown is updated by plan.js.
// Pictogram; the preview next to the dropdown is updated by program.js.
if ($options['with_icon']) {
$builder->add('icon', ChoiceType::class, [
'label' => 'mautic.plan.config.type.icon',
'label' => 'mautic.program.config.type.icon',
'label_attr' => ['class' => 'control-label'],
'attr' => ['class' => 'form-control plan-type-icon-select'],
'attr' => ['class' => 'form-control initiative-type-icon-select'],
'choices' => Pictograms::getChoices(),
'choice_attr' => fn (?string $icon): array => ['data-icon' => (string) $icon],
'placeholder' => 'mautic.plan.config.type.icon.none',
'placeholder' => 'mautic.program.config.type.icon.none',
'required' => false,
]);
}
@@ -104,6 +104,6 @@ class ItemTypeConfigType extends AbstractType
public function getBlockPrefix(): string
{
return 'plan_item_type_config';
return 'program_item_type_config';
}
}
+13 -13
View File
@@ -2,10 +2,10 @@
declare(strict_types=1);
namespace MauticPlugin\PlanBundle\Form\Type;
namespace MauticPlugin\ProgramBundle\Form\Type;
use MauticPlugin\PlanBundle\Entity\Stakeholder;
use MauticPlugin\PlanBundle\Service\ItemTypeProvider;
use MauticPlugin\ProgramBundle\Entity\Stakeholder;
use MauticPlugin\ProgramBundle\Service\ItemTypeProvider;
use Mautic\CoreBundle\Form\Type\FormButtonsType;
use Mautic\CoreBundle\Form\Type\YesNoButtonGroupType;
use Symfony\Component\Form\AbstractType;
@@ -17,7 +17,7 @@ use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
/**
* The create and edit form of a stakeholder of the global directory (Planning > Stakeholders).
* The create and edit form of a stakeholder of the global directory (Programs > Stakeholders).
*
* @extends AbstractType<Stakeholder>
*/
@@ -33,38 +33,38 @@ class StakeholderType extends AbstractType
$kind = ItemTypeProvider::KIND_STAKEHOLDER;
$builder->add('name', TextType::class, [
'label' => 'mautic.plan.stakeholder.field.name',
'label' => 'mautic.program.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' => 'mautic.program.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' => 'mautic.program.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' => 'mautic.program.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' => 'mautic.program.stakeholder.field.type',
'label_attr' => ['class' => 'control-label'],
'attr' => ['class' => 'form-control plan-item-type'],
'attr' => ['class' => 'form-control initiative-item-type'],
'choices' => $this->typeProvider->getChoices($kind),
// The type's description and pictogram, shown next to the dropdown by plan.js.
// The type's description and pictogram, shown next to the dropdown by program.js.
'choice_attr' => fn (?string $key): array => [
'data-description' => (string) $this->typeProvider->getDescription($kind, $key),
'data-icon' => (string) $this->typeProvider->getIcon($kind, $key),
@@ -74,7 +74,7 @@ class StakeholderType extends AbstractType
]);
$builder->add('isPublished', YesNoButtonGroupType::class, [
'label' => 'mautic.plan.stakeholder.field.active',
'label' => 'mautic.program.stakeholder.field.active',
]);
$builder->add('buttons', FormButtonsType::class);
@@ -93,6 +93,6 @@ class StakeholderType extends AbstractType
public function getBlockPrefix(): string
{
return 'plan_stakeholder';
return 'program_stakeholder';
}
}
-126
View File
@@ -1,126 +0,0 @@
<?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';
}
}
+18 -18
View File
@@ -2,13 +2,13 @@
declare(strict_types=1);
namespace MauticPlugin\PlanBundle\Form\Type;
namespace MauticPlugin\ProgramBundle\Form\Type;
use Doctrine\ORM\EntityRepository;
use MauticPlugin\PlanBundle\Entity\DependencyType;
use MauticPlugin\PlanBundle\Entity\Plan;
use MauticPlugin\PlanBundle\Entity\Task;
use MauticPlugin\PlanBundle\Entity\TaskDependency;
use MauticPlugin\ProgramBundle\Entity\DependencyType;
use MauticPlugin\ProgramBundle\Entity\Initiative;
use MauticPlugin\ProgramBundle\Entity\Task;
use MauticPlugin\ProgramBundle\Entity\TaskDependency;
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\EnumType;
@@ -18,7 +18,7 @@ use Symfony\Component\OptionsResolver\OptionsResolver;
/**
* One row of the dependencies collection in TaskType: the task this one depends on, and the type of
* the relation. Only the tasks of the same plan are offered; cycles and self-edges are refused by
* the relation. Only the tasks of the same initiative are offered; cycles and self-edges are refused by
* ValidTaskDependency.
*
* @extends AbstractType<TaskDependency>
@@ -27,23 +27,23 @@ class TaskDependencyType extends AbstractType
{
public function buildForm(FormBuilderInterface $builder, array $options): void
{
/** @var Plan|null $plan */
$plan = $options['plan'];
/** @var Initiative|null $initiative */
$initiative = $options['initiative'];
/** @var Task|null $task */
$task = $options['task'];
$builder->add('dependsOn', EntityType::class, [
'label' => 'mautic.plan.task.dependency.field.depends_on',
'label' => 'mautic.program.task.dependency.field.depends_on',
'label_attr' => ['class' => 'control-label'],
'attr' => ['class' => 'form-control'],
'class' => Task::class,
'choice_label' => 'name',
'query_builder' => function (EntityRepository $er) use ($plan, $task) {
'query_builder' => function (EntityRepository $er) use ($initiative, $task) {
$qb = $er->createQueryBuilder('t')
->orderBy('t.name', 'ASC');
if (null !== $plan) {
$qb->andWhere('t.plan = :plan')->setParameter('plan', $plan);
if (null !== $initiative) {
$qb->andWhere('t.initiative = :initiative')->setParameter('initiative', $initiative);
}
if (null !== $task?->getId()) {
@@ -57,16 +57,16 @@ class TaskDependencyType extends AbstractType
]);
$builder->add('dependencyType', EnumType::class, [
'label' => 'mautic.plan.task.dependency.field.type',
'label' => 'mautic.program.task.dependency.field.type',
'label_attr' => ['class' => 'control-label'],
'attr' => ['class' => 'form-control'],
'class' => DependencyType::class,
'choice_label' => fn (DependencyType $type): string => $type->getLabelKey(),
]);
// The row's order in the collection, rewritten by plan.js after each change.
// The row's order in the collection, rewritten by program.js after each change.
$builder->add('position', HiddenType::class, [
'attr' => ['class' => 'plan-row-position'],
'attr' => ['class' => 'initiative-row-position'],
]);
}
@@ -75,13 +75,13 @@ class TaskDependencyType extends AbstractType
$resolver->setDefaults([
'data_class' => TaskDependency::class,
]);
$resolver->setDefined(['plan', 'task']);
$resolver->setAllowedTypes('plan', [Plan::class, 'null']);
$resolver->setDefined(['initiative', 'task']);
$resolver->setAllowedTypes('initiative', [Initiative::class, 'null']);
$resolver->setAllowedTypes('task', [Task::class, 'null']);
}
public function getBlockPrefix(): string
{
return 'plan_task_dependency';
return 'program_task_dependency';
}
}
+21 -21
View File
@@ -2,13 +2,13 @@
declare(strict_types=1);
namespace MauticPlugin\PlanBundle\Form\Type;
namespace MauticPlugin\ProgramBundle\Form\Type;
use Doctrine\ORM\EntityRepository;
use MauticPlugin\PlanBundle\Entity\Plan;
use MauticPlugin\PlanBundle\Entity\RaciRole;
use MauticPlugin\PlanBundle\Entity\Stakeholder;
use MauticPlugin\PlanBundle\Entity\TaskRaci;
use MauticPlugin\ProgramBundle\Entity\Initiative;
use MauticPlugin\ProgramBundle\Entity\RaciRole;
use MauticPlugin\ProgramBundle\Entity\Stakeholder;
use MauticPlugin\ProgramBundle\Entity\TaskRaci;
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\EnumType;
@@ -18,7 +18,7 @@ use Symfony\Component\OptionsResolver\OptionsResolver;
/**
* One row of the RACI collection in TaskType: a role (R/A/C/I) and the stakeholders carrying it.
* The stakeholders are picked from the plan's assigned stakeholders; several may share a role.
* The stakeholders are picked from the initiative's assigned stakeholders; several may share a role.
*
* @extends AbstractType<TaskRaci>
*/
@@ -26,11 +26,11 @@ class TaskRaciType extends AbstractType
{
public function buildForm(FormBuilderInterface $builder, array $options): void
{
/** @var Plan|null $plan */
$plan = $options['plan'];
/** @var Initiative|null $initiative */
$initiative = $options['initiative'];
$builder->add('role', EnumType::class, [
'label' => 'mautic.plan.task.raci.field.role',
'label' => 'mautic.program.task.raci.field.role',
'label_attr' => ['class' => 'control-label'],
'attr' => ['class' => 'form-control'],
'class' => RaciRole::class,
@@ -38,20 +38,20 @@ class TaskRaciType extends AbstractType
]);
$builder->add('stakeholders', EntityType::class, [
'label' => 'mautic.plan.task.raci.field.stakeholders',
'label' => 'mautic.program.task.raci.field.stakeholders',
'label_attr' => ['class' => 'control-label'],
'attr' => ['class' => 'form-control'],
'class' => Stakeholder::class,
'choice_label' => 'name',
'query_builder' => function (EntityRepository $er) use ($plan) {
'query_builder' => function (EntityRepository $er) use ($initiative) {
$qb = $er->createQueryBuilder('s')
->orderBy('s.name', 'ASC');
// The plan's assigned stakeholders, when the plan is known.
if (null !== $plan) {
$qb->join('s.planLinks', 'l')
->andWhere('l.plan = :plan')
->setParameter('plan', $plan);
// The initiative's assigned stakeholders, when the initiative is known.
if (null !== $initiative) {
$qb->join('s.initiativeLinks', 'l')
->andWhere('l.initiative = :initiative')
->setParameter('initiative', $initiative);
}
return $qb;
@@ -61,9 +61,9 @@ class TaskRaciType extends AbstractType
'required' => false,
]);
// The row's order in the collection, rewritten by plan.js after each change.
// The row's order in the collection, rewritten by program.js after each change.
$builder->add('position', HiddenType::class, [
'attr' => ['class' => 'plan-row-position'],
'attr' => ['class' => 'initiative-row-position'],
]);
}
@@ -72,12 +72,12 @@ class TaskRaciType extends AbstractType
$resolver->setDefaults([
'data_class' => TaskRaci::class,
]);
$resolver->setDefined(['plan']);
$resolver->setAllowedTypes('plan', [Plan::class, 'null']);
$resolver->setDefined(['initiative']);
$resolver->setAllowedTypes('initiative', [Initiative::class, 'null']);
}
public function getBlockPrefix(): string
{
return 'plan_task_raci';
return 'program_task_raci';
}
}
+29 -29
View File
@@ -2,16 +2,16 @@
declare(strict_types=1);
namespace MauticPlugin\PlanBundle\Form\Type;
namespace MauticPlugin\ProgramBundle\Form\Type;
use Doctrine\ORM\EntityRepository;
use Mautic\CoreBundle\Form\EventListener\CleanFormSubscriber;
use Mautic\CoreBundle\Form\Type\FormButtonsType;
use MauticPlugin\PlanBundle\Entity\Plan;
use MauticPlugin\PlanBundle\Entity\Task;
use MauticPlugin\PlanBundle\Entity\TaskKind;
use MauticPlugin\PlanBundle\Entity\TaskStatus;
use MauticPlugin\PlanBundle\Service\ItemTypeProvider;
use MauticPlugin\ProgramBundle\Entity\Initiative;
use MauticPlugin\ProgramBundle\Entity\Task;
use MauticPlugin\ProgramBundle\Entity\TaskKind;
use MauticPlugin\ProgramBundle\Entity\TaskStatus;
use MauticPlugin\ProgramBundle\Service\ItemTypeProvider;
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
@@ -25,7 +25,7 @@ use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
/**
* The create and edit form of a task (Planning > Tasks).
* The create and edit form of a task (Programs > Tasks).
*
* Kind rules: a milestone's end date is enslaved to its start date (the entity's setTaskKind copies
* the start onto the end, and the TaskDates validator keeps it in step); a phase has no status
@@ -46,7 +46,7 @@ class TaskType extends AbstractType
/** @var Task $task */
$task = $options['data'];
$plan = $task->getPlan();
$initiative = $task->getInitiative();
$kind = ItemTypeProvider::KIND_TASK;
@@ -54,7 +54,7 @@ class TaskType extends AbstractType
$taskKind = $task->getTaskKind();
$builder->add('taskKind', EnumType::class, [
'label' => 'mautic.plan.task.field.kind',
'label' => 'mautic.program.task.field.kind',
'label_attr' => ['class' => 'control-label'],
'attr' => ['class' => 'form-control'],
'class' => TaskKind::class,
@@ -62,11 +62,11 @@ class TaskType extends AbstractType
]);
$builder->add('type', ChoiceType::class, [
'label' => 'mautic.plan.task.field.type',
'label' => 'mautic.program.task.field.type',
'label_attr' => ['class' => 'control-label'],
'attr' => ['class' => 'form-control plan-item-type'],
'attr' => ['class' => 'form-control initiative-item-type'],
'choices' => $this->typeProvider->getChoices($kind),
// The type's description and pictogram, shown next to the dropdown by plan.js.
// The type's description and pictogram, shown next to the dropdown by program.js.
'choice_attr' => fn (?string $key): array => [
'data-description' => (string) $this->typeProvider->getDescription($kind, $key),
'data-icon' => (string) $this->typeProvider->getIcon($kind, $key),
@@ -76,23 +76,23 @@ class TaskType extends AbstractType
]);
$builder->add('name', TextType::class, [
'label' => 'mautic.plan.task.field.name',
'label' => 'mautic.program.task.field.name',
'label_attr' => ['class' => 'control-label'],
'attr' => ['class' => 'form-control', 'maxlength' => 255],
]);
$builder->add('description', TextareaType::class, [
'label' => 'mautic.plan.task.field.description',
'label' => 'mautic.program.task.field.description',
'label_attr' => ['class' => 'control-label'],
'attr' => ['class' => 'form-control', 'rows' => 6],
'required' => false,
]);
$builder->add('plan', EntityType::class, [
'label' => 'mautic.plan.task.field.plan',
$builder->add('initiative', EntityType::class, [
'label' => 'mautic.program.task.field.initiative',
'label_attr' => ['class' => 'control-label'],
'attr' => ['class' => 'form-control'],
'class' => Plan::class,
'class' => Initiative::class,
'choice_label' => 'name',
'query_builder' => fn (EntityRepository $er) => $er->createQueryBuilder('p')->orderBy('p.name', 'ASC'),
'placeholder' => 'mautic.core.form.chooseone',
@@ -101,7 +101,7 @@ class TaskType extends AbstractType
// Simple dates, no time (the columns are DATE since 0.13.0).
$builder->add('startDate', DateType::class, [
'label' => 'mautic.plan.task.field.start_date',
'label' => 'mautic.program.task.field.start_date',
'widget' => 'single_text',
'format' => 'yyyy-MM-dd',
'html5' => true,
@@ -112,7 +112,7 @@ class TaskType extends AbstractType
$isMilestone = TaskKind::Milestone === $task->getTaskKind();
$isPhase = TaskKind::Phase === $task->getTaskKind();
$builder->add('endDate', DateType::class, [
'label' => 'mautic.plan.task.field.end_date',
'label' => 'mautic.program.task.field.end_date',
'widget' => 'single_text',
'format' => 'yyyy-MM-dd',
'html5' => true,
@@ -123,7 +123,7 @@ class TaskType extends AbstractType
// Status: a phase has none of its own — it comes from its tasks.
if (!$isPhase) {
$builder->add('status', EnumType::class, [
'label' => 'mautic.plan.task.field.status',
'label' => 'mautic.program.task.field.status',
'label_attr' => ['class' => 'control-label'],
'attr' => ['class' => 'form-control'],
'class' => TaskStatus::class,
@@ -132,26 +132,26 @@ class TaskType extends AbstractType
}
$builder->add('definitionOfDone', TextareaType::class, [
'label' => 'mautic.plan.task.field.definition_of_done',
'label' => 'mautic.program.task.field.definition_of_done',
'label_attr' => ['class' => 'control-label'],
'attr' => ['class' => 'form-control', 'rows' => 3],
'required' => false,
]);
$builder->add('plannedWork', IntegerType::class, [
'label' => 'mautic.plan.task.field.planned_work',
'label' => 'mautic.program.task.field.planned_work',
'label_attr' => ['class' => 'control-label'],
'attr' => ['class' => 'form-control', 'min' => 0, 'step' => 1, 'postaddon_text' => 'h'],
'required' => false,
]);
// Dependencies: several edges, each another task of the plan with the relation type. The
// Dependencies: several edges, each another task of the initiative with the relation type. The
// rows are added and removed by the form template; cycles and self-edges are refused by
// ValidTaskDependency.
$builder->add('dependencies', CollectionType::class, [
'label' => 'mautic.plan.task.field.dependencies',
'label' => 'mautic.program.task.field.dependencies',
'entry_type' => TaskDependencyType::class,
'entry_options' => ['label' => false, 'plan' => $plan, 'task' => $task],
'entry_options' => ['label' => false, 'initiative' => $initiative, 'task' => $task],
'allow_add' => true,
'allow_delete' => true,
'by_reference' => false,
@@ -160,11 +160,11 @@ class TaskType extends AbstractType
'required' => false,
]);
// RACI: one row per role, several stakeholders per role, picked from the plan's stakeholders.
// RACI: one row per role, several stakeholders per role, picked from the initiative's stakeholders.
$builder->add('raci', CollectionType::class, [
'label' => 'mautic.plan.task.field.raci',
'label' => 'mautic.program.task.field.raci',
'entry_type' => TaskRaciType::class,
'entry_options' => ['label' => false, 'plan' => $plan],
'entry_options' => ['label' => false, 'initiative' => $initiative],
'allow_add' => true,
'allow_delete' => true,
'by_reference' => false,
@@ -189,6 +189,6 @@ class TaskType extends AbstractType
public function getBlockPrefix(): string
{
return 'plan_task';
return 'program_task';
}
}
@@ -2,18 +2,18 @@
declare(strict_types=1);
namespace MauticPlugin\PlanBundle\Integration;
namespace MauticPlugin\ProgramBundle\Integration;
use Mautic\IntegrationsBundle\Integration\BasicIntegration;
use Mautic\IntegrationsBundle\Integration\ConfigurationTrait;
use Mautic\IntegrationsBundle\Integration\Interfaces\BasicInterface;
class PlanIntegration extends BasicIntegration implements BasicInterface
class ProgramIntegration extends BasicIntegration implements BasicInterface
{
use ConfigurationTrait;
public const NAME = 'Plan';
public const DISPLAY_NAME = 'Plan';
public const NAME = 'Program';
public const DISPLAY_NAME = 'Program';
public function getName(): string
{
@@ -27,6 +27,6 @@ class PlanIntegration extends BasicIntegration implements BasicInterface
public function getIcon(): string
{
return 'plugins/PlanBundle/Assets/img/icon.svg';
return 'plugins/ProgramBundle/Assets/img/icon.svg';
}
}
@@ -2,13 +2,13 @@
declare(strict_types=1);
namespace MauticPlugin\PlanBundle\Integration\Support;
namespace MauticPlugin\ProgramBundle\Integration\Support;
use Mautic\IntegrationsBundle\Integration\DefaultConfigFormTrait;
use Mautic\IntegrationsBundle\Integration\Interfaces\ConfigFormInterface;
use MauticPlugin\PlanBundle\Integration\PlanIntegration;
use MauticPlugin\ProgramBundle\Integration\ProgramIntegration;
class ConfigSupport extends PlanIntegration implements ConfigFormInterface
class ProgramConfigSupport extends ProgramIntegration implements ConfigFormInterface
{
use DefaultConfigFormTrait;
}
+9 -11
View File
@@ -2,15 +2,15 @@
declare(strict_types=1);
namespace MauticPlugin\PlanBundle\Migrations;
namespace MauticPlugin\ProgramBundle\Migrations;
use Doctrine\DBAL\Schema\Schema;
use Mautic\IntegrationsBundle\Migration\AbstractMigration;
use MauticPlugin\PlanBundle\Entity\PlanObjective;
use MauticPlugin\ProgramBundle\Entity\InitiativeObjective;
/**
* 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
* Configuration > Plan Settings (parameter plan_objective_types). Adds initiative_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.
@@ -19,22 +19,20 @@ class Version_0_10_0 extends AbstractMigration
{
protected function isApplicable(Schema $schema): bool
{
$objectives = $this->concatPrefix(PlanObjective::TABLE_NAME);
if (!$schema->hasTable($objectives)) {
// Historical migration: its changes were applied on every install that ran
// it before 0.16.0 (this plugin renamed Plan→Program/Initiative in 0.16.0), and
// a fresh install creates the current tables from the entity mapping. Never
// applicable anymore.
return false;
}
return !$schema->getTable($objectives)->hasColumn('type');
}
protected function up(): void
{
$objectives = $this->concatPrefix(PlanObjective::TABLE_NAME);
$objectives = $this->concatPrefix(InitiativeObjective::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));
$this->addSql(sprintf('ALTER TABLE %s ADD type VARCHAR(%d) DEFAULT NULL', $objectives, InitiativeObjective::TYPE_MAX_LENGTH));
}
}
}
+9 -11
View File
@@ -2,40 +2,38 @@
declare(strict_types=1);
namespace MauticPlugin\PlanBundle\Migrations;
namespace MauticPlugin\ProgramBundle\Migrations;
use Doctrine\DBAL\Schema\Schema;
use Mautic\IntegrationsBundle\Migration\AbstractMigration;
use MauticPlugin\PlanBundle\Entity\PlanObjective;
use MauticPlugin\ProgramBundle\Entity\InitiativeObjective;
/**
* 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
* initiative_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)) {
// Historical migration: its changes were applied on every install that ran
// it before 0.16.0 (this plugin renamed Plan→Program/Initiative in 0.16.0), and
// a fresh install creates the current tables from the entity mapping. Never
// applicable anymore.
return false;
}
return !$schema->getTable($objectives)->hasColumn('priority');
}
protected function up(): void
{
$objectives = $this->concatPrefix(PlanObjective::TABLE_NAME);
$objectives = $this->concatPrefix(InitiativeObjective::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
InitiativeObjective::PRIORITY_MIN
));
}
}
+36 -41
View File
@@ -2,21 +2,29 @@
declare(strict_types=1);
namespace MauticPlugin\PlanBundle\Migrations;
namespace MauticPlugin\ProgramBundle\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;
use MauticPlugin\ProgramBundle\Entity\Audience;
use MauticPlugin\ProgramBundle\Entity\AudienceType as AudienceTypeEnum;
use MauticPlugin\ProgramBundle\Entity\Initiative;
/**
* 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.
* Since 0.11.0 a plan has audiences (table initiative_audiences, initiative_audiences_stages before 0.15.0) with any
* number of Mautic stages (join table initiative_audiences_stages). Creates both tables for installs created
* before 0.11.0, and repairs the ones the plugin installer created with camelCase column names (an
* early version of the mapping). Each step runs only if needed.
*
* Since 0.14.0 audiences are a global directory: initiative_audiences no longer carries plan_id (the plan
* association lives in initiative_audiences_initiative), so the plan_id repair is retired here; only the
* camelCase repair can still apply to an old install.
*
* Since 0.15.0 the tables are initiative_audiences and initiative_audiences_stages: an install already on 0.14.0
* was migrated by 0.15.0, so this migration creates nothing; one created before 0.11.0 that skipped
* every version since gets the current tables from the entity mapping directly, by looking for the
* current names too.
*/
class Version_0_11_0 extends AbstractMigration
{
@@ -32,49 +40,36 @@ class Version_0_11_0 extends AbstractMigration
protected function isApplicable(Schema $schema): bool
{
if (!$schema->hasTable($this->concatPrefix(Plan::TABLE_NAME))) {
// Historical migration: its changes were applied on every install that ran
// it before 0.16.0 (this plugin renamed Plan→Program/Initiative in 0.16.0), and
// a fresh install creates the current tables from the entity mapping. Never
// applicable anymore.
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));
// An install created before 0.11.0 that somehow never got the tables: create the current
// (0.15.0) ones from the entity mapping directly.
if (!$schema->hasTable($this->concatPrefix(Audience::TABLE_NAME))) {
$this->addSql($this->getCreateTableSql(Audience::TABLE_NAME));
}
if (!$schema->hasTable($this->concatPrefix('plan_target_stages'))) {
$this->addSql($this->getCreateTableSql('plan_target_stages'));
if (!$schema->hasTable($this->concatPrefix('initiative_audiences_stages'))
&& !$schema->hasTable($this->concatPrefix('initiative_audiences_stages'))) {
$this->addSql($this->getCreateTableSql('initiative_audiences_stages'));
}
foreach ($this->getColumnsToRename($schema) as $field => $column) {
$this->addSql(sprintf(
'ALTER TABLE %s CHANGE %s %s',
$this->concatPrefix(Target::TABLE_NAME),
$this->concatPrefix(Audience::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'
));
}
}
/**
@@ -82,11 +77,11 @@ class Version_0_11_0 extends AbstractMigration
*/
private function getColumnsToRename(Schema $schema): array
{
if (!$schema->hasTable($this->concatPrefix(Target::TABLE_NAME))) {
if (!$schema->hasTable($this->concatPrefix(Audience::TABLE_NAME))) {
return [];
}
$table = $schema->getTable($this->concatPrefix(Target::TABLE_NAME));
$table = $schema->getTable($this->concatPrefix(Audience::TABLE_NAME));
$rename = [];
foreach (self::COLUMNS as $field => $column) {
@@ -100,13 +95,13 @@ class Version_0_11_0 extends AbstractMigration
private function hasForeignKeys(Schema $schema): bool
{
$targets = $this->concatPrefix(Target::TABLE_NAME);
$audiences = $this->concatPrefix(Audience::TABLE_NAME);
if (!$schema->hasTable($targets)) {
if (!$schema->hasTable($audiences)) {
return false;
}
foreach ($schema->getTable($targets)->getForeignKeys() as $foreignKey) {
foreach ($schema->getTable($audiences)->getForeignKeys() as $foreignKey) {
if (in_array('plan_id', $foreignKey->getLocalColumns(), true)) {
return true;
}
@@ -121,7 +116,7 @@ class Version_0_11_0 extends AbstractMigration
private function getColumnDefinition(string $field, string $column): string
{
$definitions = [
'targetType' => sprintf("%s VARCHAR(30) NOT NULL DEFAULT '%s'", $column, TargetTypeEnum::Persona->value),
'targetType' => sprintf("%s VARCHAR(30) NOT NULL DEFAULT '%s'", $column, AudienceTypeEnum::Persona->value),
'profileCriteria' => $column.' LONGTEXT DEFAULT NULL',
'painPoints' => $column.' LONGTEXT DEFAULT NULL',
'valueProposition' => $column.' LONGTEXT DEFAULT NULL',
@@ -138,7 +133,7 @@ class Version_0_11_0 extends AbstractMigration
$schemaTool = new SchemaTool($this->entityManager);
$prefix = 'CREATE TABLE '.$this->concatPrefix($table).' ';
foreach ($schemaTool->getCreateSchemaSql([$this->entityManager->getClassMetadata(Target::class)]) as $sql) {
foreach ($schemaTool->getCreateSchemaSql([$this->entityManager->getClassMetadata(Audience::class)]) as $sql) {
if (str_starts_with($sql, $prefix)) {
return $sql;
}
+16 -21
View File
@@ -2,18 +2,18 @@
declare(strict_types=1);
namespace MauticPlugin\PlanBundle\Migrations;
namespace MauticPlugin\ProgramBundle\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;
use MauticPlugin\ProgramBundle\Entity\Initiative;
use MauticPlugin\ProgramBundle\Entity\InitiativeStakeholder;
use MauticPlugin\ProgramBundle\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
* Since 0.12.0 planning has a global stakeholder directory (table initiative_stakeholders), and each plan
* links to its stakeholders through initiative_stakeholders_initiative, 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.
@@ -22,18 +22,13 @@ class Version_0_12_0 extends AbstractMigration
{
protected function isApplicable(Schema $schema): bool
{
if (!$schema->hasTable($this->concatPrefix(Plan::TABLE_NAME))) {
// Historical migration: its changes were applied on every install that ran
// it before 0.16.0 (this plugin renamed Plan→Program/Initiative in 0.16.0), and
// a fresh install creates the current tables from the entity mapping. Never
// applicable anymore.
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();
@@ -42,20 +37,20 @@ class Version_0_12_0 extends AbstractMigration
$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 (!$schema->hasTable($this->concatPrefix(InitiativeStakeholder::TABLE_NAME))) {
$this->addSql($this->getCreateTableSql(InitiativeStakeholder::class, InitiativeStakeholder::TABLE_NAME));
}
if (!$this->hasForeignKeys($schema)) {
$this->addSql($this->generateAlterTableForeignKeyStatement(
PlanStakeholder::TABLE_NAME,
InitiativeStakeholder::TABLE_NAME,
['plan_id'],
Plan::TABLE_NAME,
Initiative::TABLE_NAME,
['id'],
'ON DELETE CASCADE'
));
$this->addSql($this->generateAlterTableForeignKeyStatement(
PlanStakeholder::TABLE_NAME,
InitiativeStakeholder::TABLE_NAME,
['stakeholder_id'],
Stakeholder::TABLE_NAME,
['id'],
@@ -69,7 +64,7 @@ class Version_0_12_0 extends AbstractMigration
*/
private function hasForeignKeys(Schema $schema): bool
{
$links = $this->concatPrefix(PlanStakeholder::TABLE_NAME);
$links = $this->concatPrefix(InitiativeStakeholder::TABLE_NAME);
if (!$schema->hasTable($links)) {
return false;
+14 -24
View File
@@ -2,21 +2,21 @@
declare(strict_types=1);
namespace MauticPlugin\PlanBundle\Migrations;
namespace MauticPlugin\ProgramBundle\Migrations;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\ORM\Tools\SchemaTool;
use Mautic\IntegrationsBundle\Migration\AbstractMigration;
use MauticPlugin\PlanBundle\Entity\Task;
use MauticPlugin\PlanBundle\Entity\TaskDependency;
use MauticPlugin\PlanBundle\Entity\TaskRaci;
use MauticPlugin\ProgramBundle\Entity\Task;
use MauticPlugin\ProgramBundle\Entity\TaskDependency;
use MauticPlugin\ProgramBundle\Entity\TaskRaci;
/**
* Since 0.13.0 tasks are reworked:
* - start_date and end_date become DATE (no time); existing values are truncated to the date;
* - new columns task_kind (default 'task'), definition_of_done, planned_work;
* - new tables plan_task_dependencies (dependency graph) and plan_task_raci with its
* plan_task_raci_stakeholders join table;
* - new tables initiative_task_dependencies (dependency graph) and initiative_task_raci with its
* initiative_task_raci_stakeholders join table;
* - the parent/child tree is dropped: parent_id and its index are removed, replaced by the
* dependency graph.
*
@@ -26,23 +26,13 @@ class Version_0_13_0 extends AbstractMigration
{
protected function isApplicable(Schema $schema): bool
{
$tasks = $this->concatPrefix(Task::TABLE_NAME);
if (!$schema->hasTable($tasks)) {
// Historical migration: its changes were applied on every install that ran
// it before 0.16.0 (this plugin renamed Plan→Program/Initiative in 0.16.0), and
// a fresh install creates the current tables from the entity mapping. Never
// applicable anymore.
return false;
}
$table = $schema->getTable($tasks);
return !$table->hasColumn('task_kind')
|| !$table->hasColumn('definition_of_done')
|| !$table->hasColumn('planned_work')
|| $table->hasColumn('parent_id')
|| !$schema->hasTable($this->concatPrefix(TaskDependency::TABLE_NAME))
|| !$schema->hasTable($this->concatPrefix(TaskRaci::TABLE_NAME))
|| !$schema->hasTable($this->concatPrefix(TaskRaci::JOIN_TABLE_NAME));
}
protected function up(): void
{
$tasks = $this->concatPrefix(Task::TABLE_NAME);
@@ -53,7 +43,7 @@ class Version_0_13_0 extends AbstractMigration
$this->addSql(sprintf(
"ALTER TABLE %s ADD task_kind VARCHAR(20) NOT NULL DEFAULT '%s'",
$tasks,
\MauticPlugin\PlanBundle\Entity\TaskKind::Task->value
\MauticPlugin\ProgramBundle\Entity\TaskKind::Task->value
));
}
if (!$table->hasColumn('definition_of_done')) {
@@ -91,8 +81,8 @@ class Version_0_13_0 extends AbstractMigration
$this->addSql($sql);
}
}
// The RACI join table comes with the TaskRaci entity's SQL (CREATE TABLE plan_task_raci_stakeholders),
// but it may be missing while plan_task_raci exists (a partial earlier run).
// The RACI join table comes with the TaskRaci entity's SQL (CREATE TABLE initiative_task_raci_stakeholders),
// but it may be missing while initiative_task_raci exists (a partial earlier run).
if (!$this->introspectSchema()->hasTable($this->concatPrefix(TaskRaci::JOIN_TABLE_NAME))) {
foreach ($this->getCreateTableSqls(TaskRaci::class, TaskRaci::JOIN_TABLE_NAME) as $sql) {
$this->addSql($sql);
@@ -107,7 +97,7 @@ class Version_0_13_0 extends AbstractMigration
/**
* The CREATE TABLE statements of one of this migration's entities, from Doctrine's SchemaTool —
* the entity's table and, for TaskRaci, its join table plan_task_raci_stakeholders too.
* the entity's table and, for TaskRaci, its join table initiative_task_raci_stakeholders too.
*
* @param class-string $entityClass
*
+207
View File
@@ -0,0 +1,207 @@
<?php
declare(strict_types=1);
namespace MauticPlugin\ProgramBundle\Migrations;
use Doctrine\DBAL\Schema\Schema;
use Mautic\IntegrationsBundle\Migration\AbstractMigration;
use MauticPlugin\ProgramBundle\Entity\Audience;
use MauticPlugin\ProgramBundle\Entity\Initiative;
use MauticPlugin\ProgramBundle\Entity\InitiativeAudience;
/**
* Since 0.14.0 audiences are a global directory (Planning > Audiences, called Targets before 0.15.0),
* like stakeholders:
* - the existing initiative_audiences rows become the directory entries; is_published and the audit
* columns (FormEntity) are added;
* - the new persona attributes are added: tagline, motivations, barriers, frustrations
* (replacing pain_points, whose texts are moved), triggers, decision_role, preferred_tones;
* - the initiative-specific fields (priority, value proposition, position) move to the new link table
* initiative_audiences_initiative, one row per (plan, target); the existing rows are copied there, then the
* initiative-specific columns (and plan_id) are dropped from initiative_audiences.
*
* Since 0.15.0 the tables are named initiative_audiences and initiative_audiences_initiative: this migration only
* still applies to an install on 0.13.x with the old names, or to repair one the plugin installer
* created without foreign keys (it drops foreign keys that point to core tables). Each step runs
* only if needed. Which persona attributes are offered is an admin setting (AudienceAttributes).
*/
class Version_0_14_0 extends AbstractMigration
{
protected function isApplicable(Schema $schema): bool
{
// Historical migration: its changes were applied on every install that ran
// it before 0.16.0 (this plugin renamed Plan→Program/Initiative in 0.16.0), and
// a fresh install creates the current tables from the entity mapping. Never
// applicable anymore.
return false;
}
protected function up(): void
{
$schema = $this->entityManager->getConnection()->createSchemaManager()->introspectSchema();
$names = $this->getTableNames($schema);
// Fresh install created before 0.11.0: no directory table yet. Nothing to migrate here.
if (null === $names) {
return;
}
[$directory, $links] = $names;
$oldNaming = 'initiative_audiences' === $directory;
$table = $schema->getTable($directory);
$shared = fn (string $column): bool => $table->hasColumn($this->concatPrefix($column));
// Directory columns: is_published and the audit columns of FormEntity (the installer adds
// them on a fresh install; they are missing only on an upgrade from 0.13.0).
if (!$shared('is_published')) {
$this->addSql(sprintf('ALTER TABLE %s ADD is_published TINYINT(1) NOT NULL DEFAULT 1', $directory));
$this->addSql(sprintf(
'ALTER TABLE %1$s ADD date_added DATETIME DEFAULT NULL, ADD created_by INT DEFAULT NULL, '.
'ADD created_by_user VARCHAR(191) DEFAULT NULL, ADD date_modified DATETIME DEFAULT NULL, '.
'ADD modified_by INT DEFAULT NULL, ADD modified_by_user VARCHAR(191) DEFAULT NULL, '.
'ADD checked_out DATETIME DEFAULT NULL, ADD checked_out_by INT DEFAULT NULL, '.
'ADD checked_out_by_user VARCHAR(191) DEFAULT NULL',
$directory
));
}
// The new persona attributes (free text).
foreach (['tagline', 'motivations', 'barriers', 'triggers'] as $column) {
if (!$shared($column)) {
$this->addSql(sprintf('ALTER TABLE %s ADD %s LONGTEXT DEFAULT NULL', $directory, $column));
}
}
// frustrations replaces pain_points: add the column, move the texts, then drop the old one
// (dropped with the initiative-specific columns below, in one sweep).
if (!$shared('frustrations')) {
$this->addSql(sprintf('ALTER TABLE %s ADD frustrations LONGTEXT DEFAULT NULL', $directory));
if ($shared('pain_points')) {
$this->addSql(sprintf(
'UPDATE %s SET frustrations = pain_points WHERE frustrations IS NULL AND pain_points IS NOT NULL',
$directory
));
}
}
// decision_role: a key of the admin-configured list (program_audience_decision_roles).
if (!$shared('decision_role')) {
$this->addSql(sprintf('ALTER TABLE %s ADD decision_role VARCHAR(64) DEFAULT NULL', $directory));
}
// preferred_tones: a JSON list of keys of the admin-configured list (program_audience_tones).
if (!$shared('preferred_tones')) {
$this->addSql(sprintf("ALTER TABLE %s ADD preferred_tones LONGTEXT DEFAULT NULL COMMENT '(DC2Type:json)'", $directory));
}
// The link table, one row per (plan, audience), with the initiative-specific fields. Under the old
// naming it keeps the old names (initiative_audiences_initiative, target_id); 0.15.0 renames both.
if (!$schema->hasTable($links)) {
$linkIdColumn = $oldNaming ? 'target_id' : 'audience_id';
$this->addSql(sprintf(
'CREATE TABLE IF NOT EXISTS %s (id INT UNSIGNED AUTO_INCREMENT NOT NULL, '.
'plan_id INT UNSIGNED NOT NULL, %s INT UNSIGNED NOT NULL, priority VARCHAR(20) NOT NULL, '.
'value_proposition LONGTEXT DEFAULT NULL, position INT NOT NULL, '.
'INDEX IDX_%1$s_PLAN (plan_id), INDEX IDX_%1$s_LINK (%2$s), '.
'PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci ENGINE = InnoDB',
$links,
$linkIdColumn
));
// Copy the existing rows: each audience of each plan becomes a directory entry plus a
// link carrying the initiative-specific fields. The position follows the id order, so the
// tab shows the same order as before the migration.
if ($shared('plan_id')) {
$this->addSql(sprintf(
'INSERT INTO %1$s (plan_id, %2$s, priority, value_proposition, position) '.
'SELECT t.plan_id, t.id, t.priority, t.value_proposition, '.
'(SELECT COUNT(*) FROM %1$s l WHERE l.plan_id = t.plan_id AND l.%2$s <= t.id) '.
'FROM %3$s t WHERE t.plan_id IS NOT NULL ORDER BY t.id ASC',
$links,
$linkIdColumn,
$directory
));
// The directory entry no longer belongs to a plan; the initiative-specific fields moved
// to the link table; pain_points moved to frustrations; position is the link's.
// Drop the old plan_id foreign key first: it would block the column drop.
foreach ($schema->getTable($directory)->getForeignKeys() as $foreignKey) {
if (in_array($this->concatPrefix('plan_id'), $foreignKey->getLocalColumns(), true)) {
$this->addSql(sprintf('ALTER TABLE %s DROP FOREIGN KEY %s', $directory, $foreignKey->getName()));
break;
}
}
foreach (['plan_id', 'priority', 'value_proposition', 'position', 'pain_points'] as $column) {
if ($shared($column)) {
$this->addSql(sprintf('ALTER TABLE %s DROP COLUMN %s', $directory, $column));
}
}
}
}
// Repair the foreign keys the plugin installer stripped (it drops the ones that point to
// core tables, such as plans, at install time).
if (!$this->hasForeignKeys($schema)) {
$this->addSql($this->generateAlterTableForeignKeyStatement(
$oldNaming ? 'initiative_audiences_initiative' : InitiativeAudience::TABLE_NAME,
['plan_id'],
Initiative::TABLE_NAME,
['id'],
'ON DELETE CASCADE'
));
}
}
/**
* The directory and link table names this install uses: the current ones (initiative_audiences,
* initiative_audiences_initiative, since 0.15.0) or the ones before 0.15.0 (initiative_audiences, initiative_audiences_initiative).
* Null when neither exists (a fresh install created before 0.11.0).
*
* @return array{string, string}|null
*/
private function getTableNames(Schema $schema): ?array
{
foreach ([
[Audience::TABLE_NAME, InitiativeAudience::TABLE_NAME],
['initiative_audiences', 'initiative_audiences_initiative'],
] as [$directory, $links]) {
if ($schema->hasTable($this->concatPrefix($directory))) {
return [$this->concatPrefix($directory), $this->concatPrefix($links)];
}
}
return null;
}
/**
* True when the link table's plan_id foreign key exists (the one the installer strips; the
* audience_id one points to a plugin table and survives). Checks the link table under either
* naming (initiative_audiences_initiative before 0.15.0, initiative_audiences_initiative since).
*/
private function hasForeignKeys(Schema $schema): bool
{
foreach (['initiative_audiences_initiative', InitiativeAudience::TABLE_NAME] as $links) {
$links = $this->concatPrefix($links);
if (!$schema->hasTable($links)) {
continue;
}
foreach ($schema->getTable($links)->getForeignKeys() as $foreignKey) {
if (in_array('plan_id', $foreignKey->getLocalColumns(), true)) {
return true;
}
}
return false;
}
// No link table (fresh install from before 0.11.0): up() creates it from the
// mapping, foreign keys included — nothing to repair first.
return true;
}
}
+263
View File
@@ -0,0 +1,263 @@
<?php
declare(strict_types=1);
namespace MauticPlugin\ProgramBundle\Migrations;
use Doctrine\DBAL\Schema\Schema;
use Mautic\IntegrationsBundle\Migration\AbstractMigration;
use MauticPlugin\ProgramBundle\Entity\Audience;
use MauticPlugin\ProgramBundle\Entity\Initiative;
/**
* Historical migration (from 0.15.0, when the bundle was still PlanBundle): it renamed "targets"
* to "audiences" — plan_targets became plan_audiences (its target_type column audience_type),
* plan_targets_plan became plan_audiences_plan (target_id became audience_id), plan_target_stages
* became plan_audiences_stages — and created the segments join table plan_audiences_segments.
*
* Since 0.16.0 the tables are named initiative_* (the 0.16.0 migration renames them), so this
* migration only still applies to an install upgrading from 0.14.x or older, which still carries
* the plan_targets-era names. The names of that era are kept literal here on purpose.
*/
class Version_0_15_0 extends AbstractMigration
{
protected function isApplicable(Schema $schema): bool
{
if (!$schema->hasTable($this->concatPrefix(Initiative::TABLE_NAME))
&& !$schema->hasTable($this->concatPrefix('plans'))) {
return false;
}
// The pre-0.15.0 names, or a missing piece of the 0.15.0 schema.
return $schema->hasTable($this->concatPrefix('plan_targets'))
|| $schema->hasTable($this->concatPrefix('plan_targets_plan'))
|| $schema->hasTable($this->concatPrefix('plan_target_stages'))
|| $this->needsColumnNameRename($schema, ['plan_targets', 'plan_audiences'], 'target_type')
|| $this->needsColumnNameRename($schema, ['plan_targets_plan', 'plan_audiences_plan'], 'target_id')
|| $this->needsColumnNameRename($schema, ['plan_target_stages', 'plan_audiences_stages'], 'target_id')
|| !$schema->hasTable($this->concatPrefix('plan_audiences_segments'))
|| $this->needsForeignKey($schema, 'plan_audiences_plan', 'plan_id')
|| $this->needsForeignKey($schema, 'plan_audiences_segments', 'audience_id');
}
protected function up(): void
{
// The directory table: plan_targets becomes plan_audiences.
$this->renameTableIfExists('plan_targets', 'plan_audiences');
// Its type column: target_type becomes audience_type (on whichever name the table has now).
$this->renameColumnIfExists(
['plan_targets', 'plan_audiences'],
'target_type',
'audience_type',
"VARCHAR(30) NOT NULL DEFAULT 'persona'"
);
// The link table: plan_targets_plan becomes plan_audiences_plan.
$this->renameTableIfExists('plan_targets_plan', 'plan_audiences_plan');
// Its audience reference: target_id becomes audience_id.
$this->renameColumnIfExists(
['plan_targets_plan', 'plan_audiences_plan'],
'target_id',
'audience_id',
'INT UNSIGNED NOT NULL'
);
// The stages join table: plan_target_stages becomes plan_audiences_stages.
$this->renameTableIfExists('plan_target_stages', 'plan_audiences_stages');
// Same column rename, on whichever name the table has now.
$this->renameColumnIfExists(
['plan_target_stages', 'plan_audiences_stages'],
'target_id',
'audience_id',
'INT UNSIGNED NOT NULL'
);
// The segments join table: purely informational, created empty when missing.
$this->createSegmentsTableIfMissing();
// The link table's plan_id foreign key, on the installs where it's missing.
$this->repairLinkForeignKeyIfMissing();
// The segments table's audience_id foreign key: deleting an audience deletes its links.
$this->repairSegmentsForeignKeyIfMissing();
}
/**
* Renames a table when the old name still exists and the new one doesn't.
*/
private function renameTableIfExists(string $from, string $to): void
{
$connection = $this->entityManager->getConnection();
if ($this->getTableName($connection->createSchemaManager()->introspectSchema(), [$from, $to]) === $this->concatPrefix($from)) {
$connection->executeStatement(sprintf(
'RENAME TABLE %1$s TO %2$s',
$this->concatPrefix($from),
$this->concatPrefix($to)
));
}
}
/**
* @param list<string> $tables the table's possible names, oldest first: the first that exists is used
*/
private function renameColumnIfExists(array $tables, string $fromColumn, string $toColumn, string $definition): void
{
$connection = $this->entityManager->getConnection();
$table = $this->getTableName($connection->createSchemaManager()->introspectSchema(), $tables);
if (null === $table) {
return;
}
foreach ($connection->createSchemaManager()->introspectTable($table)->getColumns() as $name => $column) {
if (strtolower($name) === strtolower($fromColumn)) {
$connection->executeStatement(sprintf(
'ALTER TABLE %s CHANGE %s %s %s',
$table,
$name,
$toColumn,
$definition
));
return;
}
}
}
/**
* True when the first of the tables that exists still carries the old column.
*
* @param list<string> $tables
*/
private function needsColumnNameRename(Schema $schema, array $tables, string $column): bool
{
$table = $this->getTableName($schema, $tables);
if (null === $table) {
return false;
}
foreach ($schema->getTable($table)->getColumns() as $name => $columnObject) {
if (strtolower($name) === strtolower($column)) {
return true;
}
}
return false;
}
/**
* True when the table exists and lacks a foreign key on the given column.
*/
private function needsForeignKey(Schema $schema, string $table, string $column): bool
{
$table = $this->concatPrefix($table);
if (!$schema->hasTable($table)) {
return false;
}
foreach ($schema->getTable($table)->getForeignKeys() as $foreignKey) {
if (in_array($column, $foreignKey->getLocalColumns(), true)) {
return false;
}
}
return true;
}
/**
* The first of the given table names that exists, prefixed.
*
* @param list<string> $tables
*/
private function getTableName(Schema $schema, array $tables): ?string
{
foreach ($tables as $table) {
if ($schema->hasTable($this->concatPrefix($table))) {
return $this->concatPrefix($table);
}
}
return null;
}
private function createSegmentsTableIfMissing(): void
{
$connection = $this->entityManager->getConnection();
if ($connection->createSchemaManager()->introspectSchema()->hasTable($this->concatPrefix('initiative_audiences_segments'))
|| $connection->createSchemaManager()->introspectSchema()->hasTable($this->concatPrefix('plan_audiences_segments'))) {
return;
}
$connection->executeStatement(sprintf(
'CREATE TABLE IF NOT EXISTS %s (audience_id INT UNSIGNED NOT NULL, leadlist_id INT UNSIGNED NOT NULL, '.
'INDEX IDX_%1$s_AUDIENCE (audience_id), INDEX IDX_%1$s_LEADLIST (leadlist_id), '.
'PRIMARY KEY (audience_id, leadlist_id)) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci ENGINE = InnoDB',
$this->concatPrefix('plan_audiences_segments')
));
}
/**
* Adds the link table's plan_id foreign key when it's missing (the plugin installer drops
* the foreign keys that point to core tables, such as plans — initiatives since 0.16.0).
*/
private function repairLinkForeignKeyIfMissing(): void
{
$connection = $this->entityManager->getConnection();
$schema = $connection->createSchemaManager()->introspectSchema();
$links = $this->getTableName($schema, ['plan_targets_plan', 'plan_audiences_plan']);
if (null === $links) {
return;
}
foreach ($schema->getTable($links)->getForeignKeys() as $foreignKey) {
if (in_array('plan_id', $foreignKey->getLocalColumns(), true)) {
return;
}
}
$connection->executeStatement(sprintf(
'ALTER TABLE %1$s ADD CONSTRAINT FK_%1$s_plan_id FOREIGN KEY (plan_id) REFERENCES %2$s (id) ON DELETE CASCADE',
$links,
$this->concatPrefix('plans')
));
}
/**
* Adds the segments table's audience_id foreign key when it's missing.
*/
private function repairSegmentsForeignKeyIfMissing(): void
{
$connection = $this->entityManager->getConnection();
$schema = $connection->createSchemaManager()->introspectSchema();
$segments = $this->getTableName($schema, ['initiative_audiences_segments', 'plan_audiences_segments']);
if (null === $segments) {
return;
}
foreach ($schema->getTable($segments)->getForeignKeys() as $foreignKey) {
if (in_array('audience_id', $foreignKey->getLocalColumns(), true)) {
return;
}
}
$audiences = $this->getTableName($schema, ['initiative_audiences', 'plan_audiences']);
if (null === $audiences) {
return;
}
$connection->executeStatement(sprintf(
'ALTER TABLE %1$s ADD CONSTRAINT FK_%1$s_audience_id FOREIGN KEY (audience_id) REFERENCES %2$s (id) ON DELETE CASCADE',
$segments,
$audiences
));
}
}
+160
View File
@@ -0,0 +1,160 @@
<?php
declare(strict_types=1);
namespace MauticPlugin\ProgramBundle\Migrations;
use Doctrine\DBAL\Schema\Schema;
use Mautic\IntegrationsBundle\Migration\AbstractMigration;
use MauticPlugin\ProgramBundle\Entity\Initiative;
/**
* Since 0.16.0 the PlanBundle is the ProgramBundle, and a plan is an initiative: the Planning
* menu is Programs, the Plans page is Initiatives. The database follows:
* - plans becomes initiatives;
* - plan_objectives, plan_description_items, plan_allocation_items become initiative_*;
* - plan_tasks, plan_task_dependencies, plan_task_raci, plan_task_raci_stakeholders become
* initiative_*;
* - plan_stakeholders, plan_stakeholders_plan become initiative_stakeholders and
* initiative_stakeholders_initiative;
* - plan_audiences, plan_audiences_plan, plan_audiences_segments, plan_audiences_stages become
* initiative_*;
* - the link tables' plan_id columns become initiative_id; plan_stakeholders_plan's
* role_in_plan becomes role_in_initiative; plan_tasks' plan_id becomes initiative_id.
*
* Every statement runs immediately and re-reads the schema first, so the migration picks up
* again wherever an earlier run stopped (MySQL auto-commits DDL, so a failing batch of addSql()
* can leave the renames half done). A fresh install created by the plugin installer already
* uses the new names from the entity mapping.
*/
class Version_0_16_0 extends AbstractMigration
{
/**
* Old table name => new table name, in dependency order (the audited tables first, then the
* ones whose foreign keys point at them — RENAME TABLE takes both in one statement when
* needed, but one rename per line keeps half-applied states recoverable).
*/
private const TABLES = [
'plans' => 'initiatives',
'plan_objectives' => 'initiative_objectives',
'plan_description_items' => 'initiative_description_items',
'plan_allocation_items' => 'initiative_allocation_items',
'plan_tasks' => 'initiative_tasks',
'plan_task_dependencies' => 'initiative_task_dependencies',
'plan_task_raci' => 'initiative_task_raci',
'plan_task_raci_stakeholders' => 'initiative_task_raci_stakeholders',
'plan_stakeholders' => 'initiative_stakeholders',
'plan_stakeholders_plan' => 'initiative_stakeholders_initiative',
'plan_audiences' => 'initiative_audiences',
'plan_audiences_plan' => 'initiative_audiences_initiative',
'plan_audiences_segments' => 'initiative_audiences_segments',
'plan_audiences_stages' => 'initiative_audiences_stages',
];
/**
* Table (any of its names) => [old column => [new column, definition]].
*/
private const COLUMNS = [
['plan_objectives', 'initiative_objectives', 'plan_id', 'initiative_id', 'INT UNSIGNED NOT NULL'],
['plan_description_items', 'initiative_description_items', 'plan_id', 'initiative_id', 'INT UNSIGNED NOT NULL'],
['plan_allocation_items', 'initiative_allocation_items', 'plan_id', 'initiative_id', 'INT UNSIGNED NOT NULL'],
['plan_tasks', 'initiative_tasks', 'plan_id', 'initiative_id', 'INT UNSIGNED NOT NULL'],
['plan_stakeholders_plan', 'initiative_stakeholders_initiative', 'plan_id', 'initiative_id', 'INT UNSIGNED NOT NULL'],
['plan_stakeholders_plan', 'initiative_stakeholders_initiative', 'role_in_plan', 'role_in_initiative', 'VARCHAR(191) DEFAULT NULL'],
['plan_audiences_plan', 'initiative_audiences_initiative', 'plan_id', 'initiative_id', 'INT UNSIGNED NOT NULL'],
];
protected function isApplicable(Schema $schema): bool
{
foreach (self::TABLES as $from => $to) {
if ($schema->hasTable($this->concatPrefix($from))) {
return true;
}
}
foreach (self::COLUMNS as [$fromTable, $toTable, $fromColumn, $toColumn]) {
$table = $this->getTableName($schema, [$fromTable, $toTable]);
if (null !== $table) {
foreach ($schema->getTable($table)->getColumns() as $name => $column) {
if (strtolower($name) === strtolower($fromColumn)) {
return true;
}
}
}
}
return false;
}
protected function up(): void
{
// Tables, one rename at a time; stable database names unique.
foreach (self::TABLES as $from => $to) {
$this->renameTableIfExists($from, $to);
}
// Columns, resolving each table to whichever name it has now.
foreach (self::COLUMNS as [$fromTable, $toTable, $fromColumn, $toColumn, $definition]) {
$this->renameColumnIfExists([$fromTable, $toTable], $fromColumn, $toColumn, $definition);
}
}
/**
* Renames a table when the old name still exists and the new one doesn't.
*/
private function renameTableIfExists(string $from, string $to): void
{
$connection = $this->entityManager->getConnection();
if ($this->getTableName($connection->createSchemaManager()->introspectSchema(), [$from, $to]) === $this->concatPrefix($from)) {
$connection->executeStatement(sprintf(
'RENAME TABLE %1$s TO %2$s',
$this->concatPrefix($from),
$this->concatPrefix($to)
));
}
}
/**
* @param list<string> $tables the table's possible names, oldest first: the first that exists is used
*/
private function renameColumnIfExists(array $tables, string $fromColumn, string $toColumn, string $definition): void
{
$connection = $this->entityManager->getConnection();
$table = $this->getTableName($connection->createSchemaManager()->introspectSchema(), $tables);
if (null === $table) {
return;
}
foreach ($connection->createSchemaManager()->introspectTable($table)->getColumns() as $name => $column) {
if (strtolower($name) === strtolower($fromColumn)) {
$connection->executeStatement(sprintf(
'ALTER TABLE %s CHANGE %s %s %s',
$table,
$name,
$toColumn,
$definition
));
return;
}
}
}
/**
* The first of the given table names that exists, prefixed.
*
* @param list<string> $tables
*/
private function getTableName(Schema $schema, array $tables): ?string
{
foreach ($tables as $table) {
if ($schema->hasTable($this->concatPrefix($table))) {
return $this->concatPrefix($table);
}
}
return null;
}
}
+9 -11
View File
@@ -2,12 +2,12 @@
declare(strict_types=1);
namespace MauticPlugin\PlanBundle\Migrations;
namespace MauticPlugin\ProgramBundle\Migrations;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\DBAL\Schema\Table;
use Mautic\IntegrationsBundle\Migration\AbstractMigration;
use MauticPlugin\PlanBundle\Entity\Plan;
use MauticPlugin\ProgramBundle\Entity\Initiative;
/**
* Brings the plans table in line with the entity mapping.
@@ -31,15 +31,13 @@ class Version_0_2_0 extends AbstractMigration
protected function isApplicable(Schema $schema): bool
{
$table = $this->getTable($schema);
if (null === $table) {
// Historical migration: its changes were applied on every install that ran
// it before 0.16.0 (this plugin renamed Plan→Program/Initiative in 0.16.0), and
// a fresh install creates the current tables from the entity mapping. Never
// applicable anymore.
return false;
}
return [] !== $this->getMissingForeignKeys($table) || $this->statusNeedsResize($table);
}
protected function up(): void
{
$schema = $this->entityManager->getConnection()->createSchemaManager()->introspectSchema();
@@ -52,14 +50,14 @@ class Version_0_2_0 extends AbstractMigration
if ($this->statusNeedsResize($table)) {
$this->addSql(sprintf(
'ALTER TABLE %s MODIFY status VARCHAR(%d) NOT NULL',
$this->concatPrefix(Plan::TABLE_NAME),
$this->concatPrefix(Initiative::TABLE_NAME),
self::STATUS_LENGTH
));
}
foreach ($this->getMissingForeignKeys($table) as $column => $referenceTable) {
$this->addSql($this->generateAlterTableForeignKeyStatement(
Plan::TABLE_NAME,
Initiative::TABLE_NAME,
[$column],
$referenceTable,
['id'],
@@ -70,7 +68,7 @@ class Version_0_2_0 extends AbstractMigration
private function getTable(Schema $schema): ?Table
{
$name = $this->concatPrefix(Plan::TABLE_NAME);
$name = $this->concatPrefix(Initiative::TABLE_NAME);
return $schema->hasTable($name) ? $schema->getTable($name) : null;
}
+12 -15
View File
@@ -2,15 +2,15 @@
declare(strict_types=1);
namespace MauticPlugin\PlanBundle\Migrations;
namespace MauticPlugin\ProgramBundle\Migrations;
use Doctrine\DBAL\Schema\Schema;
use Mautic\IntegrationsBundle\Migration\AbstractMigration;
use MauticPlugin\PlanBundle\Entity\Plan;
use MauticPlugin\PlanBundle\Entity\PlanObjective;
use MauticPlugin\ProgramBundle\Entity\Initiative;
use MauticPlugin\ProgramBundle\Entity\InitiativeObjective;
/**
* Adds plans.version and the plan_objectives table to installs created before 0.3.0.
* Adds plans.version and the initiative_objectives table to installs created before 0.3.0.
*
* Fresh installs get both from the entity mapping, so this migration then finds nothing to do.
*/
@@ -18,29 +18,26 @@ class Version_0_3_0 extends AbstractMigration
{
protected function isApplicable(Schema $schema): bool
{
$plans = $this->concatPrefix(Plan::TABLE_NAME);
if (!$schema->hasTable($plans)) {
// Historical migration: its changes were applied on every install that ran
// it before 0.16.0 (this plugin renamed Plan→Program/Initiative in 0.16.0), and
// a fresh install creates the current tables from the entity mapping. Never
// applicable anymore.
return false;
}
return !$schema->getTable($plans)->hasColumn('version')
|| !$schema->hasTable($this->concatPrefix(PlanObjective::TABLE_NAME));
}
protected function up(): void
{
$schema = $this->entityManager->getConnection()->createSchemaManager()->introspectSchema();
$plans = $this->concatPrefix(Plan::TABLE_NAME);
$objectives = $this->concatPrefix(PlanObjective::TABLE_NAME);
$plans = $this->concatPrefix(Initiative::TABLE_NAME);
$objectives = $this->concatPrefix(InitiativeObjective::TABLE_NAME);
if (!$schema->getTable($plans)->hasColumn('version')) {
$this->addSql("ALTER TABLE {$plans} ADD version SMALLINT UNSIGNED DEFAULT 1 NOT NULL");
}
if (!$schema->hasTable($objectives)) {
$index = $this->generatePropertyName(PlanObjective::TABLE_NAME, 'idx', ['plan_id']);
$foreignKey = $this->generatePropertyName(PlanObjective::TABLE_NAME, 'fk', ['plan_id']);
$index = $this->generatePropertyName(InitiativeObjective::TABLE_NAME, 'idx', ['plan_id']);
$foreignKey = $this->generatePropertyName(InitiativeObjective::TABLE_NAME, 'fk', ['plan_id']);
$this->addSql("CREATE TABLE {$objectives} (
id INT UNSIGNED AUTO_INCREMENT NOT NULL,
+10 -14
View File
@@ -2,23 +2,23 @@
declare(strict_types=1);
namespace MauticPlugin\PlanBundle\Migrations;
namespace MauticPlugin\ProgramBundle\Migrations;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\DBAL\Schema\Table;
use Doctrine\ORM\Tools\SchemaTool;
use Mautic\IntegrationsBundle\Migration\AbstractMigration;
use MauticPlugin\PlanBundle\Entity\Plan;
use MauticPlugin\PlanBundle\Entity\Task;
use MauticPlugin\ProgramBundle\Entity\Initiative;
use MauticPlugin\ProgramBundle\Entity\Task;
/**
* Adds the plan_tasks table and its foreign keys to installs created before 0.4.0.
* Adds the initiative_tasks table and its foreign keys to installs created before 0.4.0.
*
* The CREATE TABLE comes from the Task mapping, so it can't drift from the entity. Only that statement
* is kept: SchemaTool's output also contains statements for other tables (for example Symfony
* Messenger's messenger_messages), which would fail on an existing install.
*
* The foreign keys are added one by one when missing, so the migration also repairs a plan_tasks table
* The foreign keys are added one by one when missing, so the migration also repairs a initiative_tasks table
* that exists without them. Fresh installs get everything from the entity mapping, so this migration
* then finds nothing to do.
*/
@@ -31,22 +31,18 @@ class Version_0_4_0 extends AbstractMigration
* so only plan_id is repaired here.
*/
private const FOREIGN_KEYS = [
'plan_id' => [Plan::TABLE_NAME, 'CASCADE'],
'plan_id' => [Initiative::TABLE_NAME, 'CASCADE'],
];
protected function isApplicable(Schema $schema): bool
{
if (!$schema->hasTable($this->concatPrefix(Plan::TABLE_NAME))) {
// Historical migration: its changes were applied on every install that ran
// it before 0.16.0 (this plugin renamed Plan→Program/Initiative in 0.16.0), and
// a fresh install creates the current tables from the entity mapping. Never
// applicable anymore.
return false;
}
$tasks = $this->concatPrefix(Task::TABLE_NAME);
$table = $schema->hasTable($tasks) ? $schema->getTable($tasks) : null;
return null === $table || [] !== $this->getMissingForeignKeys($table);
}
protected function up(): void
{
$schema = $this->entityManager->getConnection()->createSchemaManager()->introspectSchema();
+8 -15
View File
@@ -2,15 +2,15 @@
declare(strict_types=1);
namespace MauticPlugin\PlanBundle\Migrations;
namespace MauticPlugin\ProgramBundle\Migrations;
use Doctrine\DBAL\Schema\Schema;
use Mautic\IntegrationsBundle\Migration\AbstractMigration;
use MauticPlugin\PlanBundle\Entity\Task;
use MauticPlugin\PlanBundle\Entity\TaskStatus;
use MauticPlugin\ProgramBundle\Entity\Task;
use MauticPlugin\ProgramBundle\Entity\TaskStatus;
/**
* Adds start_date, end_date and status (default "new", indexed) to plan_tasks, for installs created
* Adds start_date, end_date and status (default "new", indexed) to initiative_tasks, for installs created
* before 0.5.0. Existing tasks get the status "new". Each column is added only if missing.
*/
class Version_0_5_0 extends AbstractMigration
@@ -19,20 +19,13 @@ class Version_0_5_0 extends AbstractMigration
protected function isApplicable(Schema $schema): bool
{
$tasks = $this->concatPrefix(Task::TABLE_NAME);
if (!$schema->hasTable($tasks)) {
// Historical migration: its changes were applied on every install that ran
// it before 0.16.0 (this plugin renamed Plan→Program/Initiative in 0.16.0), and
// a fresh install creates the current tables from the entity mapping. Never
// applicable anymore.
return false;
}
$table = $schema->getTable($tasks);
return !$table->hasColumn('start_date')
|| !$table->hasColumn('end_date')
|| !$table->hasColumn('status')
|| !$table->hasIndex(self::STATUS_INDEX);
}
protected function up(): void
{
$tasks = $this->concatPrefix(Task::TABLE_NAME);
+16 -22
View File
@@ -2,17 +2,17 @@
declare(strict_types=1);
namespace MauticPlugin\PlanBundle\Migrations;
namespace MauticPlugin\ProgramBundle\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\PlanDescriptionItem;
use MauticPlugin\ProgramBundle\Entity\Initiative;
use MauticPlugin\ProgramBundle\Entity\InitiativeDescriptionItem;
/**
* For installs created before 0.6.0:
* - creates plan_description_items (and its foreign key to plans, ON DELETE CASCADE);
* - creates initiative_description_items (and its foreign key to plans, ON DELETE CASCADE);
* - drops plans.description, which description items replace. Its content is deleted, as decided
* when description items were introduced.
*
@@ -23,24 +23,18 @@ class Version_0_6_0 extends AbstractMigration
{
protected function isApplicable(Schema $schema): bool
{
$plans = $this->concatPrefix(Plan::TABLE_NAME);
if (!$schema->hasTable($plans)) {
// Historical migration: its changes were applied on every install that ran
// it before 0.16.0 (this plugin renamed Plan→Program/Initiative in 0.16.0), and
// a fresh install creates the current tables from the entity mapping. Never
// applicable anymore.
return false;
}
$items = $this->concatPrefix(PlanDescriptionItem::TABLE_NAME);
return !$schema->hasTable($items)
|| !$this->hasPlanForeignKey($schema)
|| $schema->getTable($plans)->hasColumn('description');
}
protected function up(): void
{
$schema = $this->entityManager->getConnection()->createSchemaManager()->introspectSchema();
$plans = $this->concatPrefix(Plan::TABLE_NAME);
$items = $this->concatPrefix(PlanDescriptionItem::TABLE_NAME);
$plans = $this->concatPrefix(Initiative::TABLE_NAME);
$items = $this->concatPrefix(InitiativeDescriptionItem::TABLE_NAME);
if (!$schema->hasTable($items)) {
$this->addSql($this->getCreateTableSql());
@@ -48,9 +42,9 @@ class Version_0_6_0 extends AbstractMigration
if (!$schema->hasTable($items) || !$this->hasPlanForeignKey($schema)) {
$this->addSql($this->generateAlterTableForeignKeyStatement(
PlanDescriptionItem::TABLE_NAME,
InitiativeDescriptionItem::TABLE_NAME,
['plan_id'],
Plan::TABLE_NAME,
Initiative::TABLE_NAME,
['id'],
'ON DELETE CASCADE'
));
@@ -63,7 +57,7 @@ class Version_0_6_0 extends AbstractMigration
private function hasPlanForeignKey(Schema $schema): bool
{
$items = $this->concatPrefix(PlanDescriptionItem::TABLE_NAME);
$items = $this->concatPrefix(InitiativeDescriptionItem::TABLE_NAME);
if (!$schema->hasTable($items)) {
return false;
@@ -81,14 +75,14 @@ class Version_0_6_0 extends AbstractMigration
private function getCreateTableSql(): string
{
$schemaTool = new SchemaTool($this->entityManager);
$prefix = 'CREATE TABLE '.$this->concatPrefix(PlanDescriptionItem::TABLE_NAME).' ';
$prefix = 'CREATE TABLE '.$this->concatPrefix(InitiativeDescriptionItem::TABLE_NAME).' ';
foreach ($schemaTool->getCreateSchemaSql([$this->entityManager->getClassMetadata(PlanDescriptionItem::class)]) as $sql) {
foreach ($schemaTool->getCreateSchemaSql([$this->entityManager->getClassMetadata(InitiativeDescriptionItem::class)]) as $sql) {
if (str_starts_with($sql, $prefix)) {
return $sql;
}
}
throw new \RuntimeException('SchemaTool returned no CREATE TABLE statement for '.PlanDescriptionItem::TABLE_NAME.'.');
throw new \RuntimeException('SchemaTool returned no CREATE TABLE statement for '.InitiativeDescriptionItem::TABLE_NAME.'.');
}
}
+15 -15
View File
@@ -2,16 +2,16 @@
declare(strict_types=1);
namespace MauticPlugin\PlanBundle\Migrations;
namespace MauticPlugin\ProgramBundle\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\PlanAllocationItem;
use MauticPlugin\ProgramBundle\Entity\Initiative;
use MauticPlugin\ProgramBundle\Entity\InitiativeAllocationItem;
/**
* Creates plan_allocation_items (and its foreign key to plans, ON DELETE CASCADE) for installs created
* Creates initiative_allocation_items (and its foreign key to plans, ON DELETE CASCADE) for installs created
* before 0.7.0. Each step runs only if needed. As in Version_0_4_0, only the CREATE TABLE statement for
* this table is kept from SchemaTool's output.
*/
@@ -19,17 +19,17 @@ class Version_0_7_0 extends AbstractMigration
{
protected function isApplicable(Schema $schema): bool
{
if (!$schema->hasTable($this->concatPrefix(Plan::TABLE_NAME))) {
// Historical migration: its changes were applied on every install that ran
// it before 0.16.0 (this plugin renamed Plan→Program/Initiative in 0.16.0), and
// a fresh install creates the current tables from the entity mapping. Never
// applicable anymore.
return false;
}
return !$schema->hasTable($this->concatPrefix(PlanAllocationItem::TABLE_NAME)) || !$this->hasPlanForeignKey($schema);
}
protected function up(): void
{
$schema = $this->entityManager->getConnection()->createSchemaManager()->introspectSchema();
$items = $this->concatPrefix(PlanAllocationItem::TABLE_NAME);
$items = $this->concatPrefix(InitiativeAllocationItem::TABLE_NAME);
if (!$schema->hasTable($items)) {
$this->addSql($this->getCreateTableSql());
@@ -37,9 +37,9 @@ class Version_0_7_0 extends AbstractMigration
if (!$this->hasPlanForeignKey($schema)) {
$this->addSql($this->generateAlterTableForeignKeyStatement(
PlanAllocationItem::TABLE_NAME,
InitiativeAllocationItem::TABLE_NAME,
['plan_id'],
Plan::TABLE_NAME,
Initiative::TABLE_NAME,
['id'],
'ON DELETE CASCADE'
));
@@ -48,7 +48,7 @@ class Version_0_7_0 extends AbstractMigration
private function hasPlanForeignKey(Schema $schema): bool
{
$items = $this->concatPrefix(PlanAllocationItem::TABLE_NAME);
$items = $this->concatPrefix(InitiativeAllocationItem::TABLE_NAME);
if (!$schema->hasTable($items)) {
return false;
@@ -66,14 +66,14 @@ class Version_0_7_0 extends AbstractMigration
private function getCreateTableSql(): string
{
$schemaTool = new SchemaTool($this->entityManager);
$prefix = 'CREATE TABLE '.$this->concatPrefix(PlanAllocationItem::TABLE_NAME).' ';
$prefix = 'CREATE TABLE '.$this->concatPrefix(InitiativeAllocationItem::TABLE_NAME).' ';
foreach ($schemaTool->getCreateSchemaSql([$this->entityManager->getClassMetadata(PlanAllocationItem::class)]) as $sql) {
foreach ($schemaTool->getCreateSchemaSql([$this->entityManager->getClassMetadata(InitiativeAllocationItem::class)]) as $sql) {
if (str_starts_with($sql, $prefix)) {
return $sql;
}
}
throw new \RuntimeException('SchemaTool returned no CREATE TABLE statement for '.PlanAllocationItem::TABLE_NAME.'.');
throw new \RuntimeException('SchemaTool returned no CREATE TABLE statement for '.InitiativeAllocationItem::TABLE_NAME.'.');
}
}
+12 -8
View File
@@ -2,17 +2,17 @@
declare(strict_types=1);
namespace MauticPlugin\PlanBundle\Migrations;
namespace MauticPlugin\ProgramBundle\Migrations;
use Doctrine\DBAL\Schema\Schema;
use Mautic\IntegrationsBundle\Migration\AbstractMigration;
use MauticPlugin\PlanBundle\Entity\Plan;
use MauticPlugin\PlanBundle\Entity\PlanAllocationItem;
use MauticPlugin\ProgramBundle\Entity\Initiative;
use MauticPlugin\ProgramBundle\Entity\InitiativeAllocationItem;
/**
* Since 0.8.0 every amount is in one general currency (Settings > Configuration > Plan Settings, parameter
* plan_currency), so the per-record currency columns are dropped: plans.currency,
* plan_allocation_items.planned_currency and plan_allocation_items.real_currency. Amounts are kept as they
* program_currency), so the per-record currency columns are dropped: plans.currency,
* initiative_allocation_items.planned_currency and initiative_allocation_items.real_currency. Amounts are kept as they
* are. Each column is dropped only if it exists.
*/
class Version_0_8_0 extends AbstractMigration
@@ -21,13 +21,17 @@ class Version_0_8_0 extends AbstractMigration
* Table => columns to drop.
*/
private const COLUMNS = [
Plan::TABLE_NAME => ['currency'],
PlanAllocationItem::TABLE_NAME => ['planned_currency', 'real_currency'],
Initiative::TABLE_NAME => ['currency'],
InitiativeAllocationItem::TABLE_NAME => ['planned_currency', 'real_currency'],
];
protected function isApplicable(Schema $schema): bool
{
return [] !== $this->getColumnsToDrop($schema);
// Historical migration: its changes were applied on every install that ran
// it before 0.16.0 (this plugin renamed Plan→Program/Initiative in 0.16.0), and
// a fresh install creates the current tables from the entity mapping. Never
// applicable anymore.
return false;
}
protected function up(): void
+7 -9
View File
@@ -2,15 +2,15 @@
declare(strict_types=1);
namespace MauticPlugin\PlanBundle\Migrations;
namespace MauticPlugin\ProgramBundle\Migrations;
use Doctrine\DBAL\Schema\Schema;
use Mautic\IntegrationsBundle\Migration\AbstractMigration;
use MauticPlugin\PlanBundle\Entity\Task;
use MauticPlugin\ProgramBundle\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
* Settings (parameter plan_task_types). Adds initiative_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.
*/
@@ -18,15 +18,13 @@ class Version_0_9_0 extends AbstractMigration
{
protected function isApplicable(Schema $schema): bool
{
$tasks = $this->concatPrefix(Task::TABLE_NAME);
if (!$schema->hasTable($tasks)) {
// Historical migration: its changes were applied on every install that ran
// it before 0.16.0 (this plugin renamed Plan→Program/Initiative in 0.16.0), and
// a fresh install creates the current tables from the entity mapping. Never
// applicable anymore.
return false;
}
return !$schema->getTable($tasks)->hasColumn('type');
}
protected function up(): void
{
$tasks = $this->concatPrefix(Task::TABLE_NAME);
+63
View File
@@ -0,0 +1,63 @@
<?php
declare(strict_types=1);
namespace MauticPlugin\ProgramBundle\Model;
use Mautic\CoreBundle\Model\FormModel;
use MauticPlugin\ProgramBundle\Entity\Audience;
use MauticPlugin\ProgramBundle\Entity\AudienceRepository;
use MauticPlugin\ProgramBundle\Form\Type\AudienceType;
use Symfony\Component\Form\FormFactoryInterface;
use Symfony\Component\Form\FormInterface;
use Symfony\Component\HttpKernel\Exception\MethodNotAllowedHttpException;
/**
* Available as mautic.program.model.audience, or getModel('program.audience').
*
* Audiences are a global directory (Programs > Audiences), independent of plans; plans link to
* them from their Audiences tab through InitiativeAudience (which carries the audience's priority in
* that initiative).
*/
class AudienceModel extends FormModel
{
public function getRepository(): AudienceRepository
{
$repository = $this->em->getRepository(Audience::class);
\assert($repository instanceof AudienceRepository);
return $repository;
}
public function getPermissionBase(): string
{
return 'program:audiences';
}
public function getEntity($id = null): ?Audience
{
if (null === $id) {
return new Audience();
}
$audience = parent::getEntity($id);
return $audience instanceof Audience ? $audience : null;
}
/**
* @param array<string, mixed> $options
*/
public function createForm($entity, FormFactoryInterface $formFactory, $action = null, $options = []): FormInterface
{
if (!$entity instanceof Audience) {
throw new MethodNotAllowedHttpException(['Audience']);
}
if (!empty($action)) {
$options['action'] = $action;
}
return $formFactory->create(AudienceType::class, $entity, $options);
}
}
+77
View File
@@ -0,0 +1,77 @@
<?php
declare(strict_types=1);
namespace MauticPlugin\ProgramBundle\Model;
use Mautic\CoreBundle\Model\FormModel;
use MauticPlugin\ProgramBundle\Entity\Initiative;
use MauticPlugin\ProgramBundle\Entity\InitiativeRepository;
use MauticPlugin\ProgramBundle\Form\Type\InitiativeType;
use Symfony\Component\Form\FormFactoryInterface;
use Symfony\Component\Form\FormInterface;
use Symfony\Component\HttpKernel\Exception\MethodNotAllowedHttpException;
/**
* @extends FormModel<Initiative>
*/
class InitiativeModel extends FormModel
{
public function getRepository(): InitiativeRepository
{
$repository = $this->em->getRepository(Initiative::class);
\assert($repository instanceof InitiativeRepository);
return $repository;
}
public function getPermissionBase(): string
{
return 'program:initiatives';
}
/**
* With no ID, returns a new initiative with the current user as owner.
*/
public function getEntity($id = null): ?Initiative
{
if (null === $id) {
$initiative = new Initiative();
$initiative->setOwner($this->userHelper->getUser(true));
return $initiative;
}
$initiative = parent::getEntity($id);
return $initiative instanceof Initiative ? $initiative : null;
}
/**
* Keeps objective and description item positions contiguous (0..n-1) before saving.
*/
public function saveEntity($entity, $unlock = true): void
{
if ($entity instanceof Initiative) {
$entity->normalizePositions();
}
parent::saveEntity($entity, $unlock);
}
/**
* @param array<string, mixed> $options
*/
public function createForm($entity, FormFactoryInterface $formFactory, $action = null, $options = []): FormInterface
{
if (!$entity instanceof Initiative) {
throw new MethodNotAllowedHttpException(['Initiative']);
}
if (!empty($action)) {
$options['action'] = $action;
}
return $formFactory->create(InitiativeType::class, $entity, $options);
}
}
-77
View File
@@ -1,77 +0,0 @@
<?php
declare(strict_types=1);
namespace MauticPlugin\PlanBundle\Model;
use Mautic\CoreBundle\Model\FormModel;
use MauticPlugin\PlanBundle\Entity\Plan;
use MauticPlugin\PlanBundle\Entity\PlanRepository;
use MauticPlugin\PlanBundle\Form\Type\PlanType;
use Symfony\Component\Form\FormFactoryInterface;
use Symfony\Component\Form\FormInterface;
use Symfony\Component\HttpKernel\Exception\MethodNotAllowedHttpException;
/**
* @extends FormModel<Plan>
*/
class PlanModel extends FormModel
{
public function getRepository(): PlanRepository
{
$repository = $this->em->getRepository(Plan::class);
\assert($repository instanceof PlanRepository);
return $repository;
}
public function getPermissionBase(): string
{
return 'plan:plans';
}
/**
* With no ID, returns a new plan with the current user as owner.
*/
public function getEntity($id = null): ?Plan
{
if (null === $id) {
$plan = new Plan();
$plan->setOwner($this->userHelper->getUser(true));
return $plan;
}
$plan = parent::getEntity($id);
return $plan instanceof Plan ? $plan : null;
}
/**
* Keeps objective and description item positions contiguous (0..n-1) before saving.
*/
public function saveEntity($entity, $unlock = true): void
{
if ($entity instanceof Plan) {
$entity->normalizePositions();
}
parent::saveEntity($entity, $unlock);
}
/**
* @param array<string, mixed> $options
*/
public function createForm($entity, FormFactoryInterface $formFactory, $action = null, $options = []): FormInterface
{
if (!$entity instanceof Plan) {
throw new MethodNotAllowedHttpException(['Plan']);
}
if (!empty($action)) {
$options['action'] = $action;
}
return $formFactory->create(PlanType::class, $entity, $options);
}
}
+8 -8
View File
@@ -2,24 +2,24 @@
declare(strict_types=1);
namespace MauticPlugin\PlanBundle\Model;
namespace MauticPlugin\ProgramBundle\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 MauticPlugin\ProgramBundle\Entity\Stakeholder;
use MauticPlugin\ProgramBundle\Entity\StakeholderRepository;
use MauticPlugin\ProgramBundle\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').
* Available as mautic.program.model.stakeholder, or getModel('program.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
* Configuration > Initiative Settings (parameter program_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
@@ -27,7 +27,7 @@ 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 PHONE_REGION_PARAMETER = 'program_stakeholder_phone_region';
public const DEFAULT_PHONE_REGION = 'FR';
@@ -41,7 +41,7 @@ class StakeholderModel extends FormModel
public function getPermissionBase(): string
{
return 'plan:stakeholders';
return 'program:stakeholders';
}
public function getEntity($id = null): ?Stakeholder
+10 -10
View File
@@ -2,19 +2,19 @@
declare(strict_types=1);
namespace MauticPlugin\PlanBundle\Model;
namespace MauticPlugin\ProgramBundle\Model;
use Mautic\CoreBundle\Model\FormModel;
use MauticPlugin\PlanBundle\Entity\Plan;
use MauticPlugin\PlanBundle\Entity\Task;
use MauticPlugin\PlanBundle\Entity\TaskRepository;
use MauticPlugin\PlanBundle\Form\Type\TaskType;
use MauticPlugin\ProgramBundle\Entity\Initiative;
use MauticPlugin\ProgramBundle\Entity\Task;
use MauticPlugin\ProgramBundle\Entity\TaskRepository;
use MauticPlugin\ProgramBundle\Form\Type\TaskType;
use Symfony\Component\Form\FormFactoryInterface;
use Symfony\Component\Form\FormInterface;
use Symfony\Component\HttpKernel\Exception\MethodNotAllowedHttpException;
/**
* Available as mautic.plan.model.task, or getModel('plan.task').
* Available as mautic.program.model.task, or getModel('program.task').
*
* @extends FormModel<Task>
*/
@@ -30,7 +30,7 @@ class TaskModel extends FormModel
public function getPermissionBase(): string
{
return 'plan:tasks';
return 'program:tasks';
}
public function getEntity($id = null): ?Task
@@ -45,16 +45,16 @@ class TaskModel extends FormModel
}
/**
* The plan's tasks as rows for the plan's Tasks tab: the tasks ordered by name, each with its
* The plan's tasks as rows for the initiative's Tasks tab: the tasks ordered by name, each with its
* dependencies and RACI rows loaded. The former parent/child tree is gone; the tab lists the
* tasks flat, and the dependencies are shown per task.
*
* @return array<int, array{task: Task, depth: int}>
*/
public function getTaskTree(Plan $plan): array
public function getTaskTree(Initiative $initiative): array
{
$rows = [];
foreach ($this->getRepository()->findByPlan($plan) as $task) {
foreach ($this->getRepository()->findByInitiative($initiative) as $task) {
$rows[] = ['task' => $task, 'depth' => 0];
}
+2 -2
View File
@@ -2,10 +2,10 @@
declare(strict_types=1);
namespace MauticPlugin\PlanBundle;
namespace MauticPlugin\ProgramBundle;
use Mautic\IntegrationsBundle\Bundle\AbstractPluginBundle;
class PlanBundle extends AbstractPluginBundle
class ProgramBundle extends AbstractPluginBundle
{
}
+164
View File
@@ -0,0 +1,164 @@
{% extends '@MauticCore/Default/content.html.twig' %}
{% block mauticContent %}programAudience{% endblock %}
{% block preHeader %}
<div class="pull-right">
{{ include('@MauticCore/Helper/page_actions.html.twig', {
'item': item,
'templateButtons': {
'edit': securityHasEntityAccess(permissions['program:audiences:editown'], permissions['program:audiences:editother'], item.createdBy),
'delete': securityHasEntityAccess(permissions['program:audiences:deleteown'], permissions['program:audiences:deleteother'], item.createdBy),
},
'actionRoute': 'initiative_audience_action',
'indexRoute': 'initiative_audience_index',
'langVar': 'initiative.audience',
}) }}
</div>
{% endblock %}
{% block headerTitle %}{{ item.name }}{% endblock %}
{% block publishStatus %}
<div class="col-xs-0 col-sm-3 text-right pr-0">
<span class="label {{ item.isPublished ? 'label-success' : 'label-gray' }}">
{{ (item.isPublished ? 'mautic.program.audience.active' : 'mautic.program.audience.inactive')|trans }}
</span>
</div>
{% endblock %}
{% block content %}
<div class="pa-md">
<table class="table table-hover mb-md initiative-audience-details">
<tbody>
<tr>
<td class="col-md-3 text-muted" style="width: 30%;">{{ 'mautic.program.audience.field.type'|trans }}</td>
<td>
<i class="{{ item.audienceType.icon }} initiative-item-type-icon" style="font-size: 24px;" aria-hidden="true"></i>
{{ item.audienceType.labelKey|trans }}
</td>
</tr>
{% if item.segments is not empty %}
<tr>
<td class="text-muted">{{ 'mautic.program.audience.field.segments'|trans }}</td>
<td>
{% for segment in item.segments %}
<span class="label label-info">{{ segment.name }} ({{ program_audience_segment_count(segment.id) }})</span>{% if not loop.last %} {% endif %}
{% endfor %}
</td>
</tr>
{% endif %}
{% if item.tagline %}
<tr>
<td class="text-muted">{{ 'mautic.program.audience.field.tagline'|trans }}</td>
<td>{{ item.tagline|program_linkify }}</td>
</tr>
{% endif %}
{% if item.profileCriteria %}
<tr>
<td class="text-muted">{{ 'mautic.program.audience.field.profile_criteria'|trans }}</td>
<td style="white-space: pre-wrap;">{{ item.profileCriteria|program_linkify }}</td>
</tr>
{% endif %}
{% if item.motivations %}
<tr>
<td class="text-muted">{{ 'mautic.program.audience.field.motivations'|trans }}</td>
<td style="white-space: pre-wrap;">{{ item.motivations|program_linkify }}</td>
</tr>
{% endif %}
{% if item.barriers %}
<tr>
<td class="text-muted">{{ 'mautic.program.audience.field.barriers'|trans }}</td>
<td style="white-space: pre-wrap;">{{ item.barriers|program_linkify }}</td>
</tr>
{% endif %}
{% if item.frustrations %}
<tr>
<td class="text-muted">{{ 'mautic.program.audience.field.frustrations'|trans }}</td>
<td style="white-space: pre-wrap;">{{ item.frustrations|program_linkify }}</td>
</tr>
{% endif %}
{% if item.triggers %}
<tr>
<td class="text-muted">{{ 'mautic.program.audience.field.triggers'|trans }}</td>
<td style="white-space: pre-wrap;">{{ item.triggers|program_linkify }}</td>
</tr>
{% endif %}
{% if item.decisionRole %}
<tr>
<td class="text-muted">{{ 'mautic.program.audience.field.decision_role'|trans }}</td>
<td>{{ program_audience_decision_role_label(item.decisionRole) ?? item.decisionRole }}</td>
</tr>
{% endif %}
{% if item.preferredTones is not empty %}
<tr>
<td class="text-muted">{{ 'mautic.program.audience.field.preferred_tones'|trans }}</td>
<td>
{% for tone in item.preferredTones %}
<span class="label label-default">{{ program_audience_tone_label(tone) ?? tone }}</span>
{% endfor %}
</td>
</tr>
{% endif %}
{% if item.preferredChannels is not empty %}
<tr>
<td class="text-muted">{{ 'mautic.program.audience.field.preferred_channels'|trans }}</td>
<td>
{% for channel in item.preferredChannels %}
<span class="label label-default">{{ program_audience_channel_label(channel)|trans }}</span>
{% endfor %}
</td>
</tr>
{% endif %}
{% if item.stages is not empty %}
<tr>
<td class="text-muted">{{ 'mautic.program.audience.field.stages'|trans }}</td>
<td>{{ item.stages|map(stage => stage.name)|join(', ') }}</td>
</tr>
{% endif %}
{% if item.estimatedSize %}
<tr>
<td class="text-muted">{{ 'mautic.program.audience.field.estimated_size'|trans }}</td>
<td>{{ item.estimatedSize }}</td>
</tr>
{% endif %}
<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.program.audience.field.plans'|trans }}</h4>
{% if item.initiativeLinks is empty %}
<p class="text-muted">{{ 'mautic.program.audience.no_plans'|trans }}</p>
{% else %}
<div class="table-responsive">
<table class="table table-hover initiative-audience-initiatives-view">
<thead>
<tr>
<th>{{ 'mautic.program.field.name'|trans }}</th>
<th>{{ 'mautic.program.audience.field.priority'|trans }}</th>
<th>{{ 'mautic.program.audience.field.value_proposition'|trans }}</th>
<th>{{ 'mautic.program.field.status'|trans }}</th>
</tr>
</thead>
<tbody>
{% for link in item.initiativeLinks %}
<tr>
<td><a href="{{ path('initiative_action', {'objectAction': 'view', 'objectId': link.initiative.id}) }}" data-toggle="ajax">{{ link.initiative.name }}</a></td>
<td><span class="label {{ link.priority.labelClass }}">{{ link.priority.labelKey|trans }}</span></td>
<td class="text-muted">{{ link.valueProposition|default('—') }}</td>
<td><span class="label {{ link.initiative.status.labelClass }}">{{ link.initiative.status.labelKey|trans }}</span></td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
{% endif %}
</div>
{% endblock %}
+53
View File
@@ -0,0 +1,53 @@
{% extends '@MauticCore/Default/content.html.twig' %}
{% block mauticContent %}programAudience{% endblock %}
{% block headerTitle %}
{% if entity.id %}
{{ 'mautic.program.audience.header.edit'|trans({'%name%': entity.name}) }}
{% else %}
{{ 'mautic.program.audience.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, fixed per type; programAudienceOnLoad updates it
when the dropdown changes. A new form defaults to Persona. #}
<div class="col-xs-1 text-center pt-lg">
<i class="{{ (entity.audienceType ?? constant('MauticPlugin\\ProgramBundle\\Entity\\AudienceType::Persona'))|program_audience_type_icon }} initiative-item-type-icon" style="font-size: 28px;" aria-hidden="true"></i>
</div>
<div class="col-xs-11">
{{ form_row(form.audienceType) }}
<p class="text-muted small">{{ 'mautic.program.audience.type.fixed_note'|trans }}</p>
</div>
</div>
{{ form_row(form.segments) }}
<p class="text-muted small">{{ 'mautic.program.audience.segments.note'|trans }}</p>
{% if form.tagline is defined %}{{ form_row(form.tagline) }}{% endif %}
{% if form.profileCriteria is defined %}{{ form_row(form.profileCriteria) }}{% endif %}
{% if form.motivations is defined %}{{ form_row(form.motivations) }}{% endif %}
{% if form.barriers is defined %}{{ form_row(form.barriers) }}{% endif %}
{% if form.frustrations is defined %}{{ form_row(form.frustrations) }}{% endif %}
{% if form.triggers is defined %}{{ form_row(form.triggers) }}{% endif %}
{% if form.decisionRole is defined %}{{ form_row(form.decisionRole) }}{% endif %}
{% if form.preferredTones is defined %}{{ form_row(form.preferredTones) }}{% endif %}
{% if form.preferredChannels is defined %}{{ form_row(form.preferredChannels) }}{% endif %}
{% if form.stages is defined %}{{ form_row(form.stages) }}{% endif %}
{% if form.estimatedSize is defined %}{{ form_row(form.estimatedSize) }}{% endif %}
</div>
</div>
<div class="col-md-3 height-auto">
<div class="pr-lg pl-lg pt-md pb-md">
{{ form_row(form.isPublished) }}
<p class="text-muted small">{{ 'mautic.program.audience.active.help'|trans }}</p>
</div>
</div>
</div>
{{ form_end(form) }}
{% endblock %}
+165
View File
@@ -0,0 +1,165 @@
{% set isIndex = 'index' == tmpl ? true : false %}
{% set tmpl = 'list' %}
{% extends isIndex ? '@MauticCore/Default/content.html.twig' : '@MauticCore/Default/raw_output.html.twig' %}
{% block mauticContent %}programAudience{% endblock %}
{% block headerTitle %}{{ 'mautic.program.audience.header.index'|trans }}{% endblock %}
{% block content %}
{% set segmentCounts = program_audience_segment_counts(items) %}
<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['program:audiences:create'],
},
'langVar': 'initiative.audience',
},
'bulk_actions': {
'langVar': 'initiative.audience',
'templateButtons': {
'delete': permissions['program:audiences:deleteown'] or permissions['program:audiences:deleteother'],
},
},
}) -}}
<div class="page-list">
{% if items is defined and items is not empty %}
<div class="table-responsive">
<table class="table table-hover" id="programAudienceTable">
<thead>
<tr>
{{ include('@MauticCore/Helper/tableheader.html.twig', {
'checkall': 'true',
'target': '#programAudienceTable',
}) }}
{# Columns: ID, Pictogram, Type, Name (+ tagline), Segments (with contact
counts), Estimated size, Active, Assigned initiatives. #}
{{ include('@MauticCore/Helper/tableheader.html.twig', {
'sessionVar': 'initiative.audience',
'orderBy': 't.id',
'text': 'mautic.core.id',
'class': 'col-initiative-audience-id',
}) }}
{{ include('@MauticCore/Helper/tableheader.html.twig', {
'sessionVar': 'initiative.audience',
'text': 'mautic.program.audience.field.pictogram',
'class': 'col-initiative-audience-pictogram',
}) }}
{{ include('@MauticCore/Helper/tableheader.html.twig', {
'sessionVar': 'initiative.audience',
'orderBy': 't.audienceType',
'text': 'mautic.program.audience.field.type',
'class': 'col-initiative-audience-type',
}) }}
{{ include('@MauticCore/Helper/tableheader.html.twig', {
'sessionVar': 'initiative.audience',
'orderBy': 't.name',
'text': 'mautic.program.audience.field.name',
'class': 'col-initiative-audience-name',
'default': true,
}) }}
{{ include('@MauticCore/Helper/tableheader.html.twig', {
'sessionVar': 'initiative.audience',
'text': 'mautic.program.audience.field.segments',
'class': 'visible-md visible-lg col-initiative-audience-segments',
}) }}
{{ include('@MauticCore/Helper/tableheader.html.twig', {
'sessionVar': 'initiative.audience',
'text': 'mautic.program.audience.field.estimated_size',
'class': 'visible-md visible-lg col-initiative-audience-size',
}) }}
{{ include('@MauticCore/Helper/tableheader.html.twig', {
'sessionVar': 'initiative.audience',
'orderBy': 't.isPublished',
'text': 'mautic.program.audience.field.active',
'class': 'col-initiative-audience-active',
}) }}
{{ include('@MauticCore/Helper/tableheader.html.twig', {
'sessionVar': 'initiative.audience',
'text': 'mautic.program.audience.field.plans',
'class': 'visible-md visible-lg col-initiative-audience-initiatives',
}) }}
</tr>
</thead>
<tbody>
{% for item in items %}
{% set canEdit = securityHasEntityAccess(permissions['program:audiences:editown'], permissions['program:audiences:editother'], item.createdBy) %}
<tr>
<td>
{{- include('@MauticCore/Helper/list_actions.html.twig', {
'item': item,
'templateButtons': {
'edit': canEdit,
'delete': securityHasEntityAccess(permissions['program:audiences:deleteown'], permissions['program:audiences:deleteother'], item.createdBy),
},
'langVar': 'initiative.audience',
}) -}}
</td>
<td>{{ item.id }}</td>
<td class="text-center">
<i class="{{ item.audienceType.icon }} initiative-item-type-icon" style="font-size: 24px;" aria-hidden="true"></i>
</td>
<td>{{ item.audienceType.labelKey|trans }}</td>
<td>
{% if canEdit %}
<a href="{{ path('initiative_audience_action', {'objectAction': 'edit', 'objectId': item.id}) }}" data-toggle="ajax">{% if item.tagline %}{{ item.name }} <span class="text-muted small font-lato">— {{ item.tagline }}</span>{% else %}{{ item.name }}{% endif %}</a>
{% else %}
{{ item.name }}{% if item.tagline %} <span class="text-muted small font-lato">— {{ item.tagline }}</span>{% endif %}
{% endif %}
</td>
<td class="visible-md visible-lg">
{# The segments this audience maps to, purely informational: names with
their contact counts next to them. May be none. #}
{% set counts = segmentCounts[item.id] ?? [] %}
{% for segment in item.segments %}
<span class="label label-info">{{ segment.name }} ({{ counts[segment.id] ?? 0 }})</span>{% if not loop.last %} {% endif %}
{% else %}
<span class="text-muted">—</span>
{% endfor %}
</td>
<td class="visible-md visible-lg text-right text-nowrap">{{ item.estimatedSize }}</td>
<td>
<span class="label {{ item.isPublished ? 'label-success' : 'label-gray' }}">
{{ (item.isPublished ? 'mautic.program.audience.active' : 'mautic.program.audience.inactive')|trans }}
</span>
</td>
<td class="visible-md visible-lg">
{# The initiatives this audience is assigned to, through their Audiences tab. #}
{% set links = item.initiativeLinks|default([]) %}
{% for link in links %}
<a href="{{ path('initiative_action', {'objectAction': 'view', 'objectId': link.initiative.id}) }}" data-toggle="ajax">{{ link.initiative.name }}</a>{% if link.valueProposition %} <span class="text-muted small">({{ link.valueProposition }})</span>{% endif %}{% if not loop.last %}, {% endif %}
{% else %}
<span class="text-muted">{{ 'mautic.program.audience.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('initiative_audience_index'),
'sessionVar': 'initiative.audience',
}) -}}
</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.program.audience.onboarding.heading',
'subheading': 'mautic.program.audience.onboarding.subheading',
'copy': 'mautic.program.audience.onboarding.copy',
}) }}
</div>
{% endif %}
</div>
</div>
{% endblock %}
@@ -1,110 +0,0 @@
{#
# 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) %}
<div class="panel panel-default plan-config-type">
<div class="panel-body">
{{ form_widget(type.children.key) }}
{{ form_errors(type) }}
{% if type.children.icon is defined %}
{% set icon = type.children.icon.vars.value %}
<div class="row mb-sm">
<div class="col-xs-1 text-center pt-lg">
<i class="plan-type-icon-preview {{ icon }}" style="font-size: 28px;" aria-hidden="true"></i>
</div>
<div class="col-xs-5">{{ form_row(type.children.icon) }}</div>
</div>
{% endif %}
<table class="table table-condensed mb-0">
<thead>
<tr>
<th class="col-xs-2">{{ 'mautic.plan.config.type.language'|trans }}</th>
<th class="col-xs-4">{{ 'mautic.plan.config.type.name'|trans }}</th>
<th class="col-xs-6">{{ 'mautic.plan.config.type.description'|trans }}</th>
</tr>
</thead>
<tbody>
{% for locale, name in type.children.names.children %}
<tr>
<td class="text-muted" title="{{ name.vars.attr['data-locale'] }}">
{{ name.vars.attr['data-language'] }}
{% if name.vars.required %}<span class="required">*</span>{% endif %}
</td>
<td>
{{ form_widget(name) }}
{{ form_errors(name) }}
</td>
<td>
{{ form_widget(type.children.descriptions.children[locale]) }}
{{ form_errors(type.children.descriptions.children[locale]) }}
</td>
</tr>
{% endfor %}
</tbody>
</table>
<div class="text-right mt-xs">
<button type="button" class="btn btn-ghost btn-sm plan-config-type-remove">
<i class="ri-delete-bin-line"></i> {{ 'mautic.plan.config.type.remove'|trans }}
</button>
</div>
</div>
</div>
{% endmacro %}
{# One editable list of types (one per kind of plan item). #}
{% macro type_section(types, titleKey, helpKey) %}
{% import _self as plan %}
<h4 class="fw-sb mt-lg mb-xs">{{ titleKey|trans }}</h4>
<p class="text-muted small">{{ helpKey|trans }}</p>
{{ form_errors(types) }}
<div class="plan-config-types" data-prototype="{{ plan.type_row(types.vars.prototype)|e('html_attr') }}">
<p class="text-muted plan-config-types-empty{% if types|length > 0 %} hide{% endif %}">
{{ 'mautic.plan.config.types.empty'|trans }}
</p>
<div class="plan-config-types-list">
{% for type in types %}
{{ plan.type_row(type) }}
{% endfor %}
</div>
<button type="button" class="btn btn-ghost plan-config-type-add">
<i class="ri-add-line"></i> {{ 'mautic.plan.config.type.add'|trans }}
</button>
</div>
{% do types.setRendered %}
{% endmacro %}
{% block _config_planconfig_widget %}
{% import _self as plan %}
<div class="text-muted small pb-md">{{ 'mautic.plan.config.description'|trans }}</div>
<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>
{{ plan.type_section(form.children.plan_description_item_types,
'mautic.plan.config.section.description_item_types',
'mautic.plan.config.section.description_item_types.help') }}
{{ 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,128 @@
{#
# Settings > Configuration > Program Settings: the general currency, then one section per kind of initiative
# item (insights, allocation, objectives, tasks), each with a pictogram. Adding and removing
# types, and the pictogram preview, are handled by Assets/js/program.js (delegated handlers on
# .program-config-types).
#}
{% macro type_row(type) %}
<div class="panel panel-default program-config-type">
<div class="panel-body">
{{ form_widget(type.children.key) }}
{{ form_errors(type) }}
{% if type.children.icon is defined %}
{% set icon = type.children.icon.vars.value %}
<div class="row mb-sm">
<div class="col-xs-1 text-center pt-lg">
<i class="initiative-type-icon-preview {{ icon }}" style="font-size: 28px;" aria-hidden="true"></i>
</div>
<div class="col-xs-5">{{ form_row(type.children.icon) }}</div>
</div>
{% endif %}
<table class="table table-condensed mb-0">
<thead>
<tr>
<th class="col-xs-2">{{ 'mautic.program.config.type.language'|trans }}</th>
<th class="col-xs-4">{{ 'mautic.program.config.type.name'|trans }}</th>
<th class="col-xs-6">{{ 'mautic.program.config.type.description'|trans }}</th>
</tr>
</thead>
<tbody>
{% for locale, name in type.children.names.children %}
<tr>
<td class="text-muted" title="{{ name.vars.attr['data-locale'] }}">
{{ name.vars.attr['data-language'] }}
{% if name.vars.required %}<span class="required">*</span>{% endif %}
</td>
<td>
{{ form_widget(name) }}
{{ form_errors(name) }}
</td>
<td>
{{ form_widget(type.children.descriptions.children[locale]) }}
{{ form_errors(type.children.descriptions.children[locale]) }}
</td>
</tr>
{% endfor %}
</tbody>
</table>
<div class="text-right mt-xs">
<button type="button" class="btn btn-ghost btn-sm program-config-type-remove">
<i class="ri-delete-bin-line"></i> {{ 'mautic.program.config.type.remove'|trans }}
</button>
</div>
</div>
</div>
{% endmacro %}
{# One editable list of types (one per kind of initiative item). #}
{% macro type_section(types, titleKey, helpKey) %}
{% import _self as cfg %}
<h4 class="fw-sb mt-lg mb-xs">{{ titleKey|trans }}</h4>
<p class="text-muted small">{{ helpKey|trans }}</p>
{{ form_errors(types) }}
<div class="program-config-types" data-prototype="{{ cfg.type_row(types.vars.prototype)|e('html_attr') }}">
<p class="text-muted program-config-types-empty{% if types|length > 0 %} hide{% endif %}">
{{ 'mautic.program.config.types.empty'|trans }}
</p>
<div class="program-config-types-list">
{% for type in types %}
{{ cfg.type_row(type) }}
{% endfor %}
</div>
<button type="button" class="btn btn-ghost program-config-type-add">
<i class="ri-add-line"></i> {{ 'mautic.program.config.type.add'|trans }}
</button>
</div>
{% do types.setRendered %}
{% endmacro %}
{% block _config_programconfig_widget %}
{% import _self as cfg %}
<div class="text-muted small pb-md">{{ 'mautic.program.config.description'|trans }}</div>
<h4 class="fw-sb mb-xs">{{ 'mautic.program.config.section.general'|trans }}</h4>
<div class="row">
<div class="col-md-6">{{ form_row(form.children.program_currency) }}</div>
<div class="col-md-6">{{ form_row(form.children.program_stakeholder_phone_region) }}</div>
</div>
<p class="text-muted small">{{ 'mautic.program.config.currency.help'|trans }}</p>
{{ cfg.type_section(form.children.program_description_item_types,
'mautic.program.config.section.description_item_types',
'mautic.program.config.section.description_item_types.help') }}
{{ cfg.type_section(form.children.program_allocation_item_types,
'mautic.program.config.section.allocation_item_types',
'mautic.program.config.section.allocation_item_types.help') }}
{{ cfg.type_section(form.children.program_objective_types,
'mautic.program.config.section.objective_types',
'mautic.program.config.section.objective_types.help') }}
{{ cfg.type_section(form.children.program_task_types,
'mautic.program.config.section.task_types',
'mautic.program.config.section.task_types.help') }}
{{ cfg.type_section(form.children.program_stakeholder_types,
'mautic.program.config.section.stakeholder_types',
'mautic.program.config.section.stakeholder_types.help') }}
<h4 class="fw-sb mt-lg mb-xs">{{ 'mautic.program.config.section.audience_values'|trans }}</h4>
<p class="text-muted small">{{ 'mautic.program.config.section.audience_values.help'|trans }}</p>
{{ cfg.type_section(form.children.program_audience_decision_roles,
'mautic.program.config.section.audience_decision_roles',
'mautic.program.config.section.audience_decision_roles.help') }}
{{ cfg.type_section(form.children.program_audience_tones,
'mautic.program.config.section.audience_tones',
'mautic.program.config.section.audience_tones.help') }}
<h4 class="fw-sb mt-lg mb-xs">{{ 'mautic.program.config.section.audience_attributes'|trans }}</h4>
<p class="text-muted small">{{ 'mautic.program.config.section.audience_attributes.help'|trans }}</p>
<div class="program-config-audience-attributes">
{% for attribute in program_audience_attributes() %}
{{ form_row(form.children[program_audience_attribute_toggle(attribute)]) }}
{% endfor %}
</div>
{% endblock %}
@@ -4,21 +4,21 @@
# 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)
# text: the text to show (may contain line breaks; URLs in it become links, see program_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"
<div class="initiative-read-more" id="{{ id }}">
<div class="initiative-read-more-text" style="display: -webkit-box; -webkit-line-clamp: {{ lines }}; -webkit-box-orient: vertical; overflow: hidden; white-space: pre-wrap;">{{ text|program_linkify }}</div>
<button type="button" class="btn btn-link btn-xs p-0 initiative-read-more-toggle"
data-target="{{ id }}"
data-more-text="{{ 'mautic.plan.read_more.more'|trans }}"
data-less-text="{{ 'mautic.plan.read_more.less'|trans }}"
data-more-text="{{ 'mautic.program.read_more.more'|trans }}"
data-less-text="{{ 'mautic.program.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>
{{ 'mautic.program.read_more.more'|trans }} <i class="ri-arrow-down-s-line"></i>
</button>
</div>
{% endif %}
@@ -0,0 +1,11 @@
{#
# The filter box of an initiative tab table (Description, Objectives, Allocation, Tasks) and the switch that
# shows the "no match" message. Filtering and sorting are handled by Assets/js/program.js
# (Mautic.programInitTabTable), on any table with the data-initiative-tab-table attribute.
#}
<div class="initiative-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 initiative-tab-table-filter-input"
placeholder="{{ 'mautic.program.filter.placeholder'|trans }}" aria-label="{{ 'mautic.program.filter.placeholder'|trans }}">
</div>
<p class="text-muted initiative-tab-table-nomatch hide">{{ 'mautic.program.filter.no_match'|trans }}</p>
@@ -0,0 +1,32 @@
{#
# Tab bar shared by the initiative form and the initiative detail page.
#
# Parameters:
# initiativeId: the initiative's id (null for a new initiative)
# counts (optional): tab id => number shown next to the tab name
#
# The tab panes use the ids initiative-tab-<id>. Assets/js/program.js reopens the tab last used for this plan
# (so Edit, Save and Cancel keep the same tab), and on the form marks the tabs whose pane contains a
# validation error and opens the first of them.
#}
{% set initiativeTabs = {
'details': 'mautic.program.tab.details',
'description': 'mautic.program.tab.description',
'objectives': 'mautic.program.tab.objectives',
'allocation': 'mautic.program.tab.allocations',
'audiences': 'mautic.program.tab.audiences',
'stakeholders': 'mautic.program.tab.stakeholders',
'tasks': 'mautic.program.tab.tasks',
} %}
<ul class="nav nav-tabs nav-tabs-contained tabs-horizontal initiative-tabs" role="tablist" data-initiative-id="{{ initiativeId|default('') }}">
{% for id, label in initiativeTabs %}
<li class="{{ loop.first ? 'active' : '' }}" data-tab-id="initiative-tab-{{ id }}">
<a href="#initiative-tab-{{ id }}" role="tab" data-toggle="tab">
<span>{{ label|trans }}</span>
{% if counts is defined and counts[id] is defined %}
<span class="badge">{{ counts[id] }}</span>
{% endif %}
</a>
</li>
{% endfor %}
</ul>
@@ -0,0 +1,93 @@
{#
# The initiative's tasks, for the Tasks tab of the initiative 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:
# initiative: the Initiative
# taskTree: rows from TaskModel::getTaskTree(): {task, depth}, in display order
# readOnly: true on the initiative form: no links, no filter, so that following one can't drop unsaved changes
# taskPermissions: program:tasks:* permissions (create, editown, editother), when not read-only
#
# Links carry returnTo=initiative, so that Save and Cancel on the task form come back to this initiative page
# (see TaskController). Opened from Programs > Tasks, the task form goes back to the task list.
#}
{% set readOnly = readOnly|default(false) %}
{% set taskPermissions = taskPermissions|default({}) %}
{% set canCreate = not readOnly and initiative.id and taskPermissions['program:tasks:create']|default(false) %}
{% if canCreate %}
<div class="mb-md">
<a class="btn btn-ghost initiative-task-add" href="{{ path('initiative_task_action', {'objectAction': 'new', 'initiative': initiative.id, 'returnTo': 'initiative'}) }}" data-toggle="ajax">
<i class="ri-add-line"></i> {{ 'mautic.program.task.add'|trans }}
</a>
</div>
{% endif %}
{% if not initiative.id %}
<p class="text-muted">{{ 'mautic.program.task.save_initiative_first'|trans }}</p>
{% elseif taskTree is empty %}
<p class="text-muted">{{ 'mautic.program.task.empty'|trans }}</p>
{% else %}
{% if not readOnly %}
{# Filter + click-to-sort on the detail page (program.js). The form's read-only copy stays plain. #}
{{ include('@Program/Initiative/_tab_table_filter.html.twig') }}
{% endif %}
<div class="table-responsive">
<table class="table table-hover initiative-tab-table initiative-task-table{% if not readOnly %}" data-initiative-tab-table data-empty-text="{{ 'mautic.program.filter.no_match'|trans }}" data-sort-hint="{{ 'mautic.program.filter.sort_hint'|trans }}{% endif %}">
<thead>
<tr>
<th class="initiative-col-pictogram" aria-label="{{ 'mautic.program.task.field.pictogram'|trans }}"></th>
<th class="initiative-col-type">{{ 'mautic.program.task.field.type'|trans }}</th>
<th class="initiative-col-name">{{ 'mautic.program.task.field.name'|trans }}</th>
<th class="initiative-col-description">{{ 'mautic.program.task.field.description'|trans }}</th>
<th class="initiative-col-date">{{ 'mautic.program.task.field.start_date'|trans }}</th>
<th class="initiative-col-date">{{ 'mautic.program.task.field.end_date'|trans }}</th>
<th class="initiative-col-status">{{ 'mautic.program.task.field.status'|trans }}</th>
</tr>
</thead>
<tbody>
{% for row in taskTree %}
{% set task = row.task %}
{% set canEdit = not readOnly and securityHasEntityAccess(taskPermissions['program:tasks:editown']|default(false), taskPermissions['program:tasks:editother']|default(false), task.createdBy) %}
<tr class="initiative-task" data-task-id="{{ task.id }}">
<td class="initiative-col-pictogram text-center">
{% set taskTypeIcon = program_item_type_icon('task', task.type) %}
{% if taskTypeIcon %}<i class="{{ taskTypeIcon }} initiative-item-type-icon" style="font-size: 24px;" aria-hidden="true"></i>{% endif %}
</td>
<td class="initiative-col-type"{% if program_item_type_description('task', task.type) %} title="{{ program_item_type_description('task', task.type) }}" data-toggle="tooltip"{% endif %}>
{{ program_item_type_name('task', task.type) ?? 'mautic.program.description_item.type.unknown'|trans({'%key%': task.type}) }}
</td>
<td class="initiative-col-name">
{% if canEdit %}
<a href="{{ path('initiative_task_action', {'objectAction': 'edit', 'objectId': task.id, 'returnTo': 'initiative'}) }}" data-toggle="ajax">{{ task.name }}</a>
{% else %}
{{ task.name }}
{% endif %}
{% if task.taskKind == constant('MauticPlugin\\ProgramBundle\\Entity\\TaskKind::Milestone') %}
<span class="label label-success" title="{{ 'mautic.program.task.kind.milestone'|trans }}">{{ 'mautic.program.task.kind.milestone_short'|trans }}</span>
{% elseif task.taskKind == constant('MauticPlugin\\ProgramBundle\\Entity\\TaskKind::Phase') %}
<span class="label label-primary" title="{{ 'mautic.program.task.kind.phase'|trans }}">{{ 'mautic.program.task.kind.phase_short'|trans }}</span>
{% endif %}
</td>
<td class="initiative-col-description text-muted">
{# Same 10-line clamp and read-more as the Description tab; URLs become links. #}
{{ include('@Program/Initiative/_description_read_more.html.twig', {
'text': task.description|default('')|striptags,
'id': 'initiative-task-desc-' ~ task.id,
}) }}
</td>
<td class="initiative-col-date">{{ task.startDate ? task.startDate|date('Y-m-d') : '' }}</td>
<td class="initiative-col-date">{{ task.endDate ? task.endDate|date('Y-m-d') : '' }}</td>
<td class="initiative-col-status">
{# A phase has no status of its own — skip the column value. #}
{% if task.taskKind != constant('MauticPlugin\\ProgramBundle\\Entity\\TaskKind::Phase') %}
<span class="label {{ task.status.labelClass }}">{{ task.status.labelKey|trans }}</span>
{% endif %}
</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
{% endif %}
@@ -0,0 +1,449 @@
{% extends '@MauticCore/Default/content.html.twig' %}
{% block mauticContent %}program{% endblock %}
{#
# No routeBase on the page_actions includes: core would turn it into mautic_program_* route names.
# The buttons use actionRoute (initiative_action) from the controller, and the close button gets its URL here.
#}
{% block preHeader %}
{{- include('@MauticCore/Helper/page_actions.html.twig', {
'item': item,
'templateButtons': {
'close': true,
},
'closeUrl': path('initiative_index'),
'targetLabel': 'mautic.program.header.index'|trans,
}) -}}
{# Core's helper renders an empty pill when there is no category. #}
{% if item.category %}
{{ include('@MauticCore/Modules/category--inline.html.twig', {'category': item.category}) }}
{% endif %}
{% endblock %}
{% block headerTitle %}{{ item.name }}{% endblock %}
{#
# Under the title, as on an email's page: the plan status, then the total planned and real costs of the
# allocation items, in the general currency. A real total above the planned total is red, otherwise green.
#}
{% block publishStatus %}
{% set statusColors = {
'draft': 'warm-gray', 'planned': 'blue', 'active': 'green',
'paused': 'warning', 'completed': 'teal', 'archived': 'cool-gray',
} %}
{% include '@MauticCore/Helper/_tag.html.twig' with { tags: [{
color: statusColors[item.status.value]|default('gray'),
label: item.status.labelKey,
icon: 'ri-flag-line',
attributes: {'class': 'initiative-status-tag'},
}] } %}
{% set totals = item.allocationTotals %}
{% if totals.planned is not null or totals.real is not null %}
<div class="label__divider"></div>
{% set totalTags = [] %}
{% if totals.planned is not null %}
{% set totalTags = totalTags|merge([{
color: 'high-contrast',
icon: 'ri-wallet-3-line',
label: 'mautic.program.header.total_planned'|trans({'%amount%': program_money(totals.planned), '%currency%': program_currency()}),
attributes: {'class': 'initiative-total-planned', 'title': 'mautic.program.header.total_planned.tooltip'|trans, 'data-toggle': 'tooltip'},
}]) %}
{% endif %}
{% if totals.real is not null %}
{% set overPlan = totals.planned is not null and (totals.real + 0) > (totals.planned + 0) %}
{% set totalTags = totalTags|merge([{
color: overPlan ? 'red' : 'green',
icon: overPlan ? 'ri-error-warning-line' : 'ri-checkbox-circle-line',
label: 'mautic.program.header.total_real'|trans({'%amount%': program_money(totals.real), '%currency%': program_currency()}),
attributes: {'class': 'initiative-total-real', 'title': (overPlan ? 'mautic.program.header.total_real.over' : 'mautic.program.header.total_real.tooltip')|trans, 'data-toggle': 'tooltip'},
}]) %}
{% endif %}
{% include '@MauticCore/Helper/_tag.html.twig' with { tags: totalTags } %}
{% endif %}
{% endblock %}
{% block actions %}
{{- include('@MauticCore/Helper/page_actions.html.twig', {
'item': item,
'templateButtons': {
'edit': securityHasEntityAccess(permissions['program:initiatives:editown'], permissions['program:initiatives:editother'], item.createdBy),
'delete': securityHasEntityAccess(permissions['program:initiatives:deleteown'], permissions['program:initiatives:deleteother'], item.createdBy),
},
'langVar': 'initiative',
}) -}}
{% endblock %}
{% block content %}
{% set objectives = item.objectives %}
{% set achievedCount = objectives|filter(o => o.achieved)|length %}
{% set descriptionItems = item.descriptionItems %}
{% set allocationItems = item.allocationItems %}
{% set allocationTotals = item.allocationTotals %}
{{ include('@Program/Initiative/_tabs.html.twig', {'initiativeId': item.id, 'counts': {
'description': descriptionItems|length,
'objectives': objectives|length,
'allocation': allocationItems|length,
'audiences': item.audiences|length,
'stakeholders': item.stakeholders|length,
'tasks': taskTree|length,
}}) }}
<div class="tab-content pa-md">
{# Details #}
<div class="tab-pane active bdr-w-0" id="initiative-tab-details" role="tabpanel">
<table class="table table-hover mb-0 initiative-details">
<tbody>
<tr>
<td class="col-md-3 text-muted">{{ 'mautic.program.field.status'|trans }}</td>
<td>{{ item.status.labelKey|trans }}</td>
</tr>
{% if item.completedAt %}
<tr>
<td class="text-muted">{{ 'mautic.program.field.completed_at'|trans }}</td>
<td>{{ dateToFull(item.completedAt) }}</td>
</tr>
{% endif %}
<tr>
<td class="text-muted">{{ 'mautic.program.field.version'|trans }}</td>
<td>{{ item.version }}</td>
</tr>
<tr>
<td class="text-muted">{{ 'mautic.program.field.owner'|trans }}</td>
<td>{{ item.owner ? item.owner.name : 'mautic.program.owner.none'|trans }}</td>
</tr>
<tr>
<td class="text-muted">{{ 'mautic.program.field.start_date'|trans }}</td>
<td>{{ item.startDate ? dateToFull(item.startDate) : 'mautic.program.value.none'|trans }}</td>
</tr>
<tr>
<td class="text-muted">{{ 'mautic.program.field.end_date'|trans }}</td>
<td>{{ item.endDate ? dateToFull(item.endDate) : 'mautic.program.value.none'|trans }}</td>
</tr>
<tr>
<td class="text-muted">{{ 'mautic.core.category'|trans }}</td>
<td>{{ item.category ? item.category.title : 'mautic.program.value.none'|trans }}</td>
</tr>
<tr>
<td class="text-muted">{{ 'mautic.core.form.available'|trans }}</td>
<td>{{ (item.isPublished ? 'mautic.core.form.yes' : 'mautic.core.form.no')|trans }}</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>
{% if item.dateModified %}
<tr>
<td class="text-muted">{{ 'mautic.core.modified'|trans }}</td>
<td>{{ dateToFull(item.dateModified) }}{% if item.modifiedByUser %} ({{ item.modifiedByUser }}){% endif %}</td>
</tr>
{% endif %}
<tr>
<td class="text-muted">{{ 'mautic.core.id'|trans }}</td>
<td>{{ item.id }}</td>
</tr>
</tbody>
</table>
</div>
{# Description #}
<div class="tab-pane bdr-w-0" id="initiative-tab-description" role="tabpanel">
{% if descriptionItems is empty %}
<p class="text-muted">{{ 'mautic.program.description_item.empty'|trans }}</p>
{% else %}
{# 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 (program.js). #}
{{ include('@Program/Initiative/_tab_table_filter.html.twig') }}
<div class="table-responsive">
<table class="table table-hover initiative-tab-table initiative-description-items-view"
data-initiative-tab-table data-empty-text="{{ 'mautic.program.filter.no_match'|trans }}" data-sort-hint="{{ 'mautic.program.filter.sort_hint'|trans }}">
<thead>
<tr>
<th class="initiative-col-pictogram" aria-label="{{ 'mautic.program.description_item.field.pictogram'|trans }}"></th>
<th class="initiative-col-type">{{ 'mautic.program.description_item.field.type'|trans }}</th>
<th class="initiative-col-description">{{ 'mautic.program.description_item.field.description'|trans }}</th>
</tr>
</thead>
<tbody>
{% for descriptionItem in descriptionItems %}
{% set typeName = program_item_type_name('description', descriptionItem.type) %}
{% set typeDescription = program_item_type_description('description', descriptionItem.type) %}
{% set typeIcon = program_item_type_icon('description', descriptionItem.type) %}
<tr>
<td class="initiative-col-pictogram text-center">
{% if typeIcon %}<i class="{{ typeIcon }} initiative-item-type-icon" style="font-size: 24px;" aria-hidden="true"></i>{% endif %}
</td>
<td class="initiative-col-type"{% if typeDescription %} title="{{ typeDescription }}" data-toggle="tooltip"{% endif %}>
{{ typeName ?? 'mautic.program.description_item.type.unknown'|trans({'%key%': descriptionItem.type}) }}
</td>
<td class="initiative-col-description">
{{ include('@Program/Initiative/_description_read_more.html.twig', {
'text': descriptionItem.description,
'id': 'initiative-desc-item-' ~ descriptionItem.id,
}) }}
</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
{% endif %}
</div>
{# Objectives #}
<div class="tab-pane bdr-w-0" id="initiative-tab-objectives" role="tabpanel">
{% if objectives is empty %}
<p class="text-muted">{{ 'mautic.program.objective.empty'|trans }}</p>
{% else %}
<p class="text-muted initiative-objectives-progress">
{{ 'mautic.program.objective.progress'|trans({'%achieved%': achievedCount, '%total%': objectives|length}) }}
</p>
{# Harmonized columns: Pictogram (no label), Type, Name (title), Description, Priority,
Status (achieved). Filter + click-to-sort (program.js). #}
{{ include('@Program/Initiative/_tab_table_filter.html.twig') }}
<div class="table-responsive">
<table class="table table-hover initiative-tab-table initiative-objectives-view"
data-initiative-tab-table data-empty-text="{{ 'mautic.program.filter.no_match'|trans }}" data-sort-hint="{{ 'mautic.program.filter.sort_hint'|trans }}">
<thead>
<tr>
<th class="initiative-col-pictogram" aria-label="{{ 'mautic.program.objective.field.pictogram'|trans }}"></th>
<th class="initiative-col-type">{{ 'mautic.program.objective.field.type'|trans }}</th>
<th class="initiative-col-name">{{ 'mautic.program.objective.field.name'|trans }}</th>
<th class="initiative-col-description">{{ 'mautic.program.objective.field.description'|trans }}</th>
<th class="initiative-col-priority">{{ 'mautic.program.objective.field.priority'|trans }}</th>
<th class="initiative-col-status">{{ 'mautic.program.objective.field.is_achieved'|trans }}</th>
</tr>
</thead>
<tbody>
{% for objective in objectives %}
{% set typeName = program_item_type_name('objective', objective.type) %}
{% set typeDescription = program_item_type_description('objective', objective.type) %}
{% set typeIcon = program_item_type_icon('objective', objective.type) %}
<tr>
<td class="initiative-col-pictogram text-center">
{% if typeIcon %}<i class="{{ typeIcon }} initiative-item-type-icon" style="font-size: 24px;" aria-hidden="true"></i>{% endif %}
</td>
<td class="initiative-col-type"{% if typeDescription %} title="{{ typeDescription }}" data-toggle="tooltip"{% endif %}>
{{ typeName ?? 'mautic.program.description_item.type.unknown'|trans({'%key%': objective.type}) }}
</td>
<td class="initiative-col-name">{{ objective.title }}</td>
<td class="initiative-col-description text-muted" style="white-space: pre-wrap;">{{ objective.description|program_linkify }}</td>
<td class="initiative-col-priority">{{ objective.priority ?? '—' }}</td>
<td class="initiative-col-status">
{% if objective.achieved %}
<span class="label label-success"><i class="ri-checkbox-circle-fill" title="{{ 'mautic.program.objective.achieved'|trans }}"></i> {{ 'mautic.program.objective.achieved'|trans }}</span>
{% else %}
<span class="label label-default"><i class="ri-checkbox-blank-circle-line" title="{{ 'mautic.program.objective.not_achieved'|trans }}"></i> {{ 'mautic.program.objective.not_achieved'|trans }}</span>
{% endif %}
</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
{% endif %}
</div>
{# Allocation: the initiative's budget, then the allocation items (cost lines) with their totals. #}
<div class="tab-pane bdr-w-0" id="initiative-tab-allocation" role="tabpanel">
<table class="table table-hover mb-md initiative-allocation">
<tbody>
<tr>
<td class="col-md-3 text-muted">{{ 'mautic.program.field.budget_planned'|trans }}</td>
<td>
{% if item.budgetPlanned is not null %}
{{ program_money(item.budgetPlanned) }} {{ program_currency() }}
{% else %}
{{ 'mautic.program.value.none'|trans }}
{% endif %}
</td>
</tr>
</tbody>
</table>
<h4 class="mb-sm">{{ 'mautic.program.field.allocation_items'|trans }}</h4>
{% if allocationItems is empty %}
<p class="text-muted">{{ 'mautic.program.allocation_item.empty'|trans }}</p>
{% else %}
{# Harmonized columns: Pictogram (no label), Type, Name, Description, then the costs.
Filter + click-to-sort (program.js). #}
{{ include('@Program/Initiative/_tab_table_filter.html.twig') }}
<div class="table-responsive">
<table class="table table-hover initiative-tab-table initiative-allocation-items-view"
data-initiative-tab-table data-empty-text="{{ 'mautic.program.filter.no_match'|trans }}" data-sort-hint="{{ 'mautic.program.filter.sort_hint'|trans }}">
<thead>
<tr>
<th class="initiative-col-pictogram" aria-label="{{ 'mautic.program.allocation_item.field.pictogram'|trans }}"></th>
<th class="initiative-col-type">{{ 'mautic.program.allocation_item.field.type'|trans }}</th>
<th class="initiative-col-name">{{ 'mautic.program.allocation_item.field.name'|trans }}</th>
<th class="initiative-col-description">{{ 'mautic.program.allocation_item.field.description'|trans }}</th>
<th class="initiative-col-cost text-right">{{ 'mautic.program.allocation_item.field.planned_cost'|trans }}</th>
<th class="initiative-col-cost text-right">{{ 'mautic.program.allocation_item.field.real_cost'|trans }}</th>
</tr>
</thead>
<tbody>
{% for allocationItem in allocationItems %}
{% set typeName = program_item_type_name('allocation', allocationItem.type) %}
{% set typeDescription = program_item_type_description('allocation', allocationItem.type) %}
{% set typeIcon = program_item_type_icon('allocation', allocationItem.type) %}
<tr>
<td class="initiative-col-pictogram text-center">
{% if typeIcon %}<i class="{{ typeIcon }} initiative-item-type-icon" style="font-size: 24px;" aria-hidden="true"></i>{% endif %}
</td>
<td class="initiative-col-type"{% if typeDescription %} title="{{ typeDescription }}" data-toggle="tooltip"{% endif %}>
{{ typeName ?? 'mautic.program.description_item.type.unknown'|trans({'%key%': allocationItem.type}) }}
</td>
<td class="initiative-col-name">{{ allocationItem.name }}</td>
<td class="initiative-col-description text-muted" style="white-space: pre-wrap;">{{ allocationItem.description|program_linkify }}</td>
<td class="initiative-col-cost text-right text-nowrap">
{% if allocationItem.plannedCost is not null %}{{ program_money(allocationItem.plannedCost) }} {{ program_currency() }}{% endif %}
</td>
<td class="initiative-col-cost text-right text-nowrap">
{% if allocationItem.realCost is not null %}{{ program_money(allocationItem.realCost) }} {{ program_currency() }}{% endif %}
</td>
</tr>
{% endfor %}
</tbody>
<tfoot>
<tr class="initiative-allocation-total">
<th colspan="4">{{ 'mautic.program.allocation.total'|trans }}</th>
<th class="initiative-col-cost text-right text-nowrap">
{% if allocationTotals.planned is not null %}{{ program_money(allocationTotals.planned) }} {{ program_currency() }}{% endif %}
</th>
<th class="initiative-col-cost text-right text-nowrap">
{% if allocationTotals.real is not null %}{{ program_money(allocationTotals.real) }} {{ program_currency() }}{% endif %}
</th>
</tr>
</tfoot>
</table>
</div>
{% endif %}
</div>
{# Stakeholders: the initiative's links to the global directory, harmonized like the other tabs. #}
<div class="tab-pane bdr-w-0" id="initiative-tab-stakeholders" role="tabpanel">
{% set stakeholders = item.stakeholders %}
{% if stakeholders is empty %}
<p class="text-muted">{{ 'mautic.program.stakeholder.empty'|trans }}</p>
{% else %}
{# Harmonized columns: Pictogram (no label), Type, Name, then the link's own fields.
Filter + click-to-sort (program.js). #}
{{ include('@Program/Initiative/_tab_table_filter.html.twig') }}
<div class="table-responsive">
<table class="table table-hover initiative-tab-table initiative-stakeholders-view"
data-initiative-tab-table data-empty-text="{{ 'mautic.program.filter.no_match'|trans }}" data-sort-hint="{{ 'mautic.program.filter.sort_hint'|trans }}">
<thead>
<tr>
<th class="initiative-col-pictogram" aria-label="{{ 'mautic.program.stakeholder.field.pictogram'|trans }}"></th>
<th class="initiative-col-type">{{ 'mautic.program.stakeholder.field.type'|trans }}</th>
<th class="initiative-col-name">{{ 'mautic.program.stakeholder.field.name'|trans }}</th>
<th class="initiative-col-role">{{ 'mautic.program.stakeholder.field.role_in_initiative'|trans }}</th>
<th class="initiative-col-role">{{ 'mautic.program.stakeholder.field.role'|trans }}</th>
<th class="initiative-col-email">{{ 'mautic.program.stakeholder.field.email'|trans }}</th>
<th class="initiative-col-phone">{{ 'mautic.program.stakeholder.field.phone'|trans }}</th>
<th class="initiative-col-active">{{ 'mautic.program.stakeholder.field.active'|trans }}</th>
</tr>
</thead>
<tbody>
{% for link in stakeholders %}
{% set stakeholder = link.stakeholder %}
<tr>
<td class="initiative-col-pictogram text-center">
{% set typeIcon = program_item_type_icon('stakeholder', stakeholder.type) %}
{% if typeIcon %}<i class="{{ typeIcon }} initiative-item-type-icon" style="font-size: 24px;" aria-hidden="true"></i>{% endif %}
</td>
<td class="initiative-col-type"{% if program_item_type_description('stakeholder', stakeholder.type) %} title="{{ program_item_type_description('stakeholder', stakeholder.type) }}" data-toggle="tooltip"{% endif %}>
{{ program_item_type_name('stakeholder', stakeholder.type) ?? 'mautic.program.description_item.type.unknown'|trans({'%key%': stakeholder.type}) }}
</td>
<td class="initiative-col-name">
<a href="{{ path('initiative_stakeholder_action', {'objectAction': 'view', 'objectId': stakeholder.id}) }}" data-toggle="ajax">{{ stakeholder.name }}</a>
</td>
<td class="initiative-col-role">{{ link.roleInInitiative }}</td>
<td class="initiative-col-role text-muted">{{ stakeholder.role }}</td>
<td class="initiative-col-email">
{% if stakeholder.email %}<a href="mailto:{{ stakeholder.email }}">{{ stakeholder.email }}</a>{% endif %}
</td>
<td class="initiative-col-phone text-nowrap">
{% if stakeholder.phone %}<a href="tel:{{ stakeholder.phone|replace({' ': ''}) }}">{{ stakeholder.phone }}</a>{% endif %}
</td>
<td class="initiative-col-active">
<span class="label {{ stakeholder.isPublished ? 'label-success' : 'label-gray' }}">
{{ (stakeholder.isPublished ? 'mautic.program.stakeholder.active' : 'mautic.program.stakeholder.inactive')|trans }}
</span>
</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
{% endif %}
</div>
{# Audiences: the initiative's links to the global directory (Programs > Audiences), harmonized like
the other tabs: pictogram, Type, Name (link to the audience's page), priority in this plan,
then the audience's own attributes. Filter + click-to-sort (program.js). #}
<div class="tab-pane bdr-w-0" id="initiative-tab-audiences" role="tabpanel">
{% set audiences = item.audiences %}
{% if audiences is empty %}
<p class="text-muted">{{ 'mautic.program.audience.empty'|trans }}</p>
{% else %}
{{ include('@Program/Initiative/_tab_table_filter.html.twig') }}
<div class="table-responsive">
<table class="table table-hover initiative-tab-table initiative-audiences-view"
data-initiative-tab-table data-empty-text="{{ 'mautic.program.filter.no_match'|trans }}" data-sort-hint="{{ 'mautic.program.filter.sort_hint'|trans }}">
<thead>
<tr>
<th class="initiative-col-pictogram" aria-label="{{ 'mautic.program.audience.field.pictogram'|trans }}"></th>
<th class="initiative-col-type">{{ 'mautic.program.audience.field.type'|trans }}</th>
<th class="initiative-col-name">{{ 'mautic.program.audience.field.name'|trans }}</th>
<th class="initiative-col-priority">{{ 'mautic.program.audience.field.priority'|trans }}</th>
<th class="initiative-col-stages">{{ 'mautic.program.audience.field.stages'|trans }}</th>
<th class="initiative-col-size text-right">{{ 'mautic.program.audience.field.estimated_size'|trans }}</th>
<th class="initiative-col-description">{{ 'mautic.program.audience.field.value_proposition'|trans }}</th>
<th class="initiative-col-channels">{{ 'mautic.program.audience.field.preferred_channels'|trans }}</th>
</tr>
</thead>
<tbody>
{% for link in audiences %}
{% set audience = link.audience %}
<tr>
<td class="initiative-col-pictogram text-center">
<i class="{{ audience.audienceType.icon }} initiative-item-type-icon" style="font-size: 24px;" aria-hidden="true"></i>
</td>
<td class="initiative-col-type">{{ audience.audienceType.labelKey|trans }}</td>
<td class="initiative-col-name">
<a href="{{ path('initiative_audience_action', {'objectAction': 'view', 'objectId': audience.id}) }}" data-toggle="ajax">{{ audience.name }}</a>
</td>
<td class="initiative-col-priority">
<span class="label {{ link.priority.labelClass }}">{{ link.priority.labelKey|trans }}</span>
</td>
<td class="initiative-col-stages text-muted">
{{ audience.stages|map(stage => stage.name)|join(', ') }}
</td>
<td class="initiative-col-size text-right text-nowrap">{{ audience.estimatedSize }}</td>
<td class="initiative-col-description text-muted" style="white-space: pre-wrap;">{{ link.valueProposition }}</td>
<td class="initiative-col-channels">
{% for channel in audience.preferredChannels ?? [] %}
<span class="label label-default">{{ program_audience_channel_label(channel)|trans }}</span>
{% endfor %}
</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
{% endif %}
</div>
{# Tasks: same columns as Programs > Tasks, in tree order. #}
<div class="tab-pane bdr-w-0" id="initiative-tab-tasks" role="tabpanel">
{{ include('@Program/Initiative/_task_table.html.twig', {
'initiative': item,
'taskTree': taskTree,
'taskPermissions': taskPermissions,
}) }}
</div>
</div>
{% endblock %}
@@ -1,25 +1,25 @@
{% extends '@MauticCore/Default/content.html.twig' %}
{% block mauticContent %}plan{% endblock %}
{% block mauticContent %}program{% endblock %}
{% block headerTitle %}
{% if entity.id %}
{{ 'mautic.plan.header.edit'|trans({'%name%': entity.name}) }}
{{ 'mautic.program.header.edit'|trans({'%name%': entity.name}) }}
{% else %}
{{ 'mautic.plan.header.new'|trans }}
{{ 'mautic.program.header.new'|trans }}
{% endif %}
{% endblock %}
{#
# Editable, sortable rows (objectives, description items). Each macro renders one row, for existing
# rows and, through data-prototype, for new ones. Adding, removing and reordering rows is handled by
# Assets/js/plan.js, through the plan-collection-* classes.
# Assets/js/program.js, through the initiative-collection-* classes.
#}
{% macro row_start(dragLabel) %}
<li class="plan-collection-row list-group-item">
<li class="initiative-collection-row list-group-item">
<div class="row">
<div class="col-xs-1 text-center">
<span class="plan-collection-handle text-muted" title="{{ dragLabel|trans }}" style="cursor: move;">
<span class="initiative-collection-handle text-muted" title="{{ dragLabel|trans }}" style="cursor: move;">
<i class="ri-draggable ri-lg"></i>
</span>
</div>
@@ -29,7 +29,7 @@
{% macro row_end(removeLabel) %}
</div>
<div class="col-xs-1 text-right">
<button type="button" class="btn btn-ghost btn-sm plan-collection-remove" title="{{ removeLabel|trans }}">
<button type="button" class="btn btn-ghost btn-sm initiative-collection-remove" title="{{ removeLabel|trans }}">
<i class="ri-delete-bin-line"></i>
</button>
</div>
@@ -38,16 +38,16 @@
{% endmacro %}
{% macro objective_row(objective) %}
{{ _self.row_start('mautic.plan.objective.drag') }}
{{ _self.row_start('mautic.program.objective.drag') }}
<div class="row">
{# The selected type's pictogram; updated by plan.js when the type changes. #}
{# The selected type's pictogram; updated by program.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>
<i class="initiative-item-type-icon {{ program_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>
{# Filled with the selected type's description by program.js. #}
<p class="help-block initiative-item-type-help">{{ program_item_type_description('objective', objective.type.vars.value) }}</p>
</div>
</div>
{{ form_row(objective.title) }}
@@ -57,67 +57,59 @@
</div>
{{ form_row(objective.description) }}
{{ form_widget(objective.position) }}
{{ _self.row_end('mautic.plan.objective.remove') }}
{{ _self.row_end('mautic.program.objective.remove') }}
{% endmacro %}
{% macro description_item_row(item) %}
{{ _self.row_start('mautic.plan.description_item.drag') }}
{{ _self.row_start('mautic.program.description_item.drag') }}
<div class="row">
{# The selected type's pictogram; updated by plan.js when the type changes. #}
{# The selected type's pictogram; updated by program.js when the type changes. #}
<div class="col-xs-1 text-center pt-lg">
<i class="plan-item-type-icon {{ plan_item_type_icon('description', item.type.vars.value) }}" style="font-size: 28px;" aria-hidden="true"></i>
<i class="initiative-item-type-icon {{ program_item_type_icon('description', item.type.vars.value) }}" style="font-size: 28px;" aria-hidden="true"></i>
</div>
<div class="col-xs-11">
{{ form_row(item.type) }}
{# Filled with the selected type's description by plan.js. #}
<p class="help-block plan-item-type-help">{{ plan_item_type_description('description', item.type.vars.value) }}</p>
{# Filled with the selected type's description by program.js. #}
<p class="help-block initiative-item-type-help">{{ program_item_type_description('description', item.type.vars.value) }}</p>
</div>
</div>
{{ form_row(item.description) }}
{{ form_widget(item.position) }}
{{ _self.row_end('mautic.plan.description_item.remove') }}
{{ _self.row_end('mautic.program.description_item.remove') }}
{% endmacro %}
{% macro stakeholder_row(link) %}
{{ _self.row_start('mautic.plan.stakeholder.drag') }}
{{ _self.row_start('mautic.program.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 class="col-md-6">{{ form_row(link.roleInInitiative) }}</div>
</div>
{{ form_widget(link.position) }}
{{ _self.row_end('mautic.plan.stakeholder.remove') }}
{{ _self.row_end('mautic.program.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') }}
{% macro audience_row(audience) %}
{{ _self.row_start('mautic.program.audience.drag') }}
{{ form_row(audience.audience) }}
{{ form_row(audience.priority) }}
{{ form_row(audience.valueProposition) }}
{{ form_widget(audience.position) }}
{{ _self.row_end('mautic.program.audience.remove') }}
{% endmacro %}
{% macro allocation_item_row(item) %}
{{ _self.row_start('mautic.plan.allocation_item.drag') }}
{{ _self.row_start('mautic.program.allocation_item.drag') }}
<div class="row">
{# The selected type's pictogram; updated by plan.js when the type changes. #}
{# The selected type's pictogram; updated by program.js when the type changes. #}
<div class="col-xs-1 text-center pt-lg">
<i class="plan-item-type-icon {{ plan_item_type_icon('allocation', item.type.vars.value) }}" style="font-size: 28px;" aria-hidden="true"></i>
<i class="initiative-item-type-icon {{ program_item_type_icon('allocation', item.type.vars.value) }}" style="font-size: 28px;" aria-hidden="true"></i>
</div>
<div class="col-xs-11">
<div class="row">
<div class="col-md-6">
{{ form_row(item.type) }}
{# Filled with the selected type's description by plan.js. #}
<p class="help-block plan-item-type-help">{{ plan_item_type_description('allocation', item.type.vars.value) }}</p>
{# Filled with the selected type's description by program.js. #}
<p class="help-block initiative-item-type-help">{{ program_item_type_description('allocation', item.type.vars.value) }}</p>
</div>
<div class="col-md-6">{{ form_row(item.name) }}</div>
</div>
@@ -129,7 +121,7 @@
<div class="col-md-6">{{ form_row(item.realCost) }}</div>
</div>
{{ form_widget(item.position) }}
{{ _self.row_end('mautic.plan.allocation_item.remove') }}
{{ _self.row_end('mautic.program.allocation_item.remove') }}
{% endmacro %}
{% block content %}
@@ -138,11 +130,11 @@
{{ form_row(form.name) }}
</div>
{{ include('@Plan/Plan/_tabs.html.twig', {'planId': entity.id}) }}
{{ include('@Program/Initiative/_tabs.html.twig', {'initiativeId': entity.id}) }}
<div class="tab-content pa-md">
{# Details #}
<div class="tab-pane active bdr-w-0" id="plan-tab-details" role="tabpanel">
<div class="tab-pane active bdr-w-0" id="initiative-tab-details" role="tabpanel">
<div class="row">
<div class="col-md-4">{{ form_row(form.status) }}</div>
<div class="col-md-4">{{ form_row(form.version) }}</div>
@@ -150,7 +142,7 @@
</div>
{% if entity.completedAt %}
<div class="form-group">
<label class="control-label">{{ 'mautic.plan.field.completed_at'|trans }}</label>
<label class="control-label">{{ 'mautic.program.field.completed_at'|trans }}</label>
<p class="form-control-static">{{ dateToFull(entity.completedAt) }}</p>
</div>
{% endif %}
@@ -165,26 +157,26 @@
</div>
{# Description: description items. #}
<div class="tab-pane bdr-w-0" id="plan-tab-description" role="tabpanel">
<div class="tab-pane bdr-w-0" id="initiative-tab-description" role="tabpanel">
{% set hasTypes = form.descriptionItems.vars.prototype.type.vars.choices is not empty %}
<div class="plan-collection plan-description-items"
<div class="initiative-collection initiative-description-items"
data-prototype="{{ _self.description_item_row(form.descriptionItems.vars.prototype)|e('html_attr') }}"
data-prototype-name="__descitem__">
{{ form_errors(form.descriptionItems) }}
{% if not hasTypes %}
<div class="alert alert-info">{{ 'mautic.plan.description_item.no_types'|trans }}</div>
<div class="alert alert-info">{{ 'mautic.program.description_item.no_types'|trans }}</div>
{% endif %}
<p class="text-muted plan-collection-empty{% if form.descriptionItems|length > 0 %} hide{% endif %}">
{{ 'mautic.plan.description_item.empty'|trans }}
<p class="text-muted initiative-collection-empty{% if form.descriptionItems|length > 0 %} hide{% endif %}">
{{ 'mautic.program.description_item.empty'|trans }}
</p>
<ul class="list-group plan-collection-list">
<ul class="list-group initiative-collection-list">
{% for item in form.descriptionItems %}
{{ _self.description_item_row(item) }}
{% endfor %}
</ul>
{% if hasTypes %}
<button type="button" class="btn btn-ghost plan-collection-add">
<i class="ri-add-line"></i> {{ 'mautic.plan.description_item.add'|trans }}
<button type="button" class="btn btn-ghost initiative-collection-add">
<i class="ri-add-line"></i> {{ 'mautic.program.description_item.add'|trans }}
</button>
{% endif %}
</div>
@@ -192,113 +184,114 @@
</div>
{# Objectives #}
<div class="tab-pane bdr-w-0" id="plan-tab-objectives" role="tabpanel">
<div class="tab-pane bdr-w-0" id="initiative-tab-objectives" role="tabpanel">
{% set hasObjectiveTypes = form.objectives.vars.prototype.type.vars.choices is not empty %}
<div class="plan-collection plan-objectives"
<div class="initiative-collection initiative-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>
<div class="alert alert-info">{{ 'mautic.program.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 class="text-muted initiative-collection-empty{% if form.objectives|length > 0 %} hide{% endif %}">
{{ 'mautic.program.objective.empty'|trans }}
</p>
<ul class="list-group plan-collection-list">
<ul class="list-group initiative-collection-list">
{% for objective in form.objectives %}
{{ _self.objective_row(objective) }}
{% endfor %}
</ul>
{% if hasObjectiveTypes %}
<button type="button" class="btn btn-ghost plan-collection-add">
<i class="ri-add-line"></i> {{ 'mautic.plan.objective.add'|trans }}
<button type="button" class="btn btn-ghost initiative-collection-add">
<i class="ri-add-line"></i> {{ 'mautic.program.objective.add'|trans }}
</button>
{% endif %}
</div>
{% do form.objectives.setRendered %}
</div>
{# Allocation: the plan's budget, then the allocation items (cost lines). #}
<div class="tab-pane bdr-w-0" id="plan-tab-allocation" role="tabpanel">
{# Allocation: the initiative's budget, then the allocation items (cost lines). #}
<div class="tab-pane bdr-w-0" id="initiative-tab-allocation" role="tabpanel">
<div class="row">
<div class="col-md-6">{{ form_row(form.budgetPlanned) }}</div>
</div>
{% set hasAllocationTypes = form.allocationItems.vars.prototype.type.vars.choices is not empty %}
<div class="plan-collection plan-allocation-items"
<div class="initiative-collection initiative-allocation-items"
data-prototype="{{ _self.allocation_item_row(form.allocationItems.vars.prototype)|e('html_attr') }}"
data-prototype-name="__allocitem__">
<h4 class="mt-lg mb-sm">{{ 'mautic.plan.field.allocation_items'|trans }}</h4>
<h4 class="mt-lg mb-sm">{{ 'mautic.program.field.allocation_items'|trans }}</h4>
{{ form_errors(form.allocationItems) }}
{% if not hasAllocationTypes %}
<div class="alert alert-info">{{ 'mautic.plan.allocation_item.no_types'|trans }}</div>
<div class="alert alert-info">{{ 'mautic.program.allocation_item.no_types'|trans }}</div>
{% endif %}
<p class="text-muted plan-collection-empty{% if form.allocationItems|length > 0 %} hide{% endif %}">
{{ 'mautic.plan.allocation_item.empty'|trans }}
<p class="text-muted initiative-collection-empty{% if form.allocationItems|length > 0 %} hide{% endif %}">
{{ 'mautic.program.allocation_item.empty'|trans }}
</p>
<ul class="list-group plan-collection-list">
<ul class="list-group initiative-collection-list">
{% for item in form.allocationItems %}
{{ _self.allocation_item_row(item) }}
{% endfor %}
</ul>
{% if hasAllocationTypes %}
<button type="button" class="btn btn-ghost plan-collection-add">
<i class="ri-add-line"></i> {{ 'mautic.plan.allocation_item.add'|trans }}
<button type="button" class="btn btn-ghost initiative-collection-add">
<i class="ri-add-line"></i> {{ 'mautic.program.allocation_item.add'|trans }}
</button>
{% endif %}
</div>
{% do form.allocationItems.setRendered %}
</div>
{# 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"
{# Stakeholders: links to the global directory (Programs > Stakeholders). #}
<div class="tab-pane bdr-w-0" id="initiative-tab-stakeholders" role="tabpanel">
<div class="initiative-collection initiative-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 class="text-muted initiative-collection-empty{% if form.stakeholders|length > 0 %} hide{% endif %}">
{{ 'mautic.program.stakeholder.empty'|trans }}
</p>
<ul class="list-group plan-collection-list">
<ul class="list-group initiative-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 type="button" class="btn btn-ghost initiative-collection-add">
<i class="ri-add-line"></i> {{ 'mautic.program.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">
<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 }}
{# Audiences: the initiative's links to the global directory (Programs > Audiences). #}
<div class="tab-pane bdr-w-0" id="initiative-tab-audiences" role="tabpanel">
<p class="text-muted small">{{ 'mautic.program.audience.link_tab.help'|trans }}</p>
<div class="initiative-collection initiative-audiences"
data-prototype="{{ _self.audience_row(form.audiences.vars.prototype)|e('html_attr') }}"
data-prototype-name="__audience__">
{{ form_errors(form.audiences) }}
<p class="text-muted initiative-collection-empty{% if form.audiences|length > 0 %} hide{% endif %}">
{{ 'mautic.program.audience.empty'|trans }}
</p>
<ul class="list-group plan-collection-list">
{% for target in form.targets %}
{{ _self.target_row(target) }}
<ul class="list-group initiative-collection-list">
{% for audience in form.audiences %}
{{ _self.audience_row(audience) }}
{% endfor %}
</ul>
<button type="button" class="btn btn-ghost plan-collection-add">
<i class="ri-add-line"></i> {{ 'mautic.plan.target.add'|trans }}
<button type="button" class="btn btn-ghost initiative-collection-add">
<i class="ri-add-line"></i> {{ 'mautic.program.audience.add'|trans }}
</button>
</div>
{% do form.targets.setRendered %}
{% do form.audiences.setRendered %}
</div>
{# Tasks: read-only here, so that following a link doesn't drop unsaved changes to the plan. #}
<div class="tab-pane bdr-w-0" id="plan-tab-tasks" role="tabpanel">
<div class="tab-pane bdr-w-0" id="initiative-tab-tasks" role="tabpanel">
{% if entity.id %}
<p class="text-muted small">{{ 'mautic.plan.task.manage_from_plan_page'|trans }}</p>
<p class="text-muted small">{{ 'mautic.program.task.manage_from_initiative_page'|trans }}</p>
{% endif %}
{{ include('@Plan/Plan/_task_table.html.twig', {
'plan': entity,
{{ include('@Program/Initiative/_task_table.html.twig', {
'initiative': entity,
'taskTree': taskTree|default([]),
'readOnly': true,
}) }}
@@ -2,9 +2,9 @@
{% set tmpl = 'list' %}
{% extends isIndex ? '@MauticCore/Default/content.html.twig' : '@MauticCore/Default/raw_output.html.twig' %}
{% block mauticContent %}plan{% endblock %}
{% block mauticContent %}program{% endblock %}
{% block headerTitle %}{{ 'mautic.plan.header.index'|trans }}{% endblock %}
{% block headerTitle %}{{ 'mautic.program.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">
@@ -13,95 +13,95 @@
'action': currentRoute,
'page_actions': {
'templateButtons': {
'new': permissions['plan:plans:create'],
'new': permissions['program:initiatives:create'],
},
'routeBase': 'plan',
'langVar': 'plan',
'routeBase': 'initiative',
'langVar': 'initiative',
},
'bulk_actions': {
'langVar': 'plan',
'routeBase': 'plan',
'langVar': 'initiative',
'routeBase': 'initiative',
'templateButtons': {
'delete': permissions['plan:plans:deleteown'] or permissions['plan:plans:deleteother'],
'delete': permissions['program:initiatives:deleteown'] or permissions['program:initiatives:deleteother'],
},
},
}) -}}
<div class="page-list">
{% if items is defined and items is not empty %}
<div class="table-responsive">
<table class="table table-hover" id="planTable">
<table class="table table-hover" id="initiativeTable">
<thead>
<tr>
{{ include('@MauticCore/Helper/tableheader.html.twig', {
'checkall': 'true',
'target': '#planTable',
'target': '#initiativeTable',
}) }}
{{ include('@MauticCore/Helper/tableheader.html.twig', {
'sessionVar': 'plan',
'sessionVar': 'initiative',
'orderBy': 'p.name',
'text': 'mautic.plan.field.name',
'class': 'col-plan-name',
'text': 'mautic.program.field.name',
'class': 'col-initiative-name',
'default': true,
}) }}
{{ include('@MauticCore/Helper/tableheader.html.twig', {
'sessionVar': 'plan',
'sessionVar': 'initiative',
'orderBy': 'p.status',
'text': 'mautic.plan.field.status',
'class': 'col-plan-status',
'text': 'mautic.program.field.status',
'class': 'col-initiative-status',
}) }}
{{ include('@MauticCore/Helper/tableheader.html.twig', {
'sessionVar': 'plan',
'text': 'mautic.plan.field.owner',
'class': 'visible-md visible-lg col-plan-owner',
'sessionVar': 'initiative',
'text': 'mautic.program.field.owner',
'class': 'visible-md visible-lg col-initiative-owner',
}) }}
{{ include('@MauticCore/Helper/tableheader.html.twig', {
'sessionVar': 'plan',
'sessionVar': 'initiative',
'orderBy': 'p.startDate',
'text': 'mautic.plan.field.start_date',
'class': 'visible-md visible-lg col-plan-start',
'text': 'mautic.program.field.start_date',
'class': 'visible-md visible-lg col-initiative-start',
}) }}
{{ include('@MauticCore/Helper/tableheader.html.twig', {
'sessionVar': 'plan',
'sessionVar': 'initiative',
'orderBy': 'p.endDate',
'text': 'mautic.plan.field.end_date',
'class': 'visible-md visible-lg col-plan-end',
'text': 'mautic.program.field.end_date',
'class': 'visible-md visible-lg col-initiative-end',
}) }}
{{ include('@MauticCore/Helper/tableheader.html.twig', {
'sessionVar': 'plan',
'sessionVar': 'initiative',
'orderBy': 'p.budgetPlanned',
'text': 'mautic.plan.field.budget_planned',
'class': 'visible-md visible-lg col-plan-budget text-right',
'text': 'mautic.program.field.budget_planned',
'class': 'visible-md visible-lg col-initiative-budget text-right',
}) }}
{{ include('@MauticCore/Helper/tableheader.html.twig', {
'sessionVar': 'plan',
'sessionVar': 'initiative',
'orderBy': 'p.id',
'text': 'mautic.core.id',
'class': 'visible-md visible-lg col-plan-id',
'class': 'visible-md visible-lg col-initiative-id',
}) }}
</tr>
</thead>
<tbody>
{% for item in items %}
{% set canEdit = securityHasEntityAccess(permissions['plan:plans:editown'], permissions['plan:plans:editother'], item.createdBy) %}
{% set canEdit = securityHasEntityAccess(permissions['program:initiatives:editown'], permissions['program:initiatives:editother'], item.createdBy) %}
<tr>
<td>
{{- include('@MauticCore/Helper/list_actions.html.twig', {
'item': item,
'templateButtons': {
'edit': canEdit,
'delete': securityHasEntityAccess(permissions['plan:plans:deleteown'], permissions['plan:plans:deleteother'], item.createdBy),
'delete': securityHasEntityAccess(permissions['program:initiatives:deleteown'], permissions['program:initiatives:deleteother'], item.createdBy),
},
'routeBase': 'plan',
'langVar': 'plan',
'routeBase': 'initiative',
'langVar': 'initiative',
}) -}}
</td>
<td>
<div>
{{- include('@MauticCore/Helper/publishstatus_icon.html.twig', {
'item': item,
'model': 'plan',
'model': 'initiative',
}) -}}
<a href="{{ path('plan_action', {'objectAction': 'view', 'objectId': item.id}) }}" data-toggle="ajax">
<a href="{{ path('initiative_action', {'objectAction': 'view', 'objectId': item.id}) }}" data-toggle="ajax">
{{ item.name }}
</a>
{% if item.category %}
@@ -111,13 +111,13 @@
</td>
<td>{{ item.status.labelKey|trans }}</td>
<td class="visible-md visible-lg">
{{ item.owner ? item.owner.name : 'mautic.plan.owner.none'|trans }}
{{ item.owner ? item.owner.name : 'mautic.program.owner.none'|trans }}
</td>
<td class="visible-md visible-lg">{{ item.startDate ? dateToDate(item.startDate) : '' }}</td>
<td class="visible-md visible-lg">{{ item.endDate ? dateToDate(item.endDate) : '' }}</td>
<td class="visible-md visible-lg text-right">
{% if item.budgetPlanned is not null %}
{{ plan_money(item.budgetPlanned) }} {{ plan_currency() }}
{{ program_money(item.budgetPlanned) }} {{ program_currency() }}
{% endif %}
</td>
<td class="visible-md visible-lg">{{ item.id }}</td>
@@ -130,8 +130,8 @@
'totalItems': totalItems,
'page': page,
'limit': limit,
'baseUrl': path('plan_index'),
'sessionVar': 'plan',
'baseUrl': path('initiative_index'),
'sessionVar': 'initiative',
}) -}}
</div>
</div>
@@ -140,9 +140,9 @@
{% 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.onboarding.heading',
'subheading': 'mautic.plan.onboarding.subheading',
'copy': 'mautic.plan.onboarding.copy',
'heading': 'mautic.program.onboarding.heading',
'subheading': 'mautic.program.onboarding.subheading',
'copy': 'mautic.program.onboarding.copy',
}) }}
</div>
{% endif %}
@@ -1,11 +0,0 @@
{#
# 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>
-32
View File
@@ -1,32 +0,0 @@
{#
# Tab bar shared by the plan form and the plan detail page.
#
# Parameters:
# planId: the plan's id (null for a new plan)
# counts (optional): tab id => number shown next to the tab name
#
# The tab panes use the ids plan-tab-<id>. Assets/js/plan.js reopens the tab last used for this plan
# (so Edit, Save and Cancel keep the same tab), and on the form marks the tabs whose pane contains a
# validation error and opens the first of them.
#}
{% set planTabs = {
'details': 'mautic.plan.tab.details',
'description': 'mautic.plan.tab.description',
'objectives': 'mautic.plan.tab.objectives',
'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('') }}">
{% for id, label in planTabs %}
<li class="{{ loop.first ? 'active' : '' }}" data-tab-id="plan-tab-{{ id }}">
<a href="#plan-tab-{{ id }}" role="tab" data-toggle="tab">
<span>{{ label|trans }}</span>
{% if counts is defined and counts[id] is defined %}
<span class="badge">{{ counts[id] }}</span>
{% endif %}
</a>
</li>
{% endfor %}
</ul>
@@ -1,93 +0,0 @@
{#
# 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, 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
# (see TaskController). Opened from Planning > Tasks, the task form goes back to the task list.
#}
{% set readOnly = readOnly|default(false) %}
{% set taskPermissions = taskPermissions|default({}) %}
{% set canCreate = not readOnly and plan.id and taskPermissions['plan:tasks:create']|default(false) %}
{% if canCreate %}
<div class="mb-md">
<a class="btn btn-ghost plan-task-add" href="{{ path('plan_task_action', {'objectAction': 'new', 'plan': plan.id, 'returnTo': 'plan'}) }}" data-toggle="ajax">
<i class="ri-add-line"></i> {{ 'mautic.plan.task.add'|trans }}
</a>
</div>
{% endif %}
{% if not plan.id %}
<p class="text-muted">{{ 'mautic.plan.task.save_plan_first'|trans }}</p>
{% 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-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="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>
{% for row in taskTree %}
{% set task = row.task %}
{% set canEdit = not readOnly and securityHasEntityAccess(taskPermissions['plan:tasks:editown']|default(false), taskPermissions['plan:tasks:editother']|default(false), task.createdBy) %}
<tr class="plan-task" data-task-id="{{ task.id }}">
<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">
{% if canEdit %}
<a href="{{ path('plan_task_action', {'objectAction': 'edit', 'objectId': task.id, 'returnTo': 'plan'}) }}" data-toggle="ajax">{{ task.name }}</a>
{% else %}
{{ task.name }}
{% endif %}
{% if task.taskKind == constant('MauticPlugin\\PlanBundle\\Entity\\TaskKind::Milestone') %}
<span class="label label-success" title="{{ 'mautic.plan.task.kind.milestone'|trans }}">{{ 'mautic.plan.task.kind.milestone_short'|trans }}</span>
{% elseif task.taskKind == constant('MauticPlugin\\PlanBundle\\Entity\\TaskKind::Phase') %}
<span class="label label-primary" title="{{ 'mautic.plan.task.kind.phase'|trans }}">{{ 'mautic.plan.task.kind.phase_short'|trans }}</span>
{% endif %}
</td>
<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 class="plan-col-date">{{ task.startDate ? task.startDate|date('Y-m-d') : '' }}</td>
<td class="plan-col-date">{{ task.endDate ? task.endDate|date('Y-m-d') : '' }}</td>
<td class="plan-col-status">
{# A phase has no status of its own — skip the column value. #}
{% if task.taskKind != constant('MauticPlugin\\PlanBundle\\Entity\\TaskKind::Phase') %}
<span class="label {{ task.status.labelClass }}">{{ task.status.labelKey|trans }}</span>
{% endif %}
</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
{% endif %}
-450
View File
@@ -1,450 +0,0 @@
{% extends '@MauticCore/Default/content.html.twig' %}
{% block mauticContent %}plan{% endblock %}
{#
# No routeBase on the page_actions includes: core would turn it into mautic_plan_* route names.
# The buttons use actionRoute (plan_action) from the controller, and the close button gets its URL here.
#}
{% block preHeader %}
{{- include('@MauticCore/Helper/page_actions.html.twig', {
'item': item,
'templateButtons': {
'close': true,
},
'closeUrl': path('plan_index'),
'targetLabel': 'mautic.plan.header.index'|trans,
}) -}}
{# Core's helper renders an empty pill when there is no category. #}
{% if item.category %}
{{ include('@MauticCore/Modules/category--inline.html.twig', {'category': item.category}) }}
{% endif %}
{% endblock %}
{% block headerTitle %}{{ item.name }}{% endblock %}
{#
# Under the title, as on an email's page: the plan status, then the total planned and real costs of the
# allocation items, in the general currency. A real total above the planned total is red, otherwise green.
#}
{% block publishStatus %}
{% set statusColors = {
'draft': 'warm-gray', 'planned': 'blue', 'active': 'green',
'paused': 'warning', 'completed': 'teal', 'archived': 'cool-gray',
} %}
{% include '@MauticCore/Helper/_tag.html.twig' with { tags: [{
color: statusColors[item.status.value]|default('gray'),
label: item.status.labelKey,
icon: 'ri-flag-line',
attributes: {'class': 'plan-status-tag'},
}] } %}
{% set totals = item.allocationTotals %}
{% if totals.planned is not null or totals.real is not null %}
<div class="label__divider"></div>
{% set totalTags = [] %}
{% if totals.planned is not null %}
{% set totalTags = totalTags|merge([{
color: 'high-contrast',
icon: 'ri-wallet-3-line',
label: 'mautic.plan.header.total_planned'|trans({'%amount%': plan_money(totals.planned), '%currency%': plan_currency()}),
attributes: {'class': 'plan-total-planned', 'title': 'mautic.plan.header.total_planned.tooltip'|trans, 'data-toggle': 'tooltip'},
}]) %}
{% endif %}
{% if totals.real is not null %}
{% set overPlan = totals.planned is not null and (totals.real + 0) > (totals.planned + 0) %}
{% set totalTags = totalTags|merge([{
color: overPlan ? 'red' : 'green',
icon: overPlan ? 'ri-error-warning-line' : 'ri-checkbox-circle-line',
label: 'mautic.plan.header.total_real'|trans({'%amount%': plan_money(totals.real), '%currency%': plan_currency()}),
attributes: {'class': 'plan-total-real', 'title': (overPlan ? 'mautic.plan.header.total_real.over' : 'mautic.plan.header.total_real.tooltip')|trans, 'data-toggle': 'tooltip'},
}]) %}
{% endif %}
{% include '@MauticCore/Helper/_tag.html.twig' with { tags: totalTags } %}
{% endif %}
{% endblock %}
{% block actions %}
{{- include('@MauticCore/Helper/page_actions.html.twig', {
'item': item,
'templateButtons': {
'edit': securityHasEntityAccess(permissions['plan:plans:editown'], permissions['plan:plans:editother'], item.createdBy),
'delete': securityHasEntityAccess(permissions['plan:plans:deleteown'], permissions['plan:plans:deleteother'], item.createdBy),
},
'langVar': 'plan',
}) -}}
{% endblock %}
{% block content %}
{% set objectives = item.objectives %}
{% set achievedCount = objectives|filter(o => o.achieved)|length %}
{% set descriptionItems = item.descriptionItems %}
{% set allocationItems = item.allocationItems %}
{% set allocationTotals = item.allocationTotals %}
{{ include('@Plan/Plan/_tabs.html.twig', {'planId': item.id, 'counts': {
'description': descriptionItems|length,
'objectives': objectives|length,
'allocation': allocationItems|length,
'targets': item.targets|length,
'stakeholders': item.stakeholders|length,
'tasks': taskTree|length,
}}) }}
<div class="tab-content pa-md">
{# Details #}
<div class="tab-pane active bdr-w-0" id="plan-tab-details" role="tabpanel">
<table class="table table-hover mb-0 plan-details">
<tbody>
<tr>
<td class="col-md-3 text-muted">{{ 'mautic.plan.field.status'|trans }}</td>
<td>{{ item.status.labelKey|trans }}</td>
</tr>
{% if item.completedAt %}
<tr>
<td class="text-muted">{{ 'mautic.plan.field.completed_at'|trans }}</td>
<td>{{ dateToFull(item.completedAt) }}</td>
</tr>
{% endif %}
<tr>
<td class="text-muted">{{ 'mautic.plan.field.version'|trans }}</td>
<td>{{ item.version }}</td>
</tr>
<tr>
<td class="text-muted">{{ 'mautic.plan.field.owner'|trans }}</td>
<td>{{ item.owner ? item.owner.name : 'mautic.plan.owner.none'|trans }}</td>
</tr>
<tr>
<td class="text-muted">{{ 'mautic.plan.field.start_date'|trans }}</td>
<td>{{ item.startDate ? dateToFull(item.startDate) : 'mautic.plan.value.none'|trans }}</td>
</tr>
<tr>
<td class="text-muted">{{ 'mautic.plan.field.end_date'|trans }}</td>
<td>{{ item.endDate ? dateToFull(item.endDate) : 'mautic.plan.value.none'|trans }}</td>
</tr>
<tr>
<td class="text-muted">{{ 'mautic.core.category'|trans }}</td>
<td>{{ item.category ? item.category.title : 'mautic.plan.value.none'|trans }}</td>
</tr>
<tr>
<td class="text-muted">{{ 'mautic.core.form.available'|trans }}</td>
<td>{{ (item.isPublished ? 'mautic.core.form.yes' : 'mautic.core.form.no')|trans }}</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>
{% if item.dateModified %}
<tr>
<td class="text-muted">{{ 'mautic.core.modified'|trans }}</td>
<td>{{ dateToFull(item.dateModified) }}{% if item.modifiedByUser %} ({{ item.modifiedByUser }}){% endif %}</td>
</tr>
{% endif %}
<tr>
<td class="text-muted">{{ 'mautic.core.id'|trans }}</td>
<td>{{ item.id }}</td>
</tr>
</tbody>
</table>
</div>
{# Description #}
<div class="tab-pane bdr-w-0" id="plan-tab-description" role="tabpanel">
{% if descriptionItems is empty %}
<p class="text-muted">{{ 'mautic.plan.description_item.empty'|trans }}</p>
{% else %}
{# 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-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="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>
{% for descriptionItem in descriptionItems %}
{% set typeName = plan_item_type_name('description', descriptionItem.type) %}
{% set typeDescription = plan_item_type_description('description', descriptionItem.type) %}
{% set typeIcon = plan_item_type_icon('description', descriptionItem.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%': 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>
</tr>
{% endfor %}
</tbody>
</table>
</div>
{% endif %}
</div>
{# Objectives #}
<div class="tab-pane bdr-w-0" id="plan-tab-objectives" role="tabpanel">
{% if objectives is empty %}
<p class="text-muted">{{ 'mautic.plan.objective.empty'|trans }}</p>
{% else %}
<p class="text-muted plan-objectives-progress">
{{ 'mautic.plan.objective.progress'|trans({'%achieved%': achievedCount, '%total%': objectives|length}) }}
</p>
{# 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>
{# Allocation: the plan's budget, then the allocation items (cost lines) with their totals. #}
<div class="tab-pane bdr-w-0" id="plan-tab-allocation" role="tabpanel">
<table class="table table-hover mb-md plan-allocation">
<tbody>
<tr>
<td class="col-md-3 text-muted">{{ 'mautic.plan.field.budget_planned'|trans }}</td>
<td>
{% if item.budgetPlanned is not null %}
{{ plan_money(item.budgetPlanned) }} {{ plan_currency() }}
{% else %}
{{ 'mautic.plan.value.none'|trans }}
{% endif %}
</td>
</tr>
</tbody>
</table>
<h4 class="mb-sm">{{ 'mautic.plan.field.allocation_items'|trans }}</h4>
{% 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-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="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>
{% for allocationItem in allocationItems %}
{% set typeName = plan_item_type_name('allocation', allocationItem.type) %}
{% set typeDescription = plan_item_type_description('allocation', allocationItem.type) %}
{% set typeIcon = plan_item_type_icon('allocation', allocationItem.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%': allocationItem.type}) }}
</td>
<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="plan-col-cost text-right text-nowrap">
{% if allocationItem.realCost is not null %}{{ plan_money(allocationItem.realCost) }} {{ plan_currency() }}{% endif %}
</td>
</tr>
{% endfor %}
</tbody>
<tfoot>
<tr class="plan-allocation-total">
<th colspan="4">{{ 'mautic.plan.allocation.total'|trans }}</th>
<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="plan-col-cost text-right text-nowrap">
{% if allocationTotals.real is not null %}{{ plan_money(allocationTotals.real) }} {{ plan_currency() }}{% endif %}
</th>
</tr>
</tfoot>
</table>
</div>
{% endif %}
</div>
{# 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">
{% 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. #}
<div class="tab-pane bdr-w-0" id="plan-tab-tasks" role="tabpanel">
{{ include('@Plan/Plan/_task_table.html.twig', {
'plan': item,
'taskTree': taskTree,
'taskPermissions': taskPermissions,
}) }}
</div>
</div>
{% endblock %}
+30 -30
View File
@@ -1,6 +1,6 @@
{% extends '@MauticCore/Default/content.html.twig' %}
{% block mauticContent %}planStakeholder{% endblock %}
{% block mauticContent %}programStakeholder{% endblock %}
{% block preHeader %}
{{- include('@MauticCore/Helper/page_actions.html.twig', {
@@ -8,8 +8,8 @@
'templateButtons': {
'close': true,
},
'closeUrl': path('plan_stakeholder_index'),
'targetLabel': 'mautic.plan.stakeholder.header.index'|trans,
'closeUrl': path('initiative_stakeholder_index'),
'targetLabel': 'mautic.program.stakeholder.header.index'|trans,
}) -}}
{% endblock %}
@@ -18,9 +18,9 @@
{% 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,
label: (item.isPublished ? 'mautic.program.stakeholder.active' : 'mautic.program.stakeholder.inactive')|trans,
icon: item.isPublished ? 'ri-checkbox-circle-line' : 'ri-time-line',
attributes: {'class': 'plan-stakeholder-status-tag'},
attributes: {'class': 'initiative-stakeholder-status-tag'},
}] } %}
{% endblock %}
@@ -28,36 +28,36 @@
{{- 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),
'edit': securityHasEntityAccess(permissions['program:stakeholders:editown'], permissions['program:stakeholders:editother'], item.createdBy),
'delete': securityHasEntityAccess(permissions['program:stakeholders:deleteown'], permissions['program:stakeholders:deleteother'], item.createdBy),
},
'langVar': 'plan.stakeholder',
'langVar': 'initiative.stakeholder',
}) -}}
{% endblock %}
{% block content %}
<div class="pa-md">
<table class="table table-hover mb-md plan-stakeholder-details">
<table class="table table-hover mb-md initiative-stakeholder-details">
<tbody>
<tr>
<td class="col-md-3 text-muted">{{ 'mautic.plan.stakeholder.field.type'|trans }}</td>
<td class="col-md-3 text-muted">{{ 'mautic.program.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}) }}
{% set typeIcon = program_item_type_icon('stakeholder', item.type) %}
{% if typeIcon %}<i class="{{ typeIcon }} initiative-item-type-icon" style="font-size: 24px;" aria-hidden="true"></i> {% endif %}
{{ program_item_type_name('stakeholder', item.type) ?? 'mautic.program.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>
<td class="text-muted">{{ 'mautic.program.stakeholder.field.role'|trans }}</td>
<td>{{ item.role|default('mautic.program.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>
<td class="text-muted">{{ 'mautic.program.stakeholder.field.email'|trans }}</td>
<td>{% if item.email %}<a href="mailto:{{ item.email }}">{{ item.email }}</a>{% else %}{{ 'mautic.program.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>
<td class="text-muted">{{ 'mautic.program.stakeholder.field.phone'|trans }}</td>
<td>{% if item.phone %}<a href="tel:{{ item.phone|replace({' ': ''}) }}">{{ item.phone }}</a>{% else %}{{ 'mautic.program.value.none'|trans }}{% endif %}</td>
</tr>
<tr>
<td class="text-muted">{{ 'mautic.core.created'|trans }}</td>
@@ -70,25 +70,25 @@
</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>
<h4 class="mb-sm">{{ 'mautic.program.stakeholder.field.plans'|trans }}</h4>
{% if item.initiativeLinks is empty %}
<p class="text-muted">{{ 'mautic.program.stakeholder.no_plans'|trans }}</p>
{% else %}
<div class="table-responsive">
<table class="table table-hover plan-stakeholder-plans-view">
<table class="table table-hover initiative-stakeholder-initiatives-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>
<th>{{ 'mautic.program.field.name'|trans }}</th>
<th>{{ 'mautic.program.stakeholder.field.role_in_initiative'|trans }}</th>
<th>{{ 'mautic.program.field.status'|trans }}</th>
</tr>
</thead>
<tbody>
{% for link in item.planLinks %}
{% for link in item.initiativeLinks %}
<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>
<td><a href="{{ path('initiative_action', {'objectAction': 'view', 'objectId': link.initiative.id}) }}" data-toggle="ajax">{{ link.initiative.name }}</a></td>
<td class="text-muted">{{ link.roleInInitiative|default('—') }}</td>
<td><span class="label {{ link.initiative.status.labelClass }}">{{ link.initiative.status.labelKey|trans }}</span></td>
</tr>
{% endfor %}
</tbody>
+8 -8
View File
@@ -1,12 +1,12 @@
{% extends '@MauticCore/Default/content.html.twig' %}
{% block mauticContent %}planStakeholder{% endblock %}
{% block mauticContent %}programStakeholder{% endblock %}
{% block headerTitle %}
{% if entity.id %}
{{ 'mautic.plan.stakeholder.header.edit'|trans({'%name%': entity.name}) }}
{{ 'mautic.program.stakeholder.header.edit'|trans({'%name%': entity.name}) }}
{% else %}
{{ 'mautic.plan.stakeholder.header.new'|trans }}
{{ 'mautic.program.stakeholder.header.new'|trans }}
{% endif %}
{% endblock %}
@@ -17,14 +17,14 @@
<div class="pa-md">
{{ form_row(form.name) }}
<div class="row">
{# The selected type's pictogram; updated by plan.js when the type changes. #}
{# The selected type's pictogram; updated by program.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>
<i class="initiative-item-type-icon {{ program_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>
{# Filled with the selected type's description by program.js. #}
<p class="help-block initiative-item-type-help">{{ program_item_type_description('stakeholder', form.type.vars.value) }}</p>
</div>
</div>
{{ form_row(form.role) }}
@@ -35,7 +35,7 @@
{{ form_row(form.isPublished) }}
{{ form_row(form.email) }}
{{ form_row(form.phone) }}
<p class="text-muted small">{{ 'mautic.plan.stakeholder.phone.help'|trans }}</p>
<p class="text-muted small">{{ 'mautic.program.stakeholder.phone.help'|trans }}</p>
</div>
</div>
</div>
+54 -54
View File
@@ -2,9 +2,9 @@
{% set tmpl = 'list' %}
{% extends isIndex ? '@MauticCore/Default/content.html.twig' : '@MauticCore/Default/raw_output.html.twig' %}
{% block mauticContent %}planStakeholder{% endblock %}
{% block mauticContent %}programStakeholder{% endblock %}
{% block headerTitle %}{{ 'mautic.plan.stakeholder.header.index'|trans }}{% endblock %}
{% block headerTitle %}{{ 'mautic.program.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">
@@ -13,107 +13,107 @@
'action': currentRoute,
'page_actions': {
'templateButtons': {
'new': permissions['plan:stakeholders:create'],
'new': permissions['program:stakeholders:create'],
},
'langVar': 'plan.stakeholder',
'langVar': 'initiative.stakeholder',
},
'bulk_actions': {
'langVar': 'plan.stakeholder',
'langVar': 'initiative.stakeholder',
'templateButtons': {
'delete': permissions['plan:stakeholders:deleteown'] or permissions['plan:stakeholders:deleteother'],
'delete': permissions['program:stakeholders:deleteown'] or permissions['program: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">
<table class="table table-hover" id="programStakeholderTable">
<thead>
<tr>
{{ include('@MauticCore/Helper/tableheader.html.twig', {
'checkall': 'true',
'target': '#planStakeholderTable',
'target': '#programStakeholderTable',
}) }}
{# Columns: ID, Pictogram, Type, Name, Role, Email, Phone, Active, Assigned plans. #}
{# Columns: ID, Pictogram, Type, Name, Role, Email, Phone, Active, Assigned initiatives. #}
{{ include('@MauticCore/Helper/tableheader.html.twig', {
'sessionVar': 'plan.stakeholder',
'sessionVar': 'initiative.stakeholder',
'orderBy': 's.id',
'text': 'mautic.core.id',
'class': 'col-plan-stakeholder-id',
'class': 'col-initiative-stakeholder-id',
}) }}
{{ include('@MauticCore/Helper/tableheader.html.twig', {
'sessionVar': 'plan.stakeholder',
'text': 'mautic.plan.stakeholder.field.pictogram',
'class': 'col-plan-stakeholder-pictogram',
'sessionVar': 'initiative.stakeholder',
'text': 'mautic.program.stakeholder.field.pictogram',
'class': 'col-initiative-stakeholder-pictogram',
}) }}
{{ include('@MauticCore/Helper/tableheader.html.twig', {
'sessionVar': 'plan.stakeholder',
'sessionVar': 'initiative.stakeholder',
'orderBy': 's.type',
'text': 'mautic.plan.stakeholder.field.type',
'class': 'col-plan-stakeholder-type',
'text': 'mautic.program.stakeholder.field.type',
'class': 'col-initiative-stakeholder-type',
}) }}
{{ include('@MauticCore/Helper/tableheader.html.twig', {
'sessionVar': 'plan.stakeholder',
'sessionVar': 'initiative.stakeholder',
'orderBy': 's.name',
'text': 'mautic.plan.stakeholder.field.name',
'class': 'col-plan-stakeholder-name',
'text': 'mautic.program.stakeholder.field.name',
'class': 'col-initiative-stakeholder-name',
'default': true,
}) }}
{{ include('@MauticCore/Helper/tableheader.html.twig', {
'sessionVar': 'plan.stakeholder',
'sessionVar': 'initiative.stakeholder',
'orderBy': 's.role',
'text': 'mautic.plan.stakeholder.field.role',
'class': 'visible-md visible-lg col-plan-stakeholder-role',
'text': 'mautic.program.stakeholder.field.role',
'class': 'visible-md visible-lg col-initiative-stakeholder-role',
}) }}
{{ include('@MauticCore/Helper/tableheader.html.twig', {
'sessionVar': 'plan.stakeholder',
'sessionVar': 'initiative.stakeholder',
'orderBy': 's.email',
'text': 'mautic.plan.stakeholder.field.email',
'class': 'col-plan-stakeholder-email',
'text': 'mautic.program.stakeholder.field.email',
'class': 'col-initiative-stakeholder-email',
}) }}
{{ include('@MauticCore/Helper/tableheader.html.twig', {
'sessionVar': 'plan.stakeholder',
'text': 'mautic.plan.stakeholder.field.phone',
'class': 'col-plan-stakeholder-phone',
'sessionVar': 'initiative.stakeholder',
'text': 'mautic.program.stakeholder.field.phone',
'class': 'col-initiative-stakeholder-phone',
}) }}
{{ include('@MauticCore/Helper/tableheader.html.twig', {
'sessionVar': 'plan.stakeholder',
'sessionVar': 'initiative.stakeholder',
'orderBy': 's.isPublished',
'text': 'mautic.plan.stakeholder.field.active',
'class': 'col-plan-stakeholder-active',
'text': 'mautic.program.stakeholder.field.active',
'class': 'col-initiative-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',
'sessionVar': 'initiative.stakeholder',
'text': 'mautic.program.stakeholder.field.plans',
'class': 'visible-md visible-lg col-initiative-stakeholder-initiatives',
}) }}
</tr>
</thead>
<tbody>
{% for item in items %}
{% set canEdit = securityHasEntityAccess(permissions['plan:stakeholders:editown'], permissions['plan:stakeholders:editother'], item.createdBy) %}
{% set canEdit = securityHasEntityAccess(permissions['program:stakeholders:editown'], permissions['program: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),
'delete': securityHasEntityAccess(permissions['program:stakeholders:deleteown'], permissions['program:stakeholders:deleteother'], item.createdBy),
},
'langVar': 'plan.stakeholder',
'langVar': 'initiative.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 %}
{% set typeIcon = program_item_type_icon('stakeholder', item.type) %}
{% if typeIcon %}<i class="{{ typeIcon }} initiative-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{% if program_item_type_description('stakeholder', item.type) %} title="{{ program_item_type_description('stakeholder', item.type) }}"{% endif %}>
{{ program_item_type_name('stakeholder', item.type) ?? 'mautic.program.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>
<a href="{{ path('initiative_stakeholder_action', {'objectAction': 'edit', 'objectId': item.id}) }}" data-toggle="ajax">{{ item.name }}</a>
{% else %}
{{ item.name }}
{% endif %}
@@ -127,16 +127,16 @@
</td>
<td>
<span class="label {{ item.isPublished ? 'label-success' : 'label-gray' }}">
{{ (item.isPublished ? 'mautic.plan.stakeholder.active' : 'mautic.plan.stakeholder.inactive')|trans }}
{{ (item.isPublished ? 'mautic.program.stakeholder.active' : 'mautic.program.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 %}
{# The initiatives this stakeholder is assigned to, through their Stakeholders tab. #}
{% set initiatives = item.initiativeLinks|default([]) %}
{% for link in initiatives %}
<a href="{{ path('initiative_action', {'objectAction': 'view', 'objectId': link.initiative.id}) }}" data-toggle="ajax">{{ link.initiative.name }}</a>{% if link.roleInInitiative %} <span class="text-muted small">({{ link.roleInInitiative }})</span>{% endif %}{% if not loop.last %}, {% endif %}
{% else %}
<span class="text-muted">{{ 'mautic.plan.stakeholder.no_plans'|trans }}</span>
<span class="text-muted">{{ 'mautic.program.stakeholder.no_plans'|trans }}</span>
{% endfor %}
</td>
</tr>
@@ -148,8 +148,8 @@
'totalItems': totalItems,
'page': page,
'limit': limit,
'baseUrl': path('plan_stakeholder_index'),
'sessionVar': 'plan.stakeholder',
'baseUrl': path('initiative_stakeholder_index'),
'sessionVar': 'initiative.stakeholder',
}) -}}
</div>
</div>
@@ -158,9 +158,9 @@
{% 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',
'heading': 'mautic.program.stakeholder.onboarding.heading',
'subheading': 'mautic.program.stakeholder.onboarding.subheading',
'copy': 'mautic.program.stakeholder.onboarding.copy',
}) }}
</div>
{% endif %}
Loaded 100 of 121 files, more files were not shown because too many files have changed in this diff. Show more