From 02874d80adf9f96abf4f95a4d1edab185d79e45e Mon Sep 17 00:00:00 2001 From: Mathieu Santostefano Date: Tue, 6 Aug 2024 14:30:11 +0200 Subject: [PATCH 1/4] fix(ui-element): Add missing LinksUiElement templates --- .../UiElement/links_ui_element.html.twig | 16 ++++++++++--- .../Shop/UiElement/links_ui_element.html.twig | 24 +++++++++++++++++-- 2 files changed, 35 insertions(+), 5 deletions(-) diff --git a/src/Resources/views/Admin/UiElement/links_ui_element.html.twig b/src/Resources/views/Admin/UiElement/links_ui_element.html.twig index 178bef5..29bb1ff 100644 --- a/src/Resources/views/Admin/UiElement/links_ui_element.html.twig +++ b/src/Resources/views/Admin/UiElement/links_ui_element.html.twig @@ -15,7 +15,17 @@ element fields: {% if element.title.content|default('') is not empty %} {{ element.title.content|raw }} {% endif %} -{# {% for linkItem in element.links %}#} - -{# {% endfor %}#} + {% for linkItem in element.links %} +
+ {{ linkItem.label }}
+ {{ 'monsieurbiz_ui_elements.common.fields.type'|trans }} : {{ linkItem.type }} +
+ {% endfor %} +
+ +
diff --git a/src/Resources/views/Shop/UiElement/links_ui_element.html.twig b/src/Resources/views/Shop/UiElement/links_ui_element.html.twig index d7d0753..09d15f4 100644 --- a/src/Resources/views/Shop/UiElement/links_ui_element.html.twig +++ b/src/Resources/views/Shop/UiElement/links_ui_element.html.twig @@ -1,6 +1,26 @@ {# UI Element template -type: links_ui_element +type: customer_quote_ui_element element fields: - - … + - title + - quote + - author + - link + - link + - label + - type #} + +
+

+ {% if element.title|default('') is not empty %} + {{ element.title|raw }} + {% endif %} + {% if element.subtitle|default('') is not empty %} + {{ element.subtitle }} + {% endif %} +

+ {% if element.description|default('') is not empty %} +

{{ element.description }}

+ {% endif %} +
From d1a59b068e74241c82fa971b6c00f4c747718e5b Mon Sep 17 00:00:00 2001 From: Mathieu Santostefano Date: Tue, 6 Aug 2024 14:38:24 +0200 Subject: [PATCH 2/4] fix(ui-element): Fix HeroUiElement field types --- src/Form/Type/UiElement/HeroUiElementType.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/Form/Type/UiElement/HeroUiElementType.php b/src/Form/Type/UiElement/HeroUiElementType.php index 670d2a4..4f33963 100644 --- a/src/Form/Type/UiElement/HeroUiElementType.php +++ b/src/Form/Type/UiElement/HeroUiElementType.php @@ -16,6 +16,7 @@ use MonsieurBiz\SyliusRichEditorPlugin\Form\Type\WysiwygType; use MonsieurBiz\SyliusRichEditorPlugin\WysiwygEditor\EditorInterface; use Symfony\Component\Form\AbstractType; +use Symfony\Component\Form\Extension\Core\Type\TextType; use Symfony\Component\Form\FormBuilderInterface; #[AsUiElement( @@ -52,11 +53,11 @@ public function buildForm(FormBuilderInterface $builder, array $options): void ['showBlocks', 'codeView'], ], ]) - ->add('subtitle', null, [ + ->add('subtitle', TextType::class, [ 'label' => 'monsieurbiz_ui_elements.common.fields.subtitle', 'required' => false, ]) - ->add('description', null, [ + ->add('description', TextType::class, [ 'label' => 'monsieurbiz_ui_elements.common.fields.description', 'required' => false, ]) From 900180739b97b99c2908ab0c41d7e1ca49886b0c Mon Sep 17 00:00:00 2001 From: Mathieu Santostefano Date: Tue, 6 Aug 2024 14:38:41 +0200 Subject: [PATCH 3/4] feat(ui-element): Add QuoteWithLinkUiElement --- .../UiElement/CustomerQuoteUiElementType.php | 89 +++++++++++++++++++ src/Resources/translations/messages.en.yaml | 5 ++ src/Resources/translations/messages.fr.yaml | 5 ++ .../customer_quote_ui_element.html.twig | 28 ++++++ .../customer_quote_ui_element.html.twig | 28 ++++++ 5 files changed, 155 insertions(+) create mode 100644 src/Form/Type/UiElement/CustomerQuoteUiElementType.php create mode 100644 src/Resources/views/Admin/UiElement/customer_quote_ui_element.html.twig create mode 100644 src/Resources/views/Shop/UiElement/customer_quote_ui_element.html.twig diff --git a/src/Form/Type/UiElement/CustomerQuoteUiElementType.php b/src/Form/Type/UiElement/CustomerQuoteUiElementType.php new file mode 100644 index 0000000..88c8527 --- /dev/null +++ b/src/Form/Type/UiElement/CustomerQuoteUiElementType.php @@ -0,0 +1,89 @@ + + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +declare(strict_types=1); + +namespace MonsieurBiz\SyliusUiElementsPlugin\Form\Type\UiElement; + +use MonsieurBiz\SyliusRichEditorPlugin\Attribute\AsUiElement; +use MonsieurBiz\SyliusRichEditorPlugin\Attribute\TemplatesUiElement; +use MonsieurBiz\SyliusRichEditorPlugin\Form\Type\WysiwygType; +use MonsieurBiz\SyliusRichEditorPlugin\WysiwygEditor\EditorInterface; +use Symfony\Component\Form\AbstractType; +use Symfony\Component\Form\Extension\Core\Type\TextType; +use Symfony\Component\Form\Extension\Core\Type\UrlType; +use Symfony\Component\Form\FormBuilderInterface; +use Symfony\Component\Validator\Constraints as Assert; + +#[AsUiElement( + code: 'monsieurbiz_ui_elements.customer_quote_ui_element', + icon: 'quote left', + title: 'monsieurbiz_ui_elements.ui_element.customer_quote_ui_element.title', + description: 'monsieurbiz_ui_elements.ui_element.customer_quote_ui_element.description', + templates: new TemplatesUiElement( + adminRender: '@MonsieurBizSyliusUiElementsPlugin/Admin/UiElement/customer_quote_ui_element.html.twig', + frontRender: '@MonsieurBizSyliusUiElementsPlugin/Front/UiElement/customer_quote_ui_element.html.twig', + ), + tags: [], +)] +class CustomerQuoteUiElementType extends AbstractType +{ + /** + * @SuppressWarnings(PHPMD.UnusedFormalParameter) + */ + public function buildForm(FormBuilderInterface $builder, array $options): void + { + $builder + ->add('title', TextType::class, [ + 'label' => 'monsieurbiz_ui_elements.common.fields.title', + 'required' => false, + ]) + ->add('quote', WysiwygType::class, [ + 'label' => 'monsieurbiz_ui_elements.common.fields.quote', + 'required' => true, + 'editor_height' => 120, + 'editor_toolbar_type' => EditorInterface::TOOLBAR_TYPE_CUSTOM, + 'editor_toolbar_buttons' => [ + ['undo', 'redo'], + ['fontSize', 'formatBlock'], + ['bold', 'underline', 'italic', 'strike'], + ['fontColor', 'hiliteColor'], + ['removeFormat'], + ['link'], + ['showBlocks', 'codeView'], + ], + 'constraints' => [ + new Assert\NotBlank(), + ], + ]) + ->add('author', TextType::class, [ + 'label' => 'monsieurbiz_ui_elements.common.fields.author', + 'required' => false, + ]) + ->add('link', UrlType::class, [ + 'label' => 'monsieurbiz_ui_elements.common.fields.link', + 'required' => true, + 'constraints' => [ + new Assert\AtLeastOneOf([ + 'includeInternalMessages' => false, + 'message' => 'monsieurbiz_ui_elements.errors.not_valid_url', + 'constraints' => [ + new Assert\Url(['protocols' => ['http', 'https'], 'relativeProtocol' => true]), + new Assert\Regex(['pattern' => '`^(#|/[^/])`']), + ], + ]), + ], + ]) + ->add('linkLabel', TextType::class, [ + 'label' => 'monsieurbiz_ui_elements.common.fields.label', + 'required' => true, + ]) + ; + } +} diff --git a/src/Resources/translations/messages.en.yaml b/src/Resources/translations/messages.en.yaml index 01f1e88..501fdca 100644 --- a/src/Resources/translations/messages.en.yaml +++ b/src/Resources/translations/messages.en.yaml @@ -11,6 +11,8 @@ monsieurbiz_ui_elements: label: "Label" type: "Type" withDot: "With dot ?" + quote: "Quote" + author: "Author" errors: not_valid_url: "This value is not a valid URL (absolute or relative) or a valid hashtag." ui_element: @@ -42,3 +44,6 @@ monsieurbiz_ui_elements: buttons: add_element: "Add key figure" delete_element: "Delete key figure" + customer_quote_ui_element: + title: "Customer quote" + description: "Quote from a customer" diff --git a/src/Resources/translations/messages.fr.yaml b/src/Resources/translations/messages.fr.yaml index 498d09e..a0a4163 100644 --- a/src/Resources/translations/messages.fr.yaml +++ b/src/Resources/translations/messages.fr.yaml @@ -11,6 +11,8 @@ monsieurbiz_ui_elements: label: "Libellé" type: "Type" withDot: "Avec point ?" + quote: "Citation" + author: "Auteur" errors: not_valid_url: "Cette valeur n'est pas une URL valide (absolue ou relative) ou un hashtag valide." ui_element: @@ -42,3 +44,6 @@ monsieurbiz_ui_elements: buttons: add_element: "Ajouter un chiffre clé" delete_element: "Supprimer un chiffre clé" + customer_quote_ui_element: + title: "Citation client" + description: "Citation d'un client" diff --git a/src/Resources/views/Admin/UiElement/customer_quote_ui_element.html.twig b/src/Resources/views/Admin/UiElement/customer_quote_ui_element.html.twig new file mode 100644 index 0000000..dc2e63f --- /dev/null +++ b/src/Resources/views/Admin/UiElement/customer_quote_ui_element.html.twig @@ -0,0 +1,28 @@ +{# +UI Element template +type: customer_quote_ui_element +element fields: + - title + - quote + - author + - link + - label +#} + +
+ {% if element.title|default('') is not empty %} + {{ element.title|raw }} + {% endif %} + {% if element.quote|default('') is not empty %} +
+ {{ element.quote | raw }} + {% if element.author|default('') is not empty %} +
{{ element.author }} + {% endif %} +
+ {% endif %} + {% if element.link|default('') is not empty + and element.linkLabel|default('') is not empty %} + {{ element.linkLabel }} + {% endif %} +
diff --git a/src/Resources/views/Shop/UiElement/customer_quote_ui_element.html.twig b/src/Resources/views/Shop/UiElement/customer_quote_ui_element.html.twig new file mode 100644 index 0000000..dc2e63f --- /dev/null +++ b/src/Resources/views/Shop/UiElement/customer_quote_ui_element.html.twig @@ -0,0 +1,28 @@ +{# +UI Element template +type: customer_quote_ui_element +element fields: + - title + - quote + - author + - link + - label +#} + +
+ {% if element.title|default('') is not empty %} + {{ element.title|raw }} + {% endif %} + {% if element.quote|default('') is not empty %} +
+ {{ element.quote | raw }} + {% if element.author|default('') is not empty %} +
{{ element.author }} + {% endif %} +
+ {% endif %} + {% if element.link|default('') is not empty + and element.linkLabel|default('') is not empty %} + {{ element.linkLabel }} + {% endif %} +
From 1441bd0eb8563ad58278fec4a6b3f7e04719d614 Mon Sep 17 00:00:00 2001 From: Mathieu Santostefano Date: Wed, 7 Aug 2024 09:40:53 +0200 Subject: [PATCH 4/4] fix(ui-element): Fix LinksUiElement shop template --- .../Shop/UiElement/links_ui_element.html.twig | 35 +++++++++++-------- 1 file changed, 20 insertions(+), 15 deletions(-) diff --git a/src/Resources/views/Shop/UiElement/links_ui_element.html.twig b/src/Resources/views/Shop/UiElement/links_ui_element.html.twig index 09d15f4..29bb1ff 100644 --- a/src/Resources/views/Shop/UiElement/links_ui_element.html.twig +++ b/src/Resources/views/Shop/UiElement/links_ui_element.html.twig @@ -1,26 +1,31 @@ {# UI Element template -type: customer_quote_ui_element +type: links_ui_element element fields: - title - - quote - - author - - link + - background + - alignment + - links - link - label - type #} -
-

- {% if element.title|default('') is not empty %} - {{ element.title|raw }} - {% endif %} - {% if element.subtitle|default('') is not empty %} - {{ element.subtitle }} - {% endif %} -

- {% if element.description|default('') is not empty %} -

{{ element.description }}

+
+ {% if element.title.content|default('') is not empty %} + {{ element.title.content|raw }} {% endif %} + {% for linkItem in element.links %} +
+ {{ linkItem.label }}
+ {{ 'monsieurbiz_ui_elements.common.fields.type'|trans }} : {{ linkItem.type }} +
+ {% endfor %} +
+
    +
  • + {{ 'monsieurbiz_ui_elements.common.fields.alignment'|trans }} : {{ element.alignment }} +
  • +
+