diff --git a/src/Bundle/ChillEventBundle/Entity/Event.php b/src/Bundle/ChillEventBundle/Entity/Event.php index 772310927..b66581e02 100644 --- a/src/Bundle/ChillEventBundle/Entity/Event.php +++ b/src/Bundle/ChillEventBundle/Entity/Event.php @@ -61,10 +61,16 @@ class Event implements HasCenterInterface, HasScopeInterface, TrackCreationInter private ?User $moderator = null; /** - * @var Collection + * @var Collection */ - #[ORM\OneToMany(mappedBy: 'event', targetEntity: Animator::class)] - private Collection $animators; + #[ORM\OneToMany(mappedBy: 'event', targetEntity: User::class)] + private Collection $animatorsIntern; + + /** + * @var Collection + */ + #[ORM\OneToMany(mappedBy: 'event', targetEntity: ThirdParty::class)] + private Collection $animatorsExtern; #[Assert\NotBlank] #[Serializer\Groups(['read'])] @@ -129,7 +135,8 @@ class Event implements HasCenterInterface, HasScopeInterface, TrackCreationInter $this->comment = new CommentEmbeddable(); $this->themes = new ArrayCollection(); $this->budgetElements = new ArrayCollection(); - $this->animators = new ArrayCollection(); + $this->animatorsIntern = new ArrayCollection(); + $this->animatorsExtern = new ArrayCollection(); } public function addBudgetElement(EventBudgetElement $budgetElement) @@ -187,21 +194,38 @@ class Event implements HasCenterInterface, HasScopeInterface, TrackCreationInter $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; } - 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 diff --git a/src/Bundle/ChillEventBundle/Form/EventType.php b/src/Bundle/ChillEventBundle/Form/EventType.php index 2e1e95946..42eec286f 100644 --- a/src/Bundle/ChillEventBundle/Form/EventType.php +++ b/src/Bundle/ChillEventBundle/Form/EventType.php @@ -68,20 +68,15 @@ class EventType extends AbstractType ->add('moderator', PickUserDynamicType::class, [ 'label' => 'Pick a moderator', ]) - ->add('animators', ChillCollectionType::class, [ - 'entry_type' => PickAnimatorType::class, - 'entry_options' => [ - 'label' => false, - ], - 'allow_add' => true, - 'allow_delete' => true, - 'by_reference' => false, - 'prototype' => true, - 'label' => 'Animators', - 'help' => 'Add users or third parties who will animate this event', - 'attr' => [ - 'data-collection' => 'true', // For JS handling - ], + ->add('animatorsIntern', PickUserDynamicType::class, [ + 'multiple' => true, + 'label' => 'Pick an internal animator', + 'required' => false, + ]) + ->add('animatorsExtern', PickThirdpartyDynamicType::class, [ + 'multiple' => true, + 'label' => 'Pick an external animator', + 'required' => false, ]) ->add('budgetElements', ChillCollectionType::class, [ 'entry_type' => AddEventBudgetElementType::class, diff --git a/src/Bundle/ChillEventBundle/Resources/views/Event/new.html.twig b/src/Bundle/ChillEventBundle/Resources/views/Event/new.html.twig index 20bc9254a..2f5a82c8d 100644 --- a/src/Bundle/ChillEventBundle/Resources/views/Event/new.html.twig +++ b/src/Bundle/ChillEventBundle/Resources/views/Event/new.html.twig @@ -20,7 +20,8 @@ {{ form_row(form.type, { label: "Event type" }) }} {{ form_row(form.themes) }} {{ form_row(form.moderator) }} - {{ form_row(form.animators) }} + {{ form_row(form.animatorsIntern) }} + {{ form_row(form.animatorsExtern) }} {{ form_row(form.location) }}
{{ form_row(form.budgetElements) }} diff --git a/src/Bundle/ChillEventBundle/migrations/Version20250619102259.php b/src/Bundle/ChillEventBundle/migrations/Version20250619102259.php deleted file mode 100644 index a9eb88caf..000000000 --- a/src/Bundle/ChillEventBundle/migrations/Version20250619102259.php +++ /dev/null @@ -1,63 +0,0 @@ -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); - } -}