-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3 from monsieurbiz/feature/figures-lame
feat(ui-element): Add FiguresUiElement
- Loading branch information
Showing
6 changed files
with
149 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of Monsieur Biz's SyliusUiElementsPlugin for Sylius. | ||
* (c) Monsieur Biz <[email protected]> | ||
* 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; | ||
|
||
use Symfony\Component\Form\AbstractType; | ||
use Symfony\Component\Form\Extension\Core\Type\TextType; | ||
use Symfony\Component\Form\FormBuilderInterface; | ||
use Symfony\Component\Validator\Constraints as Assert; | ||
|
||
class FigureType extends AbstractType | ||
{ | ||
/** | ||
* @SuppressWarnings(PHPMD.UnusedFormalParameter) | ||
*/ | ||
public function buildForm(FormBuilderInterface $builder, array $options): void | ||
{ | ||
$builder | ||
->add('figure', TextType::class, [ | ||
'required' => true, | ||
'label' => 'monsieurbiz_ui_elements.ui_element.figures_ui_element.fields.figure', | ||
'constraints' => [ | ||
new Assert\NotBlank(), | ||
new Assert\Length(['max' => 255]), | ||
], | ||
]) | ||
->add('description', TextType::class, [ | ||
'required' => false, | ||
'label' => 'monsieurbiz_ui_elements.common.fields.description', | ||
]) | ||
; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of Monsieur Biz's SyliusUiElementsPlugin for Sylius. | ||
* (c) Monsieur Biz <[email protected]> | ||
* 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\SyliusUiElementsPlugin\Form\Type\FigureType; | ||
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', | ||
templates: new TemplatesUiElement( | ||
adminRender: '@MonsieurBizSyliusUiElementsPlugin/Admin/UiElement/figures_ui_element.html.twig', | ||
frontRender: '@MonsieurBizSyliusUiElementsPlugin/Front/UiElement/figures_ui_element.html.twig', | ||
), | ||
)] | ||
class FiguresUiElementType 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, | ||
'allow_add' => true, | ||
'allow_delete' => true, | ||
'constraints' => [new Assert\Valid()], | ||
'attr' => [ | ||
'class' => 'ui segment secondary', | ||
], | ||
]); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19
src/Resources/views/Admin/UiElement/figures_ui_element.html.twig
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
{# | ||
UI Element template | ||
type: figures_ui_element | ||
element fields: | ||
- figures | ||
- figure | ||
- description | ||
#} | ||
|
||
<div class="ui grid segment"> | ||
{% for keyFigure in element.figures|default([]) %} | ||
<div class="five wide column"> | ||
<strong>{{ keyFigure.figure }}</strong> | ||
{% if keyFigure.description|default('') is not empty %} | ||
<p>{{ keyFigure.description }}</p> | ||
{% endif %} | ||
</div> | ||
{% endfor %} | ||
</div> |
19 changes: 19 additions & 0 deletions
19
src/Resources/views/Shop/UiElement/figures_ui_element.html.twig
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
{# | ||
UI Element template | ||
type: figures_ui_element | ||
element fields: | ||
- figures | ||
- figure | ||
- description | ||
#} | ||
|
||
<div class="ui grid segment"> | ||
{% for keyFigure in element.figures|default([]) %} | ||
<div class="five wide column"> | ||
<strong>{{ keyFigure.figure }}</strong> | ||
{% if keyFigure.description|default('') is not empty %} | ||
<p>{{ keyFigure.description }}</p> | ||
{% endif %} | ||
</div> | ||
{% endfor %} | ||
</div> |