improved Plan / Allocation items
This commit is contained in:
1 parent
f6684f3b2e
commit
8c8d7a6f95
12 files changed
+49
-30
No files matched your search
@@ -16,7 +16,7 @@ use Symfony\Component\Validator\Constraints\NotBlank;
|
||||
/**
|
||||
* The "Plan Settings" tab of Settings > Configuration. Each child is a local.php parameter:
|
||||
* - plan_currency: the currency of every amount in the plugin (general setting);
|
||||
* - one list of item types per kind (description items, with a pictogram; allocation items).
|
||||
* - one list of item types per kind (description items, allocation items), each with a pictogram.
|
||||
*
|
||||
* @extends AbstractType<array<string, mixed>>
|
||||
*/
|
||||
@@ -46,7 +46,7 @@ class ConfigType extends AbstractType
|
||||
$builder->add($parameter, CollectionType::class, [
|
||||
'label' => false,
|
||||
'entry_type' => ItemTypeConfigType::class,
|
||||
'entry_options' => ['label' => false, 'with_icon' => ItemTypeProvider::KIND_DESCRIPTION === $kind],
|
||||
'entry_options' => ['label' => false, 'with_icon' => true],
|
||||
'allow_add' => true,
|
||||
'allow_delete' => true,
|
||||
'prototype' => true,
|
||||
|
||||
@@ -21,7 +21,7 @@ use Symfony\Component\Validator\Constraints\NotBlank;
|
||||
|
||||
/**
|
||||
* One item type (description or allocation) in Settings > Configuration > Plan Settings: a name and a
|
||||
* description per language, and for description item types a pictogram.
|
||||
* 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
|
||||
* type doesn't affect the items that use it.
|
||||
@@ -70,7 +70,7 @@ class ItemTypeConfigType extends AbstractType
|
||||
$builder->add($names);
|
||||
$builder->add($descriptions);
|
||||
|
||||
// Description item types have a pictogram; the preview next to the dropdown is updated by plan.js.
|
||||
// Pictogram; the preview next to the dropdown is updated by plan.js.
|
||||
if ($options['with_icon']) {
|
||||
$builder->add('icon', ChoiceType::class, [
|
||||
'label' => 'mautic.plan.config.type.icon',
|
||||
@@ -96,8 +96,8 @@ class ItemTypeConfigType extends AbstractType
|
||||
public function configureOptions(OptionsResolver $resolver): void
|
||||
{
|
||||
$resolver->setDefaults([
|
||||
// True for description item types: adds the pictogram field.
|
||||
'with_icon' => false,
|
||||
// Adds the pictogram field; both kinds of item types have one.
|
||||
'with_icon' => true,
|
||||
]);
|
||||
$resolver->setAllowedTypes('with_icon', 'bool');
|
||||
}
|
||||
|
||||
@@ -18,8 +18,9 @@ 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 under the
|
||||
* dropdown, hidden position kept in display order by Assets/js/plan.js).
|
||||
* real cost (both in the general currency). Works like PlanDescriptionItemType (type description shown
|
||||
* under the dropdown and its pictogram next to it, hidden position kept in display order by
|
||||
* Assets/js/plan.js).
|
||||
*
|
||||
* @extends AbstractType<PlanAllocationItem>
|
||||
*/
|
||||
@@ -40,7 +41,11 @@ class PlanAllocationItemType extends AbstractType
|
||||
'label_attr' => ['class' => 'control-label'],
|
||||
'attr' => ['class' => 'form-control plan-item-type'],
|
||||
'choices' => $this->typeProvider->getChoices($kind),
|
||||
'choice_attr' => fn (?string $key): array => ['data-description' => (string) $this->typeProvider->getDescription($kind, $key)],
|
||||
// The type's description and pictogram, shown next to the dropdown by plan.js.
|
||||
'choice_attr' => fn (?string $key): array => [
|
||||
'data-description' => (string) $this->typeProvider->getDescription($kind, $key),
|
||||
'data-icon' => (string) $this->typeProvider->getIcon($kind, $key),
|
||||
],
|
||||
'placeholder' => 'mautic.core.form.chooseone',
|
||||
'required' => true,
|
||||
]);
|
||||
|
||||
Reference in new issue
Block a user