feat(main): Add alert type; add template override support
This commit is contained in:
@@ -27,6 +27,8 @@ final class CustomHtmlBlockDataHandler implements FormDataHandlerInterface
|
||||
$block->description = (string) ($formData['description'] ?? '');
|
||||
$block->extra_description = (string) ($formData['extra_description'] ?? '');
|
||||
$block->link = (string) ($formData['link'] ?? '');
|
||||
$block->alert_type = (string) ($formData['alert_type'] ?? 'info');
|
||||
$block->timeout = (int) ($formData['timeout'] ?? 0);
|
||||
$block->image = $this->saveUploadedImage($formData['image'] ?? null, '');
|
||||
$block->active = (int) $formData['active'];
|
||||
$block->ordering = $this->getNextOrdering($idGroup);
|
||||
@@ -57,6 +59,8 @@ final class CustomHtmlBlockDataHandler implements FormDataHandlerInterface
|
||||
$block->description = (string) ($formData['description'] ?? '');
|
||||
$block->extra_description = (string) ($formData['extra_description'] ?? '');
|
||||
$block->link = (string) ($formData['link'] ?? '');
|
||||
$block->alert_type = (string) ($formData['alert_type'] ?? 'info');
|
||||
$block->timeout = (int) ($formData['timeout'] ?? 0);
|
||||
$block->image = $this->saveUploadedImage($formData['image'] ?? null, $block->image);
|
||||
$block->active = (int) $formData['active'];
|
||||
|
||||
|
||||
@@ -28,6 +28,8 @@ final class CustomHtmlBlockDataProvider implements FormDataProviderInterface
|
||||
'description' => $block->description,
|
||||
'extra_description' => $block->extra_description,
|
||||
'link' => $block->link,
|
||||
'alert_type' => $block->alert_type,
|
||||
'timeout' => (int) $block->timeout,
|
||||
'faqs' => $this->loadFaqs((int) $id),
|
||||
'active' => (bool) $block->active,
|
||||
];
|
||||
@@ -46,6 +48,8 @@ final class CustomHtmlBlockDataProvider implements FormDataProviderInterface
|
||||
'description' => '',
|
||||
'extra_description' => '',
|
||||
'link' => '',
|
||||
'alert_type' => 'info',
|
||||
'timeout' => 0,
|
||||
'faqs' => [],
|
||||
'active' => true,
|
||||
];
|
||||
|
||||
@@ -7,6 +7,7 @@ use Symfony\Component\Form\FormBuilderInterface;
|
||||
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\CollectionType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\FileType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\IntegerType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\TextType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\TextareaType;
|
||||
use PrestaShop\PrestaShop\Core\Form\ConfigurableFormChoiceProviderInterface;
|
||||
@@ -70,10 +71,23 @@ class CustomHtmlBlockType extends AbstractType
|
||||
'prototype' => true,
|
||||
'required' => false,
|
||||
])
|
||||
->add('alert_type', ChoiceType::class, [
|
||||
'label' => $this->translator->trans('Alert style', [], 'Modules.Wscustomhtml.Admin'),
|
||||
'choices' => array_flip(Config::ALERT_STYLES),
|
||||
'required' => false,
|
||||
'row_attr' => ['class' => 'customhtmlblock-type-field customhtmlblock-type-alert'],
|
||||
])
|
||||
->add('timeout', IntegerType::class, [
|
||||
'label' => $this->translator->trans('Auto-dismiss after (seconds)', [], 'Modules.Wscustomhtml.Admin'),
|
||||
'required' => false,
|
||||
'attr' => ['min' => 0, 'placeholder' => '0'],
|
||||
'help' => $this->translator->trans('0 means the alert never auto-dismisses; visitors can still close it manually.', [], 'Modules.Wscustomhtml.Admin'),
|
||||
'row_attr' => ['class' => 'customhtmlblock-type-field customhtmlblock-type-alert'],
|
||||
])
|
||||
->add('description', TextareaType::class, [
|
||||
'label' => $this->translator->trans('Description', [], 'Modules.Wscustomhtml.Admin'),
|
||||
'required' => false,
|
||||
'row_attr' => ['class' => 'customhtmlblock-type-field customhtmlblock-type-banner'],
|
||||
'row_attr' => ['class' => 'customhtmlblock-type-field customhtmlblock-type-banner customhtmlblock-type-alert'],
|
||||
])
|
||||
->add('extra_description', TextareaType::class, [
|
||||
'label' => $this->translator->trans('Extra description', [], 'Modules.Wscustomhtml.Admin'),
|
||||
|
||||
Reference in New Issue
Block a user