diff --git a/CHANGELOG.md b/CHANGELOG.md index 3f61f05de..f6b15672e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,15 @@ and this project adheres to ## Unreleased + +## Test releases + +### 2022-05-30 + +* fix creating a new AccompanyingPeriodWorkEvaluationDocument when replacing the document (the workflow was lost) + +### 2022-05-27 + * [storedobject] add title field on StoredObject entity + use it in activity documents (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/604) * [main] add a "read more..." on comment embeddable when overflown (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/604) * [person] add closing motive to closed acc course (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/603) @@ -28,8 +37,6 @@ and this project adheres to * [address] can add extra address info even if noAddress (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/576) -## Test releases - ### 2022-05-06 * [person] add civility when creating a person (with the on-the-fly component or in the php form) (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/557) diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourseWorkEdit/store.js b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourseWorkEdit/store.js index caec4fd05..4b997d002 100644 --- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourseWorkEdit/store.js +++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourseWorkEdit/store.js @@ -232,6 +232,14 @@ const store = createStore({ return; } + let doc = evaluation.documents.find(d => d.key === payload.oldDocument.key); + + if (typeof doc === 'undefined') { + console.error('doc not found'); + } + + doc.storedObject = payload.document.storedObject; + return; let newDocument = Object.assign( payload.document, { key: evaluation.documents.length + 1, diff --git a/src/Bundle/ChillPersonBundle/Serializer/Normalizer/AccompanyingPeriodOriginNormalizer.php b/src/Bundle/ChillPersonBundle/Serializer/Normalizer/AccompanyingPeriodOriginNormalizer.php index 6cc3d446b..ca7589e79 100644 --- a/src/Bundle/ChillPersonBundle/Serializer/Normalizer/AccompanyingPeriodOriginNormalizer.php +++ b/src/Bundle/ChillPersonBundle/Serializer/Normalizer/AccompanyingPeriodOriginNormalizer.php @@ -35,6 +35,6 @@ final class AccompanyingPeriodOriginNormalizer implements NormalizerInterface public function supportsNormalization($data, $format = null): bool { - return $data instanceof Origin && $format === 'json'; + return $data instanceof Origin && 'json' === $format; } } diff --git a/src/Bundle/ChillPersonBundle/Serializer/Normalizer/AccompanyingPeriodWorkEvaluationDenormalizer.php b/src/Bundle/ChillPersonBundle/Serializer/Normalizer/AccompanyingPeriodWorkEvaluationDenormalizer.php index 4680d9fa7..77e289e6a 100644 --- a/src/Bundle/ChillPersonBundle/Serializer/Normalizer/AccompanyingPeriodWorkEvaluationDenormalizer.php +++ b/src/Bundle/ChillPersonBundle/Serializer/Normalizer/AccompanyingPeriodWorkEvaluationDenormalizer.php @@ -13,8 +13,6 @@ namespace Chill\PersonBundle\Serializer\Normalizer; use Chill\PersonBundle\Entity\AccompanyingPeriod\AccompanyingPeriodWorkEvaluation; use Chill\PersonBundle\Entity\AccompanyingPeriod\AccompanyingPeriodWorkEvaluationDocument; -use Chill\PersonBundle\Repository\AccompanyingPeriod\AccompanyingPeriodWorkRepository; -use Doctrine\ORM\EntityManagerInterface; use Symfony\Component\Serializer\Normalizer\AbstractNormalizer; use Symfony\Component\Serializer\Normalizer\ContextAwareDenormalizerInterface; use Symfony\Component\Serializer\Normalizer\DenormalizerAwareInterface; @@ -35,18 +33,6 @@ class AccompanyingPeriodWorkEvaluationDenormalizer implements ContextAwareDenorm use ObjectToPopulateTrait; - private EntityManagerInterface $em; - - private AccompanyingPeriodWorkRepository $workRepository; - - public function __construct( - AccompanyingPeriodWorkRepository $workRepository, - EntityManagerInterface $em - ) { - $this->workRepository = $workRepository; - $this->em = $em; - } - public function denormalize($data, $type, $format = null, array $context = []) { $evaluation = $this->denormalizer->denormalize($data, $type, $format, array_merge( diff --git a/src/Bundle/ChillPersonBundle/Tests/Serializer/Normalizer/AccompanyingPeriodWorkEvaluationDenormalizerTest.php b/src/Bundle/ChillPersonBundle/Tests/Serializer/Normalizer/AccompanyingPeriodWorkEvaluationDenormalizerTest.php new file mode 100644 index 000000000..f46e76932 --- /dev/null +++ b/src/Bundle/ChillPersonBundle/Tests/Serializer/Normalizer/AccompanyingPeriodWorkEvaluationDenormalizerTest.php @@ -0,0 +1,140 @@ +markTestIncomplete('not yet finished'); + $evaluation = new AccompanyingPeriodWorkEvaluation(); + $doc = new AccompanyingPeriodWorkEvaluationDocument(); + $doc->setStoredObject($storedObject = new StoredObject()); + $reflectionProperty = new ReflectionProperty(AccompanyingPeriodWorkEvaluationDocument::class, 'id'); + $reflectionProperty->setAccessible(true); + $reflectionProperty->setValue($doc, 1); + + $evaluation->addDocument($doc); + + $data = json_decode(self::ENCODED_DATA); + $context = + [AbstractNormalizer::OBJECT_TO_POPULATE => $evaluation, 'groups' => ['write']]; + + $denormalizer = new AccompanyingPeriodWorkEvaluationDenormalizer(); + + /* + $this->assertTrue( + $denormalizer->supportsDenormalization( + $data, + AccompanyingPeriodWorkEvaluation::class, + 'json', + $context + ) + ); + */ + + $denormalizedEvaluation = $denormalizer->denormalize( + $data, + AccompanyingPeriodWorkEvaluation::class, + 'json', + $context + ); + + $this->assertSame($evaluation, $denormalizedEvaluation); + $this->assertCount(1, $evaluation->getDocuments()); + $this->assertSame($doc, $evaluation->getDocuments()->first()); + $this->assertNotSame($storedObject, $evaluation->getDocuments()->first()->getStoredObject()); + } +}