From 74249cf28670cdcfae5b6fa7072c49451db457ae Mon Sep 17 00:00:00 2001 From: Etienne Gutbub Date: Fri, 4 Oct 2024 18:04:38 +0200 Subject: [PATCH 1/5] feat(JobOffer): add ui element + admin display and translations --- .../Type/UiElement/JobOfferUiElementType.php | 89 +++++++++++++++++++ src/Resources/translations/messages.en.yaml | 12 +++ src/Resources/translations/messages.fr.yaml | 12 +++ .../UiElement/job_offer_ui_element.html.twig | 30 +++++++ .../UiElement/job_offer_ui_element.html.twig | 11 +++ 5 files changed, 154 insertions(+) create mode 100644 src/Form/Type/UiElement/JobOfferUiElementType.php create mode 100644 src/Resources/views/Admin/UiElement/job_offer_ui_element.html.twig create mode 100644 src/Resources/views/Shop/UiElement/job_offer_ui_element.html.twig diff --git a/src/Form/Type/UiElement/JobOfferUiElementType.php b/src/Form/Type/UiElement/JobOfferUiElementType.php new file mode 100644 index 0000000..0d6a69a --- /dev/null +++ b/src/Form/Type/UiElement/JobOfferUiElementType.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 Symfony\Component\Form\AbstractType; +use Symfony\Component\Form\Extension\Core\Type\ChoiceType; +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.job_offer_ui_element', + icon: 'clipboard', + title: 'monsieurbiz_ui_elements.ui_element.job_offer_ui_element.title', + description: 'monsieurbiz_ui_elements.ui_element.job_offer_ui_element.description', + templates: new TemplatesUiElement( + adminRender: '@MonsieurBizSyliusUiElementsPlugin/Admin/UiElement/job_offer_ui_element.html.twig', + frontRender: '@MonsieurBizSyliusUiElementsPlugin/Shop/UiElement/job_offer_ui_element.html.twig', + ), + wireframe: '', +)] +final class JobOfferUiElementType extends AbstractType +{ + public const DISPLAY_SYNTHESIS = 'synthesis'; + + public const DISPLAY_COMPLETE = 'complete'; + + /** + * @SuppressWarnings(PHPMD.UnusedFormalParameter) + */ + public function buildForm(FormBuilderInterface $builder, array $options): void + { + $builder + ->add('display', ChoiceType::class, [ + 'label' => 'monsieurbiz_ui_elements.ui_element.job_offer_ui_element.fields.display', + 'required' => true, + 'constraints' => [ + new Assert\NotBlank(), + ], + 'choices' => [ + 'monsieurbiz_ui_elements.ui_element.job_offer_ui_element.choices.display.synthesis' => self::DISPLAY_SYNTHESIS, + 'monsieurbiz_ui_elements.ui_element.job_offer_ui_element.fields.display.complete' => self::DISPLAY_COMPLETE, + ], + ]) + ->add('title', TextType::class, [ + 'label' => 'monsieurbiz_ui_elements.common.fields.title', + 'required' => true, + 'constraints' => [ + new Assert\NotBlank(), + ], + ]) + ->add('contract', TextType::class, [ + 'label' => 'monsieurbiz_ui_elements.ui_element.job_offer_ui_element.fields.contract', + 'required' => true, + 'constraints' => [ + new Assert\NotBlank(), + ], + ]) + ->add('localisation', TextType::class, [ + 'label' => 'monsieurbiz_ui_elements.ui_element.job_offer_ui_element.fields.localisation', + 'required' => true, + 'constraints' => [ + new Assert\NotBlank(), + ], + ]) + ->add('content', WysiwygType::class, [ + 'label' => 'monsieurbiz_ui_elements.common.fields.content', + 'required' => false, + ]) + ->add('url', UrlType::class, [ + 'label' => 'monsieurbiz_ui_elements.ui_element.job_offer_ui_element.fields.url', + 'required' => false, + ]) + ; + } +} diff --git a/src/Resources/translations/messages.en.yaml b/src/Resources/translations/messages.en.yaml index 5bd4f65..4dfeadf 100644 --- a/src/Resources/translations/messages.en.yaml +++ b/src/Resources/translations/messages.en.yaml @@ -93,3 +93,15 @@ monsieurbiz_ui_elements: buttons: add_element: "Add element" delete_element: "Delete element" + job_offer_ui_element: + title: "Job offer Element" + choices: + display: + synthesis: "Synthesis" + complete: "Complete" + fields: + display: "Display" + contract: "Contract" + localisation: "Localisation" + content: "Content" + url: "Link" diff --git a/src/Resources/translations/messages.fr.yaml b/src/Resources/translations/messages.fr.yaml index 7c50a2b..c792c89 100644 --- a/src/Resources/translations/messages.fr.yaml +++ b/src/Resources/translations/messages.fr.yaml @@ -93,3 +93,15 @@ monsieurbiz_ui_elements: buttons: add_element: "Ajouter un élément" delete_element: "Supprimer un élément" + job_offer_ui_element: + title: "Lame offre d'emploi" + choices: + display: + synthesis: "Synthèse" + complete: "Complète" + fields: + display: "Affichage" + contract: "Contrat" + localisation: "Localisation" + content: "Contenu" + url: "Lien" diff --git a/src/Resources/views/Admin/UiElement/job_offer_ui_element.html.twig b/src/Resources/views/Admin/UiElement/job_offer_ui_element.html.twig new file mode 100644 index 0000000..2e1d762 --- /dev/null +++ b/src/Resources/views/Admin/UiElement/job_offer_ui_element.html.twig @@ -0,0 +1,30 @@ +{# +UI Element template +type: job_offer_ui_element +element fields: + - display + - title + - contract + - localisation + - content + - url +#} +
+ {% if element.display == constant('MonsieurBiz\\SyliusUiElementsPlugin\\Form\\Type\\UiElement\\JobOfferUiElementType::DISPLAY_SYNTHESIS') %} +
+

{{ element.title|default('') }}

+
{{ element.contract|default('') }}
+
{{ element.localisation|default('') }}
+ {{ element.url }} +
+ {% elseif element.display == constant('MonsieurBiz\\SyliusUiElementsPlugin\\Form\\Type\\UiElement\\JobOfferUiElementType::DISPLAY_COMPLETE') %} +
+

{{ element.title|default('') }}

+
{{ element.contract|default('') }}
+
{{ element.localisation|default('') }}
+
+ {{ element.content|default('')|raw }} +
+
+ {% endif %} +
diff --git a/src/Resources/views/Shop/UiElement/job_offer_ui_element.html.twig b/src/Resources/views/Shop/UiElement/job_offer_ui_element.html.twig new file mode 100644 index 0000000..f7de99e --- /dev/null +++ b/src/Resources/views/Shop/UiElement/job_offer_ui_element.html.twig @@ -0,0 +1,11 @@ +{# +UI Element template +type: job_offer_ui_element +element fields: + - display + - title + - contract + - localisation + - content + - url +#} From 7c5f5a315042d22ea1b138ae6063d5879a0526d8 Mon Sep 17 00:00:00 2001 From: Etienne Gutbub Date: Mon, 7 Oct 2024 09:26:21 +0200 Subject: [PATCH 2/5] feat(JobOffer): Add basic front --- .../Type/UiElement/JobOfferUiElementType.php | 2 +- src/Resources/translations/messages.en.yaml | 1 + src/Resources/translations/messages.fr.yaml | 1 + .../UiElement/job_offer_ui_element.html.twig | 18 ++++++++++++++++++ 4 files changed, 21 insertions(+), 1 deletion(-) diff --git a/src/Form/Type/UiElement/JobOfferUiElementType.php b/src/Form/Type/UiElement/JobOfferUiElementType.php index 0d6a69a..b550262 100644 --- a/src/Form/Type/UiElement/JobOfferUiElementType.php +++ b/src/Form/Type/UiElement/JobOfferUiElementType.php @@ -52,7 +52,7 @@ public function buildForm(FormBuilderInterface $builder, array $options): void ], 'choices' => [ 'monsieurbiz_ui_elements.ui_element.job_offer_ui_element.choices.display.synthesis' => self::DISPLAY_SYNTHESIS, - 'monsieurbiz_ui_elements.ui_element.job_offer_ui_element.fields.display.complete' => self::DISPLAY_COMPLETE, + 'monsieurbiz_ui_elements.ui_element.job_offer_ui_element.choices.display.complete' => self::DISPLAY_COMPLETE, ], ]) ->add('title', TextType::class, [ diff --git a/src/Resources/translations/messages.en.yaml b/src/Resources/translations/messages.en.yaml index 4dfeadf..eb52646 100644 --- a/src/Resources/translations/messages.en.yaml +++ b/src/Resources/translations/messages.en.yaml @@ -95,6 +95,7 @@ monsieurbiz_ui_elements: delete_element: "Delete element" job_offer_ui_element: title: "Job offer Element" + description: "Job offer with display in synthesis or complete" choices: display: synthesis: "Synthesis" diff --git a/src/Resources/translations/messages.fr.yaml b/src/Resources/translations/messages.fr.yaml index c792c89..7236535 100644 --- a/src/Resources/translations/messages.fr.yaml +++ b/src/Resources/translations/messages.fr.yaml @@ -95,6 +95,7 @@ monsieurbiz_ui_elements: delete_element: "Supprimer un élément" job_offer_ui_element: title: "Lame offre d'emploi" + description: "Affichage d'une offre d'emploi symntéthique ou complète" choices: display: synthesis: "Synthèse" diff --git a/src/Resources/views/Shop/UiElement/job_offer_ui_element.html.twig b/src/Resources/views/Shop/UiElement/job_offer_ui_element.html.twig index f7de99e..0e1ca93 100644 --- a/src/Resources/views/Shop/UiElement/job_offer_ui_element.html.twig +++ b/src/Resources/views/Shop/UiElement/job_offer_ui_element.html.twig @@ -9,3 +9,21 @@ element fields: - content - url #} +
+ {% if element.display == constant('MonsieurBiz\\SyliusUiElementsPlugin\\Form\\Type\\UiElement\\JobOfferUiElementType::DISPLAY_SYNTHESIS') %} + +

{{ element.title|default('') }}

+
{{ element.contract|default('') }}
+
{{ element.localisation|default('') }}
+
+ {% elseif element.display == constant('MonsieurBiz\\SyliusUiElementsPlugin\\Form\\Type\\UiElement\\JobOfferUiElementType::DISPLAY_COMPLETE') %} +
+

{{ element.title|default('') }}

+
{{ element.contract|default('') }}
+
{{ element.localisation|default('') }}
+
+ {{ element.content|default('')|raw }} +
+
+ {% endif %} +
From 8dcba25db2281fd00559cf483b428e03e6c7f012 Mon Sep 17 00:00:00 2001 From: Etienne Gutbub Date: Mon, 7 Oct 2024 14:15:08 +0200 Subject: [PATCH 3/5] refactor(jobOffer) Add conditions of display for each field --- .../UiElement/job_offer_ui_element.html.twig | 37 ++++++++++++++----- .../UiElement/job_offer_ui_element.html.twig | 35 +++++++++++++----- 2 files changed, 52 insertions(+), 20 deletions(-) diff --git a/src/Resources/views/Admin/UiElement/job_offer_ui_element.html.twig b/src/Resources/views/Admin/UiElement/job_offer_ui_element.html.twig index 2e1d762..cb59543 100644 --- a/src/Resources/views/Admin/UiElement/job_offer_ui_element.html.twig +++ b/src/Resources/views/Admin/UiElement/job_offer_ui_element.html.twig @@ -12,19 +12,36 @@ element fields:
{% if element.display == constant('MonsieurBiz\\SyliusUiElementsPlugin\\Form\\Type\\UiElement\\JobOfferUiElementType::DISPLAY_SYNTHESIS') %}
-

{{ element.title|default('') }}

-
{{ element.contract|default('') }}
-
{{ element.localisation|default('') }}
- {{ element.url }} + {% if element.title|default('') is not empty %} +

{{ element.title }}

+ {% endif %} + {% if element.contract|default('') is not empty %} +
{{ element.contract }}
+ {% endif %} + {% if element.localisation|default('') is not empty %} +
{{ element.localisation }}
+ {% endif %} + {% if element.url|default('') is not empty %} + {{ element.url }} + {% endif %}
{% elseif element.display == constant('MonsieurBiz\\SyliusUiElementsPlugin\\Form\\Type\\UiElement\\JobOfferUiElementType::DISPLAY_COMPLETE') %}
-

{{ element.title|default('') }}

-
{{ element.contract|default('') }}
-
{{ element.localisation|default('') }}
-
- {{ element.content|default('')|raw }} -
+ {% if element.title|default('') is not empty %} +

{{ element.title }}

+ {% endif %} + {% if element.contract|default('') is not empty %} +
{{ element.contract }}
+ {% endif %} + {% if element.localisation|default('') is not empty %} +
{{ element.localisation }}
+ {% endif %} + + {% if element.content|default('') %} +
+ {{ element.content|raw }} +
+ {% endif %}
{% endif %}
diff --git a/src/Resources/views/Shop/UiElement/job_offer_ui_element.html.twig b/src/Resources/views/Shop/UiElement/job_offer_ui_element.html.twig index 0e1ca93..7fd237a 100644 --- a/src/Resources/views/Shop/UiElement/job_offer_ui_element.html.twig +++ b/src/Resources/views/Shop/UiElement/job_offer_ui_element.html.twig @@ -11,19 +11,34 @@ element fields: #}
{% if element.display == constant('MonsieurBiz\\SyliusUiElementsPlugin\\Form\\Type\\UiElement\\JobOfferUiElementType::DISPLAY_SYNTHESIS') %} - -

{{ element.title|default('') }}

-
{{ element.contract|default('') }}
-
{{ element.localisation|default('') }}
+
+ {% if element.title|default('') is not empty %} +

{{ element.title }}

+ {% endif %} + {% if element.contract|default('') is not empty %} +
{{ element.contract }}
+ {% endif %} + {% if element.localisation|default('') is not empty %} +
{{ element.localisation }}
+ {% endif %}
{% elseif element.display == constant('MonsieurBiz\\SyliusUiElementsPlugin\\Form\\Type\\UiElement\\JobOfferUiElementType::DISPLAY_COMPLETE') %}
-

{{ element.title|default('') }}

-
{{ element.contract|default('') }}
-
{{ element.localisation|default('') }}
-
- {{ element.content|default('')|raw }} -
+ {% if element.title|default('') is not empty %} +

{{ element.title }}

+ {% endif %} + {% if element.contract|default('') is not empty %} +
{{ element.contract }}
+ {% endif %} + {% if element.localisation|default('') is not empty %} +
{{ element.localisation }}
+ {% endif %} + + {% if element.content|default('') %} +
+ {{ element.content|raw }} +
+ {% endif %}
{% endif %}
From 70ae885789ad53129aa0ee9df095f55ea9f5ef12 Mon Sep 17 00:00:00 2001 From: Etienne Gutbub Date: Mon, 7 Oct 2024 17:41:02 +0200 Subject: [PATCH 4/5] feat(jobOffer): add blank wireframe --- src/Form/Type/UiElement/JobOfferUiElementType.php | 2 +- src/Resources/views/Wireframe/job-offer.svg.twig | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) create mode 100644 src/Resources/views/Wireframe/job-offer.svg.twig diff --git a/src/Form/Type/UiElement/JobOfferUiElementType.php b/src/Form/Type/UiElement/JobOfferUiElementType.php index b550262..f1e74d0 100644 --- a/src/Form/Type/UiElement/JobOfferUiElementType.php +++ b/src/Form/Type/UiElement/JobOfferUiElementType.php @@ -30,7 +30,7 @@ adminRender: '@MonsieurBizSyliusUiElementsPlugin/Admin/UiElement/job_offer_ui_element.html.twig', frontRender: '@MonsieurBizSyliusUiElementsPlugin/Shop/UiElement/job_offer_ui_element.html.twig', ), - wireframe: '', + wireframe: 'job-offer', )] final class JobOfferUiElementType extends AbstractType { diff --git a/src/Resources/views/Wireframe/job-offer.svg.twig b/src/Resources/views/Wireframe/job-offer.svg.twig new file mode 100644 index 0000000..5a5d10d --- /dev/null +++ b/src/Resources/views/Wireframe/job-offer.svg.twig @@ -0,0 +1,3 @@ + + + From 3793c27d39ba710154b38da2a3bc1fbadc12e36c Mon Sep 17 00:00:00 2001 From: Etienne Gutbub Date: Mon, 7 Oct 2024 17:54:29 +0200 Subject: [PATCH 5/5] refactor(jobOffer): refacto templates --- .../UiElement/job_offer_ui_element.html.twig | 36 +++++++++---------- .../UiElement/job_offer_ui_element.html.twig | 29 ++++++++------- 2 files changed, 34 insertions(+), 31 deletions(-) diff --git a/src/Resources/views/Admin/UiElement/job_offer_ui_element.html.twig b/src/Resources/views/Admin/UiElement/job_offer_ui_element.html.twig index cb59543..ea2b4a4 100644 --- a/src/Resources/views/Admin/UiElement/job_offer_ui_element.html.twig +++ b/src/Resources/views/Admin/UiElement/job_offer_ui_element.html.twig @@ -11,32 +11,32 @@ element fields: #}
{% if element.display == constant('MonsieurBiz\\SyliusUiElementsPlugin\\Form\\Type\\UiElement\\JobOfferUiElementType::DISPLAY_SYNTHESIS') %} - +
+ {% if element.contract|default('') is not empty %} +
{{ element.contract }}
+ {% endif %} + {% if element.localisation|default('') is not empty %} +
{{ element.localisation }}
+ {% endif %} +
+ {% elseif element.display == constant('MonsieurBiz\\SyliusUiElementsPlugin\\Form\\Type\\UiElement\\JobOfferUiElementType::DISPLAY_COMPLETE') %}
{% if element.title|default('') is not empty %}

{{ element.title }}

{% endif %} - {% if element.contract|default('') is not empty %} -
{{ element.contract }}
- {% endif %} - {% if element.localisation|default('') is not empty %} -
{{ element.localisation }}
- {% endif %} - +
+ {% if element.contract|default('') is not empty %} +
{{ element.contract }}
+ {% endif %} + {% if element.localisation|default('') is not empty %} +
{{ element.localisation }}
+ {% endif %} +
{% if element.content|default('') %}
{{ element.content|raw }} diff --git a/src/Resources/views/Shop/UiElement/job_offer_ui_element.html.twig b/src/Resources/views/Shop/UiElement/job_offer_ui_element.html.twig index 7fd237a..0082103 100644 --- a/src/Resources/views/Shop/UiElement/job_offer_ui_element.html.twig +++ b/src/Resources/views/Shop/UiElement/job_offer_ui_element.html.twig @@ -15,25 +15,28 @@ element fields: {% if element.title|default('') is not empty %}

{{ element.title }}

{% endif %} - {% if element.contract|default('') is not empty %} -
{{ element.contract }}
- {% endif %} - {% if element.localisation|default('') is not empty %} -
{{ element.localisation }}
- {% endif %} +
+ {% if element.contract|default('') is not empty %} +
{{ element.contract }}
+ {% endif %} + {% if element.localisation|default('') is not empty %} +
{{ element.localisation }}
+ {% endif %} +
{% elseif element.display == constant('MonsieurBiz\\SyliusUiElementsPlugin\\Form\\Type\\UiElement\\JobOfferUiElementType::DISPLAY_COMPLETE') %}
{% if element.title|default('') is not empty %}

{{ element.title }}

{% endif %} - {% if element.contract|default('') is not empty %} -
{{ element.contract }}
- {% endif %} - {% if element.localisation|default('') is not empty %} -
{{ element.localisation }}
- {% endif %} - +
+ {% if element.contract|default('') is not empty %} +
{{ element.contract }}
+ {% endif %} + {% if element.localisation|default('') is not empty %} +
{{ element.localisation }}
+ {% endif %} +
{% if element.content|default('') %}
{{ element.content|raw }}