Fixes
All checks were successful
Gitea Actions / Run-Tests-On-Arm64 (push) Successful in 16m7s
Gitea Actions / Run-Tests-On-Amd64 (push) Successful in 30m11s

This commit is contained in:
Thomas 2025-03-14 20:56:58 +01:00
parent 82847ddebf
commit f168c0fe75
6 changed files with 68 additions and 5 deletions

View File

@ -1,6 +1,7 @@
<?php <?php
#[Document]
class MediaItem class MediaItem
{ {
} }

View File

@ -2,6 +2,11 @@
namespace PSC\Shop\MediaBundle\Form; namespace PSC\Shop\MediaBundle\Form;
use PSC\Shop\MediaBundle\Model\MediaItem;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
class MediaForm extends AbstractType class MediaForm extends AbstractType
{ {
public function buildForm(FormBuilderInterface $builder, array $options): void public function buildForm(FormBuilderInterface $builder, array $options): void

View File

@ -0,0 +1,10 @@
<?php
namespace PSC\Shop\MediaBundle\Model;
class MediaItem
{
public string $name;
public string $description;
}

View File

@ -13,6 +13,7 @@
namespace PSC\Shop\NewsBundle\Entity; namespace PSC\Shop\NewsBundle\Entity;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\ORM\Mapping as ORM; use Doctrine\ORM\Mapping as ORM;
use Ramsey\Uuid\Uuid; use Ramsey\Uuid\Uuid;
@ -86,6 +87,7 @@ class News
#[ORM\Column(name: 'to_date', type: 'datetime')] #[ORM\Column(name: 'to_date', type: 'datetime')]
protected ?\DateTime $toDate; protected ?\DateTime $toDate;
public $media = [];
/** /**
* enable * enable
* *
@ -93,9 +95,11 @@ class News
*/ */
#[ORM\Column(name: 'active', type: 'boolean')] #[ORM\Column(name: 'active', type: 'boolean')]
protected $enable; protected $enable;
/**
* @return int public function __construct()
*/ {
$this->media = new ArrayCollection();
}
public function getUid() public function getUid()
{ {
return $this->uid; return $this->uid;

View File

@ -14,6 +14,7 @@
namespace PSC\Shop\NewsBundle\Form\Backend; namespace PSC\Shop\NewsBundle\Form\Backend;
use PSC\Libraries\AceEditorBundle\Form\Extension\CKEditor5Type; use PSC\Libraries\AceEditorBundle\Form\Extension\CKEditor5Type;
use PSC\Shop\MediaBundle\Form\MediaForm;
use PSC\System\PluginBundle\Form\Chain\Field; use PSC\System\PluginBundle\Form\Chain\Field;
use Symfony\Component\Form\AbstractType; use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\CheckboxType; use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
@ -27,6 +28,7 @@ use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\Form\FormEvent; use Symfony\Component\Form\FormEvent;
use Symfony\Component\Form\FormEvents; use Symfony\Component\Form\FormEvents;
use Symfony\Component\OptionsResolver\OptionsResolver; use Symfony\Component\OptionsResolver\OptionsResolver;
use Symfony\UX\LiveComponent\Form\Type\LiveCollectionType;
class NewsType extends AbstractType class NewsType extends AbstractType
{ {
@ -55,8 +57,8 @@ class NewsType extends AbstractType
'Englisch' => 'en_EN' 'Englisch' => 'en_EN'
], ],
'required' => true]) 'required' => true])
->add('todoItems', LiveCollectionType::class, [ ->add('media', LiveCollectionType::class, [
'entry_type' => MediaItemForm::class, 'entry_type' => MediaForm::class,
'entry_options' => ['label' => 'media'], 'entry_options' => ['label' => 'media'],
'label' => false, 'label' => false,
'allow_add' => true, 'allow_add' => true,

View File

@ -37,6 +37,12 @@
<path d="M4.271 18.3457C4.271 18.3457 6.50002 15.5 12 15.5C17.5 15.5 19.7291 18.3457 19.7291 18.3457" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round"></path> <path d="M4.271 18.3457C4.271 18.3457 6.50002 15.5 12 15.5C17.5 15.5 19.7291 18.3457 19.7291 18.3457" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round"></path>
<path d="M12 12C13.6569 12 15 10.6569 15 9C15 7.34315 13.6569 6 12 6C10.3431 6 9 7.34315 9 9C9 10.6569 10.3431 12 12 12Z" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round"></path> <path d="M12 12C13.6569 12 15 10.6569 15 9C15 7.34315 13.6569 6 12 6C10.3431 6 9 7.34315 9 9C9 10.6569 10.3431 12 12 12Z" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round"></path>
</svg> {{ 'Text'|trans }}</a> </svg> {{ 'Text'|trans }}</a>
<a href="#" class="tab-link flex items-center text-sm px-4 py-2 text-gray-700 relative" data-dui-tab-target="media">
<svg width="1.5em" height="1.5em" stroke-width="1.5" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg" color="currentColor" class="button-icon">
<path d="M12 2C6.47715 2 2 6.47715 2 12C2 17.5228 6.47715 22 12 22C17.5228 22 22 17.5228 22 12C22 6.47715 17.5228 2 12 2Z" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round"></path>
<path d="M4.271 18.3457C4.271 18.3457 6.50002 15.5 12 15.5C17.5 15.5 19.7291 18.3457 19.7291 18.3457" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round"></path>
<path d="M12 12C13.6569 12 15 10.6569 15 9C15 7.34315 13.6569 6 12 6C10.3431 6 9 7.34315 9 9C9 10.6569 10.3431 12 12 12Z" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round"></path>
</svg> {{ 'Media'|trans }}</a>
{% for customGroup in customGroups %} {% for customGroup in customGroups %}
<a href="#" class="tab-link flex items-center text-sm px-4 py-2 text-gray-700 relative" data-dui-tab-target="{{ customGroup.id }}"> <a href="#" class="tab-link flex items-center text-sm px-4 py-2 text-gray-700 relative" data-dui-tab-target="{{ customGroup.id }}">
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="button-icon"> <svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="button-icon">
@ -71,6 +77,14 @@
{{ form_row(form.language)}} {{ form_row(form.language)}}
</div> </div>
</div> </div>
<div class="flex flex-wrap">
<div class="w-full md:w-5/12 px-4">
{{ form_row(form.fromDate)}}
</div>
<div class="w-full md:w-5/12 px-4">
{{ form_row(form.toDate)}}
</div>
</div>
<div class="w-full px-4"> <div class="w-full px-4">
{{ form_row(form.introduction)}} {{ form_row(form.introduction)}}
</div> </div>
@ -78,6 +92,33 @@
<div id="text" class="tab-content w-full text-stone-500 text-sm hidden p-4"> <div id="text" class="tab-content w-full text-stone-500 text-sm hidden p-4">
{{ form_widget(form.text) }} {{ form_widget(form.text) }}
</div> </div>
<div id="media" class="tab-content w-full text-stone-500 text-sm hidden p-4">
<twig:MediaForm :form="form" :media="news" />
<table class="table table-borderless form-no-mb">
<thead>
<tr>
<td>Name</td>
<td>Description</td>
</tr>
</thead>
<tbody>
{% for media_form in form.media %}
<tr>
<td>
{{ form_row(media_form.name) }}
</td>
<td>
{{ form_row(media_form.description) }}
</td>
<td>
{{ form_row(media_form.vars.button_delete, {label: 'X', attr: {class: 'btn btn-outline-danger'}}) }}
</td>
</tr>
{% endfor %}
</tbody>
</table>
{{ form_widget(form.media.vars.button_add, {label: '+ Add Media', attr: {class: 'btn btn-outline-primary'}}) }}
</div>
{% for customGroup in customGroups %} {% for customGroup in customGroups %}
<div class="tab-pane" id="{{ customGroup.id }}" role="tabpanel"> <div class="tab-pane" id="{{ customGroup.id }}" role="tabpanel">
{% for customField in customFields %} {% for customField in customFields %}