diff --git a/src/Bundle/ChillMainBundle/Form/Type/DataTransformer/EntityToJsonTransformer.php b/src/Bundle/ChillMainBundle/Form/Type/DataTransformer/EntityToJsonTransformer.php index c6c205a47..95c447119 100644 --- a/src/Bundle/ChillMainBundle/Form/Type/DataTransformer/EntityToJsonTransformer.php +++ b/src/Bundle/ChillMainBundle/Form/Type/DataTransformer/EntityToJsonTransformer.php @@ -45,8 +45,6 @@ class EntityToJsonTransformer implements DataTransformerInterface { $denormalized = json_decode($value, true); - dump($value); - if ($this->multiple) { if (null === $denormalized) { return []; diff --git a/src/Bundle/ChillMainBundle/Resources/public/module/pick-entity/index.js b/src/Bundle/ChillMainBundle/Resources/public/module/pick-entity/index.js index c3786f137..1fd6b34f7 100644 --- a/src/Bundle/ChillMainBundle/Resources/public/module/pick-entity/index.js +++ b/src/Bundle/ChillMainBundle/Resources/public/module/pick-entity/index.js @@ -7,7 +7,6 @@ const i18n = _createI18n(appMessages); let appsOnPage = new Map(); - function loadDynamicPicker(element) { let apps = element.querySelectorAll('[data-module="pick-dynamic"]'); @@ -75,23 +74,23 @@ function loadDynamicPicker(element) { } -// document.addEventListener('show-hide-show', function(e) { -// console.log('creation event caught') -// loadDynamicPicker(e.detail.container) -// }) +document.addEventListener('show-hide-show', function(e) { + console.log('creation event caught') + loadDynamicPicker(e.detail.container) +}) -// document.addEventListener('show-hide-hide', function(e) { -// console.log('hiding event caught') -// e.detail.container.querySelectorAll('[data-module="pick-dynamic"]').forEach((el) => { -// let uniqId = el.dataset.uniqid; -// console.log(uniqId); -// if (appsOnPage.has(uniqId)) { -// appsOnPage.get(uniqId).unmount(); -// console.log('App has been unmounted') -// appsOnPage.delete(uniqId); -// } -// }) -// }) +document.addEventListener('show-hide-hide', function(e) { + console.log('hiding event caught') + e.detail.container.querySelectorAll('[data-module="pick-dynamic"]').forEach((el) => { + let uniqId = el.dataset.uniqid; + console.log(uniqId); + if (appsOnPage.has(uniqId)) { + appsOnPage.get(uniqId).unmount(); + console.log('App has been unmounted') + appsOnPage.delete(uniqId); + } + }) +}) document.addEventListener('DOMContentLoaded', function(e) { console.log('loaded event', e) diff --git a/src/Bundle/ChillPersonBundle/Controller/PersonResourceController.php b/src/Bundle/ChillPersonBundle/Controller/PersonResourceController.php index 6b9b5dc6a..210b507e5 100644 --- a/src/Bundle/ChillPersonBundle/Controller/PersonResourceController.php +++ b/src/Bundle/ChillPersonBundle/Controller/PersonResourceController.php @@ -114,8 +114,6 @@ final class PersonResourceController extends AbstractController ]); } - dump($resource); - return $this->render( 'ChillPersonBundle:PersonResource:edit.html.twig', [ @@ -139,7 +137,7 @@ final class PersonResourceController extends AbstractController $form->handleRequest($request); - if ($request->getMethod() === Request::METHOD_POST && $form->isValid()) { + if ($form->isSubmitted() && $form->isValid()) { $this->denyAccessUnlessGranted(PersonVoter::CREATE, $personOwner); $personResource = new PersonResource(); diff --git a/src/Bundle/ChillPersonBundle/Entity/Person/PersonResource.php b/src/Bundle/ChillPersonBundle/Entity/Person/PersonResource.php index 4e1718a64..2e8441511 100644 --- a/src/Bundle/ChillPersonBundle/Entity/Person/PersonResource.php +++ b/src/Bundle/ChillPersonBundle/Entity/Person/PersonResource.php @@ -55,7 +55,7 @@ class PersonResource implements TrackCreationInterface, TrackUpdateInterface * @ORM\Column(type="text", nullable=true) * @Groups({"read"}) */ - private $freeText; + private ?string $freeText = null; /** * @ORM\Id @@ -204,6 +204,10 @@ class PersonResource implements TrackCreationInterface, TrackUpdateInterface $this->setThirdParty(null); } + if ('' === $freeText) { + $this->freeText = null; + } + return $this; } @@ -266,9 +270,8 @@ class PersonResource implements TrackCreationInterface, TrackUpdateInterface */ public function validate(ExecutionContextInterface $context, $payload) { - if (null === $this->person && null === $this->thirdParty && null === $this->freeText) { + if (null === $this->person && null === $this->thirdParty && (null === $this->freeText || '' === $this->freeText)) { $context->buildViolation('You must associate at least one entity') - ->atPath('person') ->addViolation(); } } diff --git a/src/Bundle/ChillPersonBundle/Resources/views/PersonResource/create.html.twig b/src/Bundle/ChillPersonBundle/Resources/views/PersonResource/create.html.twig index 46ba4ebef..8dde19750 100644 --- a/src/Bundle/ChillPersonBundle/Resources/views/PersonResource/create.html.twig +++ b/src/Bundle/ChillPersonBundle/Resources/views/PersonResource/create.html.twig @@ -1,5 +1,5 @@