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

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

No files matched your search

+213
View File
@@ -0,0 +1,213 @@
<?php
declare(strict_types=1);
namespace MauticPlugin\ProgramBundle\Form\Type;
use Doctrine\ORM\EntityRepository;
use Mautic\CoreBundle\Form\Type\FormButtonsType;
use Mautic\CoreBundle\Form\Type\YesNoButtonGroupType;
use Mautic\LeadBundle\Entity\LeadList;
use Mautic\StageBundle\Entity\Stage;
use MauticPlugin\ProgramBundle\Entity\Audience;
use MauticPlugin\ProgramBundle\Entity\AudienceType as AudienceTypeEnum;
use MauticPlugin\ProgramBundle\Service\AudienceAttributes;
use MauticPlugin\ProgramBundle\Service\ItemTypeProvider;
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
use Symfony\Component\Form\Extension\Core\Type\EnumType;
use Symfony\Component\Form\Extension\Core\Type\IntegerType;
use Symfony\Component\Form\Extension\Core\Type\TextareaType;
use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
/**
* The create and edit form of an audience of the global directory (Programs > Audiences): name, a
* fixed type (persona, ICP, …), the segments (purely informational), then the persona attributes
* the admin switched on in Settings > Configuration > Initiative Settings (AudienceAttributes): one
* toggle per attribute, so a b2b install and a b2c install define their personas differently.
*
* @extends AbstractType<Audience>
*/
class AudienceType extends AbstractType
{
public function __construct(
private ItemTypeProvider $typeProvider,
private AudienceAttributes $attributes,
) {
}
public function buildForm(FormBuilderInterface $builder, array $options): void
{
$enabled = $this->attributes->getEnabled();
// Name and type are always offered; everything else is a togglable attribute.
$builder->add('name', TextType::class, [
'label' => 'mautic.program.audience.field.name',
'label_attr' => ['class' => 'control-label'],
'attr' => ['class' => 'form-control', 'maxlength' => 191],
]);
$builder->add('audienceType', EnumType::class, [
'label' => 'mautic.program.audience.field.type',
'label_attr' => ['class' => 'control-label'],
'attr' => ['class' => 'form-control'],
'class' => AudienceTypeEnum::class,
'choice_label' => fn (AudienceTypeEnum $type): string => $type->getLabelKey(),
]);
// The Mautic segments this audience maps to; any number, or none. Purely informational: the
// segments are not required, and nothing in the initiative depends on them.
$builder->add('segments', EntityType::class, [
'label' => 'mautic.program.audience.field.segments',
'label_attr' => ['class' => 'control-label'],
'attr' => ['class' => 'form-control'],
'class' => LeadList::class,
'choice_label' => 'name',
'query_builder' => fn (EntityRepository $er) => $er->createQueryBuilder('s')
->orderBy('s.name', 'ASC')
->andWhere('s.isPublished = :published')
->setParameter('published', true),
'multiple' => true,
'expanded' => false,
'required' => false,
]);
if (in_array('tagline', $enabled, true)) {
$builder->add('tagline', TextareaType::class, [
'label' => 'mautic.program.audience.field.tagline',
'label_attr' => ['class' => 'control-label'],
'attr' => ['class' => 'form-control', 'rows' => 2, 'maxlength' => 500],
'required' => false,
]);
}
if (in_array('profile', $enabled, true)) {
$builder->add('profileCriteria', TextareaType::class, [
'label' => 'mautic.program.audience.field.profile_criteria',
'label_attr' => ['class' => 'control-label'],
'attr' => ['class' => 'form-control', 'rows' => 3],
'required' => false,
]);
}
if (in_array('motivations', $enabled, true)) {
$builder->add('motivations', TextareaType::class, [
'label' => 'mautic.program.audience.field.motivations',
'label_attr' => ['class' => 'control-label'],
'attr' => ['class' => 'form-control', 'rows' => 3],
'required' => false,
]);
}
if (in_array('barriers', $enabled, true)) {
$builder->add('barriers', TextareaType::class, [
'label' => 'mautic.program.audience.field.barriers',
'label_attr' => ['class' => 'control-label'],
'attr' => ['class' => 'form-control', 'rows' => 3],
'required' => false,
]);
}
if (in_array('frustrations', $enabled, true)) {
$builder->add('frustrations', TextareaType::class, [
'label' => 'mautic.program.audience.field.frustrations',
'label_attr' => ['class' => 'control-label'],
'attr' => ['class' => 'form-control', 'rows' => 3],
'required' => false,
]);
}
if (in_array('triggers', $enabled, true)) {
$builder->add('triggers', TextareaType::class, [
'label' => 'mautic.program.audience.field.triggers',
'label_attr' => ['class' => 'control-label'],
'attr' => ['class' => 'form-control', 'rows' => 3],
'required' => false,
]);
}
if (in_array('decision_role', $enabled, true)) {
$kind = ItemTypeProvider::KIND_AUDIENCE_DECISION_ROLE;
$builder->add('decisionRole', ChoiceType::class, [
'label' => 'mautic.program.audience.field.decision_role',
'label_attr' => ['class' => 'control-label'],
'attr' => ['class' => 'form-control'],
'choices' => $this->typeProvider->getChoices($kind),
'placeholder' => 'mautic.core.form.chooseone',
'required' => false,
]);
}
if (in_array('tones', $enabled, true)) {
$kind = ItemTypeProvider::KIND_AUDIENCE_TONE;
$builder->add('preferredTones', ChoiceType::class, [
'label' => 'mautic.program.audience.field.preferred_tones',
'label_attr' => ['class' => 'control-label'],
'choices' => $this->typeProvider->getChoices($kind),
'expanded' => true,
'multiple' => true,
'required' => false,
]);
}
if (in_array('channels', $enabled, true)) {
// One checkbox per channel, in the order of Audience::CHANNELS.
$builder->add('preferredChannels', ChoiceType::class, [
'label' => 'mautic.program.audience.field.preferred_channels',
'label_attr' => ['class' => 'control-label'],
'choices' => array_flip(Audience::CHANNELS),
'expanded' => true,
'multiple' => true,
'required' => false,
]);
}
if (in_array('stages', $enabled, true)) {
$builder->add('stages', EntityType::class, [
'label' => 'mautic.program.audience.field.stages',
'label_attr' => ['class' => 'control-label'],
'attr' => ['class' => 'form-control'],
'class' => Stage::class,
'choice_label' => 'name',
'query_builder' => fn (EntityRepository $er) => $er->createQueryBuilder('s')->orderBy('s.name', 'ASC'),
'multiple' => true,
'expanded' => false,
'required' => false,
]);
}
if (in_array('size', $enabled, true)) {
$builder->add('estimatedSize', IntegerType::class, [
'label' => 'mautic.program.audience.field.estimated_size',
'label_attr' => ['class' => 'control-label'],
'attr' => ['class' => 'form-control', 'min' => 0, 'step' => 1],
'required' => false,
]);
}
$builder->add('isPublished', YesNoButtonGroupType::class, [
'label' => 'mautic.program.audience.field.active',
]);
$builder->add('buttons', FormButtonsType::class);
if (!empty($options['action'])) {
$builder->setAction($options['action']);
}
}
public function configureOptions(OptionsResolver $resolver): void
{
$resolver->setDefaults([
'data_class' => Audience::class,
]);
}
public function getBlockPrefix(): string
{
return 'program_audience';
}
}
+33 -15
View File
@@ -2,43 +2,48 @@
declare(strict_types=1);
namespace MauticPlugin\PlanBundle\Form\Type;
namespace MauticPlugin\ProgramBundle\Form\Type;
use MauticPlugin\PlanBundle\Model\StakeholderModel;
use MauticPlugin\PlanBundle\Service\CurrencyProvider;
use MauticPlugin\PlanBundle\Service\ItemTypeProvider;
use MauticPlugin\ProgramBundle\Model\StakeholderModel;
use MauticPlugin\ProgramBundle\Service\CurrencyProvider;
use MauticPlugin\ProgramBundle\Service\ItemTypeProvider;
use MauticPlugin\ProgramBundle\Service\AudienceAttributes;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\CallbackTransformer;
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
use Symfony\Component\Form\Extension\Core\Type\CollectionType;
use Symfony\Component\Form\Extension\Core\Type\TextType;
use Mautic\CoreBundle\Form\Type\YesNoButtonGroupType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\Validator\Constraints\NotBlank;
/**
* The "Plan Settings" tab of Settings > Configuration. Each child is a local.php parameter:
* - plan_currency: the currency of every amount in the plugin (general setting);
* - plan_stakeholder_phone_region: default region for stakeholder phone numbers typed without a prefix;
* - one list of item types per kind (description, allocation, objective, task, stakeholder), each with
* a pictogram.
* The "Initiative Settings" tab of Settings > Configuration. Each child is a local.php parameter:
* - program_currency: the currency of every amount in the plugin (general setting);
* - program_stakeholder_phone_region: default region for stakeholder phone numbers typed without a prefix;
* - one list of item types per kind (description, allocation, objective, task, stakeholder, and the
* values of an audience's decision roles and tones), each with a pictogram;
* - one toggle per audience persona attribute (AudienceAttributes), so each install defines its
* personas as it needs (b2b, b2c…).
*
* @extends AbstractType<array<string, mixed>>
*/
class ConfigType extends AbstractType
{
public const FORM_ALIAS = 'planconfig';
public const FORM_ALIAS = 'programconfig';
public function __construct(
private CurrencyProvider $currencyProvider,
private AudienceAttributes $audienceAttributes,
) {
}
public function buildForm(FormBuilderInterface $builder, array $options): void
{
$builder->add(CurrencyProvider::CONFIG_PARAMETER, ChoiceType::class, [
'label' => 'mautic.plan.config.currency',
'label' => 'mautic.program.config.currency',
'label_attr' => ['class' => 'control-label'],
'attr' => ['class' => 'form-control', 'tooltip' => 'mautic.plan.config.currency.tooltip'],
'attr' => ['class' => 'form-control', 'tooltip' => 'mautic.program.config.currency.tooltip'],
'choices' => $this->currencyProvider->getChoices(),
'placeholder' => false,
'required' => true,
@@ -49,19 +54,22 @@ class ConfigType extends AbstractType
// Default region for stakeholder phone numbers typed without a country prefix (ISO 3166-1
// alpha-2, e.g. FR). Read by StakeholderModel on save.
$builder->add(StakeholderModel::PHONE_REGION_PARAMETER, TextType::class, [
'label' => 'mautic.plan.config.stakeholder_phone_region',
'label' => 'mautic.program.config.stakeholder_phone_region',
'label_attr' => ['class' => 'control-label'],
'attr' => ['class' => 'form-control', 'tooltip' => 'mautic.plan.config.stakeholder_phone_region.tooltip', 'maxlength' => 2],
'attr' => ['class' => 'form-control', 'tooltip' => 'mautic.program.config.stakeholder_phone_region.tooltip', 'maxlength' => 2],
'required' => true,
'constraints' => [new NotBlank()],
'empty_data' => StakeholderModel::DEFAULT_PHONE_REGION,
]);
foreach (ItemTypeProvider::PARAMETERS as $kind => $parameter) {
// The decision roles and the tones are plain value lists: no pictogram.
$withIcon = !in_array($kind, [ItemTypeProvider::KIND_AUDIENCE_DECISION_ROLE, ItemTypeProvider::KIND_AUDIENCE_TONE], true);
$builder->add($parameter, CollectionType::class, [
'label' => false,
'entry_type' => ItemTypeConfigType::class,
'entry_options' => ['label' => false, 'with_icon' => true],
'entry_options' => ['label' => false, 'with_icon' => $withIcon],
'allow_add' => true,
'allow_delete' => true,
'prototype' => true,
@@ -76,6 +84,16 @@ class ConfigType extends AbstractType
fn ($types): array => ItemTypeProvider::normalize(is_array($types) ? $types : []),
));
}
// One toggle per audience persona attribute (AudienceAttributes), defaults to enabled.
foreach (AudienceAttributes::ATTRIBUTES as $attribute => $field) {
$builder->add(AudienceAttributes::toggleParameter($attribute), YesNoButtonGroupType::class, [
'label' => 'mautic.program.audience.attribute.'.$attribute,
'label_attr' => ['class' => 'control-label'],
'data' => $this->audienceAttributes->isEnabled($attribute),
'required' => false,
]);
}
}
public function getBlockPrefix(): string
@@ -2,11 +2,11 @@
declare(strict_types=1);
namespace MauticPlugin\PlanBundle\Form\Type;
namespace MauticPlugin\ProgramBundle\Form\Type;
use MauticPlugin\PlanBundle\Entity\PlanAllocationItem;
use MauticPlugin\PlanBundle\Service\CurrencyProvider;
use MauticPlugin\PlanBundle\Service\ItemTypeProvider;
use MauticPlugin\ProgramBundle\Entity\InitiativeAllocationItem;
use MauticPlugin\ProgramBundle\Service\CurrencyProvider;
use MauticPlugin\ProgramBundle\Service\ItemTypeProvider;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
use Symfony\Component\Form\Extension\Core\Type\HiddenType;
@@ -17,14 +17,14 @@ use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
/**
* One row of the allocation items collection in PlanType: type, name, description, planned cost and
* real cost (both in the general currency). Works like PlanDescriptionItemType (type description shown
* One row of the allocation items collection in InitiativeType: type, name, description, planned cost and
* real cost (both in the general currency). Works like InitiativeDescriptionItemType (type description shown
* under the dropdown and its pictogram next to it, hidden position kept in display order by
* Assets/js/plan.js).
* Assets/js/program.js).
*
* @extends AbstractType<PlanAllocationItem>
* @extends AbstractType<InitiativeAllocationItem>
*/
class PlanAllocationItemType extends AbstractType
class InitiativeAllocationItemType extends AbstractType
{
public function __construct(
private ItemTypeProvider $typeProvider,
@@ -37,11 +37,11 @@ class PlanAllocationItemType extends AbstractType
$kind = ItemTypeProvider::KIND_ALLOCATION;
$builder->add('type', ChoiceType::class, [
'label' => 'mautic.plan.allocation_item.field.type',
'label' => 'mautic.program.allocation_item.field.type',
'label_attr' => ['class' => 'control-label'],
'attr' => ['class' => 'form-control plan-item-type'],
'attr' => ['class' => 'form-control initiative-item-type'],
'choices' => $this->typeProvider->getChoices($kind),
// The type's description and pictogram, shown next to the dropdown by plan.js.
// The type's description and pictogram, shown next to the dropdown by program.js.
'choice_attr' => fn (?string $key): array => [
'data-description' => (string) $this->typeProvider->getDescription($kind, $key),
'data-icon' => (string) $this->typeProvider->getIcon($kind, $key),
@@ -51,23 +51,23 @@ class PlanAllocationItemType extends AbstractType
]);
$builder->add('name', TextType::class, [
'label' => 'mautic.plan.allocation_item.field.name',
'label' => 'mautic.program.allocation_item.field.name',
'label_attr' => ['class' => 'control-label'],
'attr' => ['class' => 'form-control', 'maxlength' => 255],
'required' => false,
]);
$builder->add('description', TextareaType::class, [
'label' => 'mautic.plan.allocation_item.field.description',
'label' => 'mautic.program.allocation_item.field.description',
'label_attr' => ['class' => 'control-label'],
'attr' => ['class' => 'form-control', 'rows' => 3],
'required' => false,
]);
// Costs are in the general currency (Settings > Configuration > Plan Settings), shown next to the field.
// Costs are in the general currency (Settings > Configuration > Initiative Settings), shown next to the field.
foreach (['planned', 'real'] as $cost) {
$builder->add($cost.'Cost', NumberType::class, [
'label' => 'mautic.plan.allocation_item.field.'.$cost.'_cost',
'label' => 'mautic.program.allocation_item.field.'.$cost.'_cost',
'label_attr' => ['class' => 'control-label'],
'attr' => ['class' => 'form-control', 'postaddon_text' => $this->currencyProvider->getCurrency()],
'input' => 'string',
@@ -77,19 +77,19 @@ class PlanAllocationItemType extends AbstractType
}
$builder->add('position', HiddenType::class, [
'attr' => ['class' => 'plan-row-position'],
'attr' => ['class' => 'initiative-row-position'],
]);
}
public function configureOptions(OptionsResolver $resolver): void
{
$resolver->setDefaults([
'data_class' => PlanAllocationItem::class,
'data_class' => InitiativeAllocationItem::class,
]);
}
public function getBlockPrefix(): string
{
return 'plan_allocation_item';
return 'program_allocation_item';
}
}
+76
View File
@@ -0,0 +1,76 @@
<?php
declare(strict_types=1);
namespace MauticPlugin\ProgramBundle\Form\Type;
use Doctrine\ORM\EntityRepository;
use MauticPlugin\ProgramBundle\Entity\Audience;
use MauticPlugin\ProgramBundle\Entity\AudiencePriority;
use MauticPlugin\ProgramBundle\Entity\InitiativeAudience;
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\EnumType;
use Symfony\Component\Form\Extension\Core\Type\HiddenType;
use Symfony\Component\Form\Extension\Core\Type\TextareaType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
/**
* One row of the audiences collection in InitiativeType: an audience of the global directory (only the
* active ones are offered), the audience's priority in this plan, and possibly a initiative-specific
* message. The position field is hidden and kept in display order by Assets/js/program.js.
*
* @extends AbstractType<InitiativeAudience>
*/
class InitiativeAudienceType extends AbstractType
{
public function buildForm(FormBuilderInterface $builder, array $options): void
{
$builder->add('audience', EntityType::class, [
'label' => 'mautic.program.audience.field.name',
'label_attr' => ['class' => 'control-label'],
'attr' => ['class' => 'form-control'],
'class' => Audience::class,
'choice_label' => 'name',
'query_builder' => fn (EntityRepository $er) => $er->createQueryBuilder('t')
->orderBy('t.name', 'ASC')
->andWhere('t.isPublished = :published')
->setParameter('published', true),
'placeholder' => 'mautic.core.form.chooseone',
'required' => true,
]);
// Dropdown in the order of the AudiencePriority cases.
$builder->add('priority', EnumType::class, [
'label' => 'mautic.program.audience.field.priority',
'label_attr' => ['class' => 'control-label'],
'attr' => ['class' => 'form-control'],
'class' => AudiencePriority::class,
'choice_label' => fn (AudiencePriority $priority): string => $priority->getLabelKey(),
]);
$builder->add('valueProposition', TextareaType::class, [
'label' => 'mautic.program.audience.field.value_proposition',
'label_attr' => ['class' => 'control-label'],
'attr' => ['class' => 'form-control', 'rows' => 2],
'required' => false,
]);
$builder->add('position', HiddenType::class, [
'attr' => ['class' => 'initiative-row-position'],
]);
}
public function configureOptions(OptionsResolver $resolver): void
{
$resolver->setDefaults([
'data_class' => InitiativeAudience::class,
]);
}
public function getBlockPrefix(): string
{
return 'program_initiative_audience';
}
}
@@ -2,10 +2,10 @@
declare(strict_types=1);
namespace MauticPlugin\PlanBundle\Form\Type;
namespace MauticPlugin\ProgramBundle\Form\Type;
use MauticPlugin\PlanBundle\Entity\PlanDescriptionItem;
use MauticPlugin\PlanBundle\Service\ItemTypeProvider;
use MauticPlugin\ProgramBundle\Entity\InitiativeDescriptionItem;
use MauticPlugin\ProgramBundle\Service\ItemTypeProvider;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
use Symfony\Component\Form\Extension\Core\Type\HiddenType;
@@ -14,14 +14,14 @@ use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
/**
* One row of the description items collection in PlanType. The type dropdown lists the description item
* types set up in Settings > Configuration > Plan; each option carries the type's description, which
* Assets/js/plan.js shows under the dropdown. The position field is hidden and kept in display order by
* plan.js.
* One row of the description items collection in InitiativeType. The type dropdown lists the description item
* types set up in Settings > Configuration > Initiative; each option carries the type's description, which
* Assets/js/program.js shows under the dropdown. The position field is hidden and kept in display order by
* program.js.
*
* @extends AbstractType<PlanDescriptionItem>
* @extends AbstractType<InitiativeDescriptionItem>
*/
class PlanDescriptionItemType extends AbstractType
class InitiativeDescriptionItemType extends AbstractType
{
public function __construct(
private ItemTypeProvider $typeProvider,
@@ -33,11 +33,11 @@ class PlanDescriptionItemType extends AbstractType
$kind = ItemTypeProvider::KIND_DESCRIPTION;
$builder->add('type', ChoiceType::class, [
'label' => 'mautic.plan.description_item.field.type',
'label' => 'mautic.program.description_item.field.type',
'label_attr' => ['class' => 'control-label'],
'attr' => ['class' => 'form-control plan-item-type'],
'attr' => ['class' => 'form-control initiative-item-type'],
'choices' => $this->typeProvider->getChoices($kind),
// The type's description and pictogram, shown next to the dropdown by plan.js.
// The type's description and pictogram, shown next to the dropdown by program.js.
'choice_attr' => fn (?string $key): array => [
'data-description' => (string) $this->typeProvider->getDescription($kind, $key),
'data-icon' => (string) $this->typeProvider->getIcon($kind, $key),
@@ -47,26 +47,26 @@ class PlanDescriptionItemType extends AbstractType
]);
$builder->add('description', TextareaType::class, [
'label' => 'mautic.plan.description_item.field.description',
'label' => 'mautic.program.description_item.field.description',
'label_attr' => ['class' => 'control-label'],
'attr' => ['class' => 'form-control', 'rows' => 5],
'required' => false,
]);
$builder->add('position', HiddenType::class, [
'attr' => ['class' => 'plan-row-position'],
'attr' => ['class' => 'initiative-row-position'],
]);
}
public function configureOptions(OptionsResolver $resolver): void
{
$resolver->setDefaults([
'data_class' => PlanDescriptionItem::class,
'data_class' => InitiativeDescriptionItem::class,
]);
}
public function getBlockPrefix(): string
{
return 'plan_description_item';
return 'program_description_item';
}
}
@@ -2,10 +2,10 @@
declare(strict_types=1);
namespace MauticPlugin\PlanBundle\Form\Type;
namespace MauticPlugin\ProgramBundle\Form\Type;
use MauticPlugin\PlanBundle\Entity\PlanObjective;
use MauticPlugin\PlanBundle\Service\ItemTypeProvider;
use MauticPlugin\ProgramBundle\Entity\InitiativeObjective;
use MauticPlugin\ProgramBundle\Service\ItemTypeProvider;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
@@ -17,13 +17,13 @@ use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
/**
* One row of the objectives collection in PlanType: type, title, priority, description and the achieved
* flag. Works like PlanDescriptionItemType (type description shown under the dropdown and its pictogram
* next to it, hidden position kept in display order by Assets/js/plan.js).
* One row of the objectives collection in InitiativeType: type, title, priority, description and the achieved
* flag. Works like InitiativeDescriptionItemType (type description shown under the dropdown and its pictogram
* next to it, hidden position kept in display order by Assets/js/program.js).
*
* @extends AbstractType<PlanObjective>
* @extends AbstractType<InitiativeObjective>
*/
class PlanObjectiveType extends AbstractType
class InitiativeObjectiveType extends AbstractType
{
public function __construct(
private ItemTypeProvider $typeProvider,
@@ -35,11 +35,11 @@ class PlanObjectiveType extends AbstractType
$kind = ItemTypeProvider::KIND_OBJECTIVE;
$builder->add('type', ChoiceType::class, [
'label' => 'mautic.plan.objective.field.type',
'label' => 'mautic.program.objective.field.type',
'label_attr' => ['class' => 'control-label'],
'attr' => ['class' => 'form-control plan-item-type'],
'attr' => ['class' => 'form-control initiative-item-type'],
'choices' => $this->typeProvider->getChoices($kind),
// The type's description and pictogram, shown next to the dropdown by plan.js.
// The type's description and pictogram, shown next to the dropdown by program.js.
'choice_attr' => fn (?string $key): array => [
'data-description' => (string) $this->typeProvider->getDescription($kind, $key),
'data-icon' => (string) $this->typeProvider->getIcon($kind, $key),
@@ -49,36 +49,36 @@ class PlanObjectiveType extends AbstractType
]);
$builder->add('title', TextType::class, [
'label' => 'mautic.plan.objective.field.title',
'label' => 'mautic.program.objective.field.title',
'label_attr' => ['class' => 'control-label'],
'attr' => ['class' => 'form-control', 'maxlength' => 255],
]);
$builder->add('priority', IntegerType::class, [
'label' => 'mautic.plan.objective.field.priority',
'label' => 'mautic.program.objective.field.priority',
'label_attr' => ['class' => 'control-label'],
'invalid_message' => 'mautic.plan.objective.priority.range',
'invalid_message' => 'mautic.program.objective.priority.range',
'attr' => [
'class' => 'form-control',
'min' => PlanObjective::PRIORITY_MIN,
'max' => PlanObjective::PRIORITY_MAX,
'min' => InitiativeObjective::PRIORITY_MIN,
'max' => InitiativeObjective::PRIORITY_MAX,
'step' => 1,
],
]);
$builder->add('description', TextareaType::class, [
'label' => 'mautic.plan.objective.field.description',
'label' => 'mautic.program.objective.field.description',
'label_attr' => ['class' => 'control-label'],
'attr' => ['class' => 'form-control', 'rows' => 2],
'required' => false,
]);
$builder->add('position', HiddenType::class, [
'attr' => ['class' => 'plan-row-position'],
'attr' => ['class' => 'initiative-row-position'],
]);
$builder->add('isAchieved', CheckboxType::class, [
'label' => 'mautic.plan.objective.field.is_achieved',
'label' => 'mautic.program.objective.field.is_achieved',
'required' => false,
]);
}
@@ -86,12 +86,12 @@ class PlanObjectiveType extends AbstractType
public function configureOptions(OptionsResolver $resolver): void
{
$resolver->setDefaults([
'data_class' => PlanObjective::class,
'data_class' => InitiativeObjective::class,
]);
}
public function getBlockPrefix(): string
{
return 'plan_objective';
return 'program_objective';
}
}
@@ -2,11 +2,11 @@
declare(strict_types=1);
namespace MauticPlugin\PlanBundle\Form\Type;
namespace MauticPlugin\ProgramBundle\Form\Type;
use Doctrine\ORM\EntityRepository;
use MauticPlugin\PlanBundle\Entity\PlanStakeholder;
use MauticPlugin\PlanBundle\Entity\Stakeholder;
use MauticPlugin\ProgramBundle\Entity\InitiativeStakeholder;
use MauticPlugin\ProgramBundle\Entity\Stakeholder;
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\HiddenType;
@@ -15,18 +15,18 @@ use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
/**
* One row of the stakeholders collection in PlanType: a stakeholder of the global directory (only the
* One row of the stakeholders collection in InitiativeType: a stakeholder of the global directory (only the
* active ones are offered) and the stakeholder's role in this plan. The position field is hidden and
* kept in display order by Assets/js/plan.js.
* kept in display order by Assets/js/program.js.
*
* @extends AbstractType<PlanStakeholder>
* @extends AbstractType<InitiativeStakeholder>
*/
class PlanStakeholderType extends AbstractType
class InitiativeStakeholderType extends AbstractType
{
public function buildForm(FormBuilderInterface $builder, array $options): void
{
$builder->add('stakeholder', EntityType::class, [
'label' => 'mautic.plan.stakeholder.field.name',
'label' => 'mautic.program.stakeholder.field.name',
'label_attr' => ['class' => 'control-label'],
'attr' => ['class' => 'form-control'],
'class' => Stakeholder::class,
@@ -39,27 +39,27 @@ class PlanStakeholderType extends AbstractType
'required' => true,
]);
$builder->add('roleInPlan', TextType::class, [
'label' => 'mautic.plan.stakeholder.field.role_in_plan',
$builder->add('roleInInitiative', TextType::class, [
'label' => 'mautic.program.stakeholder.field.role_in_initiative',
'label_attr' => ['class' => 'control-label'],
'attr' => ['class' => 'form-control', 'maxlength' => 191],
'required' => false,
]);
$builder->add('position', HiddenType::class, [
'attr' => ['class' => 'plan-row-position'],
'attr' => ['class' => 'initiative-row-position'],
]);
}
public function configureOptions(OptionsResolver $resolver): void
{
$resolver->setDefaults([
'data_class' => PlanStakeholder::class,
'data_class' => InitiativeStakeholder::class,
]);
}
public function getBlockPrefix(): string
{
return 'plan_plan_stakeholder';
return 'program_initiative_stakeholder';
}
}
@@ -2,7 +2,7 @@
declare(strict_types=1);
namespace MauticPlugin\PlanBundle\Form\Type;
namespace MauticPlugin\ProgramBundle\Form\Type;
use Doctrine\ORM\EntityManagerInterface;
use Mautic\CategoryBundle\Form\Type\CategoryListType;
@@ -13,11 +13,11 @@ use Mautic\CoreBundle\Form\Type\FormButtonsType;
use Mautic\CoreBundle\Form\Type\YesNoButtonGroupType;
use Mautic\UserBundle\Entity\User;
use Mautic\UserBundle\Form\Type\UserListType;
use MauticPlugin\PlanBundle\Entity\Plan;
use MauticPlugin\PlanBundle\Entity\PlanStatus;
use MauticPlugin\PlanBundle\Service\CurrencyProvider;
use MauticPlugin\PlanBundle\Form\Type\TargetType as PlanTargetType;
use MauticPlugin\PlanBundle\Form\Type\PlanStakeholderType;
use MauticPlugin\ProgramBundle\Entity\Initiative;
use MauticPlugin\ProgramBundle\Entity\InitiativeStatus;
use MauticPlugin\ProgramBundle\Service\CurrencyProvider;
use MauticPlugin\ProgramBundle\Form\Type\InitiativeAudienceType;
use MauticPlugin\ProgramBundle\Form\Type\InitiativeStakeholderType;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\CollectionType;
use Symfony\Component\Form\Extension\Core\Type\EnumType;
@@ -28,9 +28,9 @@ use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
/**
* @extends AbstractType<Plan>
* @extends AbstractType<Initiative>
*/
class PlanType extends AbstractType
class InitiativeType extends AbstractType
{
public function __construct(
private CurrencyProvider $currencyProvider,
@@ -47,15 +47,15 @@ class PlanType extends AbstractType
$builder->addEventSubscriber(new CleanFormSubscriber(['name' => 'filter']));
$builder->add('name', TextType::class, [
'label' => 'mautic.plan.field.name',
'label' => 'mautic.program.field.name',
'label_attr' => ['class' => 'control-label'],
'attr' => ['class' => 'form-control'],
]);
// The Description tab. by_reference false: Symfony calls Plan::addDescriptionItem()/removeDescriptionItem().
// The Description tab. by_reference false: Symfony calls Initiative::addDescriptionItem()/removeDescriptionItem().
$builder->add('descriptionItems', CollectionType::class, [
'label' => 'mautic.plan.field.description_items',
'entry_type' => PlanDescriptionItemType::class,
'label' => 'mautic.program.field.description_items',
'entry_type' => InitiativeDescriptionItemType::class,
'entry_options' => ['label' => false],
'allow_add' => true,
'allow_delete' => true,
@@ -67,8 +67,8 @@ class PlanType extends AbstractType
// The Allocations tab's cost lines, in the general currency.
$builder->add('allocationItems', CollectionType::class, [
'label' => 'mautic.plan.field.allocation_items',
'entry_type' => PlanAllocationItemType::class,
'label' => 'mautic.program.field.allocation_items',
'entry_type' => InitiativeAllocationItemType::class,
'entry_options' => ['label' => false],
'allow_add' => true,
'allow_delete' => true,
@@ -78,24 +78,25 @@ class PlanType extends AbstractType
'required' => false,
]);
// The Targets tab's audiences. by_reference false: Symfony calls Plan::addTarget()/removeTarget().
$builder->add('targets', CollectionType::class, [
'label' => 'mautic.plan.field.targets',
'entry_type' => PlanTargetType::class,
// The Audiences tab's links to the global directory. by_reference false: Symfony calls
// Initiative::addAudience()/removeAudience().
$builder->add('audiences', CollectionType::class, [
'label' => 'mautic.program.field.audiences',
'entry_type' => InitiativeAudienceType::class,
'entry_options' => ['label' => false],
'allow_add' => true,
'allow_delete' => true,
'by_reference' => false,
'by_reference' => false,
'prototype' => true,
'prototype_name' => '__target__',
'prototype_name' => '__audience__',
'required' => false,
]);
// The Stakeholders tab's links to the global directory. by_reference false: Symfony calls
// Plan::addStakeholder()/removeStakeholder().
// Initiative::addStakeholder()/removeStakeholder().
$builder->add('stakeholders', CollectionType::class, [
'label' => 'mautic.plan.field.stakeholders',
'entry_type' => PlanStakeholderType::class,
'label' => 'mautic.program.field.stakeholders',
'entry_type' => InitiativeStakeholderType::class,
'entry_options' => ['label' => false],
'allow_add' => true,
'allow_delete' => true,
@@ -106,21 +107,21 @@ class PlanType extends AbstractType
]);
$builder->add('version', IntegerType::class, [
'label' => 'mautic.plan.field.version',
'label' => 'mautic.program.field.version',
'label_attr' => ['class' => 'control-label'],
'invalid_message' => 'mautic.plan.version.range',
'invalid_message' => 'mautic.program.version.range',
'attr' => [
'class' => 'form-control',
'min' => Plan::VERSION_MIN,
'max' => Plan::VERSION_MAX,
'min' => Initiative::VERSION_MIN,
'max' => Initiative::VERSION_MAX,
'step' => 1,
],
]);
// by_reference false: Symfony calls Plan::addObjective()/removeObjective(), which keep both sides in sync.
// by_reference false: Symfony calls Initiative::addObjective()/removeObjective(), which keep both sides in sync.
$builder->add('objectives', CollectionType::class, [
'label' => 'mautic.plan.field.objectives',
'entry_type' => PlanObjectiveType::class,
'label' => 'mautic.program.field.objectives',
'entry_type' => InitiativeObjectiveType::class,
'entry_options' => ['label' => false],
'allow_add' => true,
'allow_delete' => true,
@@ -131,9 +132,9 @@ class PlanType extends AbstractType
]);
$builder->add('status', EnumType::class, [
'class' => PlanStatus::class,
'choice_label' => fn (PlanStatus $status): string => $status->getLabelKey(),
'label' => 'mautic.plan.field.status',
'class' => InitiativeStatus::class,
'choice_label' => fn (InitiativeStatus $status): string => $status->getLabelKey(),
'label' => 'mautic.program.field.status',
'label_attr' => ['class' => 'control-label'],
'attr' => ['class' => 'form-control'],
]);
@@ -141,7 +142,7 @@ class PlanType extends AbstractType
// Required here; the column is nullable only because of onDelete SET NULL.
$builder->add(
$builder->create('owner', UserListType::class, [
'label' => 'mautic.plan.field.owner',
'label' => 'mautic.program.field.owner',
'label_attr' => ['class' => 'control-label'],
'attr' => ['class' => 'form-control'],
'required' => true,
@@ -150,16 +151,16 @@ class PlanType extends AbstractType
);
$builder->add('startDate', DatePickerType::class, [
'label' => 'mautic.plan.field.start_date',
'label' => 'mautic.program.field.start_date',
]);
$builder->add('endDate', DatePickerType::class, [
'label' => 'mautic.plan.field.end_date',
'label' => 'mautic.program.field.end_date',
]);
// In the general currency (Settings > Configuration > Plan Settings), shown next to the field.
// In the general currency (Settings > Configuration > Initiative Settings), shown next to the field.
$builder->add('budgetPlanned', NumberType::class, [
'label' => 'mautic.plan.field.budget_planned',
'label' => 'mautic.program.field.budget_planned',
'label_attr' => ['class' => 'control-label'],
'attr' => ['class' => 'form-control', 'postaddon_text' => $this->currencyProvider->getCurrency()],
'input' => 'string',
@@ -168,7 +169,7 @@ class PlanType extends AbstractType
]);
$builder->add('category', CategoryListType::class, [
'bundle' => 'plan',
'bundle' => 'initiative',
]);
$builder->add('isPublished', YesNoButtonGroupType::class, [
@@ -185,12 +186,12 @@ class PlanType extends AbstractType
public function configureOptions(OptionsResolver $resolver): void
{
$resolver->setDefaults([
'data_class' => Plan::class,
'data_class' => Initiative::class,
]);
}
public function getBlockPrefix(): string
{
return 'plan';
return 'initiative';
}
}
+13 -13
View File
@@ -2,10 +2,10 @@
declare(strict_types=1);
namespace MauticPlugin\PlanBundle\Form\Type;
namespace MauticPlugin\ProgramBundle\Form\Type;
use MauticPlugin\PlanBundle\Service\ItemTypeProvider;
use MauticPlugin\PlanBundle\Service\Pictograms;
use MauticPlugin\ProgramBundle\Service\ItemTypeProvider;
use MauticPlugin\ProgramBundle\Service\Pictograms;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
use Symfony\Component\Form\Extension\Core\Type\FormType;
@@ -20,7 +20,7 @@ use Symfony\Component\Validator\Constraints\Length;
use Symfony\Component\Validator\Constraints\NotBlank;
/**
* One item type (description or allocation) in Settings > Configuration > Plan Settings: a name and a
* One item type (description or allocation) in Settings > Configuration > Initiative Settings: a name and a
* description per language, and a pictogram.
*
* The key is hidden. It is generated when the type is created and never changes, so that renaming a
@@ -40,7 +40,7 @@ class ItemTypeConfigType extends AbstractType
$default = $this->typeProvider->getDefaultLocale();
$builder->add('key', HiddenType::class, [
'attr' => ['class' => 'plan-type-key'],
'attr' => ['class' => 'initiative-type-key'],
]);
$names = $builder->create('names', FormType::class, ['label' => false]);
@@ -50,17 +50,17 @@ class ItemTypeConfigType extends AbstractType
$isDefault = $locale === $default;
$names->add($locale, TextType::class, [
'label' => 'mautic.plan.config.type.name',
'label' => 'mautic.program.config.type.name',
'label_attr' => ['class' => 'control-label'],
'attr' => ['class' => 'form-control', 'maxlength' => 191, 'data-locale' => $locale, 'data-language' => $language],
'required' => $isDefault,
'constraints' => $isDefault
? [new NotBlank(message: 'mautic.plan.config.type.name.required'), new Length(max: 191)]
? [new NotBlank(message: 'mautic.program.config.type.name.required'), new Length(max: 191)]
: [new Length(max: 191)],
]);
$descriptions->add($locale, TextareaType::class, [
'label' => 'mautic.plan.config.type.description',
'label' => 'mautic.program.config.type.description',
'label_attr' => ['class' => 'control-label'],
'attr' => ['class' => 'form-control', 'rows' => 2, 'data-locale' => $locale],
'required' => false,
@@ -70,15 +70,15 @@ class ItemTypeConfigType extends AbstractType
$builder->add($names);
$builder->add($descriptions);
// Pictogram; the preview next to the dropdown is updated by plan.js.
// Pictogram; the preview next to the dropdown is updated by program.js.
if ($options['with_icon']) {
$builder->add('icon', ChoiceType::class, [
'label' => 'mautic.plan.config.type.icon',
'label' => 'mautic.program.config.type.icon',
'label_attr' => ['class' => 'control-label'],
'attr' => ['class' => 'form-control plan-type-icon-select'],
'attr' => ['class' => 'form-control initiative-type-icon-select'],
'choices' => Pictograms::getChoices(),
'choice_attr' => fn (?string $icon): array => ['data-icon' => (string) $icon],
'placeholder' => 'mautic.plan.config.type.icon.none',
'placeholder' => 'mautic.program.config.type.icon.none',
'required' => false,
]);
}
@@ -104,6 +104,6 @@ class ItemTypeConfigType extends AbstractType
public function getBlockPrefix(): string
{
return 'plan_item_type_config';
return 'program_item_type_config';
}
}
+13 -13
View File
@@ -2,10 +2,10 @@
declare(strict_types=1);
namespace MauticPlugin\PlanBundle\Form\Type;
namespace MauticPlugin\ProgramBundle\Form\Type;
use MauticPlugin\PlanBundle\Entity\Stakeholder;
use MauticPlugin\PlanBundle\Service\ItemTypeProvider;
use MauticPlugin\ProgramBundle\Entity\Stakeholder;
use MauticPlugin\ProgramBundle\Service\ItemTypeProvider;
use Mautic\CoreBundle\Form\Type\FormButtonsType;
use Mautic\CoreBundle\Form\Type\YesNoButtonGroupType;
use Symfony\Component\Form\AbstractType;
@@ -17,7 +17,7 @@ use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
/**
* The create and edit form of a stakeholder of the global directory (Planning > Stakeholders).
* The create and edit form of a stakeholder of the global directory (Programs > Stakeholders).
*
* @extends AbstractType<Stakeholder>
*/
@@ -33,38 +33,38 @@ class StakeholderType extends AbstractType
$kind = ItemTypeProvider::KIND_STAKEHOLDER;
$builder->add('name', TextType::class, [
'label' => 'mautic.plan.stakeholder.field.name',
'label' => 'mautic.program.stakeholder.field.name',
'label_attr' => ['class' => 'control-label'],
'attr' => ['class' => 'form-control', 'maxlength' => 191],
]);
$builder->add('email', EmailType::class, [
'label' => 'mautic.plan.stakeholder.field.email',
'label' => 'mautic.program.stakeholder.field.email',
'label_attr' => ['class' => 'control-label'],
'attr' => ['class' => 'form-control', 'maxlength' => 191],
'required' => false,
]);
$builder->add('phone', TelType::class, [
'label' => 'mautic.plan.stakeholder.field.phone',
'label' => 'mautic.program.stakeholder.field.phone',
'label_attr' => ['class' => 'control-label'],
'attr' => ['class' => 'form-control', 'maxlength' => 50],
'required' => false,
]);
$builder->add('role', TextType::class, [
'label' => 'mautic.plan.stakeholder.field.role',
'label' => 'mautic.program.stakeholder.field.role',
'label_attr' => ['class' => 'control-label'],
'attr' => ['class' => 'form-control', 'maxlength' => 191],
'required' => false,
]);
$builder->add('type', ChoiceType::class, [
'label' => 'mautic.plan.stakeholder.field.type',
'label' => 'mautic.program.stakeholder.field.type',
'label_attr' => ['class' => 'control-label'],
'attr' => ['class' => 'form-control plan-item-type'],
'attr' => ['class' => 'form-control initiative-item-type'],
'choices' => $this->typeProvider->getChoices($kind),
// The type's description and pictogram, shown next to the dropdown by plan.js.
// The type's description and pictogram, shown next to the dropdown by program.js.
'choice_attr' => fn (?string $key): array => [
'data-description' => (string) $this->typeProvider->getDescription($kind, $key),
'data-icon' => (string) $this->typeProvider->getIcon($kind, $key),
@@ -74,7 +74,7 @@ class StakeholderType extends AbstractType
]);
$builder->add('isPublished', YesNoButtonGroupType::class, [
'label' => 'mautic.plan.stakeholder.field.active',
'label' => 'mautic.program.stakeholder.field.active',
]);
$builder->add('buttons', FormButtonsType::class);
@@ -93,6 +93,6 @@ class StakeholderType extends AbstractType
public function getBlockPrefix(): string
{
return 'plan_stakeholder';
return 'program_stakeholder';
}
}
-126
View File
@@ -1,126 +0,0 @@
<?php
declare(strict_types=1);
namespace MauticPlugin\PlanBundle\Form\Type;
use Doctrine\ORM\EntityRepository;
use Mautic\StageBundle\Entity\Stage;
use MauticPlugin\PlanBundle\Entity\Target;
use MauticPlugin\PlanBundle\Entity\TargetPriority;
use MauticPlugin\PlanBundle\Entity\TargetType as TargetTypeEnum;
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
use Symfony\Component\Form\Extension\Core\Type\EnumType;
use Symfony\Component\Form\Extension\Core\Type\HiddenType;
use Symfony\Component\Form\Extension\Core\Type\IntegerType;
use Symfony\Component\Form\Extension\Core\Type\TextareaType;
use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
/**
* One row of the targets collection in PlanType: name, type, priority, stages, estimated size, the
* three texts, the preferred channels, and the hidden position kept in display order by
* Assets/js/plan.js.
*
* @extends AbstractType<Target>
*/
class TargetType extends AbstractType
{
public function buildForm(FormBuilderInterface $builder, array $options): void
{
$builder->add('name', TextType::class, [
'label' => 'mautic.plan.target.field.name',
'label_attr' => ['class' => 'control-label'],
'attr' => ['class' => 'form-control', 'maxlength' => 191],
]);
// Dropdown in the order of the TargetType cases.
$builder->add('targetType', EnumType::class, [
'label' => 'mautic.plan.target.field.type',
'label_attr' => ['class' => 'control-label'],
'attr' => ['class' => 'form-control'],
'class' => TargetTypeEnum::class,
'choice_label' => fn (TargetTypeEnum $type): string => $type->getLabelKey(),
]);
// Dropdown in the order of the TargetPriority cases.
$builder->add('priority', EnumType::class, [
'label' => 'mautic.plan.target.field.priority',
'label_attr' => ['class' => 'control-label'],
'attr' => ['class' => 'form-control'],
'class' => TargetPriority::class,
'choice_label' => fn (TargetPriority $priority): string => $priority->getLabelKey(),
]);
// The Mautic stages this target maps to; any number, or none.
$builder->add('stages', EntityType::class, [
'label' => 'mautic.plan.target.field.stages',
'label_attr' => ['class' => 'control-label'],
'attr' => ['class' => 'form-control'],
'class' => Stage::class,
'choice_label' => 'name',
'query_builder' => fn (EntityRepository $er) => $er->createQueryBuilder('s')->orderBy('s.name', 'ASC'),
'multiple' => true,
'expanded' => false,
'required' => false,
]);
$builder->add('estimatedSize', IntegerType::class, [
'label' => 'mautic.plan.target.field.estimated_size',
'label_attr' => ['class' => 'control-label'],
'attr' => ['class' => 'form-control', 'min' => 0, 'step' => 1],
'required' => false,
]);
$builder->add('profileCriteria', TextareaType::class, [
'label' => 'mautic.plan.target.field.profile_criteria',
'label_attr' => ['class' => 'control-label'],
'attr' => ['class' => 'form-control', 'rows' => 2],
'required' => false,
]);
$builder->add('painPoints', TextareaType::class, [
'label' => 'mautic.plan.target.field.pain_points',
'label_attr' => ['class' => 'control-label'],
'attr' => ['class' => 'form-control', 'rows' => 2],
'required' => false,
]);
$builder->add('valueProposition', TextareaType::class, [
'label' => 'mautic.plan.target.field.value_proposition',
'label_attr' => ['class' => 'control-label'],
'attr' => ['class' => 'form-control', 'rows' => 2],
'required' => false,
]);
// One checkbox per channel, in the order of Target::CHANNELS. The choice values are the channel
// keys; the labels are translated by the trans_choices mechanism of the choice_label.
$builder->add('preferredChannels', ChoiceType::class, [
'label' => 'mautic.plan.target.field.preferred_channels',
'label_attr' => ['class' => 'control-label'],
'choices' => array_flip(Target::CHANNELS),
'expanded' => true,
'multiple' => true,
'required' => false,
]);
$builder->add('position', HiddenType::class, [
'attr' => ['class' => 'plan-row-position'],
]);
}
public function configureOptions(OptionsResolver $resolver): void
{
$resolver->setDefaults([
'data_class' => Target::class,
]);
}
public function getBlockPrefix(): string
{
return 'plan_target';
}
}
+18 -18
View File
@@ -2,13 +2,13 @@
declare(strict_types=1);
namespace MauticPlugin\PlanBundle\Form\Type;
namespace MauticPlugin\ProgramBundle\Form\Type;
use Doctrine\ORM\EntityRepository;
use MauticPlugin\PlanBundle\Entity\DependencyType;
use MauticPlugin\PlanBundle\Entity\Plan;
use MauticPlugin\PlanBundle\Entity\Task;
use MauticPlugin\PlanBundle\Entity\TaskDependency;
use MauticPlugin\ProgramBundle\Entity\DependencyType;
use MauticPlugin\ProgramBundle\Entity\Initiative;
use MauticPlugin\ProgramBundle\Entity\Task;
use MauticPlugin\ProgramBundle\Entity\TaskDependency;
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\EnumType;
@@ -18,7 +18,7 @@ use Symfony\Component\OptionsResolver\OptionsResolver;
/**
* One row of the dependencies collection in TaskType: the task this one depends on, and the type of
* the relation. Only the tasks of the same plan are offered; cycles and self-edges are refused by
* the relation. Only the tasks of the same initiative are offered; cycles and self-edges are refused by
* ValidTaskDependency.
*
* @extends AbstractType<TaskDependency>
@@ -27,23 +27,23 @@ class TaskDependencyType extends AbstractType
{
public function buildForm(FormBuilderInterface $builder, array $options): void
{
/** @var Plan|null $plan */
$plan = $options['plan'];
/** @var Initiative|null $initiative */
$initiative = $options['initiative'];
/** @var Task|null $task */
$task = $options['task'];
$builder->add('dependsOn', EntityType::class, [
'label' => 'mautic.plan.task.dependency.field.depends_on',
'label' => 'mautic.program.task.dependency.field.depends_on',
'label_attr' => ['class' => 'control-label'],
'attr' => ['class' => 'form-control'],
'class' => Task::class,
'choice_label' => 'name',
'query_builder' => function (EntityRepository $er) use ($plan, $task) {
'query_builder' => function (EntityRepository $er) use ($initiative, $task) {
$qb = $er->createQueryBuilder('t')
->orderBy('t.name', 'ASC');
if (null !== $plan) {
$qb->andWhere('t.plan = :plan')->setParameter('plan', $plan);
if (null !== $initiative) {
$qb->andWhere('t.initiative = :initiative')->setParameter('initiative', $initiative);
}
if (null !== $task?->getId()) {
@@ -57,16 +57,16 @@ class TaskDependencyType extends AbstractType
]);
$builder->add('dependencyType', EnumType::class, [
'label' => 'mautic.plan.task.dependency.field.type',
'label' => 'mautic.program.task.dependency.field.type',
'label_attr' => ['class' => 'control-label'],
'attr' => ['class' => 'form-control'],
'class' => DependencyType::class,
'choice_label' => fn (DependencyType $type): string => $type->getLabelKey(),
]);
// The row's order in the collection, rewritten by plan.js after each change.
// The row's order in the collection, rewritten by program.js after each change.
$builder->add('position', HiddenType::class, [
'attr' => ['class' => 'plan-row-position'],
'attr' => ['class' => 'initiative-row-position'],
]);
}
@@ -75,13 +75,13 @@ class TaskDependencyType extends AbstractType
$resolver->setDefaults([
'data_class' => TaskDependency::class,
]);
$resolver->setDefined(['plan', 'task']);
$resolver->setAllowedTypes('plan', [Plan::class, 'null']);
$resolver->setDefined(['initiative', 'task']);
$resolver->setAllowedTypes('initiative', [Initiative::class, 'null']);
$resolver->setAllowedTypes('task', [Task::class, 'null']);
}
public function getBlockPrefix(): string
{
return 'plan_task_dependency';
return 'program_task_dependency';
}
}
+21 -21
View File
@@ -2,13 +2,13 @@
declare(strict_types=1);
namespace MauticPlugin\PlanBundle\Form\Type;
namespace MauticPlugin\ProgramBundle\Form\Type;
use Doctrine\ORM\EntityRepository;
use MauticPlugin\PlanBundle\Entity\Plan;
use MauticPlugin\PlanBundle\Entity\RaciRole;
use MauticPlugin\PlanBundle\Entity\Stakeholder;
use MauticPlugin\PlanBundle\Entity\TaskRaci;
use MauticPlugin\ProgramBundle\Entity\Initiative;
use MauticPlugin\ProgramBundle\Entity\RaciRole;
use MauticPlugin\ProgramBundle\Entity\Stakeholder;
use MauticPlugin\ProgramBundle\Entity\TaskRaci;
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\EnumType;
@@ -18,7 +18,7 @@ use Symfony\Component\OptionsResolver\OptionsResolver;
/**
* One row of the RACI collection in TaskType: a role (R/A/C/I) and the stakeholders carrying it.
* The stakeholders are picked from the plan's assigned stakeholders; several may share a role.
* The stakeholders are picked from the initiative's assigned stakeholders; several may share a role.
*
* @extends AbstractType<TaskRaci>
*/
@@ -26,11 +26,11 @@ class TaskRaciType extends AbstractType
{
public function buildForm(FormBuilderInterface $builder, array $options): void
{
/** @var Plan|null $plan */
$plan = $options['plan'];
/** @var Initiative|null $initiative */
$initiative = $options['initiative'];
$builder->add('role', EnumType::class, [
'label' => 'mautic.plan.task.raci.field.role',
'label' => 'mautic.program.task.raci.field.role',
'label_attr' => ['class' => 'control-label'],
'attr' => ['class' => 'form-control'],
'class' => RaciRole::class,
@@ -38,20 +38,20 @@ class TaskRaciType extends AbstractType
]);
$builder->add('stakeholders', EntityType::class, [
'label' => 'mautic.plan.task.raci.field.stakeholders',
'label' => 'mautic.program.task.raci.field.stakeholders',
'label_attr' => ['class' => 'control-label'],
'attr' => ['class' => 'form-control'],
'class' => Stakeholder::class,
'choice_label' => 'name',
'query_builder' => function (EntityRepository $er) use ($plan) {
'query_builder' => function (EntityRepository $er) use ($initiative) {
$qb = $er->createQueryBuilder('s')
->orderBy('s.name', 'ASC');
// The plan's assigned stakeholders, when the plan is known.
if (null !== $plan) {
$qb->join('s.planLinks', 'l')
->andWhere('l.plan = :plan')
->setParameter('plan', $plan);
// The initiative's assigned stakeholders, when the initiative is known.
if (null !== $initiative) {
$qb->join('s.initiativeLinks', 'l')
->andWhere('l.initiative = :initiative')
->setParameter('initiative', $initiative);
}
return $qb;
@@ -61,9 +61,9 @@ class TaskRaciType extends AbstractType
'required' => false,
]);
// The row's order in the collection, rewritten by plan.js after each change.
// The row's order in the collection, rewritten by program.js after each change.
$builder->add('position', HiddenType::class, [
'attr' => ['class' => 'plan-row-position'],
'attr' => ['class' => 'initiative-row-position'],
]);
}
@@ -72,12 +72,12 @@ class TaskRaciType extends AbstractType
$resolver->setDefaults([
'data_class' => TaskRaci::class,
]);
$resolver->setDefined(['plan']);
$resolver->setAllowedTypes('plan', [Plan::class, 'null']);
$resolver->setDefined(['initiative']);
$resolver->setAllowedTypes('initiative', [Initiative::class, 'null']);
}
public function getBlockPrefix(): string
{
return 'plan_task_raci';
return 'program_task_raci';
}
}
+29 -29
View File
@@ -2,16 +2,16 @@
declare(strict_types=1);
namespace MauticPlugin\PlanBundle\Form\Type;
namespace MauticPlugin\ProgramBundle\Form\Type;
use Doctrine\ORM\EntityRepository;
use Mautic\CoreBundle\Form\EventListener\CleanFormSubscriber;
use Mautic\CoreBundle\Form\Type\FormButtonsType;
use MauticPlugin\PlanBundle\Entity\Plan;
use MauticPlugin\PlanBundle\Entity\Task;
use MauticPlugin\PlanBundle\Entity\TaskKind;
use MauticPlugin\PlanBundle\Entity\TaskStatus;
use MauticPlugin\PlanBundle\Service\ItemTypeProvider;
use MauticPlugin\ProgramBundle\Entity\Initiative;
use MauticPlugin\ProgramBundle\Entity\Task;
use MauticPlugin\ProgramBundle\Entity\TaskKind;
use MauticPlugin\ProgramBundle\Entity\TaskStatus;
use MauticPlugin\ProgramBundle\Service\ItemTypeProvider;
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
@@ -25,7 +25,7 @@ use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
/**
* The create and edit form of a task (Planning > Tasks).
* The create and edit form of a task (Programs > Tasks).
*
* Kind rules: a milestone's end date is enslaved to its start date (the entity's setTaskKind copies
* the start onto the end, and the TaskDates validator keeps it in step); a phase has no status
@@ -46,7 +46,7 @@ class TaskType extends AbstractType
/** @var Task $task */
$task = $options['data'];
$plan = $task->getPlan();
$initiative = $task->getInitiative();
$kind = ItemTypeProvider::KIND_TASK;
@@ -54,7 +54,7 @@ class TaskType extends AbstractType
$taskKind = $task->getTaskKind();
$builder->add('taskKind', EnumType::class, [
'label' => 'mautic.plan.task.field.kind',
'label' => 'mautic.program.task.field.kind',
'label_attr' => ['class' => 'control-label'],
'attr' => ['class' => 'form-control'],
'class' => TaskKind::class,
@@ -62,11 +62,11 @@ class TaskType extends AbstractType
]);
$builder->add('type', ChoiceType::class, [
'label' => 'mautic.plan.task.field.type',
'label' => 'mautic.program.task.field.type',
'label_attr' => ['class' => 'control-label'],
'attr' => ['class' => 'form-control plan-item-type'],
'attr' => ['class' => 'form-control initiative-item-type'],
'choices' => $this->typeProvider->getChoices($kind),
// The type's description and pictogram, shown next to the dropdown by plan.js.
// The type's description and pictogram, shown next to the dropdown by program.js.
'choice_attr' => fn (?string $key): array => [
'data-description' => (string) $this->typeProvider->getDescription($kind, $key),
'data-icon' => (string) $this->typeProvider->getIcon($kind, $key),
@@ -76,23 +76,23 @@ class TaskType extends AbstractType
]);
$builder->add('name', TextType::class, [
'label' => 'mautic.plan.task.field.name',
'label' => 'mautic.program.task.field.name',
'label_attr' => ['class' => 'control-label'],
'attr' => ['class' => 'form-control', 'maxlength' => 255],
]);
$builder->add('description', TextareaType::class, [
'label' => 'mautic.plan.task.field.description',
'label' => 'mautic.program.task.field.description',
'label_attr' => ['class' => 'control-label'],
'attr' => ['class' => 'form-control', 'rows' => 6],
'required' => false,
]);
$builder->add('plan', EntityType::class, [
'label' => 'mautic.plan.task.field.plan',
$builder->add('initiative', EntityType::class, [
'label' => 'mautic.program.task.field.initiative',
'label_attr' => ['class' => 'control-label'],
'attr' => ['class' => 'form-control'],
'class' => Plan::class,
'class' => Initiative::class,
'choice_label' => 'name',
'query_builder' => fn (EntityRepository $er) => $er->createQueryBuilder('p')->orderBy('p.name', 'ASC'),
'placeholder' => 'mautic.core.form.chooseone',
@@ -101,7 +101,7 @@ class TaskType extends AbstractType
// Simple dates, no time (the columns are DATE since 0.13.0).
$builder->add('startDate', DateType::class, [
'label' => 'mautic.plan.task.field.start_date',
'label' => 'mautic.program.task.field.start_date',
'widget' => 'single_text',
'format' => 'yyyy-MM-dd',
'html5' => true,
@@ -112,7 +112,7 @@ class TaskType extends AbstractType
$isMilestone = TaskKind::Milestone === $task->getTaskKind();
$isPhase = TaskKind::Phase === $task->getTaskKind();
$builder->add('endDate', DateType::class, [
'label' => 'mautic.plan.task.field.end_date',
'label' => 'mautic.program.task.field.end_date',
'widget' => 'single_text',
'format' => 'yyyy-MM-dd',
'html5' => true,
@@ -123,7 +123,7 @@ class TaskType extends AbstractType
// Status: a phase has none of its own — it comes from its tasks.
if (!$isPhase) {
$builder->add('status', EnumType::class, [
'label' => 'mautic.plan.task.field.status',
'label' => 'mautic.program.task.field.status',
'label_attr' => ['class' => 'control-label'],
'attr' => ['class' => 'form-control'],
'class' => TaskStatus::class,
@@ -132,26 +132,26 @@ class TaskType extends AbstractType
}
$builder->add('definitionOfDone', TextareaType::class, [
'label' => 'mautic.plan.task.field.definition_of_done',
'label' => 'mautic.program.task.field.definition_of_done',
'label_attr' => ['class' => 'control-label'],
'attr' => ['class' => 'form-control', 'rows' => 3],
'required' => false,
]);
$builder->add('plannedWork', IntegerType::class, [
'label' => 'mautic.plan.task.field.planned_work',
'label' => 'mautic.program.task.field.planned_work',
'label_attr' => ['class' => 'control-label'],
'attr' => ['class' => 'form-control', 'min' => 0, 'step' => 1, 'postaddon_text' => 'h'],
'required' => false,
]);
// Dependencies: several edges, each another task of the plan with the relation type. The
// Dependencies: several edges, each another task of the initiative with the relation type. The
// rows are added and removed by the form template; cycles and self-edges are refused by
// ValidTaskDependency.
$builder->add('dependencies', CollectionType::class, [
'label' => 'mautic.plan.task.field.dependencies',
'label' => 'mautic.program.task.field.dependencies',
'entry_type' => TaskDependencyType::class,
'entry_options' => ['label' => false, 'plan' => $plan, 'task' => $task],
'entry_options' => ['label' => false, 'initiative' => $initiative, 'task' => $task],
'allow_add' => true,
'allow_delete' => true,
'by_reference' => false,
@@ -160,11 +160,11 @@ class TaskType extends AbstractType
'required' => false,
]);
// RACI: one row per role, several stakeholders per role, picked from the plan's stakeholders.
// RACI: one row per role, several stakeholders per role, picked from the initiative's stakeholders.
$builder->add('raci', CollectionType::class, [
'label' => 'mautic.plan.task.field.raci',
'label' => 'mautic.program.task.field.raci',
'entry_type' => TaskRaciType::class,
'entry_options' => ['label' => false, 'plan' => $plan],
'entry_options' => ['label' => false, 'initiative' => $initiative],
'allow_add' => true,
'allow_delete' => true,
'by_reference' => false,
@@ -189,6 +189,6 @@ class TaskType extends AbstractType
public function getBlockPrefix(): string
{
return 'plan_task';
return 'program_task';
}
}