WIP change animator field to animator intern and animator extern

This commit is contained in:
Julie Lenaerts 2025-07-01 14:29:01 +02:00
parent fab03d7c33
commit 495a43a6cd
4 changed files with 45 additions and 88 deletions

View File

@ -61,10 +61,16 @@ class Event implements HasCenterInterface, HasScopeInterface, TrackCreationInter
private ?User $moderator = null; private ?User $moderator = null;
/** /**
* @var Collection<int, Animator> * @var Collection<int, User>
*/ */
#[ORM\OneToMany(mappedBy: 'event', targetEntity: Animator::class)] #[ORM\OneToMany(mappedBy: 'event', targetEntity: User::class)]
private Collection $animators; private Collection $animatorsIntern;
/**
* @var Collection<int, ThirdParty>
*/
#[ORM\OneToMany(mappedBy: 'event', targetEntity: ThirdParty::class)]
private Collection $animatorsExtern;
#[Assert\NotBlank] #[Assert\NotBlank]
#[Serializer\Groups(['read'])] #[Serializer\Groups(['read'])]
@ -129,7 +135,8 @@ class Event implements HasCenterInterface, HasScopeInterface, TrackCreationInter
$this->comment = new CommentEmbeddable(); $this->comment = new CommentEmbeddable();
$this->themes = new ArrayCollection(); $this->themes = new ArrayCollection();
$this->budgetElements = new ArrayCollection(); $this->budgetElements = new ArrayCollection();
$this->animators = new ArrayCollection(); $this->animatorsIntern = new ArrayCollection();
$this->animatorsExtern = new ArrayCollection();
} }
public function addBudgetElement(EventBudgetElement $budgetElement) public function addBudgetElement(EventBudgetElement $budgetElement)
@ -187,21 +194,38 @@ class Event implements HasCenterInterface, HasScopeInterface, TrackCreationInter
$this->themes->removeElement($theme); $this->themes->removeElement($theme);
} }
public function getAnimators(): Collection public function getAnimatorsIntern(): Collection
{ {
return $this->animators; return $this->animatorsIntern;
} }
public function addAnimator(ThirdParty|User $a): self public function getAnimatorsExtern(): Collection
{ {
$this->animators->add($a); return $this->animatorsExtern;
}
public function addAnimatorIntern(User $ai): self
{
$this->animatorsIntern->add($ai);
return $this; return $this;
} }
public function removeAnimator(ThirdParty|User $a): void public function removeAnimatorIntern(User $ai): void
{ {
$this->animators->removeElement($a); $this->animatorsIntern->removeElement($ai);
}
public function addAnimatorExtern(User $ae): self
{
$this->animatorsExtern->add($ae);
return $this;
}
public function removeAnimatorExtern(User $ae): void
{
$this->animatorsExtern->removeElement($ae);
} }
public function getCenter(): Center public function getCenter(): Center

View File

@ -68,20 +68,15 @@ class EventType extends AbstractType
->add('moderator', PickUserDynamicType::class, [ ->add('moderator', PickUserDynamicType::class, [
'label' => 'Pick a moderator', 'label' => 'Pick a moderator',
]) ])
->add('animators', ChillCollectionType::class, [ ->add('animatorsIntern', PickUserDynamicType::class, [
'entry_type' => PickAnimatorType::class, 'multiple' => true,
'entry_options' => [ 'label' => 'Pick an internal animator',
'label' => false, 'required' => false,
], ])
'allow_add' => true, ->add('animatorsExtern', PickThirdpartyDynamicType::class, [
'allow_delete' => true, 'multiple' => true,
'by_reference' => false, 'label' => 'Pick an external animator',
'prototype' => true, 'required' => false,
'label' => 'Animators',
'help' => 'Add users or third parties who will animate this event',
'attr' => [
'data-collection' => 'true', // For JS handling
],
]) ])
->add('budgetElements', ChillCollectionType::class, [ ->add('budgetElements', ChillCollectionType::class, [
'entry_type' => AddEventBudgetElementType::class, 'entry_type' => AddEventBudgetElementType::class,

View File

@ -20,7 +20,8 @@
{{ form_row(form.type, { label: "Event type" }) }} {{ form_row(form.type, { label: "Event type" }) }}
{{ form_row(form.themes) }} {{ form_row(form.themes) }}
{{ form_row(form.moderator) }} {{ form_row(form.moderator) }}
{{ form_row(form.animators) }} {{ form_row(form.animatorsIntern) }}
{{ form_row(form.animatorsExtern) }}
{{ form_row(form.location) }} {{ form_row(form.location) }}
<div id="location"></div> <div id="location"></div>
{{ form_row(form.budgetElements) }} {{ form_row(form.budgetElements) }}

View File

@ -1,63 +0,0 @@
<?php
declare(strict_types=1);
namespace Chill\Migrations\Event;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;
final class Version20250619102259 extends AbstractMigration
{
public function getDescription(): string
{
return 'Add animator entity to event module';
}
public function up(Schema $schema): void
{
$this->addSql(<<<'SQL'
CREATE SEQUENCE chill_event_animator_id_seq INCREMENT BY 1 MINVALUE 1 START 1
SQL);
$this->addSql(<<<'SQL'
CREATE TABLE chill_event_animator (id INT NOT NULL, thirdparty_id INT DEFAULT NULL, user_id INT DEFAULT NULL, event_id INT NOT NULL, PRIMARY KEY(id))
SQL);
$this->addSql(<<<'SQL'
CREATE INDEX IDX_A7FA35FEC7D3A8E6 ON chill_event_animator (thirdparty_id)
SQL);
$this->addSql(<<<'SQL'
CREATE INDEX IDX_A7FA35FEA76ED395 ON chill_event_animator (user_id)
SQL);
$this->addSql(<<<'SQL'
CREATE INDEX IDX_A7FA35FE71F7E88B ON chill_event_animator (event_id)
SQL);
$this->addSql(<<<'SQL'
ALTER TABLE chill_event_animator ADD CONSTRAINT FK_A7FA35FEC7D3A8E6 FOREIGN KEY (thirdparty_id) REFERENCES chill_3party.third_party (id) NOT DEFERRABLE INITIALLY IMMEDIATE
SQL);
$this->addSql(<<<'SQL'
ALTER TABLE chill_event_animator ADD CONSTRAINT FK_A7FA35FEA76ED395 FOREIGN KEY (user_id) REFERENCES users (id) NOT DEFERRABLE INITIALLY IMMEDIATE
SQL);
$this->addSql(<<<'SQL'
ALTER TABLE chill_event_animator ADD CONSTRAINT FK_A7FA35FE71F7E88B FOREIGN KEY (event_id) REFERENCES chill_event_event (id) NOT DEFERRABLE INITIALLY IMMEDIATE
SQL);
}
public function down(Schema $schema): void
{
$this->addSql(<<<'SQL'
DROP SEQUENCE chill_event_animator_id_seq CASCADE
SQL);
$this->addSql(<<<'SQL'
ALTER TABLE chill_event_animator DROP CONSTRAINT FK_A7FA35FEC7D3A8E6
SQL);
$this->addSql(<<<'SQL'
ALTER TABLE chill_event_animator DROP CONSTRAINT FK_A7FA35FEA76ED395
SQL);
$this->addSql(<<<'SQL'
ALTER TABLE chill_event_animator DROP CONSTRAINT FK_A7FA35FE71F7E88B
SQL);
$this->addSql(<<<'SQL'
DROP TABLE chill_event_animator
SQL);
}
}