Skip to content

Commit

Permalink
Change figures element to key facts
Browse files Browse the repository at this point in the history
  • Loading branch information
maximehuran committed Sep 4, 2024
1 parent 13c4edc commit cc0af2e
Show file tree
Hide file tree
Showing 9 changed files with 52 additions and 54 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,17 @@
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\Validator\Constraints as Assert;

class FigureType extends AbstractType
class KeyFactType extends AbstractType
{
/**
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
public function buildForm(FormBuilderInterface $builder, array $options): void
{
$builder
->add('figure', TextType::class, [
->add('title', TextType::class, [
'required' => true,
'label' => 'monsieurbiz_ui_elements.ui_element.figures_ui_element.fields.figure',
'label' => 'monsieurbiz_ui_elements.common.fields.title',
'constraints' => [
new Assert\NotBlank(),
new Assert\Length(['max' => 255]),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,37 +13,37 @@

use MonsieurBiz\SyliusRichEditorPlugin\Attribute\AsUiElement;
use MonsieurBiz\SyliusRichEditorPlugin\Attribute\TemplatesUiElement;
use MonsieurBiz\SyliusUiElementsPlugin\Form\Type\FigureType;
use MonsieurBiz\SyliusUiElementsPlugin\Form\Type\KeyFactType;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\CollectionType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\Validator\Constraints as Assert;

#[AsUiElement(
code: 'monsieurbiz_ui_elements.figures_ui_element',
icon: 'percent',
title: 'monsieurbiz_ui_elements.ui_element.figures_ui_element.title',
description: 'monsieurbiz_ui_elements.ui_element.figures_ui_element.description',
code: 'monsieurbiz_ui_elements.key_facts_ui_element',
icon: 'key',
title: 'monsieurbiz_ui_elements.ui_element.key_facts_ui_element.title',
description: 'monsieurbiz_ui_elements.ui_element.key_facts_ui_element.description',
templates: new TemplatesUiElement(
adminRender: '@MonsieurBizSyliusUiElementsPlugin/Admin/UiElement/figures_ui_element.html.twig',
frontRender: '@MonsieurBizSyliusUiElementsPlugin/Shop/UiElement/figures_ui_element.html.twig',
adminRender: '@MonsieurBizSyliusUiElementsPlugin/Admin/UiElement/key_facts_ui_element.html.twig',
frontRender: '@MonsieurBizSyliusUiElementsPlugin/Shop/UiElement/key_facts_ui_element.html.twig',
),
tags: [],
wireframe: 'figures',
wireframe: 'key-facts',
)]
class FiguresUiElementType extends AbstractType
class KeyFactsUiElementType extends AbstractType
{
/**
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
public function buildForm(FormBuilderInterface $builder, array $options): void
{
$builder->add('figures', CollectionType::class, [
'label' => 'monsieurbiz_ui_elements.ui_element.figures_ui_element.fields.figures',
'button_add_label' => 'monsieurbiz_ui_elements.ui_element.figures_ui_element.buttons.add_element',
'button_delete_label' => 'monsieurbiz_ui_elements.ui_element.figures_ui_element.buttons.delete_element',
'entry_type' => FigureType::class,
'prototype_name' => '__figure__',
$builder->add('key_facts', CollectionType::class, [
'label' => 'monsieurbiz_ui_elements.ui_element.key_facts_ui_element.fields.key_facts',
'button_add_label' => 'monsieurbiz_ui_elements.ui_element.key_facts_ui_element.buttons.add_element',
'button_delete_label' => 'monsieurbiz_ui_elements.ui_element.key_facts_ui_element.buttons.delete_element',
'entry_type' => KeyFactType::class,
'prototype_name' => '__key_fact__',
'allow_add' => true,
'allow_delete' => true,
'constraints' => [new Assert\Valid()],
Expand Down
13 changes: 6 additions & 7 deletions src/Resources/translations/messages.en.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,14 @@ monsieurbiz_ui_elements:
choices:
internal: "Same window"
external: "New window"
figures_ui_element:
title: "Key Figures Element"
description: "Collection of key figures"
key_facts_ui_element:
title: "Key Facts Element"
description: "Collection of key facts"
fields:
figures: "Key figures"
figure: "Key figure"
key_facts: "Key facts"
buttons:
add_element: "Add key figure"
delete_element: "Delete key figure"
add_element: "Add key fact"
delete_element: "Delete key fact"
advanced_quote_ui_element:
title: "Advanced Quote Element"
description: "Quote with title and button with a link"
Expand Down
9 changes: 4 additions & 5 deletions src/Resources/translations/messages.fr.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,11 @@ monsieurbiz_ui_elements:
choices:
internal: "Même fenêtre"
external: "Nouvelle fenêtre"
figures_ui_element:
title: "Lame Chiffres clés"
description: "Ensemble de chiffres clés"
key_facts_ui_element:
title: "Lame éléments clés"
description: "Ensemble d'élement clés à mettre en avant"
fields:
figures: "Chiffres clés"
figure: "Chiffre clé"
key_facts: "Éléments clés"
buttons:
add_element: "Ajouter un chiffre clé"
delete_element: "Supprimer un chiffre clé"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{#
UI Element template
type: figures_ui_element
type: badges_ui_element
element fields:
- badges
- title
Expand Down
Original file line number Diff line number Diff line change
@@ -1,33 +1,33 @@
{#
UI Element template
type: figures_ui_element
type: key_facts_ui_element
element fields:
- figures
- figure
- key_facts
- title
- description
#}

{% set columns = 'five' %}
{% if element.figures|length == 4 %}
{% if element.key_facts|length == 4 %}
{% set columns = 'four' %}
{% endif %}
{% if element.figures|length == 3 %}
{% if element.key_facts|length == 3 %}
{% set columns = 'three' %}
{% endif %}
{% if element.figures|length == 2 %}
{% if element.key_facts|length == 2 %}
{% set columns = 'two' %}
{% endif %}
{% if element.figures|length == 1 %}
{% if element.key_facts|length == 1 %}
{% set columns = 'one' %}
{% endif %}

<div class="ui grid stackable {{ columns }} columns" style="padding: 0 3vw;">
{% for keyFigure in element.figures|default([]) %}
{% for keyFact in element.key_facts|default([]) %}
<div class="column">
<div class="ui segment">
<strong>{{ keyFigure.figure }}</strong>
{% if keyFigure.description|default('') is not empty %}
<p>{{ keyFigure.description }}</p>
<strong>{{ keyFact.title }}</strong>
{% if keyFact.description|default('') is not empty %}
<p>{{ keyFact.description }}</p>
{% endif %}
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{#
UI Element template
type: figures_ui_element
type: badges_ui_element
element fields:
- badges
- title
Expand Down
Original file line number Diff line number Diff line change
@@ -1,33 +1,33 @@
{#
UI Element template
type: figures_ui_element
type: key_facts_ui_element
element fields:
- figures
- figure
- key_facts
- title
- description
#}

{% set columns = 'five' %}
{% if element.figures|length == 4 %}
{% if element.key_facts|length == 4 %}
{% set columns = 'four' %}
{% endif %}
{% if element.figures|length == 3 %}
{% if element.key_facts|length == 3 %}
{% set columns = 'three' %}
{% endif %}
{% if element.figures|length == 2 %}
{% if element.key_facts|length == 2 %}
{% set columns = 'two' %}
{% endif %}
{% if element.figures|length == 1 %}
{% if element.key_facts|length == 1 %}
{% set columns = 'one' %}
{% endif %}

<div class="ui grid stackable {{ columns }} columns" style="padding: 0 3vw;">
{% for keyFigure in element.figures|default([]) %}
{% for keyFact in element.key_facts|default([]) %}
<div class="column">
<div class="ui segment">
<strong>{{ keyFigure.figure }}</strong>
{% if keyFigure.description|default('') is not empty %}
<p>{{ keyFigure.description }}</p>
<strong>{{ keyFact.title }}</strong>
{% if keyFact.description|default('') is not empty %}
<p>{{ keyFact.description }}</p>
{% endif %}
</div>
</div>
Expand Down

0 comments on commit cc0af2e

Please sign in to comment.