diff --git a/Assets/js/plan.js b/Assets/js/program.js similarity index 62% rename from Assets/js/plan.js rename to Assets/js/program.js index 25934b6..f1aa32c 100644 --- a/Assets/js/plan.js +++ b/Assets/js/program.js @@ -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(' '); + $link.append(' '); 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); }); })(); diff --git a/Config/config.php b/Config/config.php index 7e382c1..eea2fbf 100644 --- a/Config/config.php +++ b/Config/config.php @@ -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' => [], ], ]; diff --git a/Config/services.php b/Config/services.php index 201d197..9107659 100644 --- a/Config/services.php +++ b/Config/services.php @@ -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); }; diff --git a/Controller/AudienceController.php b/Controller/AudienceController.php new file mode 100644 index 0000000..bf7ca14 --- /dev/null +++ b/Controller/AudienceController.php @@ -0,0 +1,96 @@ + 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); + } +} \ No newline at end of file diff --git a/Controller/PlanController.php b/Controller/InitiativeController.php similarity index 67% rename from Controller/PlanController.php rename to Controller/InitiativeController.php index 343e0f9..7acfe83 100644 --- a/Controller/PlanController.php +++ b/Controller/InitiativeController.php @@ -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 * ":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 $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; diff --git a/Controller/StakeholderController.php b/Controller/StakeholderController.php index d7cf9e6..d118c76 100644 --- a/Controller/StakeholderController.php +++ b/Controller/StakeholderController.php @@ -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'; } /** diff --git a/Controller/TaskController.php b/Controller/TaskController.php index bcc8bac..438e937 100644 --- a/Controller/TaskController.php +++ b/Controller/TaskController.php @@ -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 $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); diff --git a/Controller/UtmTaxonomyController.php b/Controller/UtmTaxonomyController.php new file mode 100644 index 0000000..7bbcd3d --- /dev/null +++ b/Controller/UtmTaxonomyController.php @@ -0,0 +1,39 @@ + 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), + ], + ]); + } +} diff --git a/DependencyInjection/PlanExtension.php b/DependencyInjection/ProgramExtension.php similarity index 85% rename from DependencyInjection/PlanExtension.php rename to DependencyInjection/ProgramExtension.php index 03acc13..fb6c750 100644 --- a/DependencyInjection/PlanExtension.php +++ b/DependencyInjection/ProgramExtension.php @@ -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 diff --git a/Entity/Audience.php b/Entity/Audience.php index 479cf9d..03f2f6d 100644 --- a/Entity/Audience.php +++ b/Entity/Audience.php @@ -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 + * 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|null + */ + private ?array $preferredTones = null; + + /** + * Keys of self::CHANNELS the initiative means to use for this audience. * * @var list|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 */ - private int $position = 0; + private Collection $stages; + + /** + * The Mautic segments this audience maps to; any number, or none. Purely informational. + * + * @var Collection + */ + 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 + */ + private Collection $initiativeLinks; public function __construct() { - $this->stages = new ArrayCollection(); + $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->id = null; + $this->stages = new ArrayCollection(); + $this->segments = new ArrayCollection(); + $this->initiativeLinks = new ArrayCollection(); + + parent::__clone(); } public static function loadMetadata(OrmClassMetadata $metadata): void @@ -105,75 +161,88 @@ 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, + 'fieldName' => $field, 'columnName' => $column, - 'type' => Types::TEXT, - 'nullable' => true, + 'type' => Types::TEXT, + 'nullable' => true, ]); } + // 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 + */ + 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|null + */ + public function getPreferredTones(): ?array + { + return $this->preferredTones; + } + + /** + * @param list|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 + */ + public function getInitiativeLinks(): Collection { - return $this->position; - } - - public function setPosition(?int $position): static - { - $this->position = $position ?? 0; - - return $this; + return $this->initiativeLinks; } } diff --git a/Entity/AudiencePriority.php b/Entity/AudiencePriority.php index c324b88..54629cc 100644 --- a/Entity/AudiencePriority.php +++ b/Entity/AudiencePriority.php @@ -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 diff --git a/Entity/AudienceRepository.php b/Entity/AudienceRepository.php index 050e987..f608097 100644 --- a/Entity/AudienceRepository.php +++ b/Entity/AudienceRepository.php @@ -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 + * @extends CommonRepository */ -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 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 $audienceIds + * + * @return array> 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; } } diff --git a/Entity/AudienceType.php b/Entity/AudienceType.php index 92ae46a..b8486fa 100644 --- a/Entity/AudienceType.php +++ b/Entity/AudienceType.php @@ -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 diff --git a/Entity/CountsItemsByTypeTrait.php b/Entity/CountsItemsByTypeTrait.php index 310e63c..7e8c102 100644 --- a/Entity/CountsItemsByTypeTrait.php +++ b/Entity/CountsItemsByTypeTrait.php @@ -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 { diff --git a/Entity/DateRangeInterface.php b/Entity/DateRangeInterface.php index d716293..27c5803 100644 --- a/Entity/DateRangeInterface.php +++ b/Entity/DateRangeInterface.php @@ -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. diff --git a/Entity/DependencyType.php b/Entity/DependencyType.php index a2da727..5263d62 100644 --- a/Entity/DependencyType.php +++ b/Entity/DependencyType.php @@ -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; } } diff --git a/Entity/Plan.php b/Entity/Initiative.php similarity index 75% rename from Entity/Plan.php rename to Entity/Initiative.php index a4b5faf..31cbaad 100644 --- a/Entity/Plan.php +++ b/Entity/Initiative.php @@ -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 + * @var Collection */ 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 + * @var Collection */ 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 + * @var Collection */ 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 + * @var Collection */ - 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 + * @var Collection */ 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 @@ -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 + * @return Collection */ 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 + * @return Collection */ - 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 + * @return Collection */ 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 + * @return Collection */ 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 + * @return Collection */ 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 $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); } diff --git a/Entity/PlanAllocationItem.php b/Entity/InitiativeAllocationItem.php similarity index 81% rename from Entity/PlanAllocationItem.php rename to Entity/InitiativeAllocationItem.php index fcb7125..e613e8d 100644 --- a/Entity/PlanAllocationItem.php +++ b/Entity/InitiativeAllocationItem.php @@ -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; } diff --git a/Entity/PlanAllocationItemRepository.php b/Entity/InitiativeAllocationItemRepository.php similarity index 55% rename from Entity/PlanAllocationItemRepository.php rename to Entity/InitiativeAllocationItemRepository.php index 2a05470..47d09fe 100644 --- a/Entity/PlanAllocationItemRepository.php +++ b/Entity/InitiativeAllocationItemRepository.php @@ -2,14 +2,14 @@ declare(strict_types=1); -namespace MauticPlugin\PlanBundle\Entity; +namespace MauticPlugin\ProgramBundle\Entity; use Mautic\CoreBundle\Entity\CommonRepository; /** - * @extends CommonRepository + * @extends CommonRepository */ -class PlanAllocationItemRepository extends CommonRepository +class InitiativeAllocationItemRepository extends CommonRepository { use CountsItemsByTypeTrait; diff --git a/Entity/InitiativeAudience.php b/Entity/InitiativeAudience.php new file mode 100644 index 0000000..418c7e4 --- /dev/null +++ b/Entity/InitiativeAudience.php @@ -0,0 +1,157 @@ +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; + } +} diff --git a/Entity/InitiativeAudienceRepository.php b/Entity/InitiativeAudienceRepository.php new file mode 100644 index 0000000..ff11611 --- /dev/null +++ b/Entity/InitiativeAudienceRepository.php @@ -0,0 +1,18 @@ + + */ +class InitiativeAudienceRepository extends CommonRepository +{ + public function getTableAlias(): string + { + return 'pa'; + } +} \ No newline at end of file diff --git a/Entity/PlanDescriptionItem.php b/Entity/InitiativeDescriptionItem.php similarity index 72% rename from Entity/PlanDescriptionItem.php rename to Entity/InitiativeDescriptionItem.php index 6ac8e56..c9c54d5 100644 --- a/Entity/PlanDescriptionItem.php +++ b/Entity/InitiativeDescriptionItem.php @@ -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; } diff --git a/Entity/PlanDescriptionItemRepository.php b/Entity/InitiativeDescriptionItemRepository.php similarity index 54% rename from Entity/PlanDescriptionItemRepository.php rename to Entity/InitiativeDescriptionItemRepository.php index a1941eb..78b1213 100644 --- a/Entity/PlanDescriptionItemRepository.php +++ b/Entity/InitiativeDescriptionItemRepository.php @@ -2,14 +2,14 @@ declare(strict_types=1); -namespace MauticPlugin\PlanBundle\Entity; +namespace MauticPlugin\ProgramBundle\Entity; use Mautic\CoreBundle\Entity\CommonRepository; /** - * @extends CommonRepository + * @extends CommonRepository */ -class PlanDescriptionItemRepository extends CommonRepository +class InitiativeDescriptionItemRepository extends CommonRepository { use CountsItemsByTypeTrait; diff --git a/Entity/PlanObjective.php b/Entity/InitiativeObjective.php similarity index 82% rename from Entity/PlanObjective.php rename to Entity/InitiativeObjective.php index 2958a52..fc309d1 100644 --- a/Entity/PlanObjective.php +++ b/Entity/InitiativeObjective.php @@ -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; } diff --git a/Entity/PlanObjectiveRepository.php b/Entity/InitiativeObjectiveRepository.php similarity index 56% rename from Entity/PlanObjectiveRepository.php rename to Entity/InitiativeObjectiveRepository.php index 28c43fa..0460466 100644 --- a/Entity/PlanObjectiveRepository.php +++ b/Entity/InitiativeObjectiveRepository.php @@ -2,14 +2,14 @@ declare(strict_types=1); -namespace MauticPlugin\PlanBundle\Entity; +namespace MauticPlugin\ProgramBundle\Entity; use Mautic\CoreBundle\Entity\CommonRepository; /** - * @extends CommonRepository + * @extends CommonRepository */ -class PlanObjectiveRepository extends CommonRepository +class InitiativeObjectiveRepository extends CommonRepository { use CountsItemsByTypeTrait; diff --git a/Entity/PlanRepository.php b/Entity/InitiativeRepository.php similarity index 89% rename from Entity/PlanRepository.php rename to Entity/InitiativeRepository.php index 3abf133..7b8914f 100644 --- a/Entity/PlanRepository.php +++ b/Entity/InitiativeRepository.php @@ -2,14 +2,14 @@ declare(strict_types=1); -namespace MauticPlugin\PlanBundle\Entity; +namespace MauticPlugin\ProgramBundle\Entity; use Mautic\CoreBundle\Entity\CommonRepository; /** - * @extends CommonRepository + * @extends CommonRepository */ -class PlanRepository extends CommonRepository +class InitiativeRepository extends CommonRepository { public function getTableAlias(): string { diff --git a/Entity/PlanStakeholder.php b/Entity/InitiativeStakeholder.php similarity index 66% rename from Entity/PlanStakeholder.php rename to Entity/InitiativeStakeholder.php index 31ddc21..6e41732 100644 --- a/Entity/PlanStakeholder.php +++ b/Entity/InitiativeStakeholder.php @@ -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; } diff --git a/Entity/PlanStakeholderRepository.php b/Entity/InitiativeStakeholderRepository.php similarity index 51% rename from Entity/PlanStakeholderRepository.php rename to Entity/InitiativeStakeholderRepository.php index fba2b08..7e4af58 100644 --- a/Entity/PlanStakeholderRepository.php +++ b/Entity/InitiativeStakeholderRepository.php @@ -2,14 +2,14 @@ declare(strict_types=1); -namespace MauticPlugin\PlanBundle\Entity; +namespace MauticPlugin\ProgramBundle\Entity; use Mautic\CoreBundle\Entity\CommonRepository; /** - * @extends CommonRepository + * @extends CommonRepository */ -class PlanStakeholderRepository extends CommonRepository +class InitiativeStakeholderRepository extends CommonRepository { public function getTableAlias(): string { diff --git a/Entity/InitiativeStatus.php b/Entity/InitiativeStatus.php new file mode 100644 index 0000000..697b8e4 --- /dev/null +++ b/Entity/InitiativeStatus.php @@ -0,0 +1,34 @@ +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', + }; + } +} diff --git a/Entity/PlanStatus.php b/Entity/PlanStatus.php deleted file mode 100644 index 6dea618..0000000 --- a/Entity/PlanStatus.php +++ /dev/null @@ -1,20 +0,0 @@ -value; - } -} diff --git a/Entity/RaciRole.php b/Entity/RaciRole.php index 0ad555f..1763751 100644 --- a/Entity/RaciRole.php +++ b/Entity/RaciRole.php @@ -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 diff --git a/Entity/Stakeholder.php b/Entity/Stakeholder.php index 079c75c..dd09199 100644 --- a/Entity/Stakeholder.php +++ b/Entity/Stakeholder.php @@ -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 + * @var Collection */ - 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 + * @return Collection */ - public function getPlanLinks(): Collection + public function getInitiativeLinks(): Collection { - return $this->planLinks; + return $this->initiativeLinks; } public function setType(?string $type): static diff --git a/Entity/StakeholderRepository.php b/Entity/StakeholderRepository.php index 3077561..0ef881d 100644 --- a/Entity/StakeholderRepository.php +++ b/Entity/StakeholderRepository.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace MauticPlugin\PlanBundle\Entity; +namespace MauticPlugin\ProgramBundle\Entity; use Mautic\CoreBundle\Entity\CommonRepository; diff --git a/Entity/Task.php b/Entity/Task.php index 78532ad..ce72054 100644 --- a/Entity/Task.php +++ b/Entity/Task.php @@ -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; } diff --git a/Entity/TaskDependency.php b/Entity/TaskDependency.php index 635f0c3..0244e54 100644 --- a/Entity/TaskDependency.php +++ b/Entity/TaskDependency.php @@ -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; diff --git a/Entity/TaskDependencyRepository.php b/Entity/TaskDependencyRepository.php index e091adf..550bd94 100644 --- a/Entity/TaskDependencyRepository.php +++ b/Entity/TaskDependencyRepository.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace MauticPlugin\PlanBundle\Entity; +namespace MauticPlugin\ProgramBundle\Entity; use Mautic\CoreBundle\Entity\CommonRepository; diff --git a/Entity/TaskKind.php b/Entity/TaskKind.php index e99f7f7..5b0d0c5 100644 --- a/Entity/TaskKind.php +++ b/Entity/TaskKind.php @@ -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; } /** diff --git a/Entity/TaskRaci.php b/Entity/TaskRaci.php index 62f1103..3f682d5 100644 --- a/Entity/TaskRaci.php +++ b/Entity/TaskRaci.php @@ -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; diff --git a/Entity/TaskRaciRepository.php b/Entity/TaskRaciRepository.php index 34029ee..960a9f9 100644 --- a/Entity/TaskRaciRepository.php +++ b/Entity/TaskRaciRepository.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace MauticPlugin\PlanBundle\Entity; +namespace MauticPlugin\ProgramBundle\Entity; use Mautic\CoreBundle\Entity\CommonRepository; diff --git a/Entity/TaskRepository.php b/Entity/TaskRepository.php index 21ba5f5..1ec0808 100644 --- a/Entity/TaskRepository.php +++ b/Entity/TaskRepository.php @@ -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 $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() diff --git a/Entity/TaskStatus.php b/Entity/TaskStatus.php index 62396a0..5e01b39 100644 --- a/Entity/TaskStatus.php +++ b/Entity/TaskStatus.php @@ -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; } /** diff --git a/EventListener/ConfigSubscriber.php b/EventListener/ConfigSubscriber.php index 7d0798b..13ab54f 100644 --- a/EventListener/ConfigSubscriber.php +++ b/EventListener/ConfigSubscriber.php @@ -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 diff --git a/EventListener/PluginInstallSubscriber.php b/EventListener/PluginInstallSubscriber.php index 6f2798e..dc4ddac 100644 --- a/EventListener/PluginInstallSubscriber.php +++ b/EventListener/PluginInstallSubscriber.php @@ -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, diff --git a/Form/Type/AudienceType.php b/Form/Type/AudienceType.php new file mode 100644 index 0000000..adfd3f4 --- /dev/null +++ b/Form/Type/AudienceType.php @@ -0,0 +1,213 @@ + 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 + */ +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'; + } +} \ No newline at end of file diff --git a/Form/Type/ConfigType.php b/Form/Type/ConfigType.php index 835322a..00f6c86 100644 --- a/Form/Type/ConfigType.php +++ b/Form/Type/ConfigType.php @@ -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> */ 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 diff --git a/Form/Type/PlanAllocationItemType.php b/Form/Type/InitiativeAllocationItemType.php similarity index 68% rename from Form/Type/PlanAllocationItemType.php rename to Form/Type/InitiativeAllocationItemType.php index a901bab..2354c0d 100644 --- a/Form/Type/PlanAllocationItemType.php +++ b/Form/Type/InitiativeAllocationItemType.php @@ -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 + * @extends AbstractType */ -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'; } } diff --git a/Form/Type/InitiativeAudienceType.php b/Form/Type/InitiativeAudienceType.php new file mode 100644 index 0000000..dde973f --- /dev/null +++ b/Form/Type/InitiativeAudienceType.php @@ -0,0 +1,76 @@ + + */ +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'; + } +} \ No newline at end of file diff --git a/Form/Type/PlanDescriptionItemType.php b/Form/Type/InitiativeDescriptionItemType.php similarity index 63% rename from Form/Type/PlanDescriptionItemType.php rename to Form/Type/InitiativeDescriptionItemType.php index 40c9176..db80e7e 100644 --- a/Form/Type/PlanDescriptionItemType.php +++ b/Form/Type/InitiativeDescriptionItemType.php @@ -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 + * @extends AbstractType */ -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'; } } diff --git a/Form/Type/PlanObjectiveType.php b/Form/Type/InitiativeObjectiveType.php similarity index 65% rename from Form/Type/PlanObjectiveType.php rename to Form/Type/InitiativeObjectiveType.php index d9939f4..af7c3b6 100644 --- a/Form/Type/PlanObjectiveType.php +++ b/Form/Type/InitiativeObjectiveType.php @@ -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 + * @extends AbstractType */ -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'; } } diff --git a/Form/Type/PlanStakeholderType.php b/Form/Type/InitiativeStakeholderType.php similarity index 67% rename from Form/Type/PlanStakeholderType.php rename to Form/Type/InitiativeStakeholderType.php index 12abf3e..fb98ddb 100644 --- a/Form/Type/PlanStakeholderType.php +++ b/Form/Type/InitiativeStakeholderType.php @@ -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 + * @extends AbstractType */ -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'; } } diff --git a/Form/Type/PlanType.php b/Form/Type/InitiativeType.php similarity index 68% rename from Form/Type/PlanType.php rename to Form/Type/InitiativeType.php index cd1db56..41268c5 100644 --- a/Form/Type/PlanType.php +++ b/Form/Type/InitiativeType.php @@ -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 + * @extends AbstractType */ -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, + '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'; } } diff --git a/Form/Type/ItemTypeConfigType.php b/Form/Type/ItemTypeConfigType.php index 3faf6ae..c79529f 100644 --- a/Form/Type/ItemTypeConfigType.php +++ b/Form/Type/ItemTypeConfigType.php @@ -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'; } } diff --git a/Form/Type/StakeholderType.php b/Form/Type/StakeholderType.php index 38627e2..6d41935 100644 --- a/Form/Type/StakeholderType.php +++ b/Form/Type/StakeholderType.php @@ -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 */ @@ -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'; } } diff --git a/Form/Type/TargetType.php b/Form/Type/TargetType.php deleted file mode 100644 index f7f6379..0000000 --- a/Form/Type/TargetType.php +++ /dev/null @@ -1,126 +0,0 @@ - - */ -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'; - } -} diff --git a/Form/Type/TaskDependencyType.php b/Form/Type/TaskDependencyType.php index 1a49159..05be56c 100644 --- a/Form/Type/TaskDependencyType.php +++ b/Form/Type/TaskDependencyType.php @@ -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 @@ -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'; } } diff --git a/Form/Type/TaskRaciType.php b/Form/Type/TaskRaciType.php index 676c1b3..2f7756d 100644 --- a/Form/Type/TaskRaciType.php +++ b/Form/Type/TaskRaciType.php @@ -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 */ @@ -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'; } } diff --git a/Form/Type/TaskType.php b/Form/Type/TaskType.php index 0cd19b0..79c7303 100644 --- a/Form/Type/TaskType.php +++ b/Form/Type/TaskType.php @@ -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'; } } diff --git a/Integration/PlanIntegration.php b/Integration/ProgramIntegration.php similarity index 63% rename from Integration/PlanIntegration.php rename to Integration/ProgramIntegration.php index 0ab36ce..9c750a1 100644 --- a/Integration/PlanIntegration.php +++ b/Integration/ProgramIntegration.php @@ -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'; } } diff --git a/Integration/Support/ConfigSupport.php b/Integration/Support/ProgramConfigSupport.php similarity index 50% rename from Integration/Support/ConfigSupport.php rename to Integration/Support/ProgramConfigSupport.php index 952f60b..531f0d6 100644 --- a/Integration/Support/ConfigSupport.php +++ b/Integration/Support/ProgramConfigSupport.php @@ -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; } diff --git a/Migrations/Version_0_10_0.php b/Migrations/Version_0_10_0.php index d0c55e7..adaf369 100644 --- a/Migrations/Version_0_10_0.php +++ b/Migrations/Version_0_10_0.php @@ -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)) { - return false; - } - - return !$schema->getTable($objectives)->hasColumn('type'); + // 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 { - $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)); } } } diff --git a/Migrations/Version_0_10_1.php b/Migrations/Version_0_10_1.php index 2771dfa..95d9bd8 100644 --- a/Migrations/Version_0_10_1.php +++ b/Migrations/Version_0_10_1.php @@ -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)) { - return false; - } - - return !$schema->getTable($objectives)->hasColumn('priority'); + // 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 { - $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 )); } } diff --git a/Migrations/Version_0_11_0.php b/Migrations/Version_0_11_0.php index d16d7b9..fdcd460 100644 --- a/Migrations/Version_0_11_0.php +++ b/Migrations/Version_0_11_0.php @@ -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))) { - 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); + // 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(); - 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; } diff --git a/Migrations/Version_0_12_0.php b/Migrations/Version_0_12_0.php index 29fb880..67673a8 100644 --- a/Migrations/Version_0_12_0.php +++ b/Migrations/Version_0_12_0.php @@ -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,16 +22,11 @@ class Version_0_12_0 extends AbstractMigration { protected function isApplicable(Schema $schema): bool { - if (!$schema->hasTable($this->concatPrefix(Plan::TABLE_NAME))) { - return false; - } - - if (!$schema->hasTable($this->concatPrefix(Stakeholder::TABLE_NAME)) - || !$schema->hasTable($this->concatPrefix(PlanStakeholder::TABLE_NAME))) { - return true; - } - - return !$this->hasForeignKeys($schema); + // 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 @@ -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; diff --git a/Migrations/Version_0_13_0.php b/Migrations/Version_0_13_0.php index ecd0ddb..8dda520 100644 --- a/Migrations/Version_0_13_0.php +++ b/Migrations/Version_0_13_0.php @@ -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,21 +26,11 @@ class Version_0_13_0 extends AbstractMigration { protected function isApplicable(Schema $schema): bool { - $tasks = $this->concatPrefix(Task::TABLE_NAME); - - if (!$schema->hasTable($tasks)) { - return false; - } - - $table = $schema->getTable($tasks); - - return !$table->hasColumn('task_kind') - || !$table->hasColumn('definition_of_done') - || !$table->hasColumn('planned_work') - || $table->hasColumn('parent_id') - || !$schema->hasTable($this->concatPrefix(TaskDependency::TABLE_NAME)) - || !$schema->hasTable($this->concatPrefix(TaskRaci::TABLE_NAME)) - || !$schema->hasTable($this->concatPrefix(TaskRaci::JOIN_TABLE_NAME)); + // 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 @@ -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 * diff --git a/Migrations/Version_0_14_0.php b/Migrations/Version_0_14_0.php new file mode 100644 index 0000000..9e12e88 --- /dev/null +++ b/Migrations/Version_0_14_0.php @@ -0,0 +1,207 @@ + 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; + } +} \ No newline at end of file diff --git a/Migrations/Version_0_15_0.php b/Migrations/Version_0_15_0.php new file mode 100644 index 0000000..968c76b --- /dev/null +++ b/Migrations/Version_0_15_0.php @@ -0,0 +1,263 @@ +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 $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 $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 $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 + )); + } +} diff --git a/Migrations/Version_0_16_0.php b/Migrations/Version_0_16_0.php new file mode 100644 index 0000000..d7762fa --- /dev/null +++ b/Migrations/Version_0_16_0.php @@ -0,0 +1,160 @@ + 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 $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 $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; + } +} diff --git a/Migrations/Version_0_2_0.php b/Migrations/Version_0_2_0.php index f5b0c9c..541145e 100644 --- a/Migrations/Version_0_2_0.php +++ b/Migrations/Version_0_2_0.php @@ -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,13 +31,11 @@ class Version_0_2_0 extends AbstractMigration protected function isApplicable(Schema $schema): bool { - $table = $this->getTable($schema); - - if (null === $table) { - return false; - } - - return [] !== $this->getMissingForeignKeys($table) || $this->statusNeedsResize($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; } protected function up(): void @@ -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; } diff --git a/Migrations/Version_0_3_0.php b/Migrations/Version_0_3_0.php index cafa4a0..f0116e7 100644 --- a/Migrations/Version_0_3_0.php +++ b/Migrations/Version_0_3_0.php @@ -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)) { - return false; - } - - return !$schema->getTable($plans)->hasColumn('version') - || !$schema->hasTable($this->concatPrefix(PlanObjective::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; } 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, diff --git a/Migrations/Version_0_4_0.php b/Migrations/Version_0_4_0.php index 5100606..d3e4230 100644 --- a/Migrations/Version_0_4_0.php +++ b/Migrations/Version_0_4_0.php @@ -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,20 +31,16 @@ 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))) { - return false; - } - - $tasks = $this->concatPrefix(Task::TABLE_NAME); - - $table = $schema->hasTable($tasks) ? $schema->getTable($tasks) : null; - - return null === $table || [] !== $this->getMissingForeignKeys($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; } protected function up(): void diff --git a/Migrations/Version_0_5_0.php b/Migrations/Version_0_5_0.php index 9378ede..1d257b9 100644 --- a/Migrations/Version_0_5_0.php +++ b/Migrations/Version_0_5_0.php @@ -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,18 +19,11 @@ class Version_0_5_0 extends AbstractMigration protected function isApplicable(Schema $schema): bool { - $tasks = $this->concatPrefix(Task::TABLE_NAME); - - if (!$schema->hasTable($tasks)) { - return false; - } - - $table = $schema->getTable($tasks); - - return !$table->hasColumn('start_date') - || !$table->hasColumn('end_date') - || !$table->hasColumn('status') - || !$table->hasIndex(self::STATUS_INDEX); + // 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 diff --git a/Migrations/Version_0_6_0.php b/Migrations/Version_0_6_0.php index 72db35e..e06111a 100644 --- a/Migrations/Version_0_6_0.php +++ b/Migrations/Version_0_6_0.php @@ -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)) { - return false; - } - - $items = $this->concatPrefix(PlanDescriptionItem::TABLE_NAME); - - return !$schema->hasTable($items) - || !$this->hasPlanForeignKey($schema) - || $schema->getTable($plans)->hasColumn('description'); + // 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(); - $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.'.'); } } diff --git a/Migrations/Version_0_7_0.php b/Migrations/Version_0_7_0.php index 5ee3ed6..a4793c2 100644 --- a/Migrations/Version_0_7_0.php +++ b/Migrations/Version_0_7_0.php @@ -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))) { - return false; - } - - return !$schema->hasTable($this->concatPrefix(PlanAllocationItem::TABLE_NAME)) || !$this->hasPlanForeignKey($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 { $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.'.'); } } diff --git a/Migrations/Version_0_8_0.php b/Migrations/Version_0_8_0.php index 01a3dec..3a09413 100644 --- a/Migrations/Version_0_8_0.php +++ b/Migrations/Version_0_8_0.php @@ -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 diff --git a/Migrations/Version_0_9_0.php b/Migrations/Version_0_9_0.php index 95f5723..e975198 100644 --- a/Migrations/Version_0_9_0.php +++ b/Migrations/Version_0_9_0.php @@ -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,13 +18,11 @@ class Version_0_9_0 extends AbstractMigration { protected function isApplicable(Schema $schema): bool { - $tasks = $this->concatPrefix(Task::TABLE_NAME); - - if (!$schema->hasTable($tasks)) { - return false; - } - - return !$schema->getTable($tasks)->hasColumn('type'); + // 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 diff --git a/Model/AudienceModel.php b/Model/AudienceModel.php new file mode 100644 index 0000000..e8e3934 --- /dev/null +++ b/Model/AudienceModel.php @@ -0,0 +1,63 @@ + 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 $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); + } +} \ No newline at end of file diff --git a/Model/InitiativeModel.php b/Model/InitiativeModel.php new file mode 100644 index 0000000..5f6a764 --- /dev/null +++ b/Model/InitiativeModel.php @@ -0,0 +1,77 @@ + + */ +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 $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); + } +} diff --git a/Model/PlanModel.php b/Model/PlanModel.php deleted file mode 100644 index 79b8c1e..0000000 --- a/Model/PlanModel.php +++ /dev/null @@ -1,77 +0,0 @@ - - */ -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 $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); - } -} diff --git a/Model/StakeholderModel.php b/Model/StakeholderModel.php index 9d5f8cc..4413db8 100644 --- a/Model/StakeholderModel.php +++ b/Model/StakeholderModel.php @@ -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 diff --git a/Model/TaskModel.php b/Model/TaskModel.php index 6612c4b..3195257 100644 --- a/Model/TaskModel.php +++ b/Model/TaskModel.php @@ -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 */ @@ -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 */ - 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]; } diff --git a/PlanBundle.php b/ProgramBundle.php similarity index 52% rename from PlanBundle.php rename to ProgramBundle.php index 210fded..699199d 100644 --- a/PlanBundle.php +++ b/ProgramBundle.php @@ -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 { } diff --git a/Resources/views/Audience/details.html.twig b/Resources/views/Audience/details.html.twig new file mode 100644 index 0000000..98234fe --- /dev/null +++ b/Resources/views/Audience/details.html.twig @@ -0,0 +1,164 @@ +{% extends '@MauticCore/Default/content.html.twig' %} + +{% block mauticContent %}programAudience{% endblock %} + +{% block preHeader %} +
+ {{ 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', + }) }} +
+{% endblock %} + +{% block headerTitle %}{{ item.name }}{% endblock %} + +{% block publishStatus %} +
+ + {{ (item.isPublished ? 'mautic.program.audience.active' : 'mautic.program.audience.inactive')|trans }} + +
+{% endblock %} + +{% block content %} +
+ + + + + + + {% if item.segments is not empty %} + + + + + {% endif %} + {% if item.tagline %} + + + + + {% endif %} + {% if item.profileCriteria %} + + + + + {% endif %} + {% if item.motivations %} + + + + + {% endif %} + {% if item.barriers %} + + + + + {% endif %} + {% if item.frustrations %} + + + + + {% endif %} + {% if item.triggers %} + + + + + {% endif %} + {% if item.decisionRole %} + + + + + {% endif %} + {% if item.preferredTones is not empty %} + + + + + {% endif %} + {% if item.preferredChannels is not empty %} + + + + + {% endif %} + {% if item.stages is not empty %} + + + + + {% endif %} + {% if item.estimatedSize %} + + + + + {% endif %} + + + + + + + + + +
{{ 'mautic.program.audience.field.type'|trans }} + + {{ item.audienceType.labelKey|trans }} +
{{ 'mautic.program.audience.field.segments'|trans }} + {% for segment in item.segments %} + {{ segment.name }} ({{ program_audience_segment_count(segment.id) }}){% if not loop.last %} {% endif %} + {% endfor %} +
{{ 'mautic.program.audience.field.tagline'|trans }}{{ item.tagline|program_linkify }}
{{ 'mautic.program.audience.field.profile_criteria'|trans }}{{ item.profileCriteria|program_linkify }}
{{ 'mautic.program.audience.field.motivations'|trans }}{{ item.motivations|program_linkify }}
{{ 'mautic.program.audience.field.barriers'|trans }}{{ item.barriers|program_linkify }}
{{ 'mautic.program.audience.field.frustrations'|trans }}{{ item.frustrations|program_linkify }}
{{ 'mautic.program.audience.field.triggers'|trans }}{{ item.triggers|program_linkify }}
{{ 'mautic.program.audience.field.decision_role'|trans }}{{ program_audience_decision_role_label(item.decisionRole) ?? item.decisionRole }}
{{ 'mautic.program.audience.field.preferred_tones'|trans }} + {% for tone in item.preferredTones %} + {{ program_audience_tone_label(tone) ?? tone }} + {% endfor %} +
{{ 'mautic.program.audience.field.preferred_channels'|trans }} + {% for channel in item.preferredChannels %} + {{ program_audience_channel_label(channel)|trans }} + {% endfor %} +
{{ 'mautic.program.audience.field.stages'|trans }}{{ item.stages|map(stage => stage.name)|join(', ') }}
{{ 'mautic.program.audience.field.estimated_size'|trans }}{{ item.estimatedSize }}
{{ 'mautic.core.created'|trans }}{{ item.dateAdded ? dateToFull(item.dateAdded) : '' }}{% if item.createdByUser %} ({{ item.createdByUser }}){% endif %}
{{ 'mautic.core.id'|trans }}{{ item.id }}
+ +

{{ 'mautic.program.audience.field.plans'|trans }}

+ {% if item.initiativeLinks is empty %} +

{{ 'mautic.program.audience.no_plans'|trans }}

+ {% else %} +
+ + + + + + + + + + + {% for link in item.initiativeLinks %} + + + + + + + {% endfor %} + +
{{ 'mautic.program.field.name'|trans }}{{ 'mautic.program.audience.field.priority'|trans }}{{ 'mautic.program.audience.field.value_proposition'|trans }}{{ 'mautic.program.field.status'|trans }}
{{ link.initiative.name }}{{ link.priority.labelKey|trans }}{{ link.valueProposition|default('—') }}{{ link.initiative.status.labelKey|trans }}
+
+ {% endif %} +
+{% endblock %} \ No newline at end of file diff --git a/Resources/views/Audience/form.html.twig b/Resources/views/Audience/form.html.twig new file mode 100644 index 0000000..028adbf --- /dev/null +++ b/Resources/views/Audience/form.html.twig @@ -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) }} +
+
+
+ {{ form_row(form.name) }} +
+ {# The selected type's pictogram, fixed per type; programAudienceOnLoad updates it + when the dropdown changes. A new form defaults to Persona. #} +
+ +
+
+ {{ form_row(form.audienceType) }} +

{{ 'mautic.program.audience.type.fixed_note'|trans }}

+
+
+ {{ form_row(form.segments) }} +

{{ 'mautic.program.audience.segments.note'|trans }}

+ {% 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 %} +
+
+
+
+ {{ form_row(form.isPublished) }} +

{{ 'mautic.program.audience.active.help'|trans }}

+
+
+
+ {{ form_end(form) }} +{% endblock %} \ No newline at end of file diff --git a/Resources/views/Audience/list.html.twig b/Resources/views/Audience/list.html.twig new file mode 100644 index 0000000..ea72820 --- /dev/null +++ b/Resources/views/Audience/list.html.twig @@ -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) %} +
+ {{- 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'], + }, + }, + }) -}} +
+ {% if items is defined and items is not empty %} +
+ + + + {{ 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', + }) }} + + + + {% for item in items %} + {% set canEdit = securityHasEntityAccess(permissions['program:audiences:editown'], permissions['program:audiences:editother'], item.createdBy) %} + + + + + + + + + + + + {% endfor %} + +
+ {{- 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', + }) -}} + {{ item.id }} + + {{ item.audienceType.labelKey|trans }} + {% if canEdit %} + {% if item.tagline %}{{ item.name }} — {{ item.tagline }}{% else %}{{ item.name }}{% endif %} + {% else %} + {{ item.name }}{% if item.tagline %} — {{ item.tagline }}{% endif %} + {% endif %} + + {# 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 %} + {{ segment.name }} ({{ counts[segment.id] ?? 0 }}){% if not loop.last %} {% endif %} + {% else %} + — + {% endfor %} + {{ item.estimatedSize }} + + {{ (item.isPublished ? 'mautic.program.audience.active' : 'mautic.program.audience.inactive')|trans }} + + + {# The initiatives this audience is assigned to, through their Audiences tab. #} + {% set links = item.initiativeLinks|default([]) %} + {% for link in links %} + {{ link.initiative.name }}{% if link.valueProposition %} ({{ link.valueProposition }}){% endif %}{% if not loop.last %}, {% endif %} + {% else %} + {{ 'mautic.program.audience.no_plans'|trans }} + {% endfor %} +
+ +
+ {% elseif searchValue is not empty %} + {{ include('@MauticCore/Helper/noresults.html.twig') }} + {% else %} +
+ {{ 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', + }) }} +
+ {% endif %} +
+
+{% endblock %} \ No newline at end of file diff --git a/Resources/views/FormTheme/Config/_config_planconfig_widget.html.twig b/Resources/views/FormTheme/Config/_config_planconfig_widget.html.twig deleted file mode 100644 index 4a9372f..0000000 --- a/Resources/views/FormTheme/Config/_config_planconfig_widget.html.twig +++ /dev/null @@ -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) %} -
-
- {{ form_widget(type.children.key) }} - {{ form_errors(type) }} - {% if type.children.icon is defined %} - {% set icon = type.children.icon.vars.value %} -
-
- -
-
{{ form_row(type.children.icon) }}
-
- {% endif %} - - - - - - - - - - {% for locale, name in type.children.names.children %} - - - - - - {% endfor %} - -
{{ 'mautic.plan.config.type.language'|trans }}{{ 'mautic.plan.config.type.name'|trans }}{{ 'mautic.plan.config.type.description'|trans }}
- {{ name.vars.attr['data-language'] }} - {% if name.vars.required %}*{% endif %} - - {{ form_widget(name) }} - {{ form_errors(name) }} - - {{ form_widget(type.children.descriptions.children[locale]) }} - {{ form_errors(type.children.descriptions.children[locale]) }} -
-
- -
-
-
-{% endmacro %} - -{# One editable list of types (one per kind of plan item). #} -{% macro type_section(types, titleKey, helpKey) %} - {% import _self as plan %} -

{{ titleKey|trans }}

-

{{ helpKey|trans }}

- {{ form_errors(types) }} -
-

- {{ 'mautic.plan.config.types.empty'|trans }} -

-
- {% for type in types %} - {{ plan.type_row(type) }} - {% endfor %} -
- -
- {% do types.setRendered %} -{% endmacro %} - -{% block _config_planconfig_widget %} -{% import _self as plan %} -
{{ 'mautic.plan.config.description'|trans }}
- -

{{ 'mautic.plan.config.section.general'|trans }}

-
-
{{ form_row(form.children.plan_currency) }}
-
{{ form_row(form.children.plan_stakeholder_phone_region) }}
-
-

{{ 'mautic.plan.config.currency.help'|trans }}

- -{{ 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 %} diff --git a/Resources/views/FormTheme/Config/_config_programconfig_widget.html.twig b/Resources/views/FormTheme/Config/_config_programconfig_widget.html.twig new file mode 100644 index 0000000..c23cac4 --- /dev/null +++ b/Resources/views/FormTheme/Config/_config_programconfig_widget.html.twig @@ -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) %} +
+
+ {{ form_widget(type.children.key) }} + {{ form_errors(type) }} + {% if type.children.icon is defined %} + {% set icon = type.children.icon.vars.value %} +
+
+ +
+
{{ form_row(type.children.icon) }}
+
+ {% endif %} + + + + + + + + + + {% for locale, name in type.children.names.children %} + + + + + + {% endfor %} + +
{{ 'mautic.program.config.type.language'|trans }}{{ 'mautic.program.config.type.name'|trans }}{{ 'mautic.program.config.type.description'|trans }}
+ {{ name.vars.attr['data-language'] }} + {% if name.vars.required %}*{% endif %} + + {{ form_widget(name) }} + {{ form_errors(name) }} + + {{ form_widget(type.children.descriptions.children[locale]) }} + {{ form_errors(type.children.descriptions.children[locale]) }} +
+
+ +
+
+
+{% endmacro %} + +{# One editable list of types (one per kind of initiative item). #} +{% macro type_section(types, titleKey, helpKey) %} + {% import _self as cfg %} +

{{ titleKey|trans }}

+

{{ helpKey|trans }}

+ {{ form_errors(types) }} +
+

+ {{ 'mautic.program.config.types.empty'|trans }} +

+
+ {% for type in types %} + {{ cfg.type_row(type) }} + {% endfor %} +
+ +
+ {% do types.setRendered %} +{% endmacro %} + +{% block _config_programconfig_widget %} +{% import _self as cfg %} +
{{ 'mautic.program.config.description'|trans }}
+ +

{{ 'mautic.program.config.section.general'|trans }}

+
+
{{ form_row(form.children.program_currency) }}
+
{{ form_row(form.children.program_stakeholder_phone_region) }}
+
+

{{ 'mautic.program.config.currency.help'|trans }}

+ +{{ 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') }} + +

{{ 'mautic.program.config.section.audience_values'|trans }}

+

{{ 'mautic.program.config.section.audience_values.help'|trans }}

+{{ 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') }} + +

{{ 'mautic.program.config.section.audience_attributes'|trans }}

+

{{ 'mautic.program.config.section.audience_attributes.help'|trans }}

+
+ {% for attribute in program_audience_attributes() %} + {{ form_row(form.children[program_audience_attribute_toggle(attribute)]) }} + {% endfor %} +
+{% endblock %} diff --git a/Resources/views/Plan/_description_read_more.html.twig b/Resources/views/Initiative/_description_read_more.html.twig similarity index 53% rename from Resources/views/Plan/_description_read_more.html.twig rename to Resources/views/Initiative/_description_read_more.html.twig index eb43f70..1970c4b 100644 --- a/Resources/views/Plan/_description_read_more.html.twig +++ b/Resources/views/Initiative/_description_read_more.html.twig @@ -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 %} -
-
{{ text|plan_linkify }}
-
{% endif %} diff --git a/Resources/views/Initiative/_tab_table_filter.html.twig b/Resources/views/Initiative/_tab_table_filter.html.twig new file mode 100644 index 0000000..d4d6459 --- /dev/null +++ b/Resources/views/Initiative/_tab_table_filter.html.twig @@ -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. + #} +
+ + +
+

{{ 'mautic.program.filter.no_match'|trans }}

diff --git a/Resources/views/Initiative/_tabs.html.twig b/Resources/views/Initiative/_tabs.html.twig new file mode 100644 index 0000000..5ae5dbe --- /dev/null +++ b/Resources/views/Initiative/_tabs.html.twig @@ -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-. 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', +} %} + diff --git a/Resources/views/Initiative/_task_table.html.twig b/Resources/views/Initiative/_task_table.html.twig new file mode 100644 index 0000000..0315389 --- /dev/null +++ b/Resources/views/Initiative/_task_table.html.twig @@ -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 %} + +{% endif %} + +{% if not initiative.id %} +

{{ 'mautic.program.task.save_initiative_first'|trans }}

+{% elseif taskTree is empty %} +

{{ 'mautic.program.task.empty'|trans }}

+{% 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 %} +
+ + + + + + + + + + + + + + {% 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) %} + + + + + + + + + + {% endfor %} + +
{{ 'mautic.program.task.field.type'|trans }}{{ 'mautic.program.task.field.name'|trans }}{{ 'mautic.program.task.field.description'|trans }}{{ 'mautic.program.task.field.start_date'|trans }}{{ 'mautic.program.task.field.end_date'|trans }}{{ 'mautic.program.task.field.status'|trans }}
+ {% set taskTypeIcon = program_item_type_icon('task', task.type) %} + {% if taskTypeIcon %}{% endif %} + + {{ program_item_type_name('task', task.type) ?? 'mautic.program.description_item.type.unknown'|trans({'%key%': task.type}) }} + + {% if canEdit %} + {{ task.name }} + {% else %} + {{ task.name }} + {% endif %} + {% if task.taskKind == constant('MauticPlugin\\ProgramBundle\\Entity\\TaskKind::Milestone') %} + {{ 'mautic.program.task.kind.milestone_short'|trans }} + {% elseif task.taskKind == constant('MauticPlugin\\ProgramBundle\\Entity\\TaskKind::Phase') %} + {{ 'mautic.program.task.kind.phase_short'|trans }} + {% endif %} + + {# 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, + }) }} + {{ task.startDate ? task.startDate|date('Y-m-d') : '' }}{{ task.endDate ? task.endDate|date('Y-m-d') : '' }} + {# A phase has no status of its own — skip the column value. #} + {% if task.taskKind != constant('MauticPlugin\\ProgramBundle\\Entity\\TaskKind::Phase') %} + {{ task.status.labelKey|trans }} + {% endif %} +
+
+{% endif %} diff --git a/Resources/views/Initiative/details.html.twig b/Resources/views/Initiative/details.html.twig new file mode 100644 index 0000000..7c04f5a --- /dev/null +++ b/Resources/views/Initiative/details.html.twig @@ -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 %} +
+ {% 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, + }}) }} + +
+ {# Details #} +
+ + + + + + + {% if item.completedAt %} + + + + + {% endif %} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + {% if item.dateModified %} + + + + + {% endif %} + + + + + +
{{ 'mautic.program.field.status'|trans }}{{ item.status.labelKey|trans }}
{{ 'mautic.program.field.completed_at'|trans }}{{ dateToFull(item.completedAt) }}
{{ 'mautic.program.field.version'|trans }}{{ item.version }}
{{ 'mautic.program.field.owner'|trans }}{{ item.owner ? item.owner.name : 'mautic.program.owner.none'|trans }}
{{ 'mautic.program.field.start_date'|trans }}{{ item.startDate ? dateToFull(item.startDate) : 'mautic.program.value.none'|trans }}
{{ 'mautic.program.field.end_date'|trans }}{{ item.endDate ? dateToFull(item.endDate) : 'mautic.program.value.none'|trans }}
{{ 'mautic.core.category'|trans }}{{ item.category ? item.category.title : 'mautic.program.value.none'|trans }}
{{ 'mautic.core.form.available'|trans }}{{ (item.isPublished ? 'mautic.core.form.yes' : 'mautic.core.form.no')|trans }}
{{ 'mautic.core.created'|trans }}{{ item.dateAdded ? dateToFull(item.dateAdded) : '' }}{% if item.createdByUser %} ({{ item.createdByUser }}){% endif %}
{{ 'mautic.core.modified'|trans }}{{ dateToFull(item.dateModified) }}{% if item.modifiedByUser %} ({{ item.modifiedByUser }}){% endif %}
{{ 'mautic.core.id'|trans }}{{ item.id }}
+
+ + {# Description #} +
+ {% if descriptionItems is empty %} +

{{ 'mautic.program.description_item.empty'|trans }}

+ {% 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') }} +
+ + + + + + + + + + {% 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) %} + + + + + + {% endfor %} + +
{{ 'mautic.program.description_item.field.type'|trans }}{{ 'mautic.program.description_item.field.description'|trans }}
+ {% if typeIcon %}{% endif %} + + {{ typeName ?? 'mautic.program.description_item.type.unknown'|trans({'%key%': descriptionItem.type}) }} + + {{ include('@Program/Initiative/_description_read_more.html.twig', { + 'text': descriptionItem.description, + 'id': 'initiative-desc-item-' ~ descriptionItem.id, + }) }} +
+
+ {% endif %} +
+ + {# Objectives #} +
+ {% if objectives is empty %} +

{{ 'mautic.program.objective.empty'|trans }}

+ {% else %} +

+ {{ 'mautic.program.objective.progress'|trans({'%achieved%': achievedCount, '%total%': objectives|length}) }} +

+ {# 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') }} +
+ + + + + + + + + + + + + {% 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) %} + + + + + + + + + {% endfor %} + +
{{ 'mautic.program.objective.field.type'|trans }}{{ 'mautic.program.objective.field.name'|trans }}{{ 'mautic.program.objective.field.description'|trans }}{{ 'mautic.program.objective.field.priority'|trans }}{{ 'mautic.program.objective.field.is_achieved'|trans }}
+ {% if typeIcon %}{% endif %} + + {{ typeName ?? 'mautic.program.description_item.type.unknown'|trans({'%key%': objective.type}) }} + {{ objective.title }}{{ objective.description|program_linkify }}{{ objective.priority ?? '—' }} + {% if objective.achieved %} + {{ 'mautic.program.objective.achieved'|trans }} + {% else %} + {{ 'mautic.program.objective.not_achieved'|trans }} + {% endif %} +
+
+ {% endif %} +
+ + {# Allocation: the initiative's budget, then the allocation items (cost lines) with their totals. #} +
+ + + + + + + +
{{ 'mautic.program.field.budget_planned'|trans }} + {% if item.budgetPlanned is not null %} + {{ program_money(item.budgetPlanned) }} {{ program_currency() }} + {% else %} + {{ 'mautic.program.value.none'|trans }} + {% endif %} +
+ +

{{ 'mautic.program.field.allocation_items'|trans }}

+ {% if allocationItems is empty %} +

{{ 'mautic.program.allocation_item.empty'|trans }}

+ {% 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') }} +
+ + + + + + + + + + + + + {% 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) %} + + + + + + + + + {% endfor %} + + + + + + + + +
{{ 'mautic.program.allocation_item.field.type'|trans }}{{ 'mautic.program.allocation_item.field.name'|trans }}{{ 'mautic.program.allocation_item.field.description'|trans }}{{ 'mautic.program.allocation_item.field.planned_cost'|trans }}{{ 'mautic.program.allocation_item.field.real_cost'|trans }}
+ {% if typeIcon %}{% endif %} + + {{ typeName ?? 'mautic.program.description_item.type.unknown'|trans({'%key%': allocationItem.type}) }} + {{ allocationItem.name }}{{ allocationItem.description|program_linkify }} + {% if allocationItem.plannedCost is not null %}{{ program_money(allocationItem.plannedCost) }} {{ program_currency() }}{% endif %} + + {% if allocationItem.realCost is not null %}{{ program_money(allocationItem.realCost) }} {{ program_currency() }}{% endif %} +
{{ 'mautic.program.allocation.total'|trans }} + {% if allocationTotals.planned is not null %}{{ program_money(allocationTotals.planned) }} {{ program_currency() }}{% endif %} + + {% if allocationTotals.real is not null %}{{ program_money(allocationTotals.real) }} {{ program_currency() }}{% endif %} +
+
+ {% endif %} +
+ + {# Stakeholders: the initiative's links to the global directory, harmonized like the other tabs. #} +
+ {% set stakeholders = item.stakeholders %} + {% if stakeholders is empty %} +

{{ 'mautic.program.stakeholder.empty'|trans }}

+ {% 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') }} +
+ + + + + + + + + + + + + + + {% for link in stakeholders %} + {% set stakeholder = link.stakeholder %} + + + + + + + + + + + {% endfor %} + +
{{ 'mautic.program.stakeholder.field.type'|trans }}{{ 'mautic.program.stakeholder.field.name'|trans }}{{ 'mautic.program.stakeholder.field.role_in_initiative'|trans }}{{ 'mautic.program.stakeholder.field.role'|trans }}{{ 'mautic.program.stakeholder.field.phone'|trans }}{{ 'mautic.program.stakeholder.field.active'|trans }}
+ {% set typeIcon = program_item_type_icon('stakeholder', stakeholder.type) %} + {% if typeIcon %}{% endif %} + + {{ program_item_type_name('stakeholder', stakeholder.type) ?? 'mautic.program.description_item.type.unknown'|trans({'%key%': stakeholder.type}) }} + + {{ stakeholder.name }} + {{ link.roleInInitiative }}{{ stakeholder.role }} + {% if stakeholder.phone %}{{ stakeholder.phone }}{% endif %} + + + {{ (stakeholder.isPublished ? 'mautic.program.stakeholder.active' : 'mautic.program.stakeholder.inactive')|trans }} + +
+
+ {% endif %} +
+ + {# 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). #} +
+ {% set audiences = item.audiences %} + {% if audiences is empty %} +

{{ 'mautic.program.audience.empty'|trans }}

+ {% else %} + {{ include('@Program/Initiative/_tab_table_filter.html.twig') }} +
+ + + + + + + + + + + + + + + {% for link in audiences %} + {% set audience = link.audience %} + + + + + + + + + + + {% endfor %} + +
{{ 'mautic.program.audience.field.type'|trans }}{{ 'mautic.program.audience.field.name'|trans }}{{ 'mautic.program.audience.field.priority'|trans }}{{ 'mautic.program.audience.field.stages'|trans }}{{ 'mautic.program.audience.field.estimated_size'|trans }}{{ 'mautic.program.audience.field.value_proposition'|trans }}{{ 'mautic.program.audience.field.preferred_channels'|trans }}
+ + {{ audience.audienceType.labelKey|trans }} + {{ audience.name }} + + {{ link.priority.labelKey|trans }} + + {{ audience.stages|map(stage => stage.name)|join(', ') }} + {{ audience.estimatedSize }}{{ link.valueProposition }} + {% for channel in audience.preferredChannels ?? [] %} + {{ program_audience_channel_label(channel)|trans }} + {% endfor %} +
+
+ {% endif %} +
+ + {# Tasks: same columns as Programs > Tasks, in tree order. #} +
+ {{ include('@Program/Initiative/_task_table.html.twig', { + 'initiative': item, + 'taskTree': taskTree, + 'taskPermissions': taskPermissions, + }) }} +
+
+{% endblock %} diff --git a/Resources/views/Plan/form.html.twig b/Resources/views/Initiative/form.html.twig similarity index 52% rename from Resources/views/Plan/form.html.twig rename to Resources/views/Initiative/form.html.twig index ace229f..02d3b51 100644 --- a/Resources/views/Plan/form.html.twig +++ b/Resources/views/Initiative/form.html.twig @@ -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) %} -
  • +
  • - +
    @@ -29,7 +29,7 @@ {% macro row_end(removeLabel) %}
    -
    @@ -38,16 +38,16 @@ {% endmacro %} {% macro objective_row(objective) %} - {{ _self.row_start('mautic.plan.objective.drag') }} + {{ _self.row_start('mautic.program.objective.drag') }}
    - {# 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. #}
    - +
    {{ form_row(objective.type) }} - {# Filled with the selected type's description by plan.js. #} -

    {{ plan_item_type_description('objective', objective.type.vars.value) }}

    + {# Filled with the selected type's description by program.js. #} +

    {{ program_item_type_description('objective', objective.type.vars.value) }}

    {{ form_row(objective.title) }} @@ -57,67 +57,59 @@ {{ 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') }}
    - {# 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. #}
    - +
    {{ form_row(item.type) }} - {# Filled with the selected type's description by plan.js. #} -

    {{ plan_item_type_description('description', item.type.vars.value) }}

    + {# Filled with the selected type's description by program.js. #} +

    {{ program_item_type_description('description', item.type.vars.value) }}

    {{ 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') }}
    {{ form_row(link.stakeholder) }}
    -
    {{ form_row(link.roleInPlan) }}
    +
    {{ form_row(link.roleInInitiative) }}
    {{ 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) }} -
    -
    {{ form_row(target.targetType) }}
    -
    {{ form_row(target.priority) }}
    -
    {{ form_row(target.estimatedSize) }}
    -
    - {{ 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') }}
    - {# 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. #}
    - +
    {{ form_row(item.type) }} - {# Filled with the selected type's description by plan.js. #} -

    {{ plan_item_type_description('allocation', item.type.vars.value) }}

    + {# Filled with the selected type's description by program.js. #} +

    {{ program_item_type_description('allocation', item.type.vars.value) }}

    {{ form_row(item.name) }}
    @@ -129,7 +121,7 @@
    {{ form_row(item.realCost) }}
    {{ 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) }}
    - {{ include('@Plan/Plan/_tabs.html.twig', {'planId': entity.id}) }} + {{ include('@Program/Initiative/_tabs.html.twig', {'initiativeId': entity.id}) }}
    {# Details #} -
    +
    {{ form_row(form.status) }}
    {{ form_row(form.version) }}
    @@ -150,7 +142,7 @@
    {% if entity.completedAt %}
    - +

    {{ dateToFull(entity.completedAt) }}

    {% endif %} @@ -165,26 +157,26 @@
    {# Description: description items. #} -
    +
    {% set hasTypes = form.descriptionItems.vars.prototype.type.vars.choices is not empty %} -
    {{ form_errors(form.descriptionItems) }} {% if not hasTypes %} -
    {{ 'mautic.plan.description_item.no_types'|trans }}
    +
    {{ 'mautic.program.description_item.no_types'|trans }}
    {% endif %} -

    - {{ 'mautic.plan.description_item.empty'|trans }} +

    + {{ 'mautic.program.description_item.empty'|trans }}

    -
      +
        {% for item in form.descriptionItems %} {{ _self.description_item_row(item) }} {% endfor %}
      {% if hasTypes %} - {% endif %}
    @@ -192,113 +184,114 @@
    {# Objectives #} -
    +
    {% set hasObjectiveTypes = form.objectives.vars.prototype.type.vars.choices is not empty %} -
    {{ form_errors(form.objectives) }} {% if not hasObjectiveTypes %} -
    {{ 'mautic.plan.objective.no_types'|trans }}
    +
    {{ 'mautic.program.objective.no_types'|trans }}
    {% endif %} -

    - {{ 'mautic.plan.objective.empty'|trans }} +

    + {{ 'mautic.program.objective.empty'|trans }}

    -
      +
        {% for objective in form.objectives %} {{ _self.objective_row(objective) }} {% endfor %}
      {% if hasObjectiveTypes %} - {% endif %}
    {% do form.objectives.setRendered %}
    - {# Allocation: the plan's budget, then the allocation items (cost lines). #} -
    + {# Allocation: the initiative's budget, then the allocation items (cost lines). #} +
    {{ form_row(form.budgetPlanned) }}
    {% set hasAllocationTypes = form.allocationItems.vars.prototype.type.vars.choices is not empty %} -
    -

    {{ 'mautic.plan.field.allocation_items'|trans }}

    +

    {{ 'mautic.program.field.allocation_items'|trans }}

    {{ form_errors(form.allocationItems) }} {% if not hasAllocationTypes %} -
    {{ 'mautic.plan.allocation_item.no_types'|trans }}
    +
    {{ 'mautic.program.allocation_item.no_types'|trans }}
    {% endif %} -

    - {{ 'mautic.plan.allocation_item.empty'|trans }} +

    + {{ 'mautic.program.allocation_item.empty'|trans }}

    -
      +
        {% for item in form.allocationItems %} {{ _self.allocation_item_row(item) }} {% endfor %}
      {% if hasAllocationTypes %} - {% endif %}
    {% do form.allocationItems.setRendered %}
    - {# Stakeholders: links to the global directory (Planning > Stakeholders). #} -
    -
    Stakeholders). #} +
    +
    {{ form_errors(form.stakeholders) }} -

    - {{ 'mautic.plan.stakeholder.empty'|trans }} +

    + {{ 'mautic.program.stakeholder.empty'|trans }}

    -
      +
        {% for link in form.stakeholders %} {{ _self.stakeholder_row(link) }} {% endfor %}
      -
    {% do form.stakeholders.setRendered %}
    - {# Targets: the plan's audiences. #} -
    -
    - {{ form_errors(form.targets) }} -

    - {{ 'mautic.plan.target.empty'|trans }} + {# Audiences: the initiative's links to the global directory (Programs > Audiences). #} +

    +

    {{ 'mautic.program.audience.link_tab.help'|trans }}

    +
    + {{ form_errors(form.audiences) }} +

    + {{ 'mautic.program.audience.empty'|trans }}

    -
      - {% for target in form.targets %} - {{ _self.target_row(target) }} +
        + {% for audience in form.audiences %} + {{ _self.audience_row(audience) }} {% endfor %}
      -
    - {% do form.targets.setRendered %} + {% do form.audiences.setRendered %}
    {# Tasks: read-only here, so that following a link doesn't drop unsaved changes to the plan. #} -
    +
    {% if entity.id %} -

    {{ 'mautic.plan.task.manage_from_plan_page'|trans }}

    +

    {{ 'mautic.program.task.manage_from_initiative_page'|trans }}

    {% endif %} - {{ include('@Plan/Plan/_task_table.html.twig', { - 'plan': entity, + {{ include('@Program/Initiative/_task_table.html.twig', { + 'initiative': entity, 'taskTree': taskTree|default([]), 'readOnly': true, }) }} diff --git a/Resources/views/Plan/list.html.twig b/Resources/views/Initiative/list.html.twig similarity index 67% rename from Resources/views/Plan/list.html.twig rename to Resources/views/Initiative/list.html.twig index 053279d..236b6fa 100644 --- a/Resources/views/Plan/list.html.twig +++ b/Resources/views/Initiative/list.html.twig @@ -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 %}
    @@ -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'], }, }, }) -}}
    {% if items is defined and items is not empty %}
    - +
    {{ 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', }) }} {% 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) %} @@ -130,8 +130,8 @@ 'totalItems': totalItems, 'page': page, 'limit': limit, - 'baseUrl': path('plan_index'), - 'sessionVar': 'plan', + 'baseUrl': path('initiative_index'), + 'sessionVar': 'initiative', }) -}} @@ -140,9 +140,9 @@ {% else %}
    {{ 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', }) }}
    {% endif %} diff --git a/Resources/views/Plan/_tab_table_filter.html.twig b/Resources/views/Plan/_tab_table_filter.html.twig deleted file mode 100644 index 31f0394..0000000 --- a/Resources/views/Plan/_tab_table_filter.html.twig +++ /dev/null @@ -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. - #} -
    - - -
    -

    {{ 'mautic.plan.filter.no_match'|trans }}

    diff --git a/Resources/views/Plan/_tabs.html.twig b/Resources/views/Plan/_tabs.html.twig deleted file mode 100644 index f527353..0000000 --- a/Resources/views/Plan/_tabs.html.twig +++ /dev/null @@ -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-. 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', -} %} - diff --git a/Resources/views/Plan/_task_table.html.twig b/Resources/views/Plan/_task_table.html.twig deleted file mode 100644 index 60e8945..0000000 --- a/Resources/views/Plan/_task_table.html.twig +++ /dev/null @@ -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 %} - -{% endif %} - -{% if not plan.id %} -

    {{ 'mautic.plan.task.save_plan_first'|trans }}

    -{% elseif taskTree is empty %} -

    {{ 'mautic.plan.task.empty'|trans }}

    -{% 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 %} -
    -
    {{- 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', }) -}}
    {{- include('@MauticCore/Helper/publishstatus_icon.html.twig', { 'item': item, - 'model': 'plan', + 'model': 'initiative', }) -}} - + {{ item.name }} {% if item.category %} @@ -111,13 +111,13 @@
    {{ item.status.labelKey|trans }} - {{ item.owner ? item.owner.name : 'mautic.plan.owner.none'|trans }} + {{ item.owner ? item.owner.name : 'mautic.program.owner.none'|trans }} {{ item.startDate ? dateToDate(item.startDate) : '' }} {{ item.endDate ? dateToDate(item.endDate) : '' }} {% if item.budgetPlanned is not null %} - {{ plan_money(item.budgetPlanned) }} {{ plan_currency() }} + {{ program_money(item.budgetPlanned) }} {{ program_currency() }} {% endif %} {{ item.id }}
    - - - - - - - - - - - - - {% 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) %} - - - - - - - - - - {% endfor %} - -
    {{ 'mautic.plan.task.field.type'|trans }}{{ 'mautic.plan.task.field.name'|trans }}{{ 'mautic.plan.task.field.description'|trans }}{{ 'mautic.plan.task.field.start_date'|trans }}{{ 'mautic.plan.task.field.end_date'|trans }}{{ 'mautic.plan.task.field.status'|trans }}
    - {% set taskTypeIcon = plan_item_type_icon('task', task.type) %} - {% if taskTypeIcon %}{% endif %} - - {{ plan_item_type_name('task', task.type) ?? 'mautic.plan.description_item.type.unknown'|trans({'%key%': task.type}) }} - - {% if canEdit %} - {{ task.name }} - {% else %} - {{ task.name }} - {% endif %} - {% if task.taskKind == constant('MauticPlugin\\PlanBundle\\Entity\\TaskKind::Milestone') %} - {{ 'mautic.plan.task.kind.milestone_short'|trans }} - {% elseif task.taskKind == constant('MauticPlugin\\PlanBundle\\Entity\\TaskKind::Phase') %} - {{ 'mautic.plan.task.kind.phase_short'|trans }} - {% endif %} - - {# 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, - }) }} - {{ task.startDate ? task.startDate|date('Y-m-d') : '' }}{{ task.endDate ? task.endDate|date('Y-m-d') : '' }} - {# A phase has no status of its own — skip the column value. #} - {% if task.taskKind != constant('MauticPlugin\\PlanBundle\\Entity\\TaskKind::Phase') %} - {{ task.status.labelKey|trans }} - {% endif %} -
    -
    -{% endif %} diff --git a/Resources/views/Plan/details.html.twig b/Resources/views/Plan/details.html.twig deleted file mode 100644 index 5e32030..0000000 --- a/Resources/views/Plan/details.html.twig +++ /dev/null @@ -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 %} -
    - {% 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, - }}) }} - -
    - {# Details #} -
    - - - - - - - {% if item.completedAt %} - - - - - {% endif %} - - - - - - - - - - - - - - - - - - - - - - - - - - - - - {% if item.dateModified %} - - - - - {% endif %} - - - - - -
    {{ 'mautic.plan.field.status'|trans }}{{ item.status.labelKey|trans }}
    {{ 'mautic.plan.field.completed_at'|trans }}{{ dateToFull(item.completedAt) }}
    {{ 'mautic.plan.field.version'|trans }}{{ item.version }}
    {{ 'mautic.plan.field.owner'|trans }}{{ item.owner ? item.owner.name : 'mautic.plan.owner.none'|trans }}
    {{ 'mautic.plan.field.start_date'|trans }}{{ item.startDate ? dateToFull(item.startDate) : 'mautic.plan.value.none'|trans }}
    {{ 'mautic.plan.field.end_date'|trans }}{{ item.endDate ? dateToFull(item.endDate) : 'mautic.plan.value.none'|trans }}
    {{ 'mautic.core.category'|trans }}{{ item.category ? item.category.title : 'mautic.plan.value.none'|trans }}
    {{ 'mautic.core.form.available'|trans }}{{ (item.isPublished ? 'mautic.core.form.yes' : 'mautic.core.form.no')|trans }}
    {{ 'mautic.core.created'|trans }}{{ item.dateAdded ? dateToFull(item.dateAdded) : '' }}{% if item.createdByUser %} ({{ item.createdByUser }}){% endif %}
    {{ 'mautic.core.modified'|trans }}{{ dateToFull(item.dateModified) }}{% if item.modifiedByUser %} ({{ item.modifiedByUser }}){% endif %}
    {{ 'mautic.core.id'|trans }}{{ item.id }}
    -
    - - {# Description #} -
    - {% if descriptionItems is empty %} -

    {{ 'mautic.plan.description_item.empty'|trans }}

    - {% 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') }} -
    - - - - - - - - - - {% 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) %} - - - - - - {% endfor %} - -
    {{ 'mautic.plan.description_item.field.type'|trans }}{{ 'mautic.plan.description_item.field.description'|trans }}
    - {% if typeIcon %}{% endif %} - - {{ typeName ?? 'mautic.plan.description_item.type.unknown'|trans({'%key%': descriptionItem.type}) }} - - {{ include('@Plan/Plan/_description_read_more.html.twig', { - 'text': descriptionItem.description, - 'id': 'plan-desc-item-' ~ descriptionItem.id, - }) }} -
    -
    - {% endif %} -
    - - {# Objectives #} -
    - {% if objectives is empty %} -

    {{ 'mautic.plan.objective.empty'|trans }}

    - {% else %} -

    - {{ 'mautic.plan.objective.progress'|trans({'%achieved%': achievedCount, '%total%': objectives|length}) }} -

    - {# 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') }} -
    - - - - - - - - - - - - - {% 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) %} - - - - - - - - - {% endfor %} - -
    {{ 'mautic.plan.objective.field.type'|trans }}{{ 'mautic.plan.objective.field.name'|trans }}{{ 'mautic.plan.objective.field.description'|trans }}{{ 'mautic.plan.objective.field.priority'|trans }}{{ 'mautic.plan.objective.field.is_achieved'|trans }}
    - {% if typeIcon %}{% endif %} - - {{ typeName ?? 'mautic.plan.description_item.type.unknown'|trans({'%key%': objective.type}) }} - {{ objective.title }}{{ objective.description|plan_linkify }}{{ objective.priority ?? '—' }} - {% if objective.achieved %} - {{ 'mautic.plan.objective.achieved'|trans }} - {% else %} - {{ 'mautic.plan.objective.not_achieved'|trans }} - {% endif %} -
    -
    - {% endif %} -
    - - {# Allocation: the plan's budget, then the allocation items (cost lines) with their totals. #} -
    - - - - - - - -
    {{ 'mautic.plan.field.budget_planned'|trans }} - {% if item.budgetPlanned is not null %} - {{ plan_money(item.budgetPlanned) }} {{ plan_currency() }} - {% else %} - {{ 'mautic.plan.value.none'|trans }} - {% endif %} -
    - -

    {{ 'mautic.plan.field.allocation_items'|trans }}

    - {% if allocationItems is empty %} -

    {{ 'mautic.plan.allocation_item.empty'|trans }}

    - {% 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') }} -
    - - - - - - - - - - - - - {% 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) %} - - - - - - - - - {% endfor %} - - - - - - - - -
    {{ 'mautic.plan.allocation_item.field.type'|trans }}{{ 'mautic.plan.allocation_item.field.name'|trans }}{{ 'mautic.plan.allocation_item.field.description'|trans }}{{ 'mautic.plan.allocation_item.field.planned_cost'|trans }}{{ 'mautic.plan.allocation_item.field.real_cost'|trans }}
    - {% if typeIcon %}{% endif %} - - {{ typeName ?? 'mautic.plan.description_item.type.unknown'|trans({'%key%': allocationItem.type}) }} - {{ allocationItem.name }}{{ allocationItem.description|plan_linkify }} - {% if allocationItem.plannedCost is not null %}{{ plan_money(allocationItem.plannedCost) }} {{ plan_currency() }}{% endif %} - - {% if allocationItem.realCost is not null %}{{ plan_money(allocationItem.realCost) }} {{ plan_currency() }}{% endif %} -
    {{ 'mautic.plan.allocation.total'|trans }} - {% if allocationTotals.planned is not null %}{{ plan_money(allocationTotals.planned) }} {{ plan_currency() }}{% endif %} - - {% if allocationTotals.real is not null %}{{ plan_money(allocationTotals.real) }} {{ plan_currency() }}{% endif %} -
    -
    - {% endif %} -
    - - {# Stakeholders: the plan's links to the global directory, harmonized like the other tabs. #} -
    - {% set stakeholders = item.stakeholders %} - {% if stakeholders is empty %} -

    {{ 'mautic.plan.stakeholder.empty'|trans }}

    - {% 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') }} -
    - - - - - - - - - - - - - - - {% for link in stakeholders %} - {% set stakeholder = link.stakeholder %} - - - - - - - - - - - {% endfor %} - -
    {{ 'mautic.plan.stakeholder.field.type'|trans }}{{ 'mautic.plan.stakeholder.field.name'|trans }}{{ 'mautic.plan.stakeholder.field.role_in_plan'|trans }}{{ 'mautic.plan.stakeholder.field.role'|trans }}{{ 'mautic.plan.stakeholder.field.phone'|trans }}{{ 'mautic.plan.stakeholder.field.active'|trans }}
    - {% set typeIcon = plan_item_type_icon('stakeholder', stakeholder.type) %} - {% if typeIcon %}{% endif %} - - {{ plan_item_type_name('stakeholder', stakeholder.type) ?? 'mautic.plan.description_item.type.unknown'|trans({'%key%': stakeholder.type}) }} - - {{ stakeholder.name }} - {{ link.roleInPlan }}{{ stakeholder.role }} - {% if stakeholder.phone %}{{ stakeholder.phone }}{% endif %} - - - {{ (stakeholder.isPublished ? 'mautic.plan.stakeholder.active' : 'mautic.plan.stakeholder.inactive')|trans }} - -
    -
    - {% endif %} -
    - - {# Targets: the plan's audiences, harmonized like the other tabs. #} -
    - {% set targets = item.targets %} - {% if targets is empty %} -

    {{ 'mautic.plan.target.empty'|trans }}

    - {% 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') }} -
    - - - - - - - - - - - - - - - - - {% for target in targets %} - - - - - - - - - - - - - {% endfor %} - -
    {{ 'mautic.plan.target.field.type'|trans }}{{ 'mautic.plan.target.field.name'|trans }}{{ 'mautic.plan.target.field.priority'|trans }}{{ 'mautic.plan.target.field.stages'|trans }}{{ 'mautic.plan.target.field.estimated_size'|trans }}{{ 'mautic.plan.target.field.profile_criteria'|trans }}{{ 'mautic.plan.target.field.pain_points'|trans }}{{ 'mautic.plan.target.field.value_proposition'|trans }}{{ 'mautic.plan.target.field.preferred_channels'|trans }}
    - - {{ target.targetType.labelKey|trans }}{{ target.name }} - {{ target.priority.labelKey|trans }} - - {{ target.stages|map(stage => stage.name)|join(', ') }} - {{ target.estimatedSize }}{{ target.profileCriteria }}{{ target.painPoints }}{{ target.valueProposition }} - {% for channel in target.preferredChannels ?? [] %} - {{ plan_target_channel_label(channel)|trans }} - {% endfor %} -
    -
    - {% endif %} -
    - - {# Tasks: same columns as Planning > Tasks, in tree order. #} -
    - {{ include('@Plan/Plan/_task_table.html.twig', { - 'plan': item, - 'taskTree': taskTree, - 'taskPermissions': taskPermissions, - }) }} -
    -
    -{% endblock %} diff --git a/Resources/views/Stakeholder/details.html.twig b/Resources/views/Stakeholder/details.html.twig index 4a4c3b4..b8f1c2b 100644 --- a/Resources/views/Stakeholder/details.html.twig +++ b/Resources/views/Stakeholder/details.html.twig @@ -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 %}
    - +
    - + - - + + - - + + - - + + @@ -70,25 +70,25 @@
    {{ 'mautic.plan.stakeholder.field.type'|trans }}{{ 'mautic.program.stakeholder.field.type'|trans }} - {% set typeIcon = plan_item_type_icon('stakeholder', item.type) %} - {% if typeIcon %} {% 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 %} {% endif %} + {{ program_item_type_name('stakeholder', item.type) ?? 'mautic.program.description_item.type.unknown'|trans({'%key%': item.type}) }}
    {{ 'mautic.plan.stakeholder.field.role'|trans }}{{ item.role|default('mautic.plan.value.none'|trans) }}{{ 'mautic.program.stakeholder.field.role'|trans }}{{ item.role|default('mautic.program.value.none'|trans) }}
    {{ 'mautic.plan.stakeholder.field.email'|trans }}{% if item.email %}{{ item.email }}{% else %}{{ 'mautic.plan.value.none'|trans }}{% endif %}{{ 'mautic.program.stakeholder.field.email'|trans }}{% if item.email %}{{ item.email }}{% else %}{{ 'mautic.program.value.none'|trans }}{% endif %}
    {{ 'mautic.plan.stakeholder.field.phone'|trans }}{% if item.phone %}{{ item.phone }}{% else %}{{ 'mautic.plan.value.none'|trans }}{% endif %}{{ 'mautic.program.stakeholder.field.phone'|trans }}{% if item.phone %}{{ item.phone }}{% else %}{{ 'mautic.program.value.none'|trans }}{% endif %}
    {{ 'mautic.core.created'|trans }}
    -

    {{ 'mautic.plan.stakeholder.field.plans'|trans }}

    - {% if item.planLinks is empty %} -

    {{ 'mautic.plan.stakeholder.no_plans'|trans }}

    +

    {{ 'mautic.program.stakeholder.field.plans'|trans }}

    + {% if item.initiativeLinks is empty %} +

    {{ 'mautic.program.stakeholder.no_plans'|trans }}

    {% else %}
    - +
    - - - + + + - {% for link in item.planLinks %} + {% for link in item.initiativeLinks %} - - - + + + {% endfor %} diff --git a/Resources/views/Stakeholder/form.html.twig b/Resources/views/Stakeholder/form.html.twig index 9afd5dd..0aa5211 100644 --- a/Resources/views/Stakeholder/form.html.twig +++ b/Resources/views/Stakeholder/form.html.twig @@ -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 @@
    {{ form_row(form.name) }}
    - {# 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. #}
    - +
    {{ form_row(form.type) }} - {# Filled with the selected type's description by plan.js. #} -

    {{ plan_item_type_description('stakeholder', form.type.vars.value) }}

    + {# Filled with the selected type's description by program.js. #} +

    {{ program_item_type_description('stakeholder', form.type.vars.value) }}

    {{ form_row(form.role) }} @@ -35,7 +35,7 @@ {{ form_row(form.isPublished) }} {{ form_row(form.email) }} {{ form_row(form.phone) }} -

    {{ 'mautic.plan.stakeholder.phone.help'|trans }}

    +

    {{ 'mautic.program.stakeholder.phone.help'|trans }}

    diff --git a/Resources/views/Stakeholder/list.html.twig b/Resources/views/Stakeholder/list.html.twig index 01631bb..e2bf56a 100644 --- a/Resources/views/Stakeholder/list.html.twig +++ b/Resources/views/Stakeholder/list.html.twig @@ -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 %}
    @@ -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'], }, }, }) -}}
    {% if items is defined and items is not empty %}
    -
    {{ 'mautic.plan.field.name'|trans }}{{ 'mautic.plan.stakeholder.field.role_in_plan'|trans }}{{ 'mautic.plan.field.status'|trans }}{{ 'mautic.program.field.name'|trans }}{{ 'mautic.program.stakeholder.field.role_in_initiative'|trans }}{{ 'mautic.program.field.status'|trans }}
    {{ link.plan.name }}{{ link.roleInPlan|default('—') }}{{ link.plan.status.labelKey|trans }}{{ link.initiative.name }}{{ link.roleInInitiative|default('—') }}{{ link.initiative.status.labelKey|trans }}
    +
    {{ 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', }) }} {% 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) %} - - {{ plan_item_type_name('stakeholder', item.type) ?? 'mautic.plan.description_item.type.unknown'|trans({'%key%': item.type}) }} + + {{ program_item_type_name('stakeholder', item.type) ?? 'mautic.program.description_item.type.unknown'|trans({'%key%': item.type}) }} @@ -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', }) -}} @@ -158,9 +158,9 @@ {% else %}
    {{ 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', }) }}
    {% endif %} diff --git a/Resources/views/Task/form.html.twig b/Resources/views/Task/form.html.twig index eebe8f1..30047e4 100644 --- a/Resources/views/Task/form.html.twig +++ b/Resources/views/Task/form.html.twig @@ -1,23 +1,23 @@ {% extends '@MauticCore/Default/content.html.twig' %} -{% block mauticContent %}planTask{% endblock %} +{% block mauticContent %}programTask{% endblock %} {% block headerTitle %} {% if entity.id %} - {{ 'mautic.plan.task.header.edit'|trans({'%name%': entity.name}) }} + {{ 'mautic.program.task.header.edit'|trans({'%name%': entity.name}) }} {% else %} - {{ 'mautic.plan.task.header.new'|trans }} + {{ 'mautic.program.task.header.new'|trans }} {% endif %} {% endblock %} -{# The dependencies and the RACI rows: the same editable, sortable rows as the plan form's - collections. Adding, removing and reordering is handled by Assets/js/plan.js through the - plan-collection-* classes. #} +{# The dependencies and the RACI rows: the same editable, sortable rows as the initiative form's + collections. Adding, removing and reordering is handled by Assets/js/program.js through the + initiative-collection-* classes. #} {% macro dependency_row(dependency) %} -
  • +
  • - +
    @@ -29,7 +29,7 @@ {{ form_widget(dependency.position) }}
    -
    @@ -38,10 +38,10 @@ {% endmacro %} {% macro raci_row(raci) %} -
  • +
  • - +
    @@ -53,7 +53,7 @@ {{ form_widget(raci.position) }}
    -
    @@ -68,14 +68,14 @@
    {{ form_row(form.name) }}
    - {# 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. #}
    - +
    {{ form_row(form.type) }} - {# Filled with the selected type's description by plan.js. #} -

    {{ plan_item_type_description('task', form.type.vars.value) }}

    + {# Filled with the selected type's description by program.js. #} +

    {{ program_item_type_description('task', form.type.vars.value) }}

    {{ form_row(form.description) }} @@ -84,7 +84,7 @@
    - {{ form_row(form.plan) }} + {{ form_row(form.initiative) }} {{ form_row(form.taskKind) }} {{ form_row(form.startDate) }} {{ form_row(form.endDate) }} @@ -92,7 +92,7 @@ {{ form_row(form.status) }} {% else %} {# A phase has no status of its own: its state comes from its tasks. #} -

    {{ 'mautic.plan.task.kind.phase_status_note'|trans }}

    +

    {{ 'mautic.program.task.kind.phase_status_note'|trans }}

    {% endif %} {{ form_row(form.plannedWork) }}
    @@ -100,42 +100,42 @@
    - {# Dependencies: several edges, each another task of the plan with the relation type. #} -
    -

    {{ 'mautic.plan.task.field.dependencies'|trans }}

    +

    {{ 'mautic.program.task.field.dependencies'|trans }}

    {{ form_errors(form.dependencies) }} -

    - {{ 'mautic.plan.task.dependency.empty'|trans }} +

    + {{ 'mautic.program.task.dependency.empty'|trans }}

    -
      +
        {% for dependency in form.dependencies %} {{ _self.dependency_row(dependency) }} {% endfor %}
      -
    {% do form.dependencies.setRendered %} - {# RACI: one row per role, several stakeholders per role, picked from the plan's. #} -
    -

    {{ 'mautic.plan.task.field.raci'|trans }}

    +

    {{ 'mautic.program.task.field.raci'|trans }}

    {{ form_errors(form.raci) }} -

    - {{ 'mautic.plan.task.raci.empty'|trans }} +

    + {{ 'mautic.program.task.raci.empty'|trans }}

    -
      +
        {% for raci in form.raci %} {{ _self.raci_row(raci) }} {% endfor %}
      -
    {% do form.raci.setRendered %} diff --git a/Resources/views/Task/list.html.twig b/Resources/views/Task/list.html.twig index 6b18bbb..5be6c06 100644 --- a/Resources/views/Task/list.html.twig +++ b/Resources/views/Task/list.html.twig @@ -2,9 +2,9 @@ {% set tmpl = 'list' %} {% extends isIndex ? '@MauticCore/Default/content.html.twig' : '@MauticCore/Default/raw_output.html.twig' %} -{% block mauticContent %}planTask{% endblock %} +{% block mauticContent %}programTask{% endblock %} -{% block headerTitle %}{{ 'mautic.plan.task.header.index'|trans }}{% endblock %} +{% block headerTitle %}{{ 'mautic.program.task.header.index'|trans }}{% endblock %} {% block content %}
    @@ -13,118 +13,118 @@ 'action': currentRoute, 'page_actions': { 'templateButtons': { - 'new': permissions['plan:tasks:create'], + 'new': permissions['program:tasks:create'], }, - 'langVar': 'plan.task', + 'langVar': 'initiative.task', }, 'bulk_actions': { - 'langVar': 'plan.task', + 'langVar': 'initiative.task', 'templateButtons': { - 'delete': permissions['plan:tasks:deleteown'] or permissions['plan:tasks:deleteother'], + 'delete': permissions['program:tasks:deleteown'] or permissions['program:tasks:deleteother'], }, }, }) -}}
    {% if items is defined and items is not empty %}
    -
  • {{- 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', }) -}} {{ item.id }} - {% set typeIcon = plan_item_type_icon('stakeholder', item.type) %} - {% if typeIcon %}{% endif %} + {% set typeIcon = program_item_type_icon('stakeholder', item.type) %} + {% if typeIcon %}{% endif %} {% if canEdit %} - {{ item.name }} + {{ item.name }} {% else %} {{ item.name }} {% endif %} @@ -127,16 +127,16 @@ - {{ (item.isPublished ? 'mautic.plan.stakeholder.active' : 'mautic.plan.stakeholder.inactive')|trans }} + {{ (item.isPublished ? 'mautic.program.stakeholder.active' : 'mautic.program.stakeholder.inactive')|trans }} - {# The plans this stakeholder is assigned to, through their Stakeholders tab. #} - {% set plans = item.planLinks|default([]) %} - {% for link in plans %} - {{ link.plan.name }}{% if link.roleInPlan %} ({{ link.roleInPlan }}){% 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 %} + {{ link.initiative.name }}{% if link.roleInInitiative %} ({{ link.roleInInitiative }}){% endif %}{% if not loop.last %}, {% endif %} {% else %} - {{ 'mautic.plan.stakeholder.no_plans'|trans }} + {{ 'mautic.program.stakeholder.no_plans'|trans }} {% endfor %}
    +
    {{ include('@MauticCore/Helper/tableheader.html.twig', { 'checkall': 'true', - 'target': '#planTaskTable', + 'target': '#programTaskTable', }) }} {# Columns: ID, Pictogram, Type, Name, Description, Start date, End date, Status. #} {{ include('@MauticCore/Helper/tableheader.html.twig', { - 'sessionVar': 'plan.task', + 'sessionVar': 'initiative.task', 'orderBy': 't.id', 'text': 'mautic.core.id', - 'class': 'col-plan-task-id', + 'class': 'col-initiative-task-id', }) }} {{ include('@MauticCore/Helper/tableheader.html.twig', { - 'sessionVar': 'plan.task', - 'text': 'mautic.plan.task.field.pictogram', - 'class': 'col-plan-task-pictogram', + 'sessionVar': 'initiative.task', + 'text': 'mautic.program.task.field.pictogram', + 'class': 'col-initiative-task-pictogram', }) }} {{ include('@MauticCore/Helper/tableheader.html.twig', { - 'sessionVar': 'plan.task', + 'sessionVar': 'initiative.task', 'orderBy': 't.type', - 'text': 'mautic.plan.task.field.type', - 'class': 'col-plan-task-type', + 'text': 'mautic.program.task.field.type', + 'class': 'col-initiative-task-type', }) }} {{ include('@MauticCore/Helper/tableheader.html.twig', { - 'sessionVar': 'plan.task', + 'sessionVar': 'initiative.task', 'orderBy': 't.name', - 'text': 'mautic.plan.task.field.name', - 'class': 'col-plan-task-name', + 'text': 'mautic.program.task.field.name', + 'class': 'col-initiative-task-name', 'default': true, }) }} {{ include('@MauticCore/Helper/tableheader.html.twig', { - 'sessionVar': 'plan.task', - 'text': 'mautic.plan.task.field.description', - 'class': 'visible-md visible-lg col-plan-task-description', + 'sessionVar': 'initiative.task', + 'text': 'mautic.program.task.field.description', + 'class': 'visible-md visible-lg col-initiative-task-description', }) }} {{ include('@MauticCore/Helper/tableheader.html.twig', { - 'sessionVar': 'plan.task', + 'sessionVar': 'initiative.task', 'orderBy': 't.startDate', - 'text': 'mautic.plan.task.field.start_date', - 'class': 'col-plan-task-start', + 'text': 'mautic.program.task.field.start_date', + 'class': 'col-initiative-task-start', }) }} {{ include('@MauticCore/Helper/tableheader.html.twig', { - 'sessionVar': 'plan.task', + 'sessionVar': 'initiative.task', 'orderBy': 't.endDate', - 'text': 'mautic.plan.task.field.end_date', - 'class': 'col-plan-task-end', + 'text': 'mautic.program.task.field.end_date', + 'class': 'col-initiative-task-end', }) }} {{ include('@MauticCore/Helper/tableheader.html.twig', { - 'sessionVar': 'plan.task', + 'sessionVar': 'initiative.task', 'orderBy': 't.status', - 'text': 'mautic.plan.task.field.status', - 'class': 'col-plan-task-status', + 'text': 'mautic.program.task.field.status', + 'class': 'col-initiative-task-status', }) }} {% for item in items %} - {% set canEdit = securityHasEntityAccess(permissions['plan:tasks:editown'], permissions['plan:tasks:editother'], item.createdBy) %} + {% set canEdit = securityHasEntityAccess(permissions['program:tasks:editown'], permissions['program:tasks:editother'], item.createdBy) %} - - {{ plan_item_type_name('task', item.type) ?? 'mautic.plan.description_item.type.unknown'|trans({'%key%': item.type}) }} + + {{ program_item_type_name('task', item.type) ?? 'mautic.program.description_item.type.unknown'|trans({'%key%': item.type}) }} @@ -136,8 +136,8 @@ 'totalItems': totalItems, 'page': page, 'limit': limit, - 'baseUrl': path('plan_task_index'), - 'sessionVar': 'plan.task', + 'baseUrl': path('initiative_task_index'), + 'sessionVar': 'initiative.task', }) -}} @@ -146,9 +146,9 @@ {% else %}
    {{ include('@MauticCore/Components/content-block.html.twig', { - 'heading': 'mautic.plan.task.onboarding.heading', - 'subheading': 'mautic.plan.task.onboarding.subheading', - 'copy': 'mautic.plan.task.onboarding.copy', + 'heading': 'mautic.program.task.onboarding.heading', + 'subheading': 'mautic.program.task.onboarding.subheading', + 'copy': 'mautic.program.task.onboarding.copy', }) }}
    {% endif %} diff --git a/Resources/views/UtmTaxonomy/list.html.twig b/Resources/views/UtmTaxonomy/list.html.twig new file mode 100644 index 0000000..c08934a --- /dev/null +++ b/Resources/views/UtmTaxonomy/list.html.twig @@ -0,0 +1,19 @@ +{% set isIndex = 'index' == tmpl ? true : false %} +{% set tmpl = 'list' %} +{% extends isIndex ? '@MauticCore/Default/content.html.twig' : '@MauticCore/Default/raw_output.html.twig' %} + +{% block mauticContent %}programUtmTaxonomy{% endblock %} + +{% block headerTitle %}{{ 'mautic.program.utm_taxonomy.header.index'|trans }}{% endblock %} + +{% block content %} +
    +
    + {{ include('@MauticCore/Components/content-block.html.twig', { + 'heading': 'mautic.program.utm_taxonomy.onboarding.heading', + 'subheading': 'mautic.program.utm_taxonomy.onboarding.subheading', + 'copy': 'mautic.program.utm_taxonomy.onboarding.copy', + }) }} +
    +
    +{% endblock %} diff --git a/Security/Permissions/PlanPermissions.php b/Security/Permissions/PlanPermissions.php deleted file mode 100644 index 983827e..0000000 --- a/Security/Permissions/PlanPermissions.php +++ /dev/null @@ -1,47 +0,0 @@ - Roles. Core discovers this class from Security/Permissions/. - */ -class PlanPermissions extends AbstractPermissions -{ - /** - * @param mixed[] $params - */ - public function __construct(array $params) - { - parent::__construct($params); - - $this->addStandardPermissions('categories'); - $this->addExtendedPermissions('plans'); - $this->addExtendedPermissions('tasks'); - $this->addExtendedPermissions('stakeholders'); - } - - public function getName(): string - { - return 'plan'; - } - - /** - * @param array $options - * @param array $data - */ - public function buildForm(FormBuilderInterface &$builder, array $options, array $data): void - { - $this->addStandardFormFields('plan', 'categories', $builder, $data); - $this->addExtendedFormFields('plan', 'plans', $builder, $data); - $this->addExtendedFormFields('plan', 'tasks', $builder, $data); - $this->addExtendedFormFields('plan', 'stakeholders', $builder, $data); - } -} diff --git a/Security/Permissions/ProgramPermissions.php b/Security/Permissions/ProgramPermissions.php new file mode 100644 index 0000000..6155f93 --- /dev/null +++ b/Security/Permissions/ProgramPermissions.php @@ -0,0 +1,49 @@ + Roles. Core discovers this class from Security/Permissions/. + */ +class ProgramPermissions extends AbstractPermissions +{ + /** + * @param mixed[] $params + */ + public function __construct(array $params) + { + parent::__construct($params); + + $this->addStandardPermissions('categories'); + $this->addExtendedPermissions('initiatives'); + $this->addExtendedPermissions('tasks'); + $this->addExtendedPermissions('stakeholders'); + $this->addExtendedPermissions('audiences'); + } + + public function getName(): string + { + return 'program'; + } + + /** + * @param array $options + * @param array $data + */ + public function buildForm(FormBuilderInterface &$builder, array $options, array $data): void + { + $this->addStandardFormFields('program', 'categories', $builder, $data); + $this->addExtendedFormFields('program', 'initiatives', $builder, $data); + $this->addExtendedFormFields('program', 'tasks', $builder, $data); + $this->addExtendedFormFields('program', 'stakeholders', $builder, $data); + $this->addExtendedFormFields('program', 'audiences', $builder, $data); + } +} diff --git a/Service/AudienceAttributes.php b/Service/AudienceAttributes.php new file mode 100644 index 0000000..1595ff7 --- /dev/null +++ b/Service/AudienceAttributes.php @@ -0,0 +1,107 @@ + Configuration > Program Settings. + * + * Which attributes of an audience persona are offered on the forms is chosen there, one toggle per + * attribute, so a b2b install and a b2c install define their personas differently. Each toggle is + * a local.php parameter (default enabled; an admin turns off what they don't use): + * - program_audience_attribute_tagline (Tagline) + * - program_audience_attribute_profile (Profile criteria) + * - program_audience_attribute_motivations (Motivations) + * - program_audience_attribute_barriers (Barriers) + * - program_audience_attribute_frustrations (Frustrations) + * - program_audience_attribute_triggers (Triggers) + * - program_audience_attribute_decision_role (Decision-making role; values program_audience_decision_roles) + * - program_audience_attribute_tones (Preferred tones; values program_audience_tones) + * - program_audience_attribute_channels (Preferred channels) + * - program_audience_attribute_stages (Stages) + * - program_audience_attribute_size (Estimated size) + * + * The values of the decision roles and the tones are lists edited in the same place, with a name + * per language — read through ItemTypeProvider (kinds "audience_decision_role" and "audience_tone"). + * + * The segments are NOT part of this: every audience offers them (always, purely informational). + */ +class AudienceAttributes +{ + /** + * Attribute key => form field name. The keys name the local.php toggle parameters; the values + * are the Audience entity's fields. The order is the order of the forms and of the tables. + */ + public const ATTRIBUTES = [ + 'tagline' => 'tagline', + 'profile' => 'profileCriteria', + 'motivations' => 'motivations', + 'barriers' => 'barriers', + 'frustrations' => 'frustrations', + 'triggers' => 'triggers', + 'decision_role' => 'decisionRole', + 'tones' => 'preferredTones', + 'channels' => 'preferredChannels', + 'stages' => 'stages', + 'size' => 'estimatedSize', + ]; + + public function __construct( + private CoreParametersHelper $coreParametersHelper, + ) { + } + + /** + * True when an attribute is offered on the audience forms. The toggle defaults to enabled, so + * an install that never touches the settings gets every attribute; turning it off stores false. + */ + public function isEnabled(string $attribute): bool + { + if (!isset(self::ATTRIBUTES[$attribute])) { + return false; + } + + // Null (parameter never set) and true both mean enabled; only an explicit false turns it off. + return false !== $this->coreParametersHelper->get(self::toggleParameter($attribute)); + } + + /** + * The enabled attribute keys, in canonical order. + * + * @return list + */ + public function getEnabled(): array + { + $enabled = []; + foreach (array_keys(self::ATTRIBUTES) as $attribute) { + if ($this->isEnabled($attribute)) { + $enabled[] = $attribute; + } + } + + return $enabled; + } + + /** + * The form field name of an attribute ('tagline', 'profileCriteria', …). + */ + public function getField(string $attribute): string + { + if (!isset(self::ATTRIBUTES[$attribute])) { + throw new \InvalidArgumentException('Unknown audience attribute: '.$attribute); + } + + return self::ATTRIBUTES[$attribute]; + } + + /** + * The local.php parameter holding an attribute's toggle. + */ + public static function toggleParameter(string $attribute): string + { + return 'program_audience_attribute_'.$attribute; + } +} \ No newline at end of file diff --git a/Service/CurrencyProvider.php b/Service/CurrencyProvider.php index 4416c47..0ee141e 100644 --- a/Service/CurrencyProvider.php +++ b/Service/CurrencyProvider.php @@ -2,22 +2,22 @@ declare(strict_types=1); -namespace MauticPlugin\PlanBundle\Service; +namespace MauticPlugin\ProgramBundle\Service; use Mautic\CoreBundle\Helper\CoreParametersHelper; use Symfony\Component\Intl\Currencies; use Symfony\Contracts\Translation\TranslatorInterface; /** - * The currency of all amounts in the plugin (plan budgets, allocation costs and totals). + * The currency of all amounts in the plugin (initiative budgets, allocation costs and totals). * - * It is a general setting, chosen by an administrator in Settings > Configuration > Plan Settings and - * stored in the local.php parameter plan_currency; users don't pick a currency. Amounts aren't converted + * It is a general setting, chosen by an administrator in Settings > Configuration > Program Settings and + * stored in the local.php parameter program_currency; users don't pick a currency. Amounts aren't converted * when it changes: they are simply shown with the new currency. */ class CurrencyProvider { - public const CONFIG_PARAMETER = 'plan_currency'; + public const CONFIG_PARAMETER = 'program_currency'; public const DEFAULT_CURRENCY = 'EUR'; diff --git a/Service/ItemTypeProvider.php b/Service/ItemTypeProvider.php index a44d6da..031a75a 100644 --- a/Service/ItemTypeProvider.php +++ b/Service/ItemTypeProvider.php @@ -2,25 +2,28 @@ declare(strict_types=1); -namespace MauticPlugin\PlanBundle\Service; +namespace MauticPlugin\ProgramBundle\Service; use Mautic\CoreBundle\Helper\CoreParametersHelper; use Mautic\CoreBundle\Helper\LanguageHelper; use Symfony\Contracts\Translation\TranslatorInterface; /** - * Reads the item types set up in Settings > Configuration > Plan. There is one list of types per kind: - * - KIND_DESCRIPTION: types of description items (Description tab), parameter plan_description_item_types; - * - KIND_ALLOCATION: types of allocation items (Allocation tab), parameter plan_allocation_item_types; - * - KIND_OBJECTIVE: types of objectives (Objectives tab), parameter plan_objective_types; - * - KIND_TASK: types of tasks (Planning > Tasks and the plan's Tasks tab), parameter plan_task_types; - * - KIND_STAKEHOLDER: types of stakeholders (Planning > Stakeholders), parameter plan_stakeholder_types. + * Reads the item types set up in Settings > Configuration > Program Settings. There is one list of types per kind: + * - KIND_DESCRIPTION: types of description items (the Insights tab), parameter program_description_item_types; + * - KIND_ALLOCATION: types of allocation items (Allocation tab), parameter program_allocation_item_types; + * - KIND_OBJECTIVE: types of objectives (Objectives tab), parameter program_objective_types; + * - KIND_TASK: types of tasks (Programs > Tasks and the initiative's Tasks tab), parameter program_task_types; + * - KIND_STAKEHOLDER: types of stakeholders (Programs > Stakeholders), parameter program_stakeholder_types; + * - KIND_AUDIENCE_DECISION_ROLE: values of an audience's "Decision-making role" attribute, parameter + * program_audience_decision_roles (Settings > Configuration > Program Settings); + * - KIND_AUDIENCE_TONE: values of an audience's "Preferred tone" attribute, parameter program_audience_tones. * * Each list is stored in local.php, in display order: * * [ * ['key' => 'type_1a2b3c4d', 'names' => ['en_US' => 'Context', 'fr' => 'Contexte'], - * 'descriptions' => ['en_US' => 'Why this plan exists', 'fr' => '…'], 'icon' => 'ri-lightbulb-line'], + * 'descriptions' => ['en_US' => 'Why this initiative exists', 'fr' => '…'], 'icon' => 'ri-lightbulb-line'], * … * ] * @@ -35,16 +38,20 @@ class ItemTypeProvider public const KIND_OBJECTIVE = 'objective'; public const KIND_TASK = 'task'; public const KIND_STAKEHOLDER = 'stakeholder'; + public const KIND_AUDIENCE_DECISION_ROLE = 'audience_decision_role'; + public const KIND_AUDIENCE_TONE = 'audience_tone'; /** * Kind => local.php parameter. */ public const PARAMETERS = [ - self::KIND_DESCRIPTION => 'plan_description_item_types', - self::KIND_ALLOCATION => 'plan_allocation_item_types', - self::KIND_OBJECTIVE => 'plan_objective_types', - self::KIND_TASK => 'plan_task_types', - self::KIND_STAKEHOLDER => 'plan_stakeholder_types', + self::KIND_DESCRIPTION => 'program_description_item_types', + self::KIND_ALLOCATION => 'program_allocation_item_types', + self::KIND_OBJECTIVE => 'program_objective_types', + self::KIND_TASK => 'program_task_types', + self::KIND_STAKEHOLDER => 'program_stakeholder_types', + self::KIND_AUDIENCE_DECISION_ROLE => 'program_audience_decision_roles', + self::KIND_AUDIENCE_TONE => 'program_audience_tones', ]; public function __construct( diff --git a/Service/Pictograms.php b/Service/Pictograms.php index 170f9df..e127d8f 100644 --- a/Service/Pictograms.php +++ b/Service/Pictograms.php @@ -2,11 +2,11 @@ declare(strict_types=1); -namespace MauticPlugin\PlanBundle\Service; +namespace MauticPlugin\ProgramBundle\Service; /** * Pictograms an administrator can give to an item type — description or allocation (Settings > - * Configuration > Plan Settings). They are icons of the Remix Icon set that Mautic ships ("ri-*" + * Configuration > Program Settings). They are icons of the Remix Icon set that Mautic ships ("ri-*" * classes); each one was checked against Mautic 7's icon stylesheet. */ final class Pictograms diff --git a/Translations/en_US/messages.ini b/Translations/en_US/messages.ini index d24e5b2..3bc128d 100644 --- a/Translations/en_US/messages.ini +++ b/Translations/en_US/messages.ini @@ -1,275 +1,332 @@ -mautic.plugin.plan.name="Plan" -mautic.plan.menu.root="Planning" -mautic.plan.menu.index="Plans" +mautic.plugin.program.name="Program" +mautic.program.menu.root="Programs" +mautic.program.menu.index="Initiatives" -mautic.plan.tab.details="Details" -mautic.plan.tab.description="Description" -mautic.plan.tab.objectives="Objectives" -mautic.plan.tab.allocations="Allocations" -mautic.plan.tab.targets="Targets" -mautic.plan.tab.stakeholders="Stakeholders" -mautic.plan.tab.tasks="Tasks" +mautic.program.tab.details="Details" +mautic.program.tab.description="Insights" +mautic.program.tab.objectives="Objectives" +mautic.program.tab.allocations="Allocations" +mautic.program.tab.audiences="Audiences" +mautic.program.tab.stakeholders="Stakeholders" +mautic.program.tab.tasks="Tasks" -mautic.plan.value.none="None" -mautic.plan.target.empty="No targets yet." -mautic.plan.task.empty="No tasks yet." +mautic.program.value.none="None" +mautic.program.audience.empty="No audiences yet." +mautic.program.task.empty="No tasks yet." -; Stakeholders (the global directory, Planning > Stakeholders, and the plan's Stakeholders tab). -mautic.plan.field.stakeholders="Stakeholders" -mautic.plan.stakeholder.menu.index="Stakeholders" -mautic.plan.stakeholder.header.index="Stakeholders" -mautic.plan.stakeholder.header.new="New stakeholder" -mautic.plan.stakeholder.header.edit="Edit stakeholder - %name%" -mautic.plan.stakeholder.error.notfound="No stakeholder with the ID %id% was found." -mautic.plan.stakeholder.form.confirmdelete="Delete the stakeholder, %name%? Its links to the plans are deleted too." -mautic.plan.stakeholder.form.confirmbatchdelete="Delete the selected stakeholders? Their links to the plans are deleted too." -mautic.plan.stakeholder.onboarding.heading="No stakeholders yet" -mautic.plan.stakeholder.onboarding.subheading="Stakeholders are the people, companies and teams involved in your plans." -mautic.plan.stakeholder.onboarding.copy="Use the New button above to add a stakeholder to the directory. Then assign it to a plan from the plan's Stakeholders tab, with its role in that plan." -mautic.plan.stakeholder.field.pictogram="Pictogram" -mautic.plan.stakeholder.field.name="Name" -mautic.plan.stakeholder.field.email="Email" -mautic.plan.stakeholder.field.phone="Phone" -mautic.plan.stakeholder.field.role="Role" -mautic.plan.stakeholder.field.type="Type" -mautic.plan.stakeholder.field.active="Active" -mautic.plan.stakeholder.field.role_in_plan="Role in the plan" -mautic.plan.stakeholder.field.plans="Assigned plans" -mautic.plan.stakeholder.active="Active" -mautic.plan.stakeholder.inactive="Inactive" -mautic.plan.stakeholder.no_plans="Not assigned to any plan" -mautic.plan.stakeholder.add="Add stakeholder" -mautic.plan.stakeholder.remove="Remove stakeholder" -mautic.plan.stakeholder.drag="Drag to reorder" -mautic.plan.stakeholder.empty="No stakeholders assigned to this plan yet." -mautic.plan.stakeholder.phone.help="Typed without a country prefix, the number is read with the default region from Settings > Configuration > Plan Settings." +; Stakeholders (the global directory, Programs > Stakeholders, and the initiative's Stakeholders tab). +mautic.program.field.stakeholders="Stakeholders" +mautic.program.stakeholder.menu.index="Stakeholders" +mautic.program.stakeholder.header.index="Stakeholders" +mautic.program.stakeholder.header.new="New stakeholder" +mautic.program.stakeholder.header.edit="Edit stakeholder - %name%" +mautic.program.stakeholder.error.notfound="No stakeholder with the ID %id% was found." +mautic.program.stakeholder.form.confirmdelete="Delete the stakeholder, %name%? Its links to the initiatives are deleted too." +mautic.program.stakeholder.form.confirmbatchdelete="Delete the selected stakeholders? Their links to the initiatives are deleted too." +mautic.program.stakeholder.onboarding.heading="No stakeholders yet" +mautic.program.stakeholder.onboarding.subheading="Stakeholders are the people, companies and teams involved in your initiatives." +mautic.program.stakeholder.onboarding.copy="Use the New button above to add a stakeholder to the directory. Then assign it to an initiative from the initiative's Stakeholders tab, with its role in that initiative." +mautic.program.stakeholder.field.pictogram="Pictogram" +mautic.program.stakeholder.field.name="Name" +mautic.program.stakeholder.field.email="Email" +mautic.program.stakeholder.field.phone="Phone" +mautic.program.stakeholder.field.role="Role" +mautic.program.stakeholder.field.type="Type" +mautic.program.stakeholder.field.active="Active" +mautic.program.stakeholder.field.role_in_initiative="Role in the initiative" +mautic.program.stakeholder.field.plans="Assigned initiatives" +mautic.program.stakeholder.active="Active" +mautic.program.stakeholder.inactive="Inactive" +mautic.program.stakeholder.no_plans="Not assigned to any initiative" +mautic.program.stakeholder.add="Add stakeholder" +mautic.program.stakeholder.remove="Remove stakeholder" +mautic.program.stakeholder.drag="Drag to reorder" +mautic.program.stakeholder.empty="No stakeholders assigned to this initiative yet." +mautic.program.stakeholder.phone.help="Typed without a country prefix, the number is read with the default region from Settings > Configuration > Program Settings." ; Stakeholder types (Settings > Configuration > Plan Settings). -mautic.plan.config.section.stakeholder_types="Stakeholder types" -mautic.plan.config.section.stakeholder_types.help="The types offered for the stakeholders of the directory (Planning > Stakeholders), in this order. Give each type a name and a description in each language, and a pictogram; the default language is required. Users see their own language, or the default language when it's empty." -mautic.plan.config.stakeholder_phone_region="Default phone region" -mautic.plan.config.stakeholder_phone_region.tooltip="ISO country code (e.g. FR) used to read stakeholder phone numbers typed without a country prefix." +mautic.program.config.section.stakeholder_types="Stakeholder types" +mautic.program.config.section.stakeholder_types.help="The types offered for the stakeholders of the directory (Programs > Stakeholders), in this order. Give each type a name and a description in each language, and a pictogram; the default language is required. Users see their own language, or the default language when it's empty." +mautic.program.config.stakeholder_phone_region="Default phone region" +mautic.program.config.stakeholder_phone_region.tooltip="ISO country code (e.g. FR) used to read stakeholder phone numbers typed without a country prefix." -; Targets (the plan's Targets tab). -mautic.plan.field.targets="Targets" -mautic.plan.target.field.pictogram="Pictogram" -mautic.plan.target.field.name="Name" -mautic.plan.target.field.type="Type" -mautic.plan.target.field.priority="Priority" -mautic.plan.target.field.stages="Stages" -mautic.plan.target.field.estimated_size="Estimated size" -mautic.plan.target.field.profile_criteria="Profile criteria" -mautic.plan.target.field.pain_points="Pain points" -mautic.plan.target.field.value_proposition="Value proposition" -mautic.plan.target.field.preferred_channels="Preferred channels" -mautic.plan.target.add="Add target" -mautic.plan.target.remove="Remove target" -mautic.plan.target.drag="Drag to reorder" -mautic.plan.target.type.persona="Buyer Persona" -mautic.plan.target.type.icp="Account / ICP" -mautic.plan.target.type.broad_audience="Broad / Ad Audience" -mautic.plan.target.type.lifecycle_cohort="Lifecycle Cohort" -mautic.plan.target.type.partner_influencer="Partner / Influencer" -mautic.plan.target.priority.primary="Primary Target" -mautic.plan.target.priority.secondary="Secondary Target" -mautic.plan.target.priority.exclusion="Exclusion / Anti-Persona" -mautic.plan.target.channel.email="Email" -mautic.plan.target.channel.sms="SMS" -mautic.plan.target.channel.web="Web" -mautic.plan.target.channel.social_organic="Social organic" -mautic.plan.target.channel.paid_social="Paid social" -mautic.plan.target.channel.paid_search="Paid search" -mautic.plan.target.channel.events_webinar="Events / webinar" -mautic.plan.target.channel.outbound_sales="Outbound sales" -mautic.plan.target.channel.partners="Partners" +; Audience attributes and values (Settings > Configuration > Plan Settings). +mautic.program.config.section.audience_values="Audience values" +mautic.program.config.section.audience_values.help="The values offered for an audience's closed attributes (decision roles, tones), in this order. Give each value a name in each language; the default language is required." +mautic.program.config.section.audience_decision_roles="Decision-making roles" +mautic.program.config.section.audience_decision_roles.help="The roles offered for an audience's decision-making role (e.g. User, Influencer, Decision-Maker, Budget Holder), in this order." +mautic.program.config.section.audience_tones="Tones" +mautic.program.config.section.audience_tones.help="The tones offered for an audience's preferred tone (e.g. Formal, Casual, Data-driven, Emotional), in this order." +mautic.program.config.section.audience_attributes="Audience attributes" +mautic.program.config.section.audience_attributes.help="Switch the persona attributes on or off to define how your installs describe their audiences (b2b, b2c). A switched-off attribute disappears from the audience forms; the values entered so far are kept." + +; Audiences (the global directory, Programs > Audiences, and the initiative's Audiences tab). +mautic.program.field.audiences="Audiences" +mautic.program.audience.menu.index="Audiences" +mautic.program.utm_taxonomy.menu.index="UTM Taxonomies" +mautic.program.utm_taxonomy.header.index="UTM Taxonomies" +mautic.program.utm_taxonomy.onboarding.heading="Coming soon" +mautic.program.utm_taxonomy.onboarding.subheading="UTM Taxonomies will classify the UTM parameters of your programs." +mautic.program.utm_taxonomy.onboarding.copy="This page is a placeholder for now; its content is coming in a later version." +mautic.program.audience.header.index="Audiences" +mautic.program.audience.header.new="New audience" +mautic.program.audience.header.edit="Edit audience - %name%" +mautic.program.audience.error.notfound="No audience with the ID %id% was found." +mautic.program.audience.form.confirmdelete="Delete the audience, %name%? Its column is removed from every initiative that lists it; the initiatives themselves are kept." +mautic.program.audience.form.confirmbatchdelete="Delete the selected audiences? Their columns are removed from every initiative that lists them; the initiatives themselves are kept." +mautic.program.audience.onboarding.heading="No audiences yet" +mautic.program.audience.onboarding.subheading="Audiences are the people your initiatives aim at." +mautic.program.audience.onboarding.copy="Use the New button above. An audience is defined once and reused in as many initiatives as needed: an initiative's Audiences tab lists the directory's audiences with their priority in that initiative, and a message specific to it." +mautic.program.audience.field.pictogram="Pictogram" +mautic.program.audience.field.name="Name" +mautic.program.audience.field.type="Type" +mautic.program.audience.field.tagline="Tagline" +mautic.program.audience.field.priority="Priority" +mautic.program.audience.field.stages="Stages" +mautic.program.audience.field.segments="Segments" +mautic.program.audience.field.estimated_size="Estimated size" +mautic.program.audience.field.profile_criteria="Profile criteria" +mautic.program.audience.field.motivations="Motivations" +mautic.program.audience.field.barriers="Barriers" +mautic.program.audience.field.frustrations="Frustrations" +mautic.program.audience.field.triggers="Triggers" +mautic.program.audience.field.decision_role="Decision-making role" +mautic.program.audience.field.preferred_tones="Preferred tone" +mautic.program.audience.field.value_proposition="Value proposition" +mautic.program.audience.field.preferred_channels="Preferred channels" +mautic.program.audience.field.active="Active" +mautic.program.audience.field.plans="Assigned initiatives" +mautic.program.audience.active="Active" +mautic.program.audience.inactive="Inactive" +mautic.program.audience.active.help="An inactive audience is hidden from the initiative forms, but keeps its history on the initiatives it is already assigned to." +mautic.program.audience.no_plans="Not assigned to any initiative" +mautic.program.audience.add="Add audience" +mautic.program.audience.remove="Remove audience" +mautic.program.audience.drag="Drag to reorder" +mautic.program.audience.empty="No audiences assigned to this initiative yet." +mautic.program.audience.link_tab.help="Pick the initiative's audiences from the directory (Programs > Audiences), with their priority in this initiative and a message specific to it." +mautic.program.audience.type.fixed_note="The type is fixed (not admin-configured); the pictogram follows it." +mautic.program.audience.type.persona="Buyer Persona" +mautic.program.audience.type.icp="Account / ICP" +mautic.program.audience.type.broad_audience="Broad / Ad Audience" +mautic.program.audience.type.lifecycle_cohort="Lifecycle Cohort" +mautic.program.audience.type.partner_influencer="Partner / Influencer" +mautic.program.audience.priority.primary="Primary audience" +mautic.program.audience.priority.secondary="Secondary audience" +mautic.program.audience.priority.exclusion="Exclusion / Anti-Persona" +mautic.program.audience.channel.email="Email" +mautic.program.audience.channel.sms="SMS" +mautic.program.audience.channel.web="Web" +mautic.program.audience.channel.social_organic="Social organic" +mautic.program.audience.channel.paid_social="Paid social" +mautic.program.audience.channel.paid_search="Paid search" +mautic.program.audience.channel.events_webinar="Events / webinar" +mautic.program.audience.channel.outbound_sales="Outbound sales" +mautic.program.audience.channel.partners="Partners" +mautic.program.audience.segments.note="The segments are informational: they hold this audience's contacts in Mautic. Pick none, one or several; the list shows their names and their number of contacts." + +; Which audience persona attributes are offered (one toggle each), and the values of the closed ones. +mautic.program.audience.attribute.tagline="Tagline" +mautic.program.audience.attribute.profile="Profile criteria" +mautic.program.audience.attribute.motivations="Motivations" +mautic.program.audience.attribute.barriers="Barriers" +mautic.program.audience.attribute.frustrations="Frustrations (replaces Pain points)" +mautic.program.audience.attribute.triggers="Triggers" +mautic.program.audience.attribute.decision_role="Decision-making role" +mautic.program.audience.attribute.tones="Preferred tone" +mautic.program.audience.attribute.channels="Preferred channels" +mautic.program.audience.attribute.stages="Stages" +mautic.program.audience.attribute.size="Estimated size" ; Plan tab tables (detail page): filter box and click-to-sort headers. -mautic.plan.filter.placeholder="Filter…" -mautic.plan.filter.no_match="No rows match the filter." -mautic.plan.filter.sort_hint="Click to sort" +mautic.program.filter.placeholder="Filter…" +mautic.program.filter.no_match="No rows match the filter." +mautic.program.filter.sort_hint="Click to sort" -; Long description item texts, clamped to 10 lines (Description tab, detail page). -mautic.plan.read_more.more="Read more" -mautic.plan.read_more.less="Show less" +; Long description item texts, clamped to 10 lines (Insights tab, detail page). +mautic.program.read_more.more="Read more" +mautic.program.read_more.less="Show less" -mautic.plan.header.index="Plans" -mautic.plan.header.new="New plan" -mautic.plan.header.edit="Edit plan - %name%" +mautic.program.header.index="Initiatives" +mautic.program.header.new="New initiative" +mautic.program.header.edit="Edit initiative - %name%" -mautic.plan.onboarding.heading="No plans yet" -mautic.plan.onboarding.subheading="Create your first plan to get started." -mautic.plan.onboarding.copy="Use the New button above to create a plan, then track its status, dates and budget here." +mautic.program.onboarding.heading="No initiatives yet" +mautic.program.onboarding.subheading="Create your first initiative to get started." +mautic.program.onboarding.copy="Use the New button above to create an initiative, then track its status, dates and budget here." -; Used by core's standard CRUD controller and buttons (translation base mautic.plan). -mautic.plan.error.notfound="No plan with the ID %id% was found." -mautic.plan.form.confirmdelete="Delete the plan, %name%? Its objectives and tasks are deleted too." -mautic.plan.form.confirmbatchdelete="Delete the selected plans? Their objectives and tasks are deleted too." +; Used by core's standard CRUD controller and buttons (translation base mautic.program). +mautic.program.error.notfound="No initiative with the ID %id% was found." +mautic.program.form.confirmdelete="Delete the initiative, %name%? Its objectives and tasks are deleted too." +mautic.program.form.confirmbatchdelete="Delete the selected initiatives? Their objectives and tasks are deleted too." ; Category type label (Settings > Categories). -mautic.plan.category.type="Plan" +mautic.program.category.type="Initiative" ; Settings > Roles. -mautic.plan.permissions.header="Plan Permissions" -mautic.plan.permissions.plans="Plans - User has access to" -mautic.plan.permissions.tasks="Tasks - User has access to" +mautic.program.permissions.header="Program Permissions" +mautic.program.permissions.initiatives="Initiatives - User has access to" +mautic.program.permissions.tasks="Tasks - User has access to" +mautic.program.permissions.stakeholders="Stakeholders - User has access to" +mautic.program.permissions.audiences="Audiences - User has access to" -; Tasks (Planning > Tasks). Translation base mautic.plan.task. -mautic.plan.task.menu.index="Tasks" -mautic.plan.task.header.index="Tasks" -mautic.plan.task.header.new="New task" -mautic.plan.task.header.edit="Edit task - %name%" -mautic.plan.task.error.notfound="No task with the ID %id% was found." -mautic.plan.task.form.confirmdelete="Delete the task, %name%? Its dependencies on other tasks and its RACI assignments are removed too." -mautic.plan.task.form.confirmbatchdelete="Delete the selected tasks? Their dependencies on other tasks and their RACI assignments are removed too." -mautic.plan.task.onboarding.heading="No tasks yet" -mautic.plan.task.onboarding.subheading="Tasks break a plan down into work to do." -mautic.plan.task.onboarding.copy="Use the New button above, or Add task on a plan's Tasks tab. A task belongs to one plan, may depend on other tasks of that plan (start to start, end to end and so on), and is assigned to the plan's stakeholders through RACI roles." -mautic.plan.task.field.name="Name" -mautic.plan.task.field.type="Type" -mautic.plan.task.field.pictogram="Pictogram" -mautic.plan.task.field.description="Description" -mautic.plan.task.field.plan="Plan" -mautic.plan.task.field.kind="Kind" -mautic.plan.task.field.start_date="Start date" -mautic.plan.task.field.end_date="End date" -mautic.plan.task.field.status="Status" -mautic.plan.task.field.definition_of_done="Definition of Done" -mautic.plan.task.field.planned_work="Planned work" -mautic.plan.task.field.dependencies="Dependencies" -mautic.plan.task.field.raci="RACI" -mautic.plan.task.status.new="New" -mautic.plan.task.status.todo="To do" -mautic.plan.task.status.in_progress="In progress" -mautic.plan.task.status.done="Done" -mautic.plan.task.kind.task="Task" -mautic.plan.task.kind.milestone="Milestone" -mautic.plan.task.kind.milestone_short="M" -mautic.plan.task.kind.phase="Phase" -mautic.plan.task.kind.phase_short="P" -mautic.plan.task.kind.task_short="T" -mautic.plan.task.kind.phase_status_note="A phase has no status of its own: its state comes from its tasks." -mautic.plan.task.kind.milestone_end_note="A milestone ends on its start date: the end date is the start date." -mautic.plan.task.planned_work_unit="hours" -mautic.plan.task.dependency.add="Add dependency" -mautic.plan.task.dependency.remove="Remove dependency" -mautic.plan.task.dependency.drag="Drag to reorder" -mautic.plan.task.dependency.empty="No dependencies yet." -mautic.plan.task.dependency.field.depends_on="Depends on" -mautic.plan.task.dependency.field.type="Relation" -mautic.plan.task.dependency_type.end_to_start="End to Start" -mautic.plan.task.dependency_type.end_to_end="End to End" -mautic.plan.task.dependency_type.start_to_start="Start to Start" -mautic.plan.task.dependency_type.start_to_end="Start to End" -mautic.plan.task.raci.add="Add RACI role" -mautic.plan.task.raci.remove="Remove" -mautic.plan.task.raci.drag="Drag to reorder" -mautic.plan.task.raci.empty="No RACI assignments yet." -mautic.plan.task.raci.field.role="Role" -mautic.plan.task.raci.field.stakeholders="Stakeholders" -mautic.plan.task.raci_role.responsible="Responsible" -mautic.plan.task.raci_role.accountable="Accountable" -mautic.plan.task.raci_role.consulted="Consulted" -mautic.plan.task.raci_role.informed="Informed" -mautic.plan.task.add="Add task" -mautic.plan.task.manage_from_plan_page="Add and edit tasks from the plan's page, after saving." +; Tasks (Programs > Tasks). Translation base mautic.program.task. +mautic.program.task.menu.index="Tasks" +mautic.program.task.header.index="Tasks" +mautic.program.task.header.new="New task" +mautic.program.task.header.edit="Edit task - %name%" +mautic.program.task.error.notfound="No task with the ID %id% was found." +mautic.program.task.form.confirmdelete="Delete the task, %name%? Its dependencies on other tasks and its RACI assignments are removed too." +mautic.program.task.form.confirmbatchdelete="Delete the selected tasks? Their dependencies on other tasks and their RACI assignments are removed too." +mautic.program.task.onboarding.heading="No tasks yet" +mautic.program.task.onboarding.subheading="Tasks break an initiative down into work to do." +mautic.program.task.onboarding.copy="Use the New button above, or Add task on an initiative's Tasks tab. A task belongs to one initiative, may depend on other tasks of that initiative (start to start, end to end and so on), and is assigned to the initiative's stakeholders through RACI roles." +mautic.program.task.field.name="Name" +mautic.program.task.field.type="Type" +mautic.program.task.field.pictogram="Pictogram" +mautic.program.task.field.description="Description" +mautic.program.task.field.initiative="Initiative" +mautic.program.task.field.kind="Kind" +mautic.program.task.field.start_date="Start date" +mautic.program.task.field.end_date="End date" +mautic.program.task.field.status="Status" +mautic.program.task.field.definition_of_done="Definition of Done" +mautic.program.task.field.planned_work="Planned work" +mautic.program.task.field.dependencies="Dependencies" +mautic.program.task.field.raci="RACI" +mautic.program.task.status.new="New" +mautic.program.task.status.todo="To do" +mautic.program.task.status.in_progress="In progress" +mautic.program.task.status.done="Done" +mautic.program.task.kind.task="Task" +mautic.program.task.kind.milestone="Milestone" +mautic.program.task.kind.milestone_short="M" +mautic.program.task.kind.phase="Phase" +mautic.program.task.kind.phase_short="P" +mautic.program.task.kind.task_short="T" +mautic.program.task.kind.phase_status_note="A phase has no status of its own: its state comes from its tasks." +mautic.program.task.kind.milestone_end_note="A milestone ends on its start date: the end date is the start date." +mautic.program.task.planned_work_unit="hours" +mautic.program.task.dependency.add="Add dependency" +mautic.program.task.dependency.remove="Remove dependency" +mautic.program.task.dependency.drag="Drag to reorder" +mautic.program.task.dependency.empty="No dependencies yet." +mautic.program.task.dependency.field.depends_on="Depends on" +mautic.program.task.dependency.field.type="Relation" +mautic.program.task.dependency_type.end_to_start="End to Start" +mautic.program.task.dependency_type.end_to_end="End to End" +mautic.program.task.dependency_type.start_to_start="Start to Start" +mautic.program.task.dependency_type.start_to_end="Start to End" +mautic.program.task.raci.add="Add RACI role" +mautic.program.task.raci.remove="Remove" +mautic.program.task.raci.drag="Drag to reorder" +mautic.program.task.raci.empty="No RACI assignments yet." +mautic.program.task.raci.field.role="Role" +mautic.program.task.raci.field.stakeholders="Stakeholders" +mautic.program.task.raci_role.responsible="Responsible" +mautic.program.task.raci_role.accountable="Accountable" +mautic.program.task.raci_role.consulted="Consulted" +mautic.program.task.raci_role.informed="Informed" +mautic.program.task.add="Add task" +mautic.program.task.manage_from_initiative_page="Add and edit tasks from the initiative's page, after saving." -mautic.plan.field.name="Name" -mautic.plan.field.status="Status" -mautic.plan.field.owner="Owner" -mautic.plan.field.start_date="Start date" -mautic.plan.field.end_date="End date" -mautic.plan.field.completed_at="Completed at" -mautic.plan.field.budget_planned="Planned budget" -mautic.plan.field.version="Version" -mautic.plan.field.objectives="Objectives" -mautic.plan.field.description_items="Description items" -mautic.plan.field.allocation_items="Allocation items" +mautic.program.field.name="Name" +mautic.program.field.status="Status" +mautic.program.field.owner="Owner" +mautic.program.field.start_date="Start date" +mautic.program.field.end_date="End date" +mautic.program.field.completed_at="Completed at" +mautic.program.field.budget_planned="Planned budget" +mautic.program.field.version="Version" +mautic.program.field.objectives="Objectives" +mautic.program.field.description_items="Description items" +mautic.program.field.allocation_items="Allocation items" -mautic.plan.objective.field.title="Title" -mautic.plan.objective.field.type="Type" -mautic.plan.objective.field.pictogram="Pictogram" -mautic.plan.objective.field.name="Name" -mautic.plan.objective.field.priority="Priority" -mautic.plan.objective.field.description="Description" -mautic.plan.objective.field.is_achieved="Achieved" -mautic.plan.objective.add="Add objective" -mautic.plan.objective.remove="Remove objective" -mautic.plan.objective.drag="Drag to reorder" -mautic.plan.objective.empty="No objectives yet." -mautic.plan.objective.no_types="No objective types are set up yet. An administrator can add them in Settings > Configuration > Plan Settings." -mautic.plan.objective.progress="%achieved% of %total% achieved" -mautic.plan.objective.achieved="Achieved" -mautic.plan.objective.not_achieved="Not achieved" +mautic.program.objective.field.title="Title" +mautic.program.objective.field.type="Type" +mautic.program.objective.field.pictogram="Pictogram" +mautic.program.objective.field.name="Name" +mautic.program.objective.field.priority="Priority" +mautic.program.objective.field.description="Description" +mautic.program.objective.field.is_achieved="Achieved" +mautic.program.objective.add="Add objective" +mautic.program.objective.remove="Remove objective" +mautic.program.objective.drag="Drag to reorder" +mautic.program.objective.empty="No objectives yet." +mautic.program.objective.no_types="No objective types are set up yet. An administrator can add them in Settings > Configuration > Program Settings." +mautic.program.objective.progress="%achieved% of %total% achieved" +mautic.program.objective.achieved="Achieved" +mautic.program.objective.not_achieved="Not achieved" -mautic.plan.owner.none="No owner" +mautic.program.owner.none="No owner" -mautic.plan.status.draft="Draft" -mautic.plan.status.planned="Planned" -mautic.plan.status.active="Active" -mautic.plan.status.paused="Paused" -mautic.plan.status.completed="Completed" -mautic.plan.status.archived="Archived" +mautic.program.status.draft="Draft" +mautic.program.status.planned="Planned" +mautic.program.status.active="Active" +mautic.program.status.paused="Paused" +mautic.program.status.completed="Completed" +mautic.program.status.archived="Archived" -; Description items (the plan's Description tab). -mautic.plan.description_item.field.type="Type" -mautic.plan.description_item.field.description="Description" -mautic.plan.description_item.add="Add description item" -mautic.plan.description_item.remove="Remove description item" -mautic.plan.description_item.drag="Drag to reorder" -mautic.plan.description_item.empty="No description items yet." -mautic.plan.description_item.no_types="No description item types are set up yet. An administrator can add them in Settings > Configuration > Plan Settings." -mautic.plan.description_item.type.unknown="Unknown type (%key%)" +; Description items (the initiative's Insights tab). +mautic.program.description_item.field.type="Type" +mautic.program.description_item.field.description="Description" +mautic.program.description_item.add="Add description item" +mautic.program.description_item.remove="Remove description item" +mautic.program.description_item.drag="Drag to reorder" +mautic.program.description_item.empty="No description items yet." +mautic.program.description_item.no_types="No insights types are set up yet. An administrator can add them in Settings > Configuration > Program Settings." +mautic.program.description_item.type.unknown="Unknown type (%key%)" ; Settings > Configuration > Plan. Core builds the tab title key from the form alias. -mautic.config.tab.planconfig="Plan Settings" -mautic.plan.config.description="Settings of the Plan plugin." -mautic.plan.config.section.description_item_types="Description item types" -mautic.plan.config.section.description_item_types.help="The types offered for the items of a plan's Description tab, in this order. Give each type a name and a description in each language; the default language is required. Users see their own language, or the default language when it's empty." -mautic.plan.config.types.empty="No types yet." -mautic.plan.config.type.add="Add type" -mautic.plan.config.type.remove="Remove type" -mautic.plan.config.type.language="Language" -mautic.plan.config.type.name="Name" -mautic.plan.config.type.description="Description" +mautic.config.tab.programconfig="Program Settings" +mautic.program.config.description="Settings of the Program plugin." +mautic.program.config.section.description_item_types="Insights types" +mautic.program.config.section.description_item_types.help="The types offered for the items of an initiative's Insights tab, in this order. Give each type a name and a description in each language, and a pictogram; the default language is required. Users see their own language, or the default language when it's empty." +mautic.program.config.types.empty="No types yet." +mautic.program.config.type.add="Add type" +mautic.program.config.type.remove="Remove type" +mautic.program.config.type.language="Language" +mautic.program.config.type.name="Name" +mautic.program.config.type.description="Description" -; Allocation items (the plan's Allocations tab). -mautic.plan.allocation_item.field.type="Type" -mautic.plan.allocation_item.field.pictogram="Pictogram" -mautic.plan.allocation_item.field.name="Name" -mautic.plan.allocation_item.field.description="Description" -mautic.plan.allocation_item.field.planned_cost="Planned cost" -mautic.plan.allocation_item.field.real_cost="Real cost" -mautic.plan.allocation_item.add="Add allocation item" -mautic.plan.allocation_item.remove="Remove allocation item" -mautic.plan.allocation_item.drag="Drag to reorder" -mautic.plan.allocation_item.empty="No allocation items yet." -mautic.plan.allocation_item.no_types="No allocation item types are set up yet. An administrator can add them in Settings > Configuration > Plan Settings." -mautic.plan.allocation.total="Total" +; Allocation items (the initiative's Allocations tab). +mautic.program.allocation_item.field.type="Type" +mautic.program.allocation_item.field.pictogram="Pictogram" +mautic.program.allocation_item.field.name="Name" +mautic.program.allocation_item.field.description="Description" +mautic.program.allocation_item.field.planned_cost="Planned cost" +mautic.program.allocation_item.field.real_cost="Real cost" +mautic.program.allocation_item.add="Add allocation item" +mautic.program.allocation_item.remove="Remove allocation item" +mautic.program.allocation_item.drag="Drag to reorder" +mautic.program.allocation_item.empty="No allocation items yet." +mautic.program.allocation_item.no_types="No allocation item types are set up yet. An administrator can add them in Settings > Configuration > Program Settings." +mautic.program.allocation.total="Total" ; Plan page header: total costs of the allocation items, in the general currency. -mautic.plan.header.total_planned="Planned: %amount% %currency%" -mautic.plan.header.total_planned.tooltip="Total planned cost of the allocation items" -mautic.plan.header.total_real="Real: %amount% %currency%" -mautic.plan.header.total_real.tooltip="Total real cost of the allocation items, within the planned cost" -mautic.plan.header.total_real.over="Total real cost of the allocation items, above the planned cost" +mautic.program.header.total_planned="Planned: %amount% %currency%" +mautic.program.header.total_planned.tooltip="Total planned cost of the allocation items" +mautic.program.header.total_real="Real: %amount% %currency%" +mautic.program.header.total_real.tooltip="Total real cost of the allocation items, within the planned cost" +mautic.program.header.total_real.over="Total real cost of the allocation items, above the planned cost" -mautic.plan.task.save_plan_first="Save the plan first, then add tasks from its page." +mautic.program.task.save_initiative_first="Save the initiative first, then add tasks from its page." -mautic.plan.config.section.allocation_item_types="Allocation item types" -mautic.plan.config.section.allocation_item_types.help="The types offered for the cost lines of a plan's Allocations tab, in this order. Give each type a name and a description in each language, and a pictogram; the default language is required. Users see their own language, or the default language when it's empty." +mautic.program.config.section.allocation_item_types="Allocation item types" +mautic.program.config.section.allocation_item_types.help="The types offered for the cost lines of an initiative's Allocations tab, in this order. Give each type a name and a description in each language, and a pictogram; the default language is required. Users see their own language, or the default language when it's empty." ; Objective types (Settings > Configuration > Plan Settings). -mautic.plan.config.section.objective_types="Objective types" -mautic.plan.config.section.objective_types.help="The types offered for the objectives of a plan's Objectives tab, in this order. Give each type a name and a description in each language, and a pictogram; the default language is required. Users see their own language, or the default language when it's empty." +mautic.program.config.section.objective_types="Objective types" +mautic.program.config.section.objective_types.help="The types offered for the objectives of an initiative's Objectives tab, in this order. Give each type a name and a description in each language, and a pictogram; the default language is required. Users see their own language, or the default language when it's empty." ; Task types (Settings > Configuration > Plan Settings). -mautic.plan.config.section.task_types="Task types" -mautic.plan.config.section.task_types.help="The types offered for tasks, in this order. Give each type a name and a description in each language, and a pictogram; the default language is required. Users see their own language, or the default language when it's empty." +mautic.program.config.section.task_types="Task types" +mautic.program.config.section.task_types.help="The types offered for tasks, in this order. Give each type a name and a description in each language, and a pictogram; the default language is required. Users see their own language, or the default language when it's empty." -mautic.plan.description_item.field.pictogram="Pictogram" -mautic.plan.config.section.general="General" -mautic.plan.config.currency="Currency" -mautic.plan.config.currency.tooltip="The currency of every amount in plans: budgets, costs and totals." -mautic.plan.config.currency.help="Users don't choose a currency: every budget, cost and total is in this currency. Changing it doesn't convert existing amounts." -mautic.plan.config.type.icon="Pictogram" -mautic.plan.config.type.icon.none="No pictogram" +mautic.program.description_item.field.pictogram="Pictogram" +mautic.program.config.section.general="General" +mautic.program.config.currency="Currency" +mautic.program.config.currency.tooltip="The currency of every amount in initiatives: budgets, costs and totals." +mautic.program.config.currency.help="Users don't choose a currency: every budget, cost and total is in this currency. Changing it doesn't convert existing amounts." +mautic.program.config.type.icon="Pictogram" +mautic.program.config.type.icon.none="No pictogram" diff --git a/Translations/en_US/validators.ini b/Translations/en_US/validators.ini index 8f3f82b..8f18731 100644 --- a/Translations/en_US/validators.ini +++ b/Translations/en_US/validators.ini @@ -1,22 +1,23 @@ -mautic.plan.owner.required="An owner is required." -mautic.plan.end_date.before_start_date="The end date must be on or after the start date." -mautic.plan.version.range="The version must be a whole number from 1 to 99." -mautic.plan.objective.title.required="An objective needs a title." -mautic.plan.objective.type.required="Choose a type." -mautic.plan.objective.priority.range="The priority must be a whole number from 1 to 99." -mautic.plan.target.name.required="A target needs a name." -mautic.plan.target.estimated_size.invalid="The estimated size must be 0 or more." -mautic.plan.stakeholder.email.invalid="This email address is not valid." -mautic.plan.stakeholder_link.stakeholder.required="Choose a stakeholder." -mautic.plan.task.plan.required="A task must be assigned to a plan." -mautic.plan.task.type.required="Choose a type." -mautic.plan.task.planned_work.invalid="The planned work must be a whole number of hours, 0 or more." -mautic.plan.task.planned_work.range="The planned work must be a whole number of hours from 0 to %max%." -mautic.plan.task.milestone.end_enslaved="A milestone ends on its start date." -mautic.plan.task.dependency.self="A task can't depend on itself." -mautic.plan.task.dependency.cycle="A task can't depend on a task that (directly or not) depends on it." -mautic.plan.task.dependency.other_plan="A task can only depend on tasks of the same plan." -mautic.plan.description_item.type.required="Choose a type." -mautic.plan.config.type.name.required="A type needs a name in the default language." -mautic.plan.config.type.in_use="These types are in use and can't be removed: %types%. Change the items or tasks that use them to another type first." -mautic.plan.allocation_item.type.required="Choose a type." +mautic.program.owner.required="An owner is required." +mautic.program.end_date.before_start_date="The end date must be on or after the start date." +mautic.program.version.range="The version must be a whole number from 1 to 99." +mautic.program.objective.title.required="An objective needs a title." +mautic.program.objective.type.required="Choose a type." +mautic.program.objective.priority.range="The priority must be a whole number from 1 to 99." +mautic.program.audience.name.required="An audience needs a name." +mautic.program.audience.estimated_size.invalid="The estimated size must be 0 or more." +mautic.program.audience_link.audience.required="Choose an audience." +mautic.program.stakeholder.email.invalid="This email address is not valid." +mautic.program.stakeholder_link.stakeholder.required="Choose a stakeholder." +mautic.program.task.initiative.required="A task must be assigned to an initiative." +mautic.program.task.type.required="Choose a type." +mautic.program.task.planned_work.invalid="The planned work must be a whole number of hours, 0 or more." +mautic.program.task.planned_work.range="The planned work must be a whole number of hours from 0 to %max%." +mautic.program.task.milestone.end_enslaved="A milestone ends on its start date." +mautic.program.task.dependency.self="A task can't depend on itself." +mautic.program.task.dependency.cycle="A task can't depend on a task that (directly or not) depends on it." +mautic.program.task.dependency.other_plan="A task can only depend on tasks of the same initiative." +mautic.program.description_item.type.required="Choose a type." +mautic.program.config.type.name.required="A type needs a name in the default language." +mautic.program.config.type.in_use="These types are in use and can't be removed: %types%. Change the items or tasks that use them to another type first." +mautic.program.allocation_item.type.required="Choose a type." diff --git a/Twig/PlanExtension.php b/Twig/PlanExtension.php deleted file mode 100644 index c41dde4..0000000 --- a/Twig/PlanExtension.php +++ /dev/null @@ -1,110 +0,0 @@ - self::linkify($text), ['is_safe' => ['html']]), - ]; - } - - public function getFunctions(): array - { - return [ - new TwigFunction('plan_item_type_name', fn (string $kind, ?string $key): ?string => $this->typeProvider->getName($kind, $key)), - new TwigFunction('plan_item_type_description', fn (string $kind, ?string $key): ?string => $this->typeProvider->getDescription($kind, $key)), - new TwigFunction('plan_item_type_icon', fn (string $kind, ?string $key): ?string => $this->typeProvider->getIcon($kind, $key)), - new TwigFunction('plan_currency', fn (): string => $this->currencyProvider->getCurrency()), - new TwigFunction('plan_money', fn ($amount): string => number_format((float) $amount, 2)), - new TwigFunction('plan_target_channel_label', fn (string $key): string => Target::CHANNELS[$key] ?? $key), - new TwigFunction('plan_target_channel_label', fn (string $key): string => Target::CHANNELS[$key] ?? $key), - ]; - } - - /** - * Plain text as HTML, with the URLs in it (https://… and www.…) turned into links that open in a - * new tab. For the description fields of plans and tasks, which stay plain text: typing or pasting - * a URL is enough, no editor needed. Everything is escaped here, so no HTML can be injected. - */ - public static function linkify(?string $text): string - { - if (null === $text || '' === $text) { - return ''; - } - - // One capture group: preg_split then alternates plain text (even) and URLs (odd). - $parts = preg_split('~((?:https?://|(?"\']+)~i', $text, -1, PREG_SPLIT_DELIM_CAPTURE); - $html = ''; - - foreach ($parts as $i => $part) { - $html .= $i % 2 ? self::urlAnchor($part) : htmlspecialchars($part, ENT_QUOTES, 'UTF-8'); - } - - return $html; - } - - /** - * One URL as a link. Sentence punctuation that follows the URL (".", ")", "!", …) stays outside - * the link, and a bare "www." address gets the https:// prefix. - */ - private static function urlAnchor(string $url): string - { - $after = ''; - - while ('' !== $url && str_contains('.,;:!?', substr($url, -1))) { - $after = substr($url, -1).$after; - $url = substr($url, 0, -1); - } - - // An unbalanced closing parenthesis belongs to the sentence, not the URL. - if (str_ends_with($url, ')') && !str_contains($url, '(')) { - $after = ')'.$after; - $url = substr($url, 0, -1); - } - - // Only a prefix is left ("www.", "https://"): not a link after all. - if ('' === $url || 'www.' === $url || 'http://' === $url || 'https://' === $url) { - return htmlspecialchars($url.$after, ENT_QUOTES, 'UTF-8'); - } - - $href = preg_match('~^https?://~i', $url) ? $url : 'https://'.$url; - - return sprintf( - '%s%s', - htmlspecialchars($href, ENT_QUOTES, 'UTF-8'), - htmlspecialchars($url, ENT_QUOTES, 'UTF-8'), - htmlspecialchars($after, ENT_QUOTES, 'UTF-8') - ); - } -} diff --git a/Twig/ProgramExtension.php b/Twig/ProgramExtension.php new file mode 100644 index 0000000..04fd815 --- /dev/null +++ b/Twig/ProgramExtension.php @@ -0,0 +1,151 @@ + (segment id => count) + * program_audience_segment_count(segmentId) the contact count of one segment + * + * Filters: + * program_linkify(text) plain text as HTML, with the URLs in it as links opening in a new tab + * program_audience_type_icon(value) the pictogram of an AudienceType case value ('persona'…) + */ +class ProgramExtension extends AbstractExtension +{ + public function __construct( + private ItemTypeProvider $typeProvider, + private CurrencyProvider $currencyProvider, + private AudienceAttributes $audienceAttributes, + private AudienceRepository $audienceRepository, + ) { + } + + public function getFilters(): array + { + return [ + // The filter escapes everything itself, so its output is safe for templates. + new TwigFilter('program_linkify', fn (?string $text): string => self::linkify($text), ['is_safe' => ['html']]), + new TwigFilter('program_audience_type_icon', fn ($value): string => self::audienceTypeIcon($value)), + ]; + } + + public function getFunctions(): array + { + return [ + new TwigFunction('program_item_type_name', fn (string $kind, ?string $key): ?string => $this->typeProvider->getName($kind, $key)), + new TwigFunction('program_item_type_description', fn (string $kind, ?string $key): ?string => $this->typeProvider->getDescription($kind, $key)), + new TwigFunction('program_item_type_icon', fn (string $kind, ?string $key): ?string => $this->typeProvider->getIcon($kind, $key)), + new TwigFunction('program_currency', fn (): string => $this->currencyProvider->getCurrency()), + new TwigFunction('program_money', fn ($amount): string => number_format((float) $amount, 2)), + new TwigFunction('program_audience_channel_label', fn (string $key): string => Audience::CHANNELS[$key] ?? $key), + new TwigFunction('program_audience_decision_role_label', fn (?string $key): ?string => $this->typeProvider->getName(ItemTypeProvider::KIND_AUDIENCE_DECISION_ROLE, $key)), + new TwigFunction('program_audience_tone_label', fn (?string $key): ?string => $this->typeProvider->getName(ItemTypeProvider::KIND_AUDIENCE_TONE, $key)), + new TwigFunction('program_audience_attributes', fn (): array => array_keys(AudienceAttributes::ATTRIBUTES)), + new TwigFunction('program_audience_attribute_toggle', fn (string $attribute): string => AudienceAttributes::toggleParameter($attribute)), + new TwigFunction('program_audience_segment_counts', fn (iterable $items): array => $this->audienceRepository->getSegmentContactCountsForAudiences( + array_map( + static fn (Audience $audience): int => $audience->getId(), + is_array($items) ? $items : iterator_to_array($items) + ) + )), + new TwigFunction('program_audience_segment_count', fn (int $leadlistId): int => $this->audienceRepository->getSegmentContactCount($leadlistId)), + ]; + } + + /** + * The pictogram of an audience type. Accepts the enum itself (what the form's and entity's value + * holds) or its backing value ('persona'); null defaults to Persona, the form's default. + */ + private static function audienceTypeIcon($value): string + { + if ($value instanceof AudienceType) { + return $value->getIcon(); + } + + try { + return AudienceType::from((string) ($value ?? 'persona'))->getIcon(); + } catch (\ValueError) { + return ''; + } + } + + /** + * Plain text as HTML, with the URLs in it (https://… and www.…) turned into links that open in a + * new tab. For the description fields of plans and tasks, which stay plain text: typing or pasting + * a URL is enough, no editor needed. Everything is escaped here, so no HTML can be injected. + */ + public static function linkify(?string $text): string + { + if (null === $text || '' === $text) { + return ''; + } + + // One capture group: preg_split then alternates plain text (even) and URLs (odd). + $parts = preg_split('~((?:https?://|(?"\']+)~i', $text, -1, PREG_SPLIT_DELIM_CAPTURE); + $html = ''; + + foreach ($parts as $i => $part) { + $html .= $i % 2 ? self::urlAnchor($part) : htmlspecialchars($part, ENT_QUOTES, 'UTF-8'); + } + + return $html; + } + + /** + * One URL as a link. Sentence punctuation that follows the URL (".", ")", "!", …) stays outside + * the link, and a bare "www." address gets the https:// prefix. + */ + private static function urlAnchor(string $url): string + { + $after = ''; + + while ('' !== $url && str_contains('.,;:!?', substr($url, -1))) { + $after = substr($url, -1).$after; + $url = substr($url, 0, -1); + } + + // An unbalanced closing parenthesis belongs to the sentence, not the URL. + if (str_ends_with($url, ')') && !str_contains($url, '(')) { + $after = ')'.$after; + $url = substr($url, 0, -1); + } + + // Only a prefix is left ("www.", "https://"): not a link after all. + if ('' === $url || 'www.' === $url || 'http://' === $url || 'https://' === $url) { + return htmlspecialchars($url.$after, ENT_QUOTES, 'UTF-8'); + } + + $href = preg_match('~^https?://~i', $url) ? $url : 'https://'.$url; + + return sprintf( + '%s%s', + htmlspecialchars($href, ENT_QUOTES, 'UTF-8'), + htmlspecialchars($url, ENT_QUOTES, 'UTF-8'), + htmlspecialchars($after, ENT_QUOTES, 'UTF-8') + ); + } +} diff --git a/Validator/Constraints/EndDateAfterStartDate.php b/Validator/Constraints/EndDateAfterStartDate.php index cf7a112..7322165 100644 --- a/Validator/Constraints/EndDateAfterStartDate.php +++ b/Validator/Constraints/EndDateAfterStartDate.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace MauticPlugin\PlanBundle\Validator\Constraints; +namespace MauticPlugin\ProgramBundle\Validator\Constraints; use Symfony\Component\Validator\Constraint; @@ -12,7 +12,7 @@ use Symfony\Component\Validator\Constraint; */ class EndDateAfterStartDate extends Constraint { - public string $message = 'mautic.plan.end_date.before_start_date'; + public string $message = 'mautic.program.end_date.before_start_date'; public function getTargets(): string { diff --git a/Validator/Constraints/EndDateAfterStartDateValidator.php b/Validator/Constraints/EndDateAfterStartDateValidator.php index 1dfd27e..913402f 100644 --- a/Validator/Constraints/EndDateAfterStartDateValidator.php +++ b/Validator/Constraints/EndDateAfterStartDateValidator.php @@ -2,9 +2,9 @@ declare(strict_types=1); -namespace MauticPlugin\PlanBundle\Validator\Constraints; +namespace MauticPlugin\ProgramBundle\Validator\Constraints; -use MauticPlugin\PlanBundle\Entity\DateRangeInterface; +use MauticPlugin\ProgramBundle\Entity\DateRangeInterface; use Symfony\Component\Validator\Constraint; use Symfony\Component\Validator\ConstraintValidator; use Symfony\Component\Validator\Exception\UnexpectedTypeException; diff --git a/Validator/Constraints/TaskDates.php b/Validator/Constraints/TaskDates.php index e0e67b8..7b87371 100644 --- a/Validator/Constraints/TaskDates.php +++ b/Validator/Constraints/TaskDates.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace MauticPlugin\PlanBundle\Validator\Constraints; +namespace MauticPlugin\ProgramBundle\Validator\Constraints; use Symfony\Component\Validator\Constraint; @@ -16,7 +16,7 @@ use Symfony\Component\Validator\Constraint; #[\Symfony\Component\Validator\Attribute\HasNamedArguments] class TaskDates extends Constraint { - public const MILESTONE_END_ENSLAVED = 'mautic.plan.task.milestone.end_enslaved'; + public const MILESTONE_END_ENSLAVED = 'mautic.program.task.milestone.end_enslaved'; public function getTargets(): string|array { diff --git a/Validator/Constraints/TaskDatesValidator.php b/Validator/Constraints/TaskDatesValidator.php index 1346074..660fc36 100644 --- a/Validator/Constraints/TaskDatesValidator.php +++ b/Validator/Constraints/TaskDatesValidator.php @@ -2,10 +2,10 @@ declare(strict_types=1); -namespace MauticPlugin\PlanBundle\Validator\Constraints; +namespace MauticPlugin\ProgramBundle\Validator\Constraints; -use MauticPlugin\PlanBundle\Entity\Task; -use MauticPlugin\PlanBundle\Entity\TaskKind; +use MauticPlugin\ProgramBundle\Entity\Task; +use MauticPlugin\ProgramBundle\Entity\TaskKind; use Symfony\Component\Validator\Constraint; use Symfony\Component\Validator\ConstraintValidator; diff --git a/Validator/Constraints/ValidTaskDependency.php b/Validator/Constraints/ValidTaskDependency.php index 26392f3..e994699 100644 --- a/Validator/Constraints/ValidTaskDependency.php +++ b/Validator/Constraints/ValidTaskDependency.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace MauticPlugin\PlanBundle\Validator\Constraints; +namespace MauticPlugin\ProgramBundle\Validator\Constraints; use Symfony\Component\Validator\Constraint; @@ -11,9 +11,9 @@ use Symfony\Component\Validator\Constraint; */ class ValidTaskDependency extends Constraint { - public const SELF_REFERENCE = 'mautic.plan.task.dependency.self'; - public const CYCLE = 'mautic.plan.task.dependency.cycle'; - public const OTHER_PLAN = 'mautic.plan.task.dependency.other_plan'; + public const SELF_REFERENCE = 'mautic.program.task.dependency.self'; + public const CYCLE = 'mautic.program.task.dependency.cycle'; + public const OTHER_PLAN = 'mautic.program.task.dependency.other_plan'; public function getTargets(): string|array { diff --git a/Validator/Constraints/ValidTaskDependencyValidator.php b/Validator/Constraints/ValidTaskDependencyValidator.php index 02d325e..87389fc 100644 --- a/Validator/Constraints/ValidTaskDependencyValidator.php +++ b/Validator/Constraints/ValidTaskDependencyValidator.php @@ -2,11 +2,11 @@ declare(strict_types=1); -namespace MauticPlugin\PlanBundle\Validator\Constraints; +namespace MauticPlugin\ProgramBundle\Validator\Constraints; use Doctrine\ORM\EntityManagerInterface; -use MauticPlugin\PlanBundle\Entity\Task; -use MauticPlugin\PlanBundle\Entity\TaskDependency; +use MauticPlugin\ProgramBundle\Entity\Task; +use MauticPlugin\ProgramBundle\Entity\TaskDependency; use Symfony\Component\Validator\Constraint; use Symfony\Component\Validator\ConstraintValidator; @@ -50,7 +50,7 @@ class ValidTaskDependencyValidator extends ConstraintValidator return; } - if (null !== $task->getPlan() && null !== $dependsOn->getPlan() && $task->getPlan()->getId() !== $dependsOn->getPlan()->getId()) { + if (null !== $task->getInitiative() && null !== $dependsOn->getInitiative() && $task->getInitiative()->getId() !== $dependsOn->getInitiative()->getId()) { $this->context->buildViolation($constraint::OTHER_PLAN)->atPath('dependencies')->addViolation(); return; diff --git a/composer.json b/composer.json index 0ce63a7..4176075 100644 --- a/composer.json +++ b/composer.json @@ -1,19 +1,23 @@ { - "name": "experiential/mautic-plan-bundle", - "description": "Plan plugin for Mautic", + "name": "experiential/mautic-program-bundle", + "description": "Program plugin for Mautic", "type": "mautic-plugin", "license": "GPL-3.0-or-later", - "keywords": ["mautic", "plugin", "plan"], + "keywords": [ + "mautic", + "plugin", + "program" + ], "require": { "php": ">=8.2", "mautic/core-lib": "^7.0" }, "autoload": { "psr-4": { - "MauticPlugin\\PlanBundle\\": "" + "MauticPlugin\\ProgramBundle\\": "" } }, "extra": { - "install-directory-name": "PlanBundle" + "install-directory-name": "ProgramBundle" } } diff --git a/readme.md b/readme.md index 89d6137..e89f9bc 100644 --- a/readme.md +++ b/readme.md @@ -1,24 +1,24 @@ -# Mautic Plan plugin +# Mautic Program plugin -A custom Mautic 7 plugin (`PlanBundle`) for managing plans: a name, status, owner, dates, budget and category. +A custom Mautic 7 plugin (`ProgramBundle`) for managing programs: a name, status, owner, dates, budget and category, with their initiatives. -This repository holds only the plugin source. The bundle files are at the repository root, and Mautic loads them from `docroot/plugins/PlanBundle`. +This repository holds only the plugin source. The bundle files are at the repository root, and Mautic loads them from `docroot/plugins/ProgramBundle`. The plugin was called `PlanBundle` (and plans `Plan`) before 0.16.0: see *Rename history* below. ## Installation -1. Copy or clone this repository into your Mautic installation as `docroot/plugins/PlanBundle`. The folder name must be `PlanBundle`. +1. Copy or clone this repository into your Mautic installation as `docroot/plugins/ProgramBundle`. The folder name must be `ProgramBundle`. 2. Clear the cache and register the plugin: ```bash - column + php bin/console cache:clear php bin/console mautic:plugins:reload ``` -3. In Mautic, go to **Settings > Plugins**, open **Plan** and publish it. +3. In Mautic, go to **Settings > Plugins**, open **Program** and publish it. -Plans are listed under **Planning > Plans** in the main menu (URL `/s/plans`), tasks under **Planning > Tasks** (URL `/s/plan-tasks`), and the stakeholder directory under **Planning > Stakeholders** (URL `/s/plan-stakeholders`). Users who aren't administrators need a role with the **Plan Permissions** set in **Settings > Roles**. +Initiatives are listed under **Programs > Initiatives** in the main menu (URL `/s/programs`), tasks under **Programs > Tasks** (URL `/s/program-tasks`), the stakeholder directory under **Programs > Stakeholders** (URL `/s/program-stakeholders`), and the audience directory under **Programs > Audiences** (URL `/s/program-audiences`). **Programs > UTM Taxonomies** (URL `/s/program-utm-taxonomies`) is a placeholder for a coming feature. Users who aren't administrators need a role with the **Program Permissions** set in **Settings > Roles**. -Before using the items of a plan's **Description**, **Objectives**, **Allocations** and **Tasks** tabs, an administrator sets up their types in **Settings > Configuration > Plan Settings**. +Before using the items of an initiative's **Insights**, **Objectives**, **Allocations** and **Tasks** tabs, an administrator sets up their types in **Settings > Configuration > Program Settings**. ## Development @@ -35,6 +35,8 @@ In the dev environment's `.env`, point it at this plugin: PLUGIN_PLAN_PATH=../mautic-plugin-plan ``` +The dev environment mounts it as `docroot/plugins/ProgramBundle`. + Run all commands from the `mautic-dev-env` folder: ```bash @@ -50,146 +52,174 @@ For the complete list of commands, see the dev environment's README. The plugin uses the IntegrationsBundle conventions: -- `PlanBundle.php`: the bundle class +- `ProgramBundle.php`: the bundle class - `Config/config.php`: metadata, routes, menu and integration service tags - `Config/services.php`: autowires and autoconfigures every class in the bundle -- `DependencyInjection/PlanExtension.php`: loads `Config/services.php` -- `Integration/PlanIntegration.php`: the integration that is listed on the Plugins page -- `Integration/Support/ConfigSupport.php`: the configuration form for the integration +- `DependencyInjection/ProgramExtension.php`: loads `Config/services.php` +- `Integration/ProgramIntegration.php`: the integration that is listed on the Plugins page +- `Integration/Support/ProgramConfigSupport.php`: the configuration form for the integration - `Translations/en_US/messages.ini` and `validators.ini`: UI strings and validation messages ### Pages and permissions -- `Controller/PlanController.php`: list, detail page, create, edit and delete (single and batch), built on core's `AbstractStandardFormController` -- `Resources/views/Plan/list.html.twig`: the list. A plan's name opens its detail page. -- `Resources/views/Plan/form.html.twig` and `details.html.twig`: the create/edit form and the detail page. Both have the same six tabs, from `_tabs.html.twig`: **Details**, **Description** (description items), **Objectives**, **Allocations** (planned budget, currency and allocation items), **Targets** and **Tasks**. -- `Resources/views/Plan/_task_table.html.twig`: the plan's tasks in the Tasks tab. It has the harmonized tab columns (pictogram, Type, Name with kind badge for milestones and phases, Description, Start date, End date, Status — no ID), one row per task, no tree: a phase's or milestone's badge marks it in the name column. On the detail page it has an **Add task** button, links to each task and the filter/sort of the other tabs. On the plan form it is read-only (no links, no filter), so that following a link doesn't drop unsaved changes. -- `Controller/TaskController.php` and `Resources/views/Task/`: the task list, and the create/edit form (**Planning > Tasks**). `new?plan=ID` preselects the plan. After Save or Cancel, the user goes back to where the form was opened from. Opened from **Planning > Tasks**, that's the task list. Opened from a plan's Tasks tab, whose links carry `returnTo=plan`, that's the plan (its new plan, if the task was moved). The origin is stored in the session when the form is opened, because the form posts without the query string. -- `Assets/js/plan.js`: on the form, the objectives editor (add, remove, drag-and-drop ordering), and after a failed save, marking the tabs that contain errors with an icon and opening the first one. Started by `Mautic.planOnLoad()`. +- `Controller/InitiativeController.php`: list, detail page, create, edit and delete (single and batch), built on core's `AbstractStandardFormController` +- `Resources/views/Initiative/list.html.twig`: the list. An initiative's name opens its detail page. +- `Resources/views/Initiative/form.html.twig` and `details.html.twig`: the create/edit form and the detail page. Both have the same seven tabs, from `_tabs.html.twig`: **Details**, **Insights** (description items), **Objectives**, **Allocations** (planned budget, currency and allocation items), **Audiences**, **Stakeholders** and **Tasks**. +- `Resources/views/Initiative/_task_table.html.twig`: the initiative's tasks in the Tasks tab. It has the harmonized tab columns (pictogram, Type, Name with kind badge for milestones and phases, Description, Start date, End date, Status — no ID), one row per task, no tree: a phase's or milestone's badge marks it in the name column. On the detail page it has an **Add task** button, links to each task and the filter/sort of the other tabs. On the initiative form it is read-only (no links, no filter), so that following a link doesn't drop unsaved changes. +- `Controller/TaskController.php` and `Resources/views/Task/`: the task list, and the create/edit form (**Programs > Tasks**). `new?initiative=ID` preselects the initiative. After Save or Cancel, the user goes back to where the form was opened from. Opened from **Programs > Tasks**, that's the task list. Opened from an initiative's Tasks tab, whose links carry `returnTo=initiative`, that's the initiative (its new initiative, if the task was moved). The origin is stored in the session when the form is opened, because the form posts without the query string. +- `Controller/UtmTaxonomyController.php` and `Resources/views/UtmTaxonomy/`: the placeholder page for the coming UTM Taxonomies feature. +- `Assets/js/program.js`: on the form, the objectives editor (add, remove, drag-and-drop ordering), and after a failed save, marking the tabs that contain errors with an icon and opening the first one. Started by `Mautic.programOnLoad()`. -The plan's tab panes deliberately have no Bootstrap `fade` class. Core reopens the last tab used on a page (`12.tabs.js`), and the plugin opens the tab with an error after a failed save. With `fade`, those two `tab('show')` calls overlapped within the 150 ms transition and left two panes visible at once, so the Tasks tab also showed the objectives. +The initiative's tab panes deliberately have no Bootstrap `fade` class. Core reopens the last tab used on a page (`12.tabs.js`), and the plugin opens the tab with an error after a failed save. With `fade`, those two `tab('show')` calls overlapped within the 150 ms transition and left two panes visible at once, so the Tasks tab also showed the objectives. -Which tab opens on a plan's detail page and form (`Mautic.planInitTabs`): +Which tab opens on an initiative's detail page and form (`Mautic.programInitTabs`): -- The tab last used for a plan is remembered for the browser session (`sessionStorage`, key `mautic.plan.tab.`). The detail page and the form both reopen it, so Edit and Save keep the current tab. Cancel goes to the plans list, as in core. +- The tab last used for an initiative is remembered for the browser session (`sessionStorage`, key `mautic.program.tab.`). The detail page and the form both reopen it, so Edit and Save keep the current tab. Cancel goes to the initiatives list, as in core. - After a failed save, the first tab with an error opens instead, and every tab with an error gets a warning icon. -- Core reopens its own remembered tab on page load and after every Ajax request (`Mautic.rememberActiveTabs`), in an order that varies. `plan.js` wraps that function, so the plan's choice is applied right after core's restore, and only during the page load. +- Core reopens its own remembered tab on page load and after every Ajax request (`Mautic.rememberActiveTabs`), in an order that varies. `program.js` wraps that function, so the initiative's choice is applied right after core's restore, and only during the page load. - A tab counts as having an error only if it shows an error message (`.help-block .alert-danger`), not just because an element has the `has-error` class. Mautic's own `checkbox_row` theme adds `has-error` to every checkbox: it tests `errors|length is not empty`, and `0` isn't "empty" in Twig. Every objective's "Achieved" checkbox would otherwise put a warning icon on the Objectives tab, and opening that tab on load looked like a jump to Objectives. -- `Security/Permissions/PlanPermissions.php`: the permissions shown in **Settings > Roles** +- `Security/Permissions/ProgramPermissions.php`: the permissions shown in **Settings > Roles** -The main menu has a top-level **Planning** entry, with **Plans** and **Tasks** as its items. Add future planning pages as more children of `mautic.plan.menu.root` in `Config/config.php`. +The main menu has a top-level **Programs** entry, with **Initiatives**, **Tasks**, **Stakeholders**, **Audiences** and **UTM Taxonomies** as its items. Add future pages as more children of `mautic.program.menu.root` in `Config/config.php`. -The **Targets** tab lists the plan's audiences, harmonized like the other tabs: pictogram (fixed per target type), Type, Name, Priority, Stages, Estimated size, Profile criteria, Pain points, Value proposition, Preferred channels. +The **Audiences** tab lists the initiative's audiences, harmonized like the other tabs: pictogram (fixed per audience type), Type, Name (a link to the audience's page in the directory), Priority in this initiative, Stages, Estimated size, Value proposition, Preferred channels. | Route | URL | Purpose | | --- | --- | --- | -| `plan_index` | `/s/plans/{page}` | Plan list, with search on name | -| `plan_action` | `/s/plans/{objectAction}/{objectId}` | `view`, `new`, `edit`, `delete`, `batchDelete` | -| `plan_task_index` | `/s/plan-tasks/{page}` | Task list, with search on name and description | -| `plan_task_action` | `/s/plan-tasks/{objectAction}/{objectId}` | `new` (optional `?plan=ID`), `edit`, `delete`, `batchDelete` | -| `plan_stakeholder_index` | `/s/plan-stakeholders/{page}` | Stakeholder directory, with search on name, email, role and type | -| `plan_stakeholder_action` | `/s/plan-stakeholders/{objectAction}/{objectId}` | `new`, `edit`, `delete`, `batchDelete` | +| `initiative_index` | `/s/programs/{page}` | Initiative list, with search on name | +| `initiative_action` | `/s/programs/{objectAction}/{objectId}` | `view`, `new`, `edit`, `delete`, `batchDelete` | +| `initiative_task_index` | `/s/program-tasks/{page}` | Task list, with search on name and description | +| `initiative_task_action` | `/s/program-tasks/{objectAction}/{objectId}` | `new` (optional `?initiative=ID`), `edit`, `delete`, `batchDelete` | +| `initiative_stakeholder_index` | `/s/program-stakeholders/{page}` | Stakeholder directory, with search on name, email, role and type | +| `initiative_stakeholder_action` | `/s/program-stakeholders/{objectAction}/{objectId}` | `new`, `edit`, `delete`, `batchDelete` | +| `initiative_audience_index` | `/s/program-audiences/{page}` | Audience directory, with search on name | +| `initiative_audience_action` | `/s/program-audiences/{objectAction}/{objectId}` | `new`, `edit`, `view`, `delete`, `batchDelete` | +| `program_utm_taxonomy_index` | `/s/program-utm-taxonomies/{page}` | UTM Taxonomies (placeholder) | -The plan templates don't pass `routeBase` to core's button helpers (`page_actions`, `list_actions`) when a "close" button is involved: from `routeBase`, core builds `mautic__*` route names, which don't exist in this plugin. The other buttons use the `actionRoute` (`plan_action`) that the controller passes to the template. +The initiative templates don't pass `routeBase` to core's button helpers (`page_actions`, `list_actions`) when a "close" button is involved: from `routeBase`, core builds `mautic__*` route names, which don't exist in this plugin. The other buttons use the `actionRoute` (`initiative_action`) that the controller passes to the template. Permission keys: -- `plan:plans:*`, `plan:tasks:*` and `plan:stakeholders:*`: `viewown`, `viewother`, `editown`, `editother`, `create`, `deleteown`, `deleteother`, `publishown`, `publishother`, `full`. "Own" means items the user created (`createdBy`), as in core objects. -- `plan:categories:*`: managing the `plan` category type. +- `program:initiatives:*`, `program:tasks:*`, `program:stakeholders:*` and `program:audiences:*`: `viewown`, `viewother`, `editown`, `editother`, `create`, `deleteown`, `deleteother`, `publishown`, `publishother`, `full`. "Own" means items the user created (`createdBy`), as in core objects. +- `program:categories:*`: managing the `program` category type. -### The Plan object +### The Initiative object -- `Entity/Plan.php`: the entity (table `plans`), with its Doctrine mapping and validation rules -- `Entity/PlanStatus.php`: the status enum (`draft`, `planned`, `active`, `paused`, `completed`, `archived`) -- `Entity/PlanRepository.php`: the repository -- `Entity/PlanObjective.php` and `PlanObjectiveRepository.php`: a plan's objectives (table `plan_objectives`): type (with its pictogram), title, description, position and an "achieved" flag -- `Entity/Target.php`, `TargetType.php`, `TargetPriority.php` and `TargetRepository.php`: a plan's targets (table `plan_targets`), the audiences of the Targets tab: name, a fixed type (persona, ICP, broad audience, lifecycle cohort, partner/influencer — each with its own pictogram), a priority (primary, secondary, exclusion), any number of Mautic stages (join table `plan_target_stages`), an estimated size, profile criteria, pain points, a value proposition, preferred channels (checkboxes: email, SMS, web, social organic, paid social, paid search, events/webinar, outbound sales, partners) and a position. Targets are edited inside the plan form like objectives, and shown in the harmonized table of the Targets tab -- `Model/PlanModel.php`: the model, available as `mautic.plan.model.plan` or with `getModel('plan')`. A new plan from `getEntity()` has the current user as owner. -- `Entity/PlanDescriptionItem.php` and `PlanDescriptionItemRepository.php`: a plan's description items (table `plan_description_items`): type, description and position. They make up the Description tab and replace the former `description` field. -- `Form/Type/PlanType.php`, `PlanObjectiveType.php` and `PlanDescriptionItemType.php`: the create and edit form, with the objectives and the description items as collections -- `Validator/Constraints/EndDateAfterStartDate.php`: the end date must be on or after the start date, when both are set. Used by plans and tasks, through `Entity/DateRangeInterface.php`. +- `Entity/Initiative.php`: the entity (table `initiatives`), with its Doctrine mapping and validation rules +- `Entity/InitiativeStatus.php`: the status enum (`draft`, `planned`, `active`, `paused`, `completed`, `archived`) +- `Entity/InitiativeRepository.php`: the repository +- `Entity/InitiativeObjective.php` and `InitiativeObjectiveRepository.php`: an initiative's objectives (table `initiative_objectives`): type (with its pictogram), title, description, position and an "achieved" flag +- `Entity/Audience.php`, `AudienceType.php`, `AudiencePriority.php` and `AudienceRepository.php`: the audiences of the global directory (table `initiative_audiences`, `plan_targets` before 0.15.0): name, a fixed type (persona, ICP, broad audience, lifecycle cohort, partner/influencer — each with its own pictogram), a tagline, the Mautic segments that hold this audience's contacts (see below), and the persona attributes the admin switched on (**Settings > Configuration > Program Settings**, one toggle per attribute, so a b2b install and a b2c install define their personas differently): profile criteria, motivations, barriers, frustrations (formerly pain points), triggers, a decision-making role (a value of the admin-edited list `program_audience_decision_roles`), a preferred tone (checkboxes of the admin-edited list `program_audience_tones`), preferred channels (checkboxes: email, SMS, web, social organic, paid social, paid search, events/webinar, outbound sales, partners), any number of Mautic stages (join table `initiative_audiences_stages`) and an estimated size. `Service/AudienceAttributes.php` reads the toggles. +- **Segments**: each audience can have any number of Mautic segments (LeadBundle lists), purely informational — nothing requires one, and nothing in the initiative depends on them. They are stored in the join table `initiative_audiences_segments` (audience_id, leadlist_id), picked in the audience form (published segments only), shown in the directory's Segments column (each with its count of contacts, from `lead_lists_leads` where `manually_removed = 0`) and on the detail page. `AudienceRepository::getSegmentContactCountsForAudiences()` computes the counts for the whole page in one query. +- `Entity/InitiativeAudience.php`: the link between an initiative and an audience (table `initiative_audiences_initiative`), with the audience's priority in that initiative (primary, secondary, exclusion), an initiative-specific value proposition and a position. Deleting the initiative or the audience deletes the link (ON DELETE CASCADE both sides). +- `Model/AudienceModel.php`: the model, available as `mautic.program.model.audience` or with `getModel('program.audience')`. +- `Controller/AudienceController.php` and `Resources/views/Audience/`: the directory (**Programs > Audiences**), with the columns ID, Pictogram, Type, Name (with its tagline), Segments (each with its contact count), Estimated size, Active, and **Assigned initiatives** — the initiatives the audience is linked to, each with its priority in that initiative. The detail page lists the segments, the persona attributes that are filled in, and those initiatives. +- `Model/InitiativeModel.php`: the model, available as `mautic.program.model.initiative` or with `getModel('program.initiative')`. A new initiative from `getEntity()` has the current user as owner. +- `Entity/InitiativeDescriptionItem.php` and `InitiativeDescriptionItemRepository.php`: an initiative's description items (table `initiative_description_items`): type, description and position. They make up the **Insights** tab and replace the former `description` field. +- `Form/Type/InitiativeType.php`, `InitiativeObjectiveType.php` and `InitiativeDescriptionItemType.php`: the create and edit form, with the objectives and the description items as collections +- `Validator/Constraints/EndDateAfterStartDate.php`: the end date must be on or after the start date, when both are set. Used by initiatives and tasks, through `Entity/DateRangeInterface.php`. Behaviour to know about: -- Setting the status to `completed` from another status sets `completedAt` to the current time. Moving a completed plan to any other status clears `completedAt`. -- `owner` is required by validation, but the column is nullable: if the user is deleted, the owner becomes `NULL` (`ON DELETE SET NULL`), and the plan must be given a new owner before it can be saved again. -- Categories use the core CategoryBundle with the `plan` type (**Settings > Categories**). -- There is one currency for every amount: plan budgets, allocation costs and totals. It's a general setting, the **Currency** dropdown in **Settings > Configuration > Plan Settings** (parameter `plan_currency`, `EUR` by default), offering 40 main world currencies (`Service/CurrencyProvider.php`). Users never choose a currency, and amount fields show it next to the input. Changing it doesn't convert existing amounts: they're simply shown with the new currency. -- `version` is a whole number from 1 to 99, and new plans start at 1. It is edited by hand and isn't related to Doctrine's optimistic locking. -- Objectives belong to their plan: they are saved with it, deleted with it (`ON DELETE CASCADE` in the database too), and an objective removed from the form is deleted (`orphanRemoval`). They are always loaded ordered by `position`. On save, the model renumbers positions to 0, 1, 2… in their current order. Description items follow the same rules. +- Setting the status to `completed` from another status sets `completedAt` to the current time. Moving a completed initiative to any other status clears `completedAt`. +- `owner` is required by validation, but the column is nullable: if the user is deleted, the owner becomes `NULL` (`ON DELETE SET NULL`), and the initiative must be given a new owner before it can be saved again. +- Categories use the core CategoryBundle with the `program` type (**Settings > Categories**), shown as "Initiative". +- There is one currency for every amount: initiative budgets, allocation costs and totals. It's a general setting, the **Currency** dropdown in **Settings > Configuration > Program Settings** (parameter `program_currency`, `EUR` by default), offering 40 main world currencies (`Service/CurrencyProvider.php`). Users never choose a currency, and amount fields show it next to the input. Changing it doesn't convert existing amounts: they're simply shown with the new currency. +- `version` is a whole number from 1 to 99, and new initiatives start at 1. It is edited by hand and isn't related to Doctrine's optimistic locking. +- Objectives belong to their initiative: they are saved with it, deleted with it (`ON DELETE CASCADE` in the database too), and an objective removed from the form is deleted (`orphanRemoval`). They are always loaded ordered by `position`. On save, the model renumbers positions to 0, 1, 2… in their current order. Description items follow the same rules. - `getObjectives()` and `getDescriptionItems()` return the rows sorted by position, as a new collection. The mapping's `orderBy` isn't enough: after a reorder, the page shown right after saving uses the collection already loaded, in its old order. -- Text typed in the plan form, including in objectives and description items, is kept as typed: line breaks, `&` and quotes are preserved, and HTML tags are removed. This depends on `PlanType` passing a mask array to `CleanFormSubscriber`. Without one, core HTML-encodes every value, again on each save. +- Text typed in the initiative form, including in objectives and description items, is kept as typed: line breaks, `&` and quotes are preserved, and HTML tags are removed. This depends on `InitiativeType` passing a mask array to `CleanFormSubscriber`. Without one, core HTML-encodes every value, again on each save. ### Typed items: description items, allocation items and tasks -- A **description item** (Description tab, `Entity/PlanDescriptionItem.php`) has a type and a description. More fields are planned. -- An **allocation item** (Allocation tab, `Entity/PlanAllocationItem.php`, table `plan_allocation_items`) is a cost line: type (with its pictogram), name (optional), description, planned cost and real cost. Costs are `DECIMAL(12,2)`, in the general currency. -- An **objective** (`Entity/PlanObjective.php`) has a type too (with its pictogram), a title, a priority (a whole number from 1, the most important, to 99), a description and the achieved flag. The plan's Objectives tab lists them by priority; ties keep the manual order. The priority is required. -- A **task** (`Entity/Task.php`) has a type too (with its pictogram): see *The Task object* above. -- Description items, allocation items and objectives are edited inside the plan form, like objectives: add, remove, drag to reorder. They're saved and deleted with the plan. Tasks are edited on their own form, where the type's pictogram and description appear around the type dropdown. -- An administrator sets up each kind's types in **Settings > Configuration > Plan Settings**, in four sections. Each type has a name and a description for each language installed in Mautic, and the default language (the `locale` parameter) requires a name. Each type also has a pictogram. Users see their own language, or the default language when theirs is empty. The order of the types is the order of the dropdown. -- The types are stored in `config/local.php`, in the `plan_description_item_types`, `plan_allocation_item_types`, `plan_objective_types` and `plan_task_types` parameters. Read them with `Service/ItemTypeProvider.php`, passing the kind (`description`, `allocation`, `objective` or `task`). In templates, use the Twig functions `plan_item_type_name(kind, key)`, `plan_item_type_description(kind, key)` and `plan_item_type_icon(kind, key)`, plus `plan_currency()` and `plan_money(amount)` (`Twig/PlanExtension.php`). -- **Every item type has a pictogram**, chosen by the administrator from a list of Remix Icons that Mautic ships (`Service/Pictograms.php`, each checked against Mautic 7's icon stylesheet), with a live preview. It's stored as `icon` in the type. On the plan form and the task form it appears next to the type dropdown when a type is chosen. -- **The four item tabs of a plan's detail page are harmonized** (`Resources/views/Plan/details.html.twig`, `_task_table.html.twig`, `_tab_table_filter.html.twig`): every column starts with the pictogram (its header stays empty — no "Pictogram" label), then Type, Name, Description, and the kind's other fields; objectives show their Priority after Description, and tasks end with Status. The plan's Tasks tab doesn't show task IDs (`data-task-id` still carries them). Each tab has one filter box that matches every column, and every column header sorts the rows asc/desc on click (`Mautic.planInitTabTable` in `Assets/js/plan.js`, client-side). The objective's achieved flag is the Status column of its table. -- A description item's long description is **clamped to 10 lines** in the Description tab, with a *Read more* / *Show less* toggle (`_description_read_more.html.twig`, `Mautic.planInitReadMore`). The toggle appears only when the text really overflows: the pane is hidden on page load, so the measurement waits for the tab to be shown. +- A **description item** (Insights tab, `Entity/InitiativeDescriptionItem.php`) has a type and a description. More fields are planned. +- An **allocation item** (Allocations tab, `Entity/InitiativeAllocationItem.php`, table `initiative_allocation_items`) is a cost line: type (with its pictogram), name (optional), description, planned cost and real cost. Costs are `DECIMAL(12,2)`, in the general currency. +- An **objective** (`Entity/InitiativeObjective.php`) has a type too (with its pictogram), a title, a priority (a whole number from 1, the most important, to 99), a description and the achieved flag. The initiative's Objectives tab lists them by priority; ties keep the manual order. The priority is required. +- A **task** (`Entity/Task.php`) has a type too (with its pictogram): see *The Task object* below. +- Description items, allocation items and objectives are edited inside the initiative form, like objectives: add, remove, drag to reorder. They're saved and deleted with the initiative. Tasks are edited on their own form, where the type's pictogram and description appear around the type dropdown. +- An administrator sets up each kind's types in **Settings > Configuration > Program Settings**, in several sections. Each type has a name and a description for each language installed in Mautic, and the default language (the `locale` parameter) requires a name. Each type also has a pictogram. Users see their own language, or the default language when theirs is empty. The order of the types is the order of the dropdown. +- The types are stored in `config/local.php`, in the `program_description_item_types`, `program_allocation_item_types`, `program_objective_types`, `program_task_types` and `program_stakeholder_types` parameters. Read them with `Service/ItemTypeProvider.php`, passing the kind (`description`, `allocation`, `objective`, `task` or `stakeholder`). In templates, use the Twig functions `program_item_type_name(kind, key)`, `program_item_type_description(kind, key)` and `program_item_type_icon(kind, key)`, plus `program_currency()` and `program_money(amount)` (`Twig/ProgramExtension.php`). +- **Every item type has a pictogram**, chosen by the administrator from a list of Remix Icons that Mautic ships (`Service/Pictograms.php`, each checked against Mautic 7's icon stylesheet), with a live preview. It's stored as `icon` in the type. On the initiative form and the task form it appears next to the type dropdown when a type is chosen. +- **The four item tabs of an initiative's detail page are harmonized** (`Resources/views/Initiative/details.html.twig`, `_task_table.html.twig`, `_tab_table_filter.html.twig`): every column starts with the pictogram (its header stays empty — no "Pictogram" label), then Type, Name, Description, and the kind's other fields; objectives show their Priority after Description, and tasks end with Status. The initiative's Tasks tab doesn't show task IDs (`data-task-id` still carries them). Each tab has one filter box that matches every column, and every column header sorts the rows asc/desc on click (`Mautic.programInitTabTable` in `Assets/js/program.js`, client-side). The objective's achieved flag is the Status column of its table. +- A description item's long description is **clamped to 10 lines** in the Insights tab, with a *Read more* / *Show less* toggle (`_description_read_more.html.twig`, `Mautic.programInitReadMore`). The toggle appears only when the text really overflows: the pane is hidden on page load, so the measurement waits for the tab to be shown. - Each type has a hidden key, generated when it's created and never changed. Items store that key, so renaming a type renames it everywhere. - A type that items use can't be removed: the configuration isn't saved, and the error lists the types and how many items use them (`EventListener/ConfigSubscriber.php`, on `CONFIG_PRE_SAVE`). -- On the plan form, the selected type's description is shown under the type dropdown. When no types are set up, the tab says where to set them up. -- Files: `Form/Type/ConfigType.php`, `ItemTypeConfigType.php`, `PlanDescriptionItemType.php`, `PlanAllocationItemType.php` and `Resources/views/FormTheme/Config/_config_planconfig_widget.html.twig`. Adding and removing types is handled in `Assets/js/plan.js`. +- On the initiative form, the selected type's description is shown under the type dropdown. When no types are set up, the tab says where to set them up. +- Files: `Form/Type/ConfigType.php`, `ItemTypeConfigType.php`, `InitiativeDescriptionItemType.php`, `InitiativeAllocationItemType.php` and `Resources/views/FormTheme/Config/_config_programconfig_widget.html.twig`. Adding and removing types is handled in `Assets/js/program.js`. ### Cost totals -- `Plan::getAllocationTotals()` adds up the allocation items' planned and real costs, in the general currency. The sums are done in cents, as integers. -- The plan detail page shows them under the title, after the plan status, as on an email's page (`publishStatus` block): a "Planned" tag and a "Real" tag. A real total above the planned total is red, otherwise green. +- `Initiative::getAllocationTotals()` adds up the allocation items' planned and real costs, in the general currency. The sums are done in cents, as integers. +- The initiative detail page shows them under the title, after the initiative status, as on an email's page (`publishStatus` block): a "Planned" tag and a "Real" tag. A real total above the planned total is red, otherwise green. - The Allocations tab of the detail page lists the cost lines, followed by a total row. - `isAchieved` is toggled by hand on the form for now. ### The Stakeholder object -- `Entity/Stakeholder.php` and `StakeholderRepository.php`: a stakeholder (table `plan_stakeholders`), the global directory of the people, companies and teams involved in the plans: name, email (validated, indexed for duplicate detection), phone, role, type and the active flag (`isPublished`). Independent of plans. -- `Entity/PlanStakeholder.php` and `PlanStakeholderRepository.php`: the link between a plan and a stakeholder (table `plan_stakeholders_plan`), with the stakeholder's role in that plan (free text) and a position. Deleting the plan or the stakeholder deletes the link (ON DELETE CASCADE both sides). -- `Model/StakeholderModel.php`: the model, available as `mautic.plan.model.stakeholder` or with `getModel('plan.stakeholder')`. On save, the phone number is normalized to E.164 using the default region from **Settings > Configuration > Plan Settings** (parameter `plan_stakeholder_phone_region`, `FR` by default); a number that doesn't parse is kept exactly as typed, and the save is never blocked. -- `Controller/StakeholderController.php` and `Resources/views/Stakeholder/`: the directory (**Planning > Stakeholders**), with the columns ID, Pictogram, Type, Name, Role, Email (mailto link), Phone (tel link), Active, and **Assigned plans** — the plans the stakeholder is linked to, each with its role in that plan. The detail page lists those plans too. -- The stakeholder's type is the key of a stakeholder type set up in **Settings > Configuration > Plan Settings** (parameter `plan_stakeholder_types`), same pattern as the other item types, pictogram included. -- A plan's **Stakeholders tab** links the directory to the plan: each row picks an active stakeholder and gives its role in the plan. The tab shows the harmonized table (pictogram, Type, Name, Role in the plan, Role, Email, Phone, Active). Unpublished stakeholders are not offered in the picker, but keep their links. +- `Entity/Stakeholder.php` and `StakeholderRepository.php`: a stakeholder (table `initiative_stakeholders`), the global directory of the people, companies and teams involved in the initiatives: name, email (validated, indexed for duplicate detection), phone, role, type and the active flag (`isPublished`). Independent of initiatives. +- `Entity/InitiativeStakeholder.php`: the link between an initiative and a stakeholder (table `initiative_stakeholders_initiative`), with the stakeholder's role in that initiative (free text, column `role_in_initiative`) and a position. Deleting the initiative or the stakeholder deletes the link (ON DELETE CASCADE both sides). +- `Model/StakeholderModel.php`: the model, available as `mautic.program.model.stakeholder` or with `getModel('program.stakeholder')`. On save, the phone number is normalized to E.164 using the default region from **Settings > Configuration > Program Settings** (parameter `program_stakeholder_phone_region`, `FR` by default); a number that doesn't parse is kept exactly as typed, and the save is never blocked. +- `Controller/StakeholderController.php` and `Resources/views/Stakeholder/`: the directory (**Programs > Stakeholders**), with the columns ID, Pictogram, Type, Name, Role, Email (mailto link), Phone (tel link), Active, and **Assigned initiatives** — the initiatives the stakeholder is linked to, each with its role in that initiative. The detail page lists those initiatives too. +- The stakeholder's type is the key of a stakeholder type set up in **Settings > Configuration > Program Settings** (parameter `program_stakeholder_types`), same pattern as the other item types, pictogram included. +- An initiative's **Stakeholders tab** links the directory to the initiative: each row picks an active stakeholder and gives its role in the initiative. The tab shows the harmonized table (pictogram, Type, Name, Role in the initiative, Role, Email, Phone, Active). Unpublished stakeholders are not offered in the picker, but keep their links. ### The Task object -- `Entity/Task.php` and `TaskRepository.php`: a task (table `plan_tasks`): type (with its pictogram), name, description, plan, kind (task, milestone or phase), optional start and end dates (plain dates, no time), definition of done, planned work in whole hours, status (not for phases), dependencies (table `plan_task_dependencies`) and RACI assignments (table `plan_task_raci` with its `plan_task_raci_stakeholders` join table) +- `Entity/Task.php` and `TaskRepository.php`: a task (table `initiative_tasks`): type (with its pictogram), name, description, initiative, kind (task, milestone or phase), optional start and end dates (plain dates, no time), definition of done, planned work in whole hours, status (not for phases), dependencies (table `initiative_task_dependencies`) and RACI assignments (table `initiative_task_raci` with its `initiative_task_raci_stakeholders` join table) - `Entity/TaskStatus.php`: the status enum. The order of its cases is the order of the dropdown: `new` (New, the default), `todo` (To do), `in_progress` (In progress), `done` (Done). Stored as `VARCHAR(20)`, indexed. -- `Model/TaskModel.php`: the model, available as `mautic.plan.model.task` or with `getModel('plan.task')`. `getTaskTree($plan)` returns a plan's tasks as flat rows for the Tasks tab, ordered by name, with their dependencies and RACI rows fully loaded. +- `Model/TaskModel.php`: the model, available as `mautic.program.model.task` or with `getModel('program.task')`. `getTaskTree($initiative)` returns an initiative's tasks as flat rows for the Tasks tab, ordered by name, with their dependencies and RACI rows fully loaded. - `Form/Type/TaskType.php`: the create and edit form -- `Validator/Constraints/ValidTaskDependency.php`: a dependency must point at another task of the same plan, and the dependency graph must not form a cycle (followed through the database, so a cycle crossing other tasks is caught too) +- `Validator/Constraints/ValidTaskDependency.php`: a dependency must point at another task of the same initiative, and the dependency graph must not form a cycle (followed through the database, so a cycle crossing other tasks is caught too) Behaviour to know about: -- A task must belong to a plan. A plan can have any number of tasks, including none. +- A task must belong to an initiative. An initiative can have any number of tasks, including none. - A task's end date must be on or after its start date, when both are set. -- The task list (**Planning > Tasks**) shows these columns, in this order: ID, Pictogram, Type, Name, Description (first 120 characters), Start date, End date, Status. Every column except Pictogram and Description can be sorted. -- A task's type is required. It's the key of a task type set up in **Settings > Configuration > Plan Settings** (parameter `plan_task_types`); on the task form the type's pictogram appears next to the dropdown and its description under it. The plan's Tasks tab shows the same Pictogram and Type columns as the task list, without the ID column. -- Deleting a plan deletes its tasks (`plan_id` `ON DELETE CASCADE`). +- The task list (**Programs > Tasks**) shows these columns, in this order: ID, Pictogram, Type, Name, Description (first 120 characters), Start date, End date, Status. Every column except Pictogram and Description can be sorted. +- A task's type is required. It's the key of a task type set up in **Settings > Configuration > Program Settings** (parameter `program_task_types`); on the task form the type's pictogram appears next to the dropdown and its description under it. The initiative's Tasks tab shows the same Pictogram and Type columns as the task list, without the ID column. +- Deleting an initiative deletes its tasks (`initiative_id` `ON DELETE CASCADE`). - Deleting a task removes its dependency edges and RACI rows too (`ON DELETE CASCADE`). -- Tasks are edited on their own pages, not inside the plan form: a task can only be picked as a dependency once it exists. +- Tasks are edited on their own pages, not inside the initiative form: a task can only be picked as a dependency once it exists. - Kinds: a **milestone**'s end date is enslaved to its start date (same day — the entity's `setTaskKind` copies it, the `TaskDates` validator keeps it in step, the form shows it disabled); a **phase** has no status of its own, it comes from its tasks (the form shows no status field). -- RACI: one row per role (Responsible, Accountable, Consulted, Informed), each with several stakeholders picked from the plan's stakeholders. +- RACI: one row per role (Responsible, Accountable, Consulted, Informed), each with several stakeholders picked from the initiative's stakeholders. -After you change `Assets/js/plan.js`, run `php bin/console mautic:assets:generate` (in the dev environment, `./dev.sh console mautic:assets:generate`), because production mode bundles plugin scripts into `app.js`. +After you change `Assets/js/program.js`, run `php bin/console mautic:assets:generate` (in the dev environment, `./dev.sh console mautic:assets:generate`), because production mode bundles plugin scripts into `app.js`. ### Database schema -Mautic creates the `plans` table from the entity mapping when it installs the plugin. However, the installer drops foreign keys that point to core tables (`users`, `categories`). `Migrations/Version_0_2_0.php` adds them and only runs when they are missing. Core runs plugin migrations when the plugin version changes, and `EventListener/PluginInstallSubscriber.php` also runs them right after a fresh install. +Mautic creates the `initiatives` table from the entity mapping when it installs the plugin. However, the installer drops foreign keys that point to core tables (`users`, `categories`). `Migrations/Version_0_2_0.php` adds them and only runs when they are missing. Core runs plugin migrations when the plugin version changes, and `EventListener/PluginInstallSubscriber.php` also runs them right after a fresh install. -`Migrations/Version_0_3_0.php` adds `plans.version` and the `plan_objectives` table to installs created before 0.3.0. `Migrations/Version_0_4_0.php` adds the `plan_tasks` table and its two foreign keys, and adds the foreign keys to an existing `plan_tasks` table that lacks them. `Migrations/Version_0_5_0.php` adds the tasks' `start_date`, `end_date` and `status` columns, and existing tasks get the status `new`. `Migrations/Version_0_6_0.php` creates `plan_description_items` with its foreign key to `plans` (`ON DELETE CASCADE`), and drops `plans.description`, deleting its content. `Migrations/Version_0_7_0.php` creates `plan_allocation_items` with its foreign key to `plans` (`ON DELETE CASCADE`). `Migrations/Version_0_8_0.php` drops the currency columns (`plans.currency`, `plan_allocation_items.planned_currency` and `real_currency`), since every amount is now in the general currency. `Migrations/Version_0_9_0.php` adds `plan_tasks.type` (nullable; tasks existed before types, so each existing task must be given a type before it can be saved again). `Migrations/Version_0_10_0.php` adds `plan_objectives.type` (nullable; existing objectives must be given a type before the plan can be saved again). `Migrations/Version_0_10_1.php` adds `plan_objectives.priority` (`INT NOT NULL`, default 1; existing objectives get 1). `Migrations/Version_0_11_0.php` creates `plan_targets` and the `plan_target_stages` join table. `Migrations/Version_0_12_0.php` creates `plan_stakeholders` and `plan_stakeholders_plan`, with their foreign keys. Every migration checks the schema first, so it's safe to run again. +`Migrations/Version_0_16_0.php` renames every table and column of the Plan era to the Program one: `plans` → `initiatives`, `plan_tasks` → `initiative_tasks`, `plan_stakeholders` → `initiative_stakeholders`, `plan_audiences` → `initiative_audiences`, `plan_stakeholders_plan` → `initiative_stakeholders_initiative`, `plan_audiences_plan` → `initiative_audiences_initiative`, `plan_audiences_segments` → `initiative_audiences_segments`, `plan_audiences_stages` → `initiative_audiences_stages`, `plan_objectives` → `initiative_objectives`, `plan_description_items` → `initiative_description_items`, `plan_allocation_items` → `initiative_allocation_items`, `plan_task_dependencies` → `initiative_task_dependencies`, `plan_task_raci` → `initiative_task_raci`, `plan_task_raci_stakeholders` → `initiative_task_raci_stakeholders`, and the `plan_id` foreign key columns become `initiative_id`; `role_in_plan` becomes `role_in_initiative`. The earlier migrations (`Version_0_2_0.php` … `Version_0_14_0.php`) keep their historical table names in their bodies but are disabled (`isApplicable()` returns `false`), since their changes are history now kept by the renames in 0.16.0. -If a migration builds its `CREATE TABLE` with Doctrine's `SchemaTool`, keep only the statement for its own table. `SchemaTool` also returns statements for other tables, such as Symfony Messenger's `messenger_messages`. Those fail on an existing install, and the migration engine then reports "There is no active transaction" instead of the real error. - -When you change the schema, add a migration in `Migrations/` and increase `version` in `Config/config.php`, then run `./dev.sh reload`. +When you change the schema, add a migration in `Migrations/` and increase `version` in `Config/config.php`, then run `./dev.sh reload`. The migration engine executes the `addSql()` statements after `up()` returns; a rename migration must instead run its statements immediately through `$connection->executeStatement()`, re-reading the schema between steps. ## Naming conventions -To avoid collisions with other plugins, such as UTM Manager, every identifier in this bundle is prefixed with `plan`: +To avoid collisions with other plugins, such as UTM Manager, every identifier in this bundle is prefixed with `program`: -- Service IDs: `mautic.plan.*` -- Route names: `plan_*` -- Translation keys: `mautic.plan.*`, plus `mautic.plugin.plan.name` -- Permission keys: `plan:*` +- Service IDs: `mautic.program.*` (and the models resolve from `getModel('program.initiative')` etc.) +- Form block prefixes: `program_*` (`program_task`, `program_audience`, …) +- Route names: `initiative_*` (the initiative pages), with `program_utm_taxonomy_index` for the placeholder +- Translation keys: `mautic.program.*`, plus `mautic.plugin.program.name` +- Permission keys: `program:*` +- Config parameters: `program_*` (`program_currency`, `program_*_types`, …) +- Menu keys: `mautic.program.menu.*` +- URL paths: `/s/programs`, `/s/program-tasks`, `/s/program-stakeholders`, `/s/program-audiences`, `/s/program-utm-taxonomies` + +The bundle class is `ProgramBundle`, the integration name is `Program`, the entity classes are `Initiative`, `Task`, `Stakeholder` and `Audience`, and their tables are `initiatives`, `initiative_tasks`, `initiative_stakeholders` and `initiative_audiences`. The DB index names follow: `program_status` on `initiatives`, `program_task_status` on `initiative_tasks`, `program_stakeholder_email` on `initiative_stakeholders`. + +## Rename history + +The plugin was born as `PlanBundle` with a `Plan` entity (table `plans`) and menu root **Planning** > **Plans**: + +- Before 0.15.0: "targets" were renamed to "audiences" (entity `Audience`, table `plan_targets` → `plan_audiences`), with Mautic segments attached to each audience. +- 0.16.0: the full rename to `ProgramBundle` / `Initiative`. The bundle namespace, class names, the `plugins` DB row (`ProgramBundle`), all tables (`plan_*` → `initiative_*`), all columns (`plan_id` → `initiative_id`, `role_in_plan` → `role_in_initiative`), all permission keys (`plan:*` → `program:*`), the config parameters and the menu (root **Programs**, entry **Initiatives**, plus the placeholder **UTM Taxonomies**) took the new names. The data was kept: the migration renames the tables, it doesn't rebuild them. +- The old URLs (`/s/plans`, `/s/plan-tasks`, …) are gone: the routes were renamed and the old names return 404. + +A rename like this needs care: + +- The historical migrations must stay literal (they describe the old schema) or be neutralized; after the entity renames, their Doctrine mappings no longer match and they can only run with literal SQL. +- The `plugins` DB row must be updated to the new bundle name (and its version kept), or Mautic's installer treats the plugin as new and its `SchemaTool` pass creates empty tables from the current mappings. If that happens, drop the empty tables and turn the install into an update before reloading. +- The permission keys of each role are stored in the `permissions` table per (bundle, name); a role that had `plan:plans:*` grants doesn't automatically get `program:initiatives:*`, and cached permission sets in the sessions need a re-login. +- `getModel()` resolves `program.initiative` to the service `mautic.program.model.initiative`, unlike core bundles' `mautic..model.`: only the service IDs decide. +- The `config/local.php` parameter keys are not renamed by the migration either (they are not in the database): `plan_currency` → `program_currency`, the `plan_*_types` lists → `program_*_types`, and the pre-0.15 audience keys `plan_target_attribute_*`, `plan_target_decision_roles` and `plan_target_tones` → `program_audience_attribute_*`, `program_audience_decision_roles` and `program_audience_tones`. Rename them by hand after upgrading, or the type lists on the settings page and every type dropdown read empty (the stored items keep their type keys, they only show "Unknown type"). \ No newline at end of file
    {{- include('@MauticCore/Helper/list_actions.html.twig', { 'item': item, 'templateButtons': { 'edit': canEdit, - 'delete': securityHasEntityAccess(permissions['plan:tasks:deleteown'], permissions['plan:tasks:deleteother'], item.createdBy), + 'delete': securityHasEntityAccess(permissions['program:tasks:deleteown'], permissions['program:tasks:deleteother'], item.createdBy), }, - 'langVar': 'plan.task', + 'langVar': 'initiative.task', }) -}} {{ item.id }} - {% set typeIcon = plan_item_type_icon('task', item.type) %} - {% if typeIcon %}{% endif %} + {% set typeIcon = program_item_type_icon('task', item.type) %} + {% if typeIcon %}{% endif %} {% if canEdit %} - {{ item.name }} + {{ item.name }} {% else %} {{ item.name }} {% endif %} {% set description = item.description|default('')|striptags|trim %} - {{ (description|length > 120 ? description|slice(0, 120) ~ '…' : description)|plan_linkify }} + {{ (description|length > 120 ? description|slice(0, 120) ~ '…' : description)|program_linkify }} {{ item.startDate ? item.startDate|date('Y-m-d') : '' }} {{ item.endDate ? item.endDate|date('Y-m-d') : '' }} {# A phase has no status of its own: its state comes from its tasks. #} - {% if item.taskKind != constant('MauticPlugin\\PlanBundle\\Entity\\TaskKind::Phase') %} + {% if item.taskKind != constant('MauticPlugin\\ProgramBundle\\Entity\\TaskKind::Phase') %} {{ item.status.labelKey|trans }} {% else %} - {{ 'mautic.plan.task.kind.phase_short'|trans }} + {{ 'mautic.program.task.kind.phase_short'|trans }} {% endif %}