From 18694a34cf5400086b14144e589b54831439c9ca Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Thu, 3 Mar 2022 16:24:37 +0100 Subject: [PATCH 01/79] logic added to only keep youngest descendant. works for issue, seems not to for action --- .../ChillActivityBundle/Entity/Activity.php | 26 +++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/src/Bundle/ChillActivityBundle/Entity/Activity.php b/src/Bundle/ChillActivityBundle/Entity/Activity.php index 0a344236c..f80d4ab86 100644 --- a/src/Bundle/ChillActivityBundle/Entity/Activity.php +++ b/src/Bundle/ChillActivityBundle/Entity/Activity.php @@ -229,7 +229,18 @@ class Activity implements AccompanyingPeriodLinkedWithSocialIssuesEntityInterfac public function addSocialAction(SocialAction $socialAction): self { - if (!$this->socialActions->contains($socialAction)) { + $descendants = $socialAction->getDescendants(); + $inCollection = false; + + if(null != $descendants) { + foreach ($descendants as $d) { + $inCollection = $this->socialActions->contains($d); + } + } else { + $inCollection = $this->socialActions->contains($socialAction); + } + + if(!$inCollection) { $this->socialActions[] = $socialAction; } @@ -238,7 +249,18 @@ class Activity implements AccompanyingPeriodLinkedWithSocialIssuesEntityInterfac public function addSocialIssue(SocialIssue $socialIssue): self { - if (!$this->socialIssues->contains($socialIssue)) { + $descendants = $socialIssue->getDescendants(); + $inCollection = false; + + if(null != $descendants) { + foreach ($descendants as $d) { + $inCollection = $this->socialIssues->contains($d); + } + } else { + $inCollection = $this->socialIssues->contains($socialIssue); + } + + if(!$inCollection) { $this->socialIssues[] = $socialIssue; } From 214ef09fe72e6971de5609b94bd60cb389581f38 Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Thu, 3 Mar 2022 16:29:35 +0100 Subject: [PATCH 02/79] update changelog --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a38f2ea47..efd8189bc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -28,7 +28,7 @@ and this project adheres to * [confidential] Fix position of toggle button so it does not cover text nor fall outside of box (no issue) * [parcours] Fix edit of both thirdparty and contact name (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/474) * [template] do not list inactive templates (for doc generator) - +* [action] Only youngest descendant is kept for social issues and actions (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/471) ## Test releases ### test release 2022-02-21 From 7c043e9d85257c0e8104f8a026fee30b43a5735a Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Fri, 4 Mar 2022 12:06:53 +0100 Subject: [PATCH 03/79] fix logic in activity entity --- .../ChillActivityBundle/Entity/Activity.php | 28 +++++++++---------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/src/Bundle/ChillActivityBundle/Entity/Activity.php b/src/Bundle/ChillActivityBundle/Entity/Activity.php index f80d4ab86..034e6073c 100644 --- a/src/Bundle/ChillActivityBundle/Entity/Activity.php +++ b/src/Bundle/ChillActivityBundle/Entity/Activity.php @@ -230,18 +230,18 @@ class Activity implements AccompanyingPeriodLinkedWithSocialIssuesEntityInterfac public function addSocialAction(SocialAction $socialAction): self { $descendants = $socialAction->getDescendants(); - $inCollection = false; - if(null != $descendants) { + if(count($descendants) > 0) { foreach ($descendants as $d) { $inCollection = $this->socialActions->contains($d); + if ($inCollection) { + return $this; + } } } else { - $inCollection = $this->socialActions->contains($socialAction); - } - - if(!$inCollection) { - $this->socialActions[] = $socialAction; + if (!$this->socialActions->contains($socialAction)) { + $this->socialActions[] = $socialAction; + }; } return $this; @@ -250,18 +250,18 @@ class Activity implements AccompanyingPeriodLinkedWithSocialIssuesEntityInterfac public function addSocialIssue(SocialIssue $socialIssue): self { $descendants = $socialIssue->getDescendants(); - $inCollection = false; - if(null != $descendants) { + if(count($descendants) > 0) { foreach ($descendants as $d) { $inCollection = $this->socialIssues->contains($d); + if ($inCollection) { + return $this; + } } } else { - $inCollection = $this->socialIssues->contains($socialIssue); - } - - if(!$inCollection) { - $this->socialIssues[] = $socialIssue; + if (!$this->socialIssues->contains($socialIssue)) { + $this->socialIssues[] = $socialIssue; + }; } return $this; From 0333e79b0ae1d3636720f595691b994b31c101a2 Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Fri, 4 Mar 2022 12:07:29 +0100 Subject: [PATCH 04/79] csfixes --- src/Bundle/ChillActivityBundle/Entity/Activity.php | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/Bundle/ChillActivityBundle/Entity/Activity.php b/src/Bundle/ChillActivityBundle/Entity/Activity.php index 034e6073c..f183ced60 100644 --- a/src/Bundle/ChillActivityBundle/Entity/Activity.php +++ b/src/Bundle/ChillActivityBundle/Entity/Activity.php @@ -35,6 +35,7 @@ use Symfony\Component\Security\Core\User\UserInterface; use Symfony\Component\Serializer\Annotation\DiscriminatorMap; use Symfony\Component\Serializer\Annotation\Groups; use Symfony\Component\Serializer\Annotation\SerializedName; +use function count; /** * Class Activity. @@ -231,9 +232,10 @@ class Activity implements AccompanyingPeriodLinkedWithSocialIssuesEntityInterfac { $descendants = $socialAction->getDescendants(); - if(count($descendants) > 0) { + if (count($descendants) > 0) { foreach ($descendants as $d) { $inCollection = $this->socialActions->contains($d); + if ($inCollection) { return $this; } @@ -241,7 +243,7 @@ class Activity implements AccompanyingPeriodLinkedWithSocialIssuesEntityInterfac } else { if (!$this->socialActions->contains($socialAction)) { $this->socialActions[] = $socialAction; - }; + } } return $this; @@ -251,9 +253,10 @@ class Activity implements AccompanyingPeriodLinkedWithSocialIssuesEntityInterfac { $descendants = $socialIssue->getDescendants(); - if(count($descendants) > 0) { + if (count($descendants) > 0) { foreach ($descendants as $d) { $inCollection = $this->socialIssues->contains($d); + if ($inCollection) { return $this; } @@ -261,7 +264,7 @@ class Activity implements AccompanyingPeriodLinkedWithSocialIssuesEntityInterfac } else { if (!$this->socialIssues->contains($socialIssue)) { $this->socialIssues[] = $socialIssue; - }; + } } return $this; From 474fffcbb5b4dd63a8866feb46c1532c7a51fe93 Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Fri, 4 Mar 2022 12:08:00 +0100 Subject: [PATCH 05/79] changelog updated --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index efd8189bc..55cc51fde 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -28,7 +28,7 @@ and this project adheres to * [confidential] Fix position of toggle button so it does not cover text nor fall outside of box (no issue) * [parcours] Fix edit of both thirdparty and contact name (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/474) * [template] do not list inactive templates (for doc generator) -* [action] Only youngest descendant is kept for social issues and actions (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/471) +* [activity] Only youngest descendant is kept for social issues and actions (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/471) ## Test releases ### test release 2022-02-21 From 4ef22748033610a69325c826c119c32675d6039b Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Thu, 3 Mar 2022 16:24:37 +0100 Subject: [PATCH 06/79] logic added to only keep youngest descendant. works for issue, seems not to for action --- .../ChillActivityBundle/Entity/Activity.php | 26 +++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/src/Bundle/ChillActivityBundle/Entity/Activity.php b/src/Bundle/ChillActivityBundle/Entity/Activity.php index 0a344236c..f80d4ab86 100644 --- a/src/Bundle/ChillActivityBundle/Entity/Activity.php +++ b/src/Bundle/ChillActivityBundle/Entity/Activity.php @@ -229,7 +229,18 @@ class Activity implements AccompanyingPeriodLinkedWithSocialIssuesEntityInterfac public function addSocialAction(SocialAction $socialAction): self { - if (!$this->socialActions->contains($socialAction)) { + $descendants = $socialAction->getDescendants(); + $inCollection = false; + + if(null != $descendants) { + foreach ($descendants as $d) { + $inCollection = $this->socialActions->contains($d); + } + } else { + $inCollection = $this->socialActions->contains($socialAction); + } + + if(!$inCollection) { $this->socialActions[] = $socialAction; } @@ -238,7 +249,18 @@ class Activity implements AccompanyingPeriodLinkedWithSocialIssuesEntityInterfac public function addSocialIssue(SocialIssue $socialIssue): self { - if (!$this->socialIssues->contains($socialIssue)) { + $descendants = $socialIssue->getDescendants(); + $inCollection = false; + + if(null != $descendants) { + foreach ($descendants as $d) { + $inCollection = $this->socialIssues->contains($d); + } + } else { + $inCollection = $this->socialIssues->contains($socialIssue); + } + + if(!$inCollection) { $this->socialIssues[] = $socialIssue; } From b6e530fec6cd84ac44edd1897a0d594ec1e2b44b Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Thu, 3 Mar 2022 16:29:35 +0100 Subject: [PATCH 07/79] update changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 380cc6afe..926363314 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -30,6 +30,7 @@ and this project adheres to * [template] do not list inactive templates (for doc generator) * [person] email added to twig personRenderbox (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/490) +* [action] Only youngest descendant is kept for social issues and actions (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/471) ## Test releases ### test release 2022-02-21 From 25fe105590299fc02e79618095b6fc65c9b27d54 Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Fri, 4 Mar 2022 12:06:53 +0100 Subject: [PATCH 08/79] fix logic in activity entity --- .../ChillActivityBundle/Entity/Activity.php | 28 +++++++++---------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/src/Bundle/ChillActivityBundle/Entity/Activity.php b/src/Bundle/ChillActivityBundle/Entity/Activity.php index f80d4ab86..034e6073c 100644 --- a/src/Bundle/ChillActivityBundle/Entity/Activity.php +++ b/src/Bundle/ChillActivityBundle/Entity/Activity.php @@ -230,18 +230,18 @@ class Activity implements AccompanyingPeriodLinkedWithSocialIssuesEntityInterfac public function addSocialAction(SocialAction $socialAction): self { $descendants = $socialAction->getDescendants(); - $inCollection = false; - if(null != $descendants) { + if(count($descendants) > 0) { foreach ($descendants as $d) { $inCollection = $this->socialActions->contains($d); + if ($inCollection) { + return $this; + } } } else { - $inCollection = $this->socialActions->contains($socialAction); - } - - if(!$inCollection) { - $this->socialActions[] = $socialAction; + if (!$this->socialActions->contains($socialAction)) { + $this->socialActions[] = $socialAction; + }; } return $this; @@ -250,18 +250,18 @@ class Activity implements AccompanyingPeriodLinkedWithSocialIssuesEntityInterfac public function addSocialIssue(SocialIssue $socialIssue): self { $descendants = $socialIssue->getDescendants(); - $inCollection = false; - if(null != $descendants) { + if(count($descendants) > 0) { foreach ($descendants as $d) { $inCollection = $this->socialIssues->contains($d); + if ($inCollection) { + return $this; + } } } else { - $inCollection = $this->socialIssues->contains($socialIssue); - } - - if(!$inCollection) { - $this->socialIssues[] = $socialIssue; + if (!$this->socialIssues->contains($socialIssue)) { + $this->socialIssues[] = $socialIssue; + }; } return $this; From 1c21b8070365ca9cb3163104b12bf12c3089a82c Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Fri, 4 Mar 2022 12:07:29 +0100 Subject: [PATCH 09/79] csfixes --- src/Bundle/ChillActivityBundle/Entity/Activity.php | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/Bundle/ChillActivityBundle/Entity/Activity.php b/src/Bundle/ChillActivityBundle/Entity/Activity.php index 034e6073c..f183ced60 100644 --- a/src/Bundle/ChillActivityBundle/Entity/Activity.php +++ b/src/Bundle/ChillActivityBundle/Entity/Activity.php @@ -35,6 +35,7 @@ use Symfony\Component\Security\Core\User\UserInterface; use Symfony\Component\Serializer\Annotation\DiscriminatorMap; use Symfony\Component\Serializer\Annotation\Groups; use Symfony\Component\Serializer\Annotation\SerializedName; +use function count; /** * Class Activity. @@ -231,9 +232,10 @@ class Activity implements AccompanyingPeriodLinkedWithSocialIssuesEntityInterfac { $descendants = $socialAction->getDescendants(); - if(count($descendants) > 0) { + if (count($descendants) > 0) { foreach ($descendants as $d) { $inCollection = $this->socialActions->contains($d); + if ($inCollection) { return $this; } @@ -241,7 +243,7 @@ class Activity implements AccompanyingPeriodLinkedWithSocialIssuesEntityInterfac } else { if (!$this->socialActions->contains($socialAction)) { $this->socialActions[] = $socialAction; - }; + } } return $this; @@ -251,9 +253,10 @@ class Activity implements AccompanyingPeriodLinkedWithSocialIssuesEntityInterfac { $descendants = $socialIssue->getDescendants(); - if(count($descendants) > 0) { + if (count($descendants) > 0) { foreach ($descendants as $d) { $inCollection = $this->socialIssues->contains($d); + if ($inCollection) { return $this; } @@ -261,7 +264,7 @@ class Activity implements AccompanyingPeriodLinkedWithSocialIssuesEntityInterfac } else { if (!$this->socialIssues->contains($socialIssue)) { $this->socialIssues[] = $socialIssue; - }; + } } return $this; From 2012df512cba695ade191a6df4643e3266d8fb83 Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Fri, 4 Mar 2022 17:27:26 +0100 Subject: [PATCH 10/79] merge conflict fixed --- CHANGELOG.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 926363314..caf897a68 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -29,8 +29,7 @@ and this project adheres to * [parcours] Fix edit of both thirdparty and contact name (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/474) * [template] do not list inactive templates (for doc generator) * [person] email added to twig personRenderbox (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/490) - -* [action] Only youngest descendant is kept for social issues and actions (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/471) +* [activity] Only youngest descendant is kept for social issues and actions (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/471) ## Test releases ### test release 2022-02-21 From 16be28681ad0d7a017803b5668a23466e0c2f015 Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Mon, 7 Mar 2022 14:53:54 +0100 Subject: [PATCH 11/79] Test added for activity-social action and social issue --- .../Tests/Entity/ActivityTest.php | 98 +++++++++++++++++++ 1 file changed, 98 insertions(+) create mode 100644 src/Bundle/ChillActivityBundle/Tests/Entity/ActivityTest.php diff --git a/src/Bundle/ChillActivityBundle/Tests/Entity/ActivityTest.php b/src/Bundle/ChillActivityBundle/Tests/Entity/ActivityTest.php new file mode 100644 index 000000000..c67c99894 --- /dev/null +++ b/src/Bundle/ChillActivityBundle/Tests/Entity/ActivityTest.php @@ -0,0 +1,98 @@ +addChild($child); + $grandChild = new SocialAction(); + $child->addChild($grandChild); + + $activity = new Activity(); + + $activity->addSocialAction($parent); + + $this->assertCount(1, $activity->getSocialActions()); + $this->assertContains($parent, $activity->getSocialActions()); + + $activity->addSocialAction($grandChild); + + $this->assertCount(1, $activity->getSocialActions()); + $this->assertContains($grandChild, $activity->getSocialActions()); + $this->assertNotContains($parent, $activity->getSocialActions()); + + $activity->addSocialAction($child); + + $this->assertCount(1, $activity->getSocialActions()); + $this->assertContains($grandChild, $activity->getSocialActions()); + $this->assertNotContains($parent, $activity->getSocialActions()); + $this->assertNotContains($child, $activity->getSocialActions()); + + $activity->addSocialAction($another = new SocialAction()); + + $this->assertCount(2, $activity->getSocialActions()); + $this->assertContains($grandChild, $activity->getSocialActions()); + $this->assertContains($another, $activity->getSocialActions()); + $this->assertNotContains($parent, $activity->getSocialActions()); + $this->assertNotContains($child, $activity->getSocialActions()); + } + + public function testHierarchySocialIssues(): void + { + $parent = new SocialIssue(); + $child = new SocialIssue(); + + $parent->addChild($child); + $grandChild = new SocialIssue(); + $child->addChild($grandChild); + + $activity = new Activity(); + + $activity->addSocialIssue($parent); + + $this->assertCount(1, $activity->getSocialIssues()); + $this->assertContains($parent, $activity->getSocialIssues()); + + $activity->addSocialIssue($grandChild); + + $this->assertCount(1, $activity->getSocialIssues()); + $this->assertContains($grandChild, $activity->getSocialIssues()); + $this->assertNotContains($parent, $activity->getSocialIssues()); + + $activity->addSocialIssue($child); + + $this->assertCount(1, $activity->getSocialIssues()); + $this->assertContains($grandChild, $activity->getSocialIssues()); + $this->assertNotContains($parent, $activity->getSocialIssues()); + $this->assertNotContains($child, $activity->getSocialIssues()); + + $activity->addSocialIssue($another = new SocialIssue()); + + $this->assertCount(2, $activity->getSocialIssues()); + $this->assertContains($grandChild, $activity->getSocialIssues()); + $this->assertContains($another, $activity->getSocialIssues()); + $this->assertNotContains($parent, $activity->getSocialIssues()); + $this->assertNotContains($child, $activity->getSocialIssues()); + } + +} \ No newline at end of file From 325ab0daf3832427e52e312261f7315c92096c27 Mon Sep 17 00:00:00 2001 From: Pol Dellaiera Date: Tue, 8 Mar 2022 15:48:26 +0100 Subject: [PATCH 12/79] chore: Update `composer.json` files. --- composer.json | 6 ++++-- src/Bundle/ChillDocGeneratorBundle/composer.json | 1 + src/Bundle/ChillDocStoreBundle/composer.json | 3 ++- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/composer.json b/composer.json index c96738df8..d0fc51c0e 100644 --- a/composer.json +++ b/composer.json @@ -21,7 +21,7 @@ "knplabs/knp-time-bundle": "^1.12", "league/csv": "^9.7.1", "nyholm/psr7": "^1.4", - "ocramius/package-versions": "^1.10", + "ocramius/package-versions": "^1.10 || ^2", "odolbeau/phone-number-bundle": "^3.6", "phpoffice/phpspreadsheet": "^1.16", "ramsey/uuid-doctrine": "^1.7", @@ -33,6 +33,7 @@ "symfony/expression-language": "^4.4", "symfony/form": "^4.4", "symfony/framework-bundle": "^4.4", + "symfony/http-foundation": "^4.4", "symfony/intl": "^4.4", "symfony/mailer": "^5.4", "symfony/mime": "^5.4", @@ -103,7 +104,8 @@ "ergebnis/composer-normalize": true, "ocramius/package-versions": true, "phpro/grumphp": true, - "phpstan/extension-installer": true + "phpstan/extension-installer": true, + "roave/you-are-using-it-wrong": true }, "bin-dir": "bin", "optimize-autoloader": true, diff --git a/src/Bundle/ChillDocGeneratorBundle/composer.json b/src/Bundle/ChillDocGeneratorBundle/composer.json index 4ae119636..42939bd2b 100644 --- a/src/Bundle/ChillDocGeneratorBundle/composer.json +++ b/src/Bundle/ChillDocGeneratorBundle/composer.json @@ -18,6 +18,7 @@ } ], "require": { + "spomky-labs/base64url": "^2" }, "require-dev": { }, diff --git a/src/Bundle/ChillDocStoreBundle/composer.json b/src/Bundle/ChillDocStoreBundle/composer.json index c011ce29b..aa636535e 100644 --- a/src/Bundle/ChillDocStoreBundle/composer.json +++ b/src/Bundle/ChillDocStoreBundle/composer.json @@ -8,7 +8,8 @@ } }, "require": { - "symfony/mime": "^4 || ^5" + "symfony/mime": "^4 || ^5", + "symfony/http-foundation": "^4" }, "license": "AGPL-3.0" } From 6ddbf35a7b334e0e6745e03e0984c4b088ee0908 Mon Sep 17 00:00:00 2001 From: Pol Dellaiera Date: Tue, 8 Mar 2022 15:46:50 +0100 Subject: [PATCH 13/79] misc: Add return types. --- src/Bundle/ChillDocStoreBundle/Entity/StoredObject.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/Bundle/ChillDocStoreBundle/Entity/StoredObject.php b/src/Bundle/ChillDocStoreBundle/Entity/StoredObject.php index c512dba73..d5afd4a28 100644 --- a/src/Bundle/ChillDocStoreBundle/Entity/StoredObject.php +++ b/src/Bundle/ChillDocStoreBundle/Entity/StoredObject.php @@ -109,12 +109,12 @@ class StoredObject implements AsyncFileInterface, Document return $this->id; } - public function getIv() + public function getIv(): array { return $this->iv; } - public function getKeyInfos() + public function getKeyInfos(): array { return $this->keyInfos; } @@ -163,21 +163,21 @@ class StoredObject implements AsyncFileInterface, Document return $this; } - public function setIv($iv) + public function setIv(array $iv) { $this->iv = $iv; return $this; } - public function setKeyInfos($keyInfos) + public function setKeyInfos(array $keyInfos) { $this->keyInfos = $keyInfos; return $this; } - public function setType($type) + public function setType(string $type) { $this->type = $type; From b8992b8eeba281559cf9b226c10d194a54bd92d9 Mon Sep 17 00:00:00 2001 From: Pol Dellaiera Date: Tue, 8 Mar 2022 15:47:33 +0100 Subject: [PATCH 14/79] misc: Update interface doc. --- .../Context/ContextManager.php | 5 +--- .../Context/ContextManagerInterface.php | 30 +++++++++++++++++++ 2 files changed, 31 insertions(+), 4 deletions(-) create mode 100644 src/Bundle/ChillDocGeneratorBundle/Context/ContextManagerInterface.php diff --git a/src/Bundle/ChillDocGeneratorBundle/Context/ContextManager.php b/src/Bundle/ChillDocGeneratorBundle/Context/ContextManager.php index 8dfecb730..b8f4d0eed 100644 --- a/src/Bundle/ChillDocGeneratorBundle/Context/ContextManager.php +++ b/src/Bundle/ChillDocGeneratorBundle/Context/ContextManager.php @@ -14,7 +14,7 @@ namespace Chill\DocGeneratorBundle\Context; use Chill\DocGeneratorBundle\Context\Exception\ContextNotFoundException; use Chill\DocGeneratorBundle\Entity\DocGeneratorTemplate; -class ContextManager +final class ContextManager implements ContextManagerInterface { /** * @var DocGeneratorContextInterface[]|iterable @@ -26,9 +26,6 @@ class ContextManager $this->contexts = $contexts; } - /** - * @throw ContextNotFoundException when the context is not found - */ public function getContextByDocGeneratorTemplate(DocGeneratorTemplate $docGeneratorTemplate): DocGeneratorContextInterface { foreach ($this->contexts as $key => $context) { diff --git a/src/Bundle/ChillDocGeneratorBundle/Context/ContextManagerInterface.php b/src/Bundle/ChillDocGeneratorBundle/Context/ContextManagerInterface.php new file mode 100644 index 000000000..3468d787d --- /dev/null +++ b/src/Bundle/ChillDocGeneratorBundle/Context/ContextManagerInterface.php @@ -0,0 +1,30 @@ + Date: Tue, 8 Mar 2022 15:46:31 +0100 Subject: [PATCH 15/79] refactor: Return a string instead of a resource. --- .../GeneratorDriver/DriverInterface.php | 7 +-- .../GeneratorDriver/RelatorioDriver.php | 46 +++++++++++++------ 2 files changed, 33 insertions(+), 20 deletions(-) diff --git a/src/Bundle/ChillDocGeneratorBundle/GeneratorDriver/DriverInterface.php b/src/Bundle/ChillDocGeneratorBundle/GeneratorDriver/DriverInterface.php index 2572484e1..d787523c9 100644 --- a/src/Bundle/ChillDocGeneratorBundle/GeneratorDriver/DriverInterface.php +++ b/src/Bundle/ChillDocGeneratorBundle/GeneratorDriver/DriverInterface.php @@ -13,10 +13,5 @@ namespace Chill\DocGeneratorBundle\GeneratorDriver; interface DriverInterface { - /** - * @param resource $template - * - * @return resource - */ - public function generateFromResource($template, string $resourceType, array $data, ?string $templateName = null); + public function generateFromString(string $template, string $resourceType, array $data, ?string $templateName = null): string; } diff --git a/src/Bundle/ChillDocGeneratorBundle/GeneratorDriver/RelatorioDriver.php b/src/Bundle/ChillDocGeneratorBundle/GeneratorDriver/RelatorioDriver.php index 7a3e4ac69..73a4ba9e0 100644 --- a/src/Bundle/ChillDocGeneratorBundle/GeneratorDriver/RelatorioDriver.php +++ b/src/Bundle/ChillDocGeneratorBundle/GeneratorDriver/RelatorioDriver.php @@ -20,40 +20,40 @@ use Symfony\Contracts\HttpClient\Exception\DecodingExceptionInterface; use Symfony\Contracts\HttpClient\Exception\HttpExceptionInterface; use Symfony\Contracts\HttpClient\Exception\TransportExceptionInterface; use Symfony\Contracts\HttpClient\HttpClientInterface; +use Throwable; -class RelatorioDriver implements DriverInterface +final class RelatorioDriver implements DriverInterface { - private LoggerInterface $logger; + private HttpClientInterface $client; - private HttpClientInterface $relatorioClient; + private LoggerInterface $logger; private string $url; public function __construct( - HttpClientInterface $relatorioClient, + HttpClientInterface $client, ParameterBagInterface $parameterBag, LoggerInterface $logger ) { - $this->relatorioClient = $relatorioClient; + $this->client = $client; $this->logger = $logger; $this->url = $parameterBag->get('chill_doc_generator')['driver']['relatorio']['url']; } - public function generateFromResource($template, string $resourceType, array $data, ?string $templateName = null) + public function generateFromString(string $template, string $resourceType, array $data, ?string $templateName = null): string { - $formFields = [ - 'variables' => json_encode($data), - 'template' => new DataPart($template, $templateName ?? uniqid('template_'), $resourceType), - ]; - $form = new FormDataPart($formFields); + $form = new FormDataPart( + [ + 'variables' => json_encode($data), + 'template' => new DataPart($template, $templateName ?? uniqid('template_'), $resourceType), + ] + ); try { - $response = $this->relatorioClient->request('POST', $this->url, [ + $response = $this->client->request('POST', $this->url, [ 'headers' => $form->getPreparedHeaders()->toArray(), 'body' => $form->bodyToIterable(), ]); - - return $response->toStream(); } catch (HttpExceptionInterface $e) { $content = $e->getResponse()->getContent(false); @@ -88,5 +88,23 @@ class RelatorioDriver implements DriverInterface throw $e; } + + try { + $content = $response->getContent(); + } catch (Throwable $exception) { + $this + ->logger + ->error( + 'relatorio: Unable to get content from response.', + [ + 'msg' => $exception->getMessage(), + 'e' => $exception->getTraceAsString(), + ] + ); + + throw $exception; + } + + return $content; } } From 62af980ea545dbcfa018ee793d8d515d1e45cb88 Mon Sep 17 00:00:00 2001 From: Pol Dellaiera Date: Tue, 8 Mar 2022 15:45:39 +0100 Subject: [PATCH 16/79] feat: Add new `StoredObjectManager` service. To read and write onto `StoredObject` document using a common interface. --- .../StoredObjectManagerException.php | 40 ++++ .../Service/StoredObjectManager.php | 133 +++++++++++++ .../Service/StoredObjectManagerInterface.php | 34 ++++ .../Tests/StoredObjectManagerTest.php | 183 ++++++++++++++++++ 4 files changed, 390 insertions(+) create mode 100644 src/Bundle/ChillDocStoreBundle/Exception/StoredObjectManagerException.php create mode 100644 src/Bundle/ChillDocStoreBundle/Service/StoredObjectManager.php create mode 100644 src/Bundle/ChillDocStoreBundle/Service/StoredObjectManagerInterface.php create mode 100644 src/Bundle/ChillDocStoreBundle/Tests/StoredObjectManagerTest.php diff --git a/src/Bundle/ChillDocStoreBundle/Exception/StoredObjectManagerException.php b/src/Bundle/ChillDocStoreBundle/Exception/StoredObjectManagerException.php new file mode 100644 index 000000000..b5d0bf679 --- /dev/null +++ b/src/Bundle/ChillDocStoreBundle/Exception/StoredObjectManagerException.php @@ -0,0 +1,40 @@ +client = $client; + $this->tempUrlGenerator = $tempUrlGenerator; + } + + public function read(StoredObject $document): string + { + try { + $response = $this + ->client + ->request( + Request::METHOD_GET, + $this + ->tempUrlGenerator + ->generate( + Request::METHOD_GET, + $document->getFilename() + ) + ->url + ); + } catch (Throwable $e) { + throw StoredObjectManagerException::errorDuringHttpRequest($e); + } + + if ($response->getStatusCode() !== Response::HTTP_OK) { + throw StoredObjectManagerException::invalidStatusCode($response->getStatusCode()); + } + + try { + $data = $response->getContent(); + } catch (Throwable $e) { + throw StoredObjectManagerException::unableToGetResponseContent($e); + } + + if (false === $this->hasKeysAndIv($document)) { + return $data; + } + + $clearData = openssl_decrypt( + $data, + self::ALGORITHM, + // TODO: Why using this library and not use base64_decode() ? + Base64Url::decode($document->getKeyInfos()['k']), + OPENSSL_RAW_DATA, + pack('C*', ...$document->getIv()) + ); + + if (false === $clearData) { + throw StoredObjectManagerException::unableToDecrypt(openssl_error_string()); + } + + return $clearData; + } + + public function write(StoredObject $document, string $clearContent): void + { + $encryptedContent = $this->hasKeysAndIv($document) + ? openssl_encrypt( + $clearContent, + self::ALGORITHM, + // TODO: Why using this library and not use base64_decode() ? + Base64Url::decode($document->getKeyInfos()['k']), + OPENSSL_RAW_DATA, + pack('C*', ...$document->getIv()) + ) + : $clearContent; + + try { + $response = $this + ->client + ->request( + Request::METHOD_PUT, + $this + ->tempUrlGenerator + ->generate( + Request::METHOD_PUT, + $document->getFilename() + ) + ->url, + [ + 'body' => $encryptedContent, + ] + ); + } catch (TransportExceptionInterface $exception) { + throw StoredObjectManagerException::errorDuringHttpRequest($exception); + } + + if ($response->getStatusCode() !== Response::HTTP_CREATED) { + throw StoredObjectManagerException::invalidStatusCode($response->getStatusCode()); + } + } + + private function hasKeysAndIv(StoredObject $storedObject): bool + { + return ([] !== $storedObject->getKeyInfos()) && ([] !== $storedObject->getIv()); + } +} diff --git a/src/Bundle/ChillDocStoreBundle/Service/StoredObjectManagerInterface.php b/src/Bundle/ChillDocStoreBundle/Service/StoredObjectManagerInterface.php new file mode 100644 index 000000000..3cf67cb0c --- /dev/null +++ b/src/Bundle/ChillDocStoreBundle/Service/StoredObjectManagerInterface.php @@ -0,0 +1,34 @@ +setFilename('encrypted.txt') + ->setKeyInfos(['k' => base64_encode('S9NIHMaFHOWzLPez3jZOIHBaNfBrMQUR5zvqBz6kme8')]) + ->setIv(unpack('C*', 'abcdefghijklmnop')), + hex2bin('741237d255fd4f7eddaaa9058912a84caae28a41b10b34d4e3e3abe41d3b9b47cb0dd8f22c3c883d4f0e9defa75ff662'), // Binary encoded string + 'The quick brown fox jumps over the lazy dog', // clear + ]; + + // Non-encrypted object + yield [ + (new StoredObject())->setFilename('non-encrypted.txt'), // The StoredObject + 'The quick brown fox jumps over the lazy dog', // Encrypted + 'The quick brown fox jumps over the lazy dog', // Clear + ]; + + /* UNHAPPY SCENARIO */ + + // Encrypted object with issue during HTTP communication + yield [ + (new StoredObject()) + ->setFilename('error_during_http_request.txt') + ->setKeyInfos(['k' => base64_encode('S9NIHMaFHOWzLPez3jZOIHBaNfBrMQUR5zvqBz6kme8')]) + ->setIv(unpack('C*', 'abcdefghijklmnop')), + hex2bin('741237d255fd4f7eddaaa9058912a84caae28a41b10b34d4e3e3abe41d3b9b47cb0dd8f22c3c883d4f0e9defa75ff662'), // Binary encoded string + 'The quick brown fox jumps over the lazy dog', // clear + StoredObjectManagerException::class, + ]; + + // Encrypted object with issue during HTTP communication: Invalid status code + yield [ + (new StoredObject()) + ->setFilename('invalid_statuscode.txt') + ->setKeyInfos(['k' => base64_encode('S9NIHMaFHOWzLPez3jZOIHBaNfBrMQUR5zvqBz6kme8')]) + ->setIv(unpack('C*', 'abcdefghijklmnop')), + hex2bin('741237d255fd4f7eddaaa9058912a84caae28a41b10b34d4e3e3abe41d3b9b47cb0dd8f22c3c883d4f0e9defa75ff662'), // Binary encoded string + 'The quick brown fox jumps over the lazy dog', // clear + StoredObjectManagerException::class, + ]; + + // Erroneous encrypted: Unable to decrypt exception. + yield [ + (new StoredObject()) + ->setFilename('unable_to_decrypt.txt') + ->setKeyInfos(['k' => base64_encode('WRONG_PASS_PHRASE')]) + ->setIv(unpack('C*', 'abcdefghijklmnop')), + 'WRONG_ENCODED_VALUE', // Binary encoded string + 'The quick brown fox jumps over the lazy dog', // clear + StoredObjectManagerException::class, + ]; + } + + /** + * @dataProvider getDataProvider + */ + public function testRead(StoredObject $storedObject, string $encodedContent, string $clearContent, ?string $exceptionClass = null) + { + if (null !== $exceptionClass) { + $this->expectException($exceptionClass); + } + + $storedObjectManager = $this->getSubject($storedObject, $encodedContent); + + self::assertEquals($clearContent, $storedObjectManager->read($storedObject)); + } + + /** + * @dataProvider getDataProvider + */ + public function testWrite(StoredObject $storedObject, string $encodedContent, string $clearContent, ?string $exceptionClass = null) + { + if (null !== $exceptionClass) { + $this->expectException($exceptionClass); + } + + $storedObjectManager = $this->getSubject($storedObject, $encodedContent); + + $storedObjectManager->write($storedObject, $clearContent); + + self::assertEquals($clearContent, $storedObjectManager->read($storedObject)); + } + + private function getHttpClient(string $encodedContent): HttpClientInterface + { + $callback = static function ($method, $url, $options) use ($encodedContent) { + if (Request::METHOD_GET === $method) { + switch ($url) { + case 'https://example.com/non-encrypted.txt': + case 'https://example.com/encrypted.txt': + return new MockResponse($encodedContent, ['http_code' => 200]); + + case 'https://example.com/error_during_http_request.txt': + return new TransportException('error_during_http_request.txt'); + + case 'https://example.com/invalid_statuscode.txt': + return new MockResponse($encodedContent, ['http_code' => 404]); + } + } + + if (Request::METHOD_PUT === $method) { + switch ($url) { + case 'https://example.com/non-encrypted.txt': + case 'https://example.com/encrypted.txt': + return new MockResponse($encodedContent, ['http_code' => 201]); + + case 'https://example.com/error_during_http_request.txt': + throw new TransportException('error_during_http_request.txt'); + + case 'https://example.com/invalid_statuscode.txt': + return new MockResponse($encodedContent, ['http_code' => 404]); + } + } + + return new MockResponse('Not found'); + }; + + return new MockHttpClient($callback); + } + + private function getSubject(StoredObject $storedObject, string $encodedContent): StoredObjectManagerInterface + { + return new StoredObjectManager( + $this->getHttpClient($encodedContent), + $this->getTempUrlGenerator($storedObject) + ); + } + + private function getTempUrlGenerator(StoredObject $storedObject): TempUrlGeneratorInterface + { + $response = new stdClass(); + $response->url = $storedObject->getFilename(); + + $tempUrlGenerator = $this + ->getMockBuilder(TempUrlGeneratorInterface::class) + ->getMock(); + + $tempUrlGenerator + ->method('generate') + ->withAnyParameters() + ->willReturn($response); + + return $tempUrlGenerator; + } +} From 35d723e5fbc22ea324ce1c174f299c3794ee5d76 Mon Sep 17 00:00:00 2001 From: Pol Dellaiera Date: Tue, 8 Mar 2022 15:48:52 +0100 Subject: [PATCH 17/79] refactor: Use `StoredObjectManager`. --- .../DocGeneratorTemplateController.php | 206 +++++++++--------- .../src/Service/Wopi/ChillDocumentManager.php | 70 +----- 2 files changed, 113 insertions(+), 163 deletions(-) diff --git a/src/Bundle/ChillDocGeneratorBundle/Controller/DocGeneratorTemplateController.php b/src/Bundle/ChillDocGeneratorBundle/Controller/DocGeneratorTemplateController.php index 000fcb03a..2f64ea81e 100644 --- a/src/Bundle/ChillDocGeneratorBundle/Controller/DocGeneratorTemplateController.php +++ b/src/Bundle/ChillDocGeneratorBundle/Controller/DocGeneratorTemplateController.php @@ -11,8 +11,6 @@ declare(strict_types=1); namespace Chill\DocGeneratorBundle\Controller; -use Base64Url\Base64Url; -use ChampsLibres\AsyncUploaderBundle\TempUrl\TempUrlGeneratorInterface; use Chill\DocGeneratorBundle\Context\ContextManager; use Chill\DocGeneratorBundle\Context\DocGeneratorContextWithPublicFormInterface; use Chill\DocGeneratorBundle\Context\Exception\ContextNotFoundException; @@ -21,11 +19,11 @@ use Chill\DocGeneratorBundle\GeneratorDriver\DriverInterface; use Chill\DocGeneratorBundle\GeneratorDriver\Exception\TemplateException; use Chill\DocGeneratorBundle\Repository\DocGeneratorTemplateRepository; use Chill\DocStoreBundle\Entity\StoredObject; +use Chill\DocStoreBundle\Service\StoredObjectManagerInterface; use Chill\MainBundle\Pagination\PaginatorFactory; use Chill\MainBundle\Serializer\Model\Collection; +use Doctrine\ORM\EntityManagerInterface; use Exception; -use GuzzleHttp\Client; -use GuzzleHttp\Exception\TransferException; use Psr\Log\LoggerInterface; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Component\Form\Extension\Core\Type\FileType; @@ -34,14 +32,14 @@ use Symfony\Component\HttpFoundation\RedirectResponse; use Symfony\Component\HttpFoundation\Request; // TODO à mettre dans services use Symfony\Component\HttpFoundation\Response; -use Symfony\Component\HttpFoundation\StreamedResponse; use Symfony\Component\HttpKernel\Exception\BadRequestHttpException; -use Symfony\Component\HttpKernel\Exception\HttpException; use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; -use Symfony\Component\HttpKernel\KernelInterface; use Symfony\Component\Routing\Annotation\Route; use Symfony\Component\Serializer\Normalizer\AbstractNormalizer; +use Symfony\Component\Serializer\Normalizer\ObjectNormalizer; use Symfony\Contracts\HttpClient\HttpClientInterface; +use Throwable; +use function strlen; final class DocGeneratorTemplateController extends AbstractController { @@ -53,13 +51,13 @@ final class DocGeneratorTemplateController extends AbstractController private DriverInterface $driver; - private KernelInterface $kernel; + private EntityManagerInterface $entityManager; private LoggerInterface $logger; private PaginatorFactory $paginatorFactory; - private TempUrlGeneratorInterface $tempUrlGenerator; + private StoredObjectManagerInterface $storedObjectManager; public function __construct( ContextManager $contextManager, @@ -67,18 +65,18 @@ final class DocGeneratorTemplateController extends AbstractController DriverInterface $driver, LoggerInterface $logger, PaginatorFactory $paginatorFactory, - TempUrlGeneratorInterface $tempUrlGenerator, - KernelInterface $kernel, - HttpClientInterface $client + HttpClientInterface $client, + StoredObjectManagerInterface $storedObjectManager, + EntityManagerInterface $entityManager ) { $this->contextManager = $contextManager; $this->docGeneratorTemplateRepository = $docGeneratorTemplateRepository; $this->driver = $driver; $this->logger = $logger; $this->paginatorFactory = $paginatorFactory; - $this->tempUrlGenerator = $tempUrlGenerator; - $this->kernel = $kernel; $this->client = $client; + $this->storedObjectManager = $storedObjectManager; + $this->entityManager = $entityManager; } /** @@ -177,8 +175,10 @@ final class DocGeneratorTemplateController extends AbstractController return $this->redirectToRoute( 'chill_docgenerator_test_generate_from_template', - ['template' => $template, 'entityClassName' => $entityClassName, 'entityId' => $entityId, - 'returnPath' => $request->query->get('returnPath', '/'), ] + [ + 'template' => $template, 'entityClassName' => $entityClassName, 'entityId' => $entityId, + 'returnPath' => $request->query->get('returnPath', '/'), + ] ); } @@ -192,16 +192,26 @@ final class DocGeneratorTemplateController extends AbstractController try { $context = $this->contextManager->getContextByDocGeneratorTemplate($template); } catch (ContextNotFoundException $e) { - throw new NotFoundHttpException($e->getMessage(), $e); + throw new NotFoundHttpException( + 'Context not found.', + $e + ); } - $entity = $this->getDoctrine()->getRepository($context->getEntityClass())->find($entityId); + $entity = $this + ->entityManager + ->getRepository($context->getEntityClass()) + ->find($entityId); if (null === $entity) { - throw new NotFoundHttpException("Entity with classname {$entityClassName} and id {$entityId} is not found"); + throw new NotFoundHttpException( + sprintf('Entity with classname %s and id %s is not found', $entityClassName, $entityId) + ); } - $contextGenerationData = []; + $contextGenerationData = [ + 'test_file' => null, + ]; if ( $context instanceof DocGeneratorContextWithPublicFormInterface @@ -235,123 +245,109 @@ final class DocGeneratorTemplateController extends AbstractController $contextGenerationData = $form->getData(); } elseif (!$form->isSubmitted() || ($form->isSubmitted() && !$form->isValid())) { $templatePath = '@ChillDocGenerator/Generator/basic_form.html.twig'; - $templateOptions = ['entity' => $entity, 'form' => $form->createView(), - 'template' => $template, 'context' => $context, ]; + $templateOptions = [ + 'entity' => $entity, 'form' => $form->createView(), + 'template' => $template, 'context' => $context, + ]; return $this->render($templatePath, $templateOptions); } } - if ($isTest && null !== $contextGenerationData['test_file']) { - /** @var File $file */ - $file = $contextGenerationData['test_file']; - $templateResource = fopen($file->getPathname(), 'rb'); + $document = $template->getFile(); + + if ($isTest && ($contextGenerationData['test_file'] instanceof File)) { + $dataDecrypted = file_get_contents($contextGenerationData['test_file']->getPathname()); } else { - $getUrlGen = $this->tempUrlGenerator->generate( - 'GET', - $template->getFile()->getFilename() - ); - - $data = $this->client->request('GET', $getUrlGen->url); - - $iv = $template->getFile()->getIv(); // iv as an Array - $ivGoodFormat = pack('C*', ...$iv); // iv as a String (ok for openssl_decrypt) - - $method = 'AES-256-CBC'; - - $key = $template->getFile()->getKeyInfos()['k']; - $keyGoodFormat = Base64Url::decode($key); - - $dataDecrypted = openssl_decrypt($data->getContent(), $method, $keyGoodFormat, 1, $ivGoodFormat); - - if (false === $dataDecrypted) { - throw new Exception('Error during Decrypt ', 1); + try { + $dataDecrypted = $this->storedObjectManager->read($document); + } catch (Throwable $exception) { + throw $exception; } - - if (false === $templateResource = fopen('php://memory', 'r+b')) { - $this->logger->error('Could not write data to memory'); - - throw new HttpException(500); - } - fwrite($templateResource, $dataDecrypted); - rewind($templateResource); } - $datas = $context->getData($template, $entity, $contextGenerationData); try { - $generatedResource = $this->driver->generateFromResource($templateResource, $template->getFile()->getType(), $datas, $template->getFile()->getFilename()); + $generatedResource = $this + ->driver + ->generateFromString( + $dataDecrypted, + $template->getFile()->getType(), + $context->getData($template, $entity, $contextGenerationData), + $template->getFile()->getFilename() + ); } catch (TemplateException $e) { - $msg = implode("\n", $e->getErrors()); - - return new Response($msg, 400, [ - 'Content-Type' => 'text/plain', - ]); + return new Response( + implode("\n", $e->getErrors()), + 400, + [ + 'Content-Type' => 'text/plain', + ] + ); } - fclose($templateResource); - if ($isTest) { - return new StreamedResponse( - static function () use ($generatedResource) { - fpassthru($generatedResource); - fclose($generatedResource); - }, + return new Response( + $generatedResource, Response::HTTP_OK, [ 'Content-Transfer-Encoding', 'binary', 'Content-Type' => 'application/vnd.oasis.opendocument.text', - 'Content-Disposition' => sprintf('attachment; filename="%s.odt"', 'generated'), - 'Content-Length' => fstat($generatedResource)['size'], + 'Content-Disposition' => 'attachment; filename="generated.odt"', + 'Content-Length' => strlen($generatedResource), ], ); } - $genDocName = 'doc_' . sprintf('%010d', mt_rand()) . 'odt'; - - $getUrlGen = $this->tempUrlGenerator->generate( - 'PUT', - $genDocName - ); - - $client = new Client(); + /** @var StoredObject $storedObject */ + $storedObject = (new ObjectNormalizer()) + ->denormalize( + [ + 'type' => $template->getFile()->getType(), + 'filename' => sprintf('%s_odt', uniqid('doc_', true)), + ], + StoredObject::class + ); try { - $putResponse = $client->request('PUT', $getUrlGen->url, [ - 'body' => $generatedResource, - ]); + $this->storedObjectManager->write($storedObject, $generatedResource); + } catch (Throwable $exception) { + throw $exception; + } - if ($putResponse->getStatusCode() === 201) { - $em = $this->getDoctrine()->getManager(); - $storedObject = new StoredObject(); - $storedObject - ->setType($template->getFile()->getType()) - ->setFilename($genDocName); + $this->entityManager->persist($storedObject); - $em->persist($storedObject); - - try { - $context->storeGenerated($template, $storedObject, $entity, $contextGenerationData); - } catch (Exception $e) { - $this->logger->error('Could not store the associated document to entity', [ + try { + $context + ->storeGenerated( + $template, + $storedObject, + $entity, + $contextGenerationData + ); + } catch (Exception $e) { + $this + ->logger + ->error( + 'Unable to store the associated document to entity', + [ 'entityClassName' => $entityClassName, 'entityId' => $entityId, 'contextKey' => $context->getName(), - ]); + ] + ); - throw $e; - } - - $em->flush(); - - return $this->redirectToRoute('chill_wopi_file_edit', [ - 'fileId' => $storedObject->getUuid(), - 'returnPath' => $request->query->get('returnPath', '/'), - ]); - } - } catch (TransferException $e) { throw $e; } - throw new Exception('Unable to generate document.'); + $this->entityManager->flush(); + + return $this + ->redirectToRoute( + 'chill_wopi_file_edit', + [ + 'fileId' => $storedObject->getUuid(), + 'returnPath' => $request->query->get('returnPath', '/'), + ] + ); } } diff --git a/src/Bundle/ChillWopiBundle/src/Service/Wopi/ChillDocumentManager.php b/src/Bundle/ChillWopiBundle/src/Service/Wopi/ChillDocumentManager.php index 19ff3c62e..7cc71188f 100644 --- a/src/Bundle/ChillWopiBundle/src/Service/Wopi/ChillDocumentManager.php +++ b/src/Bundle/ChillWopiBundle/src/Service/Wopi/ChillDocumentManager.php @@ -11,12 +11,12 @@ declare(strict_types=1); namespace Chill\WopiBundle\Service\Wopi; -use ChampsLibres\AsyncUploaderBundle\TempUrl\TempUrlGeneratorInterface; use ChampsLibres\WopiLib\Contract\Entity\Document; use ChampsLibres\WopiLib\Contract\Service\DocumentLockManagerInterface; use ChampsLibres\WopiLib\Contract\Service\DocumentManagerInterface; use Chill\DocStoreBundle\Entity\StoredObject; use Chill\DocStoreBundle\Repository\StoredObjectRepository; +use Chill\DocStoreBundle\Service\StoredObjectManagerInterface; use DateTimeInterface; use Doctrine\ORM\EntityManagerInterface; use Error; @@ -28,8 +28,6 @@ use Symfony\Bridge\PsrHttpMessage\HttpMessageFactoryInterface; use Symfony\Component\HttpFoundation\RequestStack; use Symfony\Component\Mime\MimeTypes; use Symfony\Component\Serializer\Normalizer\ObjectNormalizer; -use Symfony\Contracts\HttpClient\HttpClientInterface; -use Throwable; use function strlen; @@ -39,33 +37,29 @@ final class ChillDocumentManager implements DocumentManagerInterface private EntityManagerInterface $entityManager; - private HttpClientInterface $httpClient; - private Psr17Interface $psr17; private RequestInterface $request; private StoredObjectRepository $storedObjectRepository; - private TempUrlGeneratorInterface $tempUrlGenerator; + private StoredObjectManagerInterface $storedObjectManager; public function __construct( DocumentLockManagerInterface $documentLockManager, EntityManagerInterface $entityManager, - HttpClientInterface $httpClient, - Psr17Interface $psr17, - StoredObjectRepository $storedObjectRepository, - TempUrlGeneratorInterface $tempUrlGenerator, HttpMessageFactoryInterface $httpMessageFactory, - RequestStack $requestStack + Psr17Interface $psr17, + RequestStack $requestStack, + StoredObjectManagerInterface $storedObjectManager, + StoredObjectRepository $storedObjectRepository ) { + $this->documentLockManager = $documentLockManager; $this->entityManager = $entityManager; $this->psr17 = $psr17; - $this->storedObjectRepository = $storedObjectRepository; - $this->documentLockManager = $documentLockManager; - $this->tempUrlGenerator = $tempUrlGenerator; - $this->httpClient = $httpClient; $this->request = $httpMessageFactory->createRequest($requestStack->getCurrentRequest()); + $this->storedObjectManager = $storedObjectManager; + $this->storedObjectRepository = $storedObjectRepository; } public function create(array $data): Document @@ -197,18 +191,7 @@ final class ChillDocumentManager implements DocumentManagerInterface public function remove(Document $document): void { - $entityIsDeleted = false; - - try { - $this->entityManager->remove($document); - $entityIsDeleted = true; - } catch (Throwable $e) { - $entityIsDeleted = false; - } - - if (true === $entityIsDeleted) { - $this->deleteContent($document); - } + // TODO: To implement when we have a clearer view and API. } public function write(Document $document, array $properties = []): void @@ -216,42 +199,13 @@ final class ChillDocumentManager implements DocumentManagerInterface $this->setContent($document, $properties['content']); } - private function deleteContent(StoredObject $storedObject): void - { - /** @var StdClass $object */ - $object = $this->tempUrlGenerator->generate('DELETE', $storedObject->getFilename()); - - $response = $this->httpClient->request('DELETE', $object->url); - - if (200 !== $response->getStatusCode()) { - throw new Error('Unable to delete stored object.'); - } - } - private function getContent(StoredObject $storedObject): string { - /** @var StdClass $object */ - $object = $this->tempUrlGenerator->generate('GET', $storedObject->getFilename()); - - $response = $this->httpClient->request('GET', $object->url); - - if (200 !== $response->getStatusCode()) { - throw new Error('Unable to retrieve stored object.'); - } - - return $response->getContent(); + return $this->storedObjectManager->read($storedObject); } private function setContent(StoredObject $storedObject, string $content): void { - // TODO: Add strict typing in champs-libres/async-uploader-bundle - /** @var StdClass $object */ - $object = $this->tempUrlGenerator->generate('PUT', $storedObject->getFilename()); - - $response = $this->httpClient->request('PUT', $object->url, ['body' => $content]); - - if (201 !== $response->getStatusCode()) { - throw new Error('Unable to save stored object.'); - } + $this->storedObjectManager->write($storedObject, $content); } } From 3d7fcd99a8d5ad3e65f45fb6d583706e16e1aece Mon Sep 17 00:00:00 2001 From: Pol Dellaiera Date: Tue, 15 Mar 2022 11:25:19 +0100 Subject: [PATCH 18/79] fix: Remove `console.log`. --- .../ChillWopiBundle/src/Resources/public/page/editor/index.js | 1 - 1 file changed, 1 deletion(-) diff --git a/src/Bundle/ChillWopiBundle/src/Resources/public/page/editor/index.js b/src/Bundle/ChillWopiBundle/src/Resources/public/page/editor/index.js index 613a51d63..bb684e406 100644 --- a/src/Bundle/ChillWopiBundle/src/Resources/public/page/editor/index.js +++ b/src/Bundle/ChillWopiBundle/src/Resources/public/page/editor/index.js @@ -18,7 +18,6 @@ window.addEventListener('DOMContentLoaded', function(e) { frameholder.appendChild(office_frame); document.getElementById('office_form').submit(); - console.log(office_frame); const url = new URL(editor_url); const editor_domain = url.origin; From 22755de1dda819aa584bc0c99d43b2b36c23a705 Mon Sep 17 00:00:00 2001 From: Pol Dellaiera Date: Tue, 15 Mar 2022 13:42:13 +0100 Subject: [PATCH 19/79] fix: Remove `PrependExtensionInterface`. It is now handled by `chill_main` bundle. --- .../DependencyInjection/ChillWopiExtension.php | 18 +----------------- 1 file changed, 1 insertion(+), 17 deletions(-) diff --git a/src/Bundle/ChillWopiBundle/src/DependencyInjection/ChillWopiExtension.php b/src/Bundle/ChillWopiBundle/src/DependencyInjection/ChillWopiExtension.php index 9e8596336..37a9e2fa6 100644 --- a/src/Bundle/ChillWopiBundle/src/DependencyInjection/ChillWopiExtension.php +++ b/src/Bundle/ChillWopiBundle/src/DependencyInjection/ChillWopiExtension.php @@ -11,14 +11,12 @@ declare(strict_types=1); namespace Chill\WopiBundle\DependencyInjection; -use Ramsey\Uuid\Doctrine\UuidType; use Symfony\Component\Config\FileLocator; use Symfony\Component\DependencyInjection\ContainerBuilder; -use Symfony\Component\DependencyInjection\Extension\PrependExtensionInterface; use Symfony\Component\DependencyInjection\Loader\PhpFileLoader; use Symfony\Component\HttpKernel\DependencyInjection\Extension; -final class ChillWopiExtension extends Extension implements PrependExtensionInterface +final class ChillWopiExtension extends Extension { public function load(array $configs, ContainerBuilder $container) { @@ -33,18 +31,4 @@ final class ChillWopiExtension extends Extension implements PrependExtensionInte $loader = new PhpFileLoader($container, new FileLocator(__DIR__ . '/../Resources/config')); $loader->load('services.php'); } - - public function prepend(ContainerBuilder $container) - { - $container->prependExtensionConfig( - 'doctrine', - [ - 'dbal' => [ - 'types' => [ - 'uuid' => UuidType::class, - ], - ], - ] - ); - } } From 9551e10d2b3d902410ac3369bebf4f630cfb5bf5 Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Wed, 16 Mar 2022 11:55:19 +0100 Subject: [PATCH 20/79] improvement, but still not correct --- .../ChillActivityBundle/Entity/Activity.php | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/src/Bundle/ChillActivityBundle/Entity/Activity.php b/src/Bundle/ChillActivityBundle/Entity/Activity.php index f183ced60..db16ac9f6 100644 --- a/src/Bundle/ChillActivityBundle/Entity/Activity.php +++ b/src/Bundle/ChillActivityBundle/Entity/Activity.php @@ -235,15 +235,13 @@ class Activity implements AccompanyingPeriodLinkedWithSocialIssuesEntityInterfac if (count($descendants) > 0) { foreach ($descendants as $d) { $inCollection = $this->socialActions->contains($d); - if ($inCollection) { return $this; } } - } else { - if (!$this->socialActions->contains($socialAction)) { - $this->socialActions[] = $socialAction; - } + } + if (!$this->socialActions->contains($socialAction)) { + $this->socialActions[] = $socialAction; } return $this; @@ -256,15 +254,14 @@ class Activity implements AccompanyingPeriodLinkedWithSocialIssuesEntityInterfac if (count($descendants) > 0) { foreach ($descendants as $d) { $inCollection = $this->socialIssues->contains($d); - if ($inCollection) { return $this; } } - } else { - if (!$this->socialIssues->contains($socialIssue)) { - $this->socialIssues[] = $socialIssue; - } + } + + if (!$this->socialIssues->contains($socialIssue)) { + $this->socialIssues[] = $socialIssue; } return $this; From 02571bf727135cbb305410a046bccee41694c8a3 Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Tue, 22 Mar 2022 13:45:20 +0100 Subject: [PATCH 21/79] switch to using getDescendantsWithThis() --- src/Bundle/ChillActivityBundle/Entity/Activity.php | 13 +++++-------- .../Entity/SocialWork/SocialAction.php | 2 +- .../Entity/SocialWork/SocialIssue.php | 2 +- 3 files changed, 7 insertions(+), 10 deletions(-) diff --git a/src/Bundle/ChillActivityBundle/Entity/Activity.php b/src/Bundle/ChillActivityBundle/Entity/Activity.php index db16ac9f6..ac67a73e4 100644 --- a/src/Bundle/ChillActivityBundle/Entity/Activity.php +++ b/src/Bundle/ChillActivityBundle/Entity/Activity.php @@ -230,7 +230,7 @@ class Activity implements AccompanyingPeriodLinkedWithSocialIssuesEntityInterfac public function addSocialAction(SocialAction $socialAction): self { - $descendants = $socialAction->getDescendants(); + $descendants = $socialAction->getDescendantsWithThis(); if (count($descendants) > 0) { foreach ($descendants as $d) { @@ -240,16 +240,14 @@ class Activity implements AccompanyingPeriodLinkedWithSocialIssuesEntityInterfac } } } - if (!$this->socialActions->contains($socialAction)) { - $this->socialActions[] = $socialAction; - } + $this->socialActions[] = $socialAction; return $this; } public function addSocialIssue(SocialIssue $socialIssue): self { - $descendants = $socialIssue->getDescendants(); + $descendants = $socialIssue->getDescendantsWithThis(); if (count($descendants) > 0) { foreach ($descendants as $d) { @@ -260,9 +258,8 @@ class Activity implements AccompanyingPeriodLinkedWithSocialIssuesEntityInterfac } } - if (!$this->socialIssues->contains($socialIssue)) { - $this->socialIssues[] = $socialIssue; - } + $this->socialIssues[] = $socialIssue; + return $this; } diff --git a/src/Bundle/ChillPersonBundle/Entity/SocialWork/SocialAction.php b/src/Bundle/ChillPersonBundle/Entity/SocialWork/SocialAction.php index ec5e5a8e5..01f30f140 100644 --- a/src/Bundle/ChillPersonBundle/Entity/SocialWork/SocialAction.php +++ b/src/Bundle/ChillPersonBundle/Entity/SocialWork/SocialAction.php @@ -169,7 +169,7 @@ class SocialAction } /** - * @return Collection|self[] All the descendants with the current entity (this) + * @return Collection|self[] All the descendants including the current entity (this) */ public function getDescendantsWithThis(): Collection { diff --git a/src/Bundle/ChillPersonBundle/Entity/SocialWork/SocialIssue.php b/src/Bundle/ChillPersonBundle/Entity/SocialWork/SocialIssue.php index c735c0132..fb277f56c 100644 --- a/src/Bundle/ChillPersonBundle/Entity/SocialWork/SocialIssue.php +++ b/src/Bundle/ChillPersonBundle/Entity/SocialWork/SocialIssue.php @@ -202,7 +202,7 @@ class SocialIssue } /** - * @return Collection|self[] All the descendants with the current entity (this) + * @return Collection|self[] All the descendants including the current entity (this) */ public function getDescendantsWithThis(): Collection { From bcde4497cc435a65dc1fb7a12c90fec77a30a0f5 Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Tue, 5 Apr 2022 15:56:02 +0200 Subject: [PATCH 22/79] fix datepicker for social action --- .../public/vuejs/AccompanyingCourseWorkCreate/App.vue | 9 ++++----- .../public/vuejs/AccompanyingCourseWorkCreate/store.js | 7 ++++--- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourseWorkCreate/App.vue b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourseWorkCreate/App.vue index 503a00c59..758cd7e5e 100644 --- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourseWorkCreate/App.vue +++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourseWorkCreate/App.vue @@ -227,19 +227,18 @@ export default { }, startDate: { get() { - let d = this.$store.state.startDate; - return dateToISO(d); + return this.$store.state.startDate; }, set(value) { - this.$store.commit('setStartDate', ISOToDate(value)); + this.$store.commit('setStartDate', value); } }, endDate: { get() { - return dateToISO(this.$store.state.endDate); + return this.$store.state.endDate; }, set(value) { - this.$store.commit('setEndDate', ISOToDate(value)); + this.$store.commit('setEndDate', value); } }, setSocialIssue: { diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourseWorkCreate/store.js b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourseWorkCreate/store.js index 408115257..7b6c2b22e 100644 --- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourseWorkCreate/store.js +++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourseWorkCreate/store.js @@ -1,6 +1,6 @@ import { createStore } from 'vuex'; -import { datetimeToISO } from 'ChillMainAssets/chill/js/date.js'; +import { datetimeToISO, dateToISO, ISOToDate, ISOToDatetime } from 'ChillMainAssets/chill/js/date.js'; import { findSocialActionsBySocialIssue } from 'ChillPersonAssets/vuejs/_api/SocialWorkSocialAction.js'; // import { create } from 'ChillPersonAssets/vuejs/_api/AccompanyingCourseWork.js'; import { makeFetch } from 'ChillMainAssets/lib/api/apiMethods'; @@ -47,7 +47,7 @@ const store = createStore({ id: state.socialActionPicked.id }, startDate: { - datetime: datetimeToISO(state.startDate) + datetime: datetimeToISO(ISOToDate(state.startDate)) }, persons: [] }; @@ -61,7 +61,7 @@ const store = createStore({ if (null !== state.endDate) { payload.endDate = { - datetime: datetimeToISO(state.endDate) + datetime: datetimeToISO(ISOToDate(state.endDate)) }; } @@ -111,6 +111,7 @@ const store = createStore({ state.startDate = date; }, setEndDate(state, date) { + console.log(date) state.endDate = date; }, setPersonsPickedIds(state, ids) { From 72a62a3a1b28233864a74203797ebd5889a3e2c3 Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Tue, 5 Apr 2022 16:03:07 +0200 Subject: [PATCH 23/79] prefill startdate with now --- .../public/vuejs/AccompanyingCourseWorkCreate/store.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourseWorkCreate/store.js b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourseWorkCreate/store.js index 7b6c2b22e..3c2e034d7 100644 --- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourseWorkCreate/store.js +++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourseWorkCreate/store.js @@ -20,7 +20,7 @@ const store = createStore({ .map(p => p.person), personsReachables: window.accompanyingCourse.participations.filter(p => p.endDate == null) .map(p => p.person), - startDate: new Date(), + startDate: dateToISO(new Date()), endDate: null, isLoadingSocialActions: false, isPostingWork: false, From ad6a68487c1e9ba24fda9877c4de551a2267a704 Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Wed, 6 Apr 2022 11:24:01 +0200 Subject: [PATCH 24/79] fix datepicker for householdmember editor --- .../components/Dates.vue | 19 ++++++++++--------- .../HouseholdMembersEditor/store/index.js | 6 +++--- 2 files changed, 13 insertions(+), 12 deletions(-) diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/HouseholdMembersEditor/components/Dates.vue b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/HouseholdMembersEditor/components/Dates.vue index 94c1a146a..12867741d 100644 --- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/HouseholdMembersEditor/components/Dates.vue +++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/HouseholdMembersEditor/components/Dates.vue @@ -66,18 +66,19 @@ export default { }, startDate: { get() { - return [ - this.$store.state.startDate.getFullYear(), - (this.$store.state.startDate.getMonth() + 1).toString().padStart(2, '0'), - this.$store.state.startDate.getDate().toString().padStart(2, '0') - ].join('-'); + return this.$store.state.startDate; + // return [ + // this.$store.state.startDate.getFullYear(), + // (this.$store.state.startDate.getMonth() + 1).toString().padStart(2, '0'), + // this.$store.state.startDate.getDate().toString().padStart(2, '0') + // ].join('-'); }, set(value) { - let - [year, month, day] = value.split('-'), - dValue = new Date(year, month-1, day); + // let + // [year, month, day] = value.split('-'), + // dValue = new Date(year, month-1, day); - this.$store.dispatch('setStartDate', dValue); + this.$store.dispatch('setStartDate', value); } } } diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/HouseholdMembersEditor/store/index.js b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/HouseholdMembersEditor/store/index.js index cc5ab497c..fcb12d9f5 100644 --- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/HouseholdMembersEditor/store/index.js +++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/HouseholdMembersEditor/store/index.js @@ -2,7 +2,7 @@ import { createStore } from 'vuex'; import { householdMove, fetchHouseholdSuggestionByAccompanyingPeriod, fetchAddressSuggestionByPerson} from './../api.js'; import { fetchResults } from 'ChillMainAssets/lib/api/apiMethods.js' import { fetchHouseholdByAddressReference } from 'ChillPersonAssets/lib/household.js'; -import { datetimeToISO } from 'ChillMainAssets/chill/js/date.js'; +import { datetimeToISO, dateToISO, ISOToDate } from 'ChillMainAssets/chill/js/date.js'; const debug = process.env.NODE_ENV !== 'production'; @@ -30,7 +30,7 @@ const store = createStore({ } return 0; }), - startDate: new Date(), + startDate: dateToISO(new Date()), /** * Indicates if the destination is: * @@ -278,7 +278,7 @@ const store = createStore({ type: conc.person.type }, start_date: { - datetime: datetimeToISO(state.startDate) + datetime: datetimeToISO(ISOToDate(state.startDate)) } }; From e663bae5c4d492f471eead0881c69e76b7c858ff Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Wed, 6 Apr 2022 11:26:04 +0200 Subject: [PATCH 25/79] fix datepicker for social action edit form. still a problem with the display of already set evaluation dates... need to be transformed to correct format to display --- .../vuejs/AccompanyingCourseWorkEdit/App.vue | 8 ++++---- .../components/FormEvaluation.vue | 12 ++++++------ .../vuejs/AccompanyingCourseWorkEdit/store.js | 16 ++++++++-------- 3 files changed, 18 insertions(+), 18 deletions(-) diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourseWorkEdit/App.vue b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourseWorkEdit/App.vue index bcfa53e45..668385b8a 100644 --- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourseWorkEdit/App.vue +++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourseWorkEdit/App.vue @@ -439,18 +439,18 @@ export default { ]), startDate: { get() { - return dateToISO(this.$store.state.startDate); + return this.$store.state.startDate; }, set(v) { - this.$store.commit('setStartDate', ISOToDate(v)); + this.$store.commit('setStartDate', v); } }, endDate: { get() { - return dateToISO(this.$store.state.endDate); + return this.$store.state.endDate; }, set(v) { - this.$store.commit('setEndDate', ISOToDate(v)); + this.$store.commit('setEndDate', v); } }, note: { diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourseWorkEdit/components/FormEvaluation.vue b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourseWorkEdit/components/FormEvaluation.vue index eff62bbbb..d2b17ec2c 100644 --- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourseWorkEdit/components/FormEvaluation.vue +++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourseWorkEdit/components/FormEvaluation.vue @@ -306,26 +306,26 @@ export default { }, startDate: { get() { - return dateToISO(this.evaluation.startDate); + return this.evaluation.startDate; }, set(v) { - this.$store.commit('setEvaluationStartDate', { key: this.evaluation.key, date: ISOToDate(v) }); + this.$store.commit('setEvaluationStartDate', { key: this.evaluation.key, date: v }); } }, endDate: { get() { - return dateToISO(this.evaluation.endDate); + return this.evaluation.endDate; }, set(v) { - this.$store.commit('setEvaluationEndDate', { key: this.evaluation.key, date: ISOToDate(v) }); + this.$store.commit('setEvaluationEndDate', { key: this.evaluation.key, date: v }); } }, maxDate: { get() { - return dateToISO(this.evaluation.maxDate); + return this.evaluation.maxDate; }, set(v) { - this.$store.commit('setEvaluationMaxDate', { key: this.evaluation.key, date: ISOToDate(v) }); + this.$store.commit('setEvaluationMaxDate', { key: this.evaluation.key, date: v }); } }, warningInterval: { diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourseWorkEdit/store.js b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourseWorkEdit/store.js index 4ce0b8ebe..0bfe61d94 100644 --- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourseWorkEdit/store.js +++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourseWorkEdit/store.js @@ -1,5 +1,5 @@ import { createStore } from 'vuex'; -import { datetimeToISO, ISOToDatetime, intervalDaysToISO, intervalISOToDays } from 'ChillMainAssets/chill/js/date.js'; +import { dateToISO, ISOToDate, datetimeToISO, ISOToDatetime, intervalDaysToISO, intervalISOToDays } from 'ChillMainAssets/chill/js/date.js'; import { findSocialActionsBySocialIssue } from 'ChillPersonAssets/vuejs/_api/SocialWorkSocialAction.js'; import { create } from 'ChillPersonAssets/vuejs/_api/AccompanyingCourseWork.js'; import { fetchResults, makeFetch } from 'ChillMainAssets/lib/api/apiMethods.js'; @@ -13,9 +13,9 @@ const store = createStore({ state: { work: window.accompanyingCourseWork, startDate: window.accompanyingCourseWork.startDate !== null ? - ISOToDatetime(window.accompanyingCourseWork.startDate.datetime) : null, + dateToISO(new Date(window.accompanyingCourseWork.startDate.datetime)) : null, endDate: window.accompanyingCourseWork.endDate !== null ? - ISOToDatetime(window.accompanyingCourseWork.endDate.datetime) : null, + dateToISO(new Date(window.accompanyingCourseWork.endDate.datetime)) : null, note: window.accompanyingCourseWork.note, goalsPicked: window.accompanyingCourseWork.goals, goalsForAction: [], @@ -73,10 +73,10 @@ const store = createStore({ type: 'accompanying_period_work', id: state.work.id, startDate: state.startDate === null ? null : { - datetime: datetimeToISO(state.startDate) + datetime: datetimeToISO(ISOToDate(state.startDate)) }, endDate: state.endDate === null ? null : { - datetime: datetimeToISO(state.endDate) + datetime: datetimeToISO(ISOToDate(state.endDate)) }, note: state.note, persons: state.personsPicked.map(p => ({id: p.id, type: p.type})), @@ -110,9 +110,9 @@ const store = createStore({ id: e.evaluation.id, type: e.evaluation.type }, - startDate: e.startDate !== null ? { datetime: datetimeToISO(e.startDate) } : null, - endDate: e.endDate !== null ? { datetime: datetimeToISO(e.endDate) } : null, - maxDate: e.maxDate !== null ? { datetime: datetimeToISO(e.maxDate) } : null, + startDate: e.startDate !== null ? { datetime: datetimeToISO(ISOToDate(e.startDate)) } : null, + endDate: e.endDate !== null ? { datetime: datetimeToISO(ISOToDate(e.endDate)) } : null, + maxDate: e.maxDate !== null ? { datetime: datetimeToISO(ISOToDate(e.maxDate)) } : null, warningInterval: intervalDaysToISO(e.warningInterval), comment: e.comment, documents: e.documents From 988b67bd4b9122c85dc755ec4e36549cbcc43424 Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Thu, 3 Mar 2022 16:24:37 +0100 Subject: [PATCH 26/79] logic added to only keep youngest descendant. works for issue, seems not to for action --- .../ChillActivityBundle/Entity/Activity.php | 26 +++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/src/Bundle/ChillActivityBundle/Entity/Activity.php b/src/Bundle/ChillActivityBundle/Entity/Activity.php index 0a344236c..f80d4ab86 100644 --- a/src/Bundle/ChillActivityBundle/Entity/Activity.php +++ b/src/Bundle/ChillActivityBundle/Entity/Activity.php @@ -229,7 +229,18 @@ class Activity implements AccompanyingPeriodLinkedWithSocialIssuesEntityInterfac public function addSocialAction(SocialAction $socialAction): self { - if (!$this->socialActions->contains($socialAction)) { + $descendants = $socialAction->getDescendants(); + $inCollection = false; + + if(null != $descendants) { + foreach ($descendants as $d) { + $inCollection = $this->socialActions->contains($d); + } + } else { + $inCollection = $this->socialActions->contains($socialAction); + } + + if(!$inCollection) { $this->socialActions[] = $socialAction; } @@ -238,7 +249,18 @@ class Activity implements AccompanyingPeriodLinkedWithSocialIssuesEntityInterfac public function addSocialIssue(SocialIssue $socialIssue): self { - if (!$this->socialIssues->contains($socialIssue)) { + $descendants = $socialIssue->getDescendants(); + $inCollection = false; + + if(null != $descendants) { + foreach ($descendants as $d) { + $inCollection = $this->socialIssues->contains($d); + } + } else { + $inCollection = $this->socialIssues->contains($socialIssue); + } + + if(!$inCollection) { $this->socialIssues[] = $socialIssue; } From 432b105be567a5b1669565d3e052227e01e852a1 Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Thu, 3 Mar 2022 16:29:35 +0100 Subject: [PATCH 27/79] update changelog --- CHANGELOG.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index c278ca93e..cf4991560 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -87,6 +87,9 @@ and this project adheres to * [notification] Display of social action within workflow notification set to display block (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/537) * [onthefly] trim trailing whitespace in email of person and thirdparty (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/542) +* [action] Only youngest descendant is kept for social issues and actions (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/471) +## Test releases + ### test release 2022-02-21 * [notifications] Word 'un' changed to number '1' for notifications in user menu (https://gitlab.com/champs-libres/departement-de-la-vendee/accent-suivi-developpement/-/issues/483) From f35479e4d210e9f1810cd084d8e4f8d6112a402f Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Fri, 4 Mar 2022 12:06:53 +0100 Subject: [PATCH 28/79] fix logic in activity entity --- .../ChillActivityBundle/Entity/Activity.php | 28 +++++++++---------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/src/Bundle/ChillActivityBundle/Entity/Activity.php b/src/Bundle/ChillActivityBundle/Entity/Activity.php index f80d4ab86..034e6073c 100644 --- a/src/Bundle/ChillActivityBundle/Entity/Activity.php +++ b/src/Bundle/ChillActivityBundle/Entity/Activity.php @@ -230,18 +230,18 @@ class Activity implements AccompanyingPeriodLinkedWithSocialIssuesEntityInterfac public function addSocialAction(SocialAction $socialAction): self { $descendants = $socialAction->getDescendants(); - $inCollection = false; - if(null != $descendants) { + if(count($descendants) > 0) { foreach ($descendants as $d) { $inCollection = $this->socialActions->contains($d); + if ($inCollection) { + return $this; + } } } else { - $inCollection = $this->socialActions->contains($socialAction); - } - - if(!$inCollection) { - $this->socialActions[] = $socialAction; + if (!$this->socialActions->contains($socialAction)) { + $this->socialActions[] = $socialAction; + }; } return $this; @@ -250,18 +250,18 @@ class Activity implements AccompanyingPeriodLinkedWithSocialIssuesEntityInterfac public function addSocialIssue(SocialIssue $socialIssue): self { $descendants = $socialIssue->getDescendants(); - $inCollection = false; - if(null != $descendants) { + if(count($descendants) > 0) { foreach ($descendants as $d) { $inCollection = $this->socialIssues->contains($d); + if ($inCollection) { + return $this; + } } } else { - $inCollection = $this->socialIssues->contains($socialIssue); - } - - if(!$inCollection) { - $this->socialIssues[] = $socialIssue; + if (!$this->socialIssues->contains($socialIssue)) { + $this->socialIssues[] = $socialIssue; + }; } return $this; From 7851d9956e9c3bf07a8dac7e5c5f96763c6f004c Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Fri, 4 Mar 2022 12:07:29 +0100 Subject: [PATCH 29/79] csfixes --- src/Bundle/ChillActivityBundle/Entity/Activity.php | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/Bundle/ChillActivityBundle/Entity/Activity.php b/src/Bundle/ChillActivityBundle/Entity/Activity.php index 034e6073c..f183ced60 100644 --- a/src/Bundle/ChillActivityBundle/Entity/Activity.php +++ b/src/Bundle/ChillActivityBundle/Entity/Activity.php @@ -35,6 +35,7 @@ use Symfony\Component\Security\Core\User\UserInterface; use Symfony\Component\Serializer\Annotation\DiscriminatorMap; use Symfony\Component\Serializer\Annotation\Groups; use Symfony\Component\Serializer\Annotation\SerializedName; +use function count; /** * Class Activity. @@ -231,9 +232,10 @@ class Activity implements AccompanyingPeriodLinkedWithSocialIssuesEntityInterfac { $descendants = $socialAction->getDescendants(); - if(count($descendants) > 0) { + if (count($descendants) > 0) { foreach ($descendants as $d) { $inCollection = $this->socialActions->contains($d); + if ($inCollection) { return $this; } @@ -241,7 +243,7 @@ class Activity implements AccompanyingPeriodLinkedWithSocialIssuesEntityInterfac } else { if (!$this->socialActions->contains($socialAction)) { $this->socialActions[] = $socialAction; - }; + } } return $this; @@ -251,9 +253,10 @@ class Activity implements AccompanyingPeriodLinkedWithSocialIssuesEntityInterfac { $descendants = $socialIssue->getDescendants(); - if(count($descendants) > 0) { + if (count($descendants) > 0) { foreach ($descendants as $d) { $inCollection = $this->socialIssues->contains($d); + if ($inCollection) { return $this; } @@ -261,7 +264,7 @@ class Activity implements AccompanyingPeriodLinkedWithSocialIssuesEntityInterfac } else { if (!$this->socialIssues->contains($socialIssue)) { $this->socialIssues[] = $socialIssue; - }; + } } return $this; From d81a41bb1783d6b4c27de27b77df6c33511cc10b Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Mon, 7 Mar 2022 14:53:54 +0100 Subject: [PATCH 30/79] Test added for activity-social action and social issue --- .../Tests/Entity/ActivityTest.php | 98 +++++++++++++++++++ 1 file changed, 98 insertions(+) create mode 100644 src/Bundle/ChillActivityBundle/Tests/Entity/ActivityTest.php diff --git a/src/Bundle/ChillActivityBundle/Tests/Entity/ActivityTest.php b/src/Bundle/ChillActivityBundle/Tests/Entity/ActivityTest.php new file mode 100644 index 000000000..c67c99894 --- /dev/null +++ b/src/Bundle/ChillActivityBundle/Tests/Entity/ActivityTest.php @@ -0,0 +1,98 @@ +addChild($child); + $grandChild = new SocialAction(); + $child->addChild($grandChild); + + $activity = new Activity(); + + $activity->addSocialAction($parent); + + $this->assertCount(1, $activity->getSocialActions()); + $this->assertContains($parent, $activity->getSocialActions()); + + $activity->addSocialAction($grandChild); + + $this->assertCount(1, $activity->getSocialActions()); + $this->assertContains($grandChild, $activity->getSocialActions()); + $this->assertNotContains($parent, $activity->getSocialActions()); + + $activity->addSocialAction($child); + + $this->assertCount(1, $activity->getSocialActions()); + $this->assertContains($grandChild, $activity->getSocialActions()); + $this->assertNotContains($parent, $activity->getSocialActions()); + $this->assertNotContains($child, $activity->getSocialActions()); + + $activity->addSocialAction($another = new SocialAction()); + + $this->assertCount(2, $activity->getSocialActions()); + $this->assertContains($grandChild, $activity->getSocialActions()); + $this->assertContains($another, $activity->getSocialActions()); + $this->assertNotContains($parent, $activity->getSocialActions()); + $this->assertNotContains($child, $activity->getSocialActions()); + } + + public function testHierarchySocialIssues(): void + { + $parent = new SocialIssue(); + $child = new SocialIssue(); + + $parent->addChild($child); + $grandChild = new SocialIssue(); + $child->addChild($grandChild); + + $activity = new Activity(); + + $activity->addSocialIssue($parent); + + $this->assertCount(1, $activity->getSocialIssues()); + $this->assertContains($parent, $activity->getSocialIssues()); + + $activity->addSocialIssue($grandChild); + + $this->assertCount(1, $activity->getSocialIssues()); + $this->assertContains($grandChild, $activity->getSocialIssues()); + $this->assertNotContains($parent, $activity->getSocialIssues()); + + $activity->addSocialIssue($child); + + $this->assertCount(1, $activity->getSocialIssues()); + $this->assertContains($grandChild, $activity->getSocialIssues()); + $this->assertNotContains($parent, $activity->getSocialIssues()); + $this->assertNotContains($child, $activity->getSocialIssues()); + + $activity->addSocialIssue($another = new SocialIssue()); + + $this->assertCount(2, $activity->getSocialIssues()); + $this->assertContains($grandChild, $activity->getSocialIssues()); + $this->assertContains($another, $activity->getSocialIssues()); + $this->assertNotContains($parent, $activity->getSocialIssues()); + $this->assertNotContains($child, $activity->getSocialIssues()); + } + +} \ No newline at end of file From ea21f2d9c4070fa98341a056700e6d9871c1acea Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Wed, 16 Mar 2022 11:55:19 +0100 Subject: [PATCH 31/79] improvement, but still not correct --- .../ChillActivityBundle/Entity/Activity.php | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/src/Bundle/ChillActivityBundle/Entity/Activity.php b/src/Bundle/ChillActivityBundle/Entity/Activity.php index f183ced60..db16ac9f6 100644 --- a/src/Bundle/ChillActivityBundle/Entity/Activity.php +++ b/src/Bundle/ChillActivityBundle/Entity/Activity.php @@ -235,15 +235,13 @@ class Activity implements AccompanyingPeriodLinkedWithSocialIssuesEntityInterfac if (count($descendants) > 0) { foreach ($descendants as $d) { $inCollection = $this->socialActions->contains($d); - if ($inCollection) { return $this; } } - } else { - if (!$this->socialActions->contains($socialAction)) { - $this->socialActions[] = $socialAction; - } + } + if (!$this->socialActions->contains($socialAction)) { + $this->socialActions[] = $socialAction; } return $this; @@ -256,15 +254,14 @@ class Activity implements AccompanyingPeriodLinkedWithSocialIssuesEntityInterfac if (count($descendants) > 0) { foreach ($descendants as $d) { $inCollection = $this->socialIssues->contains($d); - if ($inCollection) { return $this; } } - } else { - if (!$this->socialIssues->contains($socialIssue)) { - $this->socialIssues[] = $socialIssue; - } + } + + if (!$this->socialIssues->contains($socialIssue)) { + $this->socialIssues[] = $socialIssue; } return $this; From f09870931c7f8b3e945f7e52f2007b0839a0f384 Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Tue, 22 Mar 2022 13:45:20 +0100 Subject: [PATCH 32/79] switch to using getDescendantsWithThis() --- src/Bundle/ChillActivityBundle/Entity/Activity.php | 13 +++++-------- .../Entity/SocialWork/SocialAction.php | 2 +- .../Entity/SocialWork/SocialIssue.php | 2 +- 3 files changed, 7 insertions(+), 10 deletions(-) diff --git a/src/Bundle/ChillActivityBundle/Entity/Activity.php b/src/Bundle/ChillActivityBundle/Entity/Activity.php index db16ac9f6..ac67a73e4 100644 --- a/src/Bundle/ChillActivityBundle/Entity/Activity.php +++ b/src/Bundle/ChillActivityBundle/Entity/Activity.php @@ -230,7 +230,7 @@ class Activity implements AccompanyingPeriodLinkedWithSocialIssuesEntityInterfac public function addSocialAction(SocialAction $socialAction): self { - $descendants = $socialAction->getDescendants(); + $descendants = $socialAction->getDescendantsWithThis(); if (count($descendants) > 0) { foreach ($descendants as $d) { @@ -240,16 +240,14 @@ class Activity implements AccompanyingPeriodLinkedWithSocialIssuesEntityInterfac } } } - if (!$this->socialActions->contains($socialAction)) { - $this->socialActions[] = $socialAction; - } + $this->socialActions[] = $socialAction; return $this; } public function addSocialIssue(SocialIssue $socialIssue): self { - $descendants = $socialIssue->getDescendants(); + $descendants = $socialIssue->getDescendantsWithThis(); if (count($descendants) > 0) { foreach ($descendants as $d) { @@ -260,9 +258,8 @@ class Activity implements AccompanyingPeriodLinkedWithSocialIssuesEntityInterfac } } - if (!$this->socialIssues->contains($socialIssue)) { - $this->socialIssues[] = $socialIssue; - } + $this->socialIssues[] = $socialIssue; + return $this; } diff --git a/src/Bundle/ChillPersonBundle/Entity/SocialWork/SocialAction.php b/src/Bundle/ChillPersonBundle/Entity/SocialWork/SocialAction.php index ec5e5a8e5..01f30f140 100644 --- a/src/Bundle/ChillPersonBundle/Entity/SocialWork/SocialAction.php +++ b/src/Bundle/ChillPersonBundle/Entity/SocialWork/SocialAction.php @@ -169,7 +169,7 @@ class SocialAction } /** - * @return Collection|self[] All the descendants with the current entity (this) + * @return Collection|self[] All the descendants including the current entity (this) */ public function getDescendantsWithThis(): Collection { diff --git a/src/Bundle/ChillPersonBundle/Entity/SocialWork/SocialIssue.php b/src/Bundle/ChillPersonBundle/Entity/SocialWork/SocialIssue.php index c735c0132..fb277f56c 100644 --- a/src/Bundle/ChillPersonBundle/Entity/SocialWork/SocialIssue.php +++ b/src/Bundle/ChillPersonBundle/Entity/SocialWork/SocialIssue.php @@ -202,7 +202,7 @@ class SocialIssue } /** - * @return Collection|self[] All the descendants with the current entity (this) + * @return Collection|self[] All the descendants including the current entity (this) */ public function getDescendantsWithThis(): Collection { From a78c62789c88b43f982700d744a14cdf028673cd Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Fri, 8 Apr 2022 18:56:37 +0200 Subject: [PATCH 33/79] if parent in collection replace with child, problem, sibling isn't added --- src/Bundle/ChillActivityBundle/Entity/Activity.php | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/Bundle/ChillActivityBundle/Entity/Activity.php b/src/Bundle/ChillActivityBundle/Entity/Activity.php index ac67a73e4..f157401a7 100644 --- a/src/Bundle/ChillActivityBundle/Entity/Activity.php +++ b/src/Bundle/ChillActivityBundle/Entity/Activity.php @@ -231,6 +231,18 @@ class Activity implements AccompanyingPeriodLinkedWithSocialIssuesEntityInterfac public function addSocialAction(SocialAction $socialAction): self { $descendants = $socialAction->getDescendantsWithThis(); + $parent = $socialAction->getParent(); + + dump($this->socialActions); + dump($parent); + + $parentKey = array_search($parent, $this->socialActions->toArray()); + + if (null !== $parentKey) { + dump(true); + $this->socialActions[$parentKey] = $socialAction; + // return $this; + } if (count($descendants) > 0) { foreach ($descendants as $d) { From 5eea202586de5c49098949c7fd88e9939f22b9ae Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Fri, 8 Apr 2022 19:04:13 +0200 Subject: [PATCH 34/79] fix adding sibling action --- src/Bundle/ChillActivityBundle/Entity/Activity.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Bundle/ChillActivityBundle/Entity/Activity.php b/src/Bundle/ChillActivityBundle/Entity/Activity.php index f157401a7..016c4b6fa 100644 --- a/src/Bundle/ChillActivityBundle/Entity/Activity.php +++ b/src/Bundle/ChillActivityBundle/Entity/Activity.php @@ -237,8 +237,9 @@ class Activity implements AccompanyingPeriodLinkedWithSocialIssuesEntityInterfac dump($parent); $parentKey = array_search($parent, $this->socialActions->toArray()); + dump($parentKey); - if (null !== $parentKey) { + if (false !== $parentKey) { dump(true); $this->socialActions[$parentKey] = $socialAction; // return $this; From 03b0a8766eefbae23144df14fbf58cb0abafe444 Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Fri, 8 Apr 2022 19:12:11 +0200 Subject: [PATCH 35/79] remove dumps --- src/Bundle/ChillActivityBundle/Entity/Activity.php | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/Bundle/ChillActivityBundle/Entity/Activity.php b/src/Bundle/ChillActivityBundle/Entity/Activity.php index 016c4b6fa..dba4f9c62 100644 --- a/src/Bundle/ChillActivityBundle/Entity/Activity.php +++ b/src/Bundle/ChillActivityBundle/Entity/Activity.php @@ -233,14 +233,9 @@ class Activity implements AccompanyingPeriodLinkedWithSocialIssuesEntityInterfac $descendants = $socialAction->getDescendantsWithThis(); $parent = $socialAction->getParent(); - dump($this->socialActions); - dump($parent); - $parentKey = array_search($parent, $this->socialActions->toArray()); - dump($parentKey); if (false !== $parentKey) { - dump(true); $this->socialActions[$parentKey] = $socialAction; // return $this; } From ebc4ec0d7c2b5eba3d571b1de57b1fd21c45d332 Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Tue, 19 Apr 2022 15:09:25 +0200 Subject: [PATCH 36/79] updating openingdate parcours fixed --- .../components/StartDate.vue | 26 ++++++++++++++----- .../vuejs/AccompanyingCourse/js/i18n.js | 2 +- .../vuejs/AccompanyingCourse/store/index.js | 6 +---- 3 files changed, 21 insertions(+), 13 deletions(-) diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/components/StartDate.vue b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/components/StartDate.vue index 349581452..b6a0344e8 100644 --- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/components/StartDate.vue +++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/components/StartDate.vue @@ -5,9 +5,9 @@
- -
- +
+ +
@@ -23,10 +23,12 @@ import { mapState, mapGetters } from 'vuex'; export default { name: 'startDate', methods: { - updateStartDate(event) { - const date = event.target.value; - // console.log(date) + updateStartDate(e) { + e.preventDefault(); + const date = e.target.previousSibling.value; + this.$store.dispatch('updateStartDate', date) + .then(this.$toast.open({type: 'success', message: this.$t('startdate.update')})) .catch(({name, violations}) => { if (name === 'ValidationException' || name === 'AccessException') { violations.forEach((violation) => this.$toast.open({message: violation})); @@ -43,4 +45,14 @@ export default { } } - \ No newline at end of file + + + \ No newline at end of file diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/js/i18n.js b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/js/i18n.js index f1e2de958..a3a8ede2d 100644 --- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/js/i18n.js +++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/js/i18n.js @@ -153,7 +153,7 @@ const appMessages = { }, startdate: { change: "Date d'ouverture", - date: "Date d'ouverture", + update: "La nouvelle date d'ouverture a été bien enregistrée" }, // catch errors 'Error while updating AccompanyingPeriod Course.': "Erreur du serveur lors de la mise à jour du parcours d'accompagnement.", diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/store/index.js b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/store/index.js index 06a3606ab..5d73aa2ed 100644 --- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/store/index.js +++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/store/index.js @@ -322,7 +322,6 @@ let initPromise = (root) => Promise.all([getScopesPromise(root), accompanyingCou } }, updateStartDate(state, date) { - console.log('new state date', date) state.accompanyingCourse.openingDate = date; } }, @@ -814,11 +813,8 @@ let initPromise = (root) => Promise.all([getScopesPromise(root), accompanyingCou }) }, updateStartDate({commit}, payload) { - console.log('payload', payload) - const date = ISOToDate(payload); const url = `/api/1.0/person/accompanying-course/${id}.json`; - const body = { type: "accompanying_period", openingDate: { datetime: datetimeToISO(date) }}; - console.log('body', body) + const body = { type: "accompanying_period", openingDate: { datetime: datetimeToISO(ISOToDate(payload)) }}; return makeFetch('PATCH', url, body) .then((response) => { commit('updateStartDate', response.openingDate); From 8882c99f5a56a44edc7f5024576c30fe3ae257f4 Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Tue, 5 Apr 2022 15:56:02 +0200 Subject: [PATCH 37/79] fix datepicker for social action --- .../public/vuejs/AccompanyingCourseWorkCreate/App.vue | 9 ++++----- .../public/vuejs/AccompanyingCourseWorkCreate/store.js | 7 ++++--- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourseWorkCreate/App.vue b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourseWorkCreate/App.vue index 503a00c59..758cd7e5e 100644 --- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourseWorkCreate/App.vue +++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourseWorkCreate/App.vue @@ -227,19 +227,18 @@ export default { }, startDate: { get() { - let d = this.$store.state.startDate; - return dateToISO(d); + return this.$store.state.startDate; }, set(value) { - this.$store.commit('setStartDate', ISOToDate(value)); + this.$store.commit('setStartDate', value); } }, endDate: { get() { - return dateToISO(this.$store.state.endDate); + return this.$store.state.endDate; }, set(value) { - this.$store.commit('setEndDate', ISOToDate(value)); + this.$store.commit('setEndDate', value); } }, setSocialIssue: { diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourseWorkCreate/store.js b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourseWorkCreate/store.js index 408115257..7b6c2b22e 100644 --- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourseWorkCreate/store.js +++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourseWorkCreate/store.js @@ -1,6 +1,6 @@ import { createStore } from 'vuex'; -import { datetimeToISO } from 'ChillMainAssets/chill/js/date.js'; +import { datetimeToISO, dateToISO, ISOToDate, ISOToDatetime } from 'ChillMainAssets/chill/js/date.js'; import { findSocialActionsBySocialIssue } from 'ChillPersonAssets/vuejs/_api/SocialWorkSocialAction.js'; // import { create } from 'ChillPersonAssets/vuejs/_api/AccompanyingCourseWork.js'; import { makeFetch } from 'ChillMainAssets/lib/api/apiMethods'; @@ -47,7 +47,7 @@ const store = createStore({ id: state.socialActionPicked.id }, startDate: { - datetime: datetimeToISO(state.startDate) + datetime: datetimeToISO(ISOToDate(state.startDate)) }, persons: [] }; @@ -61,7 +61,7 @@ const store = createStore({ if (null !== state.endDate) { payload.endDate = { - datetime: datetimeToISO(state.endDate) + datetime: datetimeToISO(ISOToDate(state.endDate)) }; } @@ -111,6 +111,7 @@ const store = createStore({ state.startDate = date; }, setEndDate(state, date) { + console.log(date) state.endDate = date; }, setPersonsPickedIds(state, ids) { From 66ab38c60ff03db6e6f852be2e5f0cba04b97819 Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Tue, 5 Apr 2022 16:03:07 +0200 Subject: [PATCH 38/79] prefill startdate with now --- .../public/vuejs/AccompanyingCourseWorkCreate/store.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourseWorkCreate/store.js b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourseWorkCreate/store.js index 7b6c2b22e..3c2e034d7 100644 --- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourseWorkCreate/store.js +++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourseWorkCreate/store.js @@ -20,7 +20,7 @@ const store = createStore({ .map(p => p.person), personsReachables: window.accompanyingCourse.participations.filter(p => p.endDate == null) .map(p => p.person), - startDate: new Date(), + startDate: dateToISO(new Date()), endDate: null, isLoadingSocialActions: false, isPostingWork: false, From de9d2aa88527de3390b70b53c44ad0968fda5ccf Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Wed, 6 Apr 2022 11:24:01 +0200 Subject: [PATCH 39/79] fix datepicker for householdmember editor --- .../components/Dates.vue | 19 ++++++++++--------- .../HouseholdMembersEditor/store/index.js | 6 +++--- 2 files changed, 13 insertions(+), 12 deletions(-) diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/HouseholdMembersEditor/components/Dates.vue b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/HouseholdMembersEditor/components/Dates.vue index 040d316bb..03feb0329 100644 --- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/HouseholdMembersEditor/components/Dates.vue +++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/HouseholdMembersEditor/components/Dates.vue @@ -66,18 +66,19 @@ export default { }, startDate: { get() { - return [ - this.$store.state.startDate.getFullYear(), - (this.$store.state.startDate.getMonth() + 1).toString().padStart(2, '0'), - this.$store.state.startDate.getDate().toString().padStart(2, '0') - ].join('-'); + return this.$store.state.startDate; + // return [ + // this.$store.state.startDate.getFullYear(), + // (this.$store.state.startDate.getMonth() + 1).toString().padStart(2, '0'), + // this.$store.state.startDate.getDate().toString().padStart(2, '0') + // ].join('-'); }, set(value) { - let - [year, month, day] = value.split('-'), - dValue = new Date(year, month-1, day); + // let + // [year, month, day] = value.split('-'), + // dValue = new Date(year, month-1, day); - this.$store.dispatch('setStartDate', dValue); + this.$store.dispatch('setStartDate', value); } } } diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/HouseholdMembersEditor/store/index.js b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/HouseholdMembersEditor/store/index.js index f09b19787..87e465a8d 100644 --- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/HouseholdMembersEditor/store/index.js +++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/HouseholdMembersEditor/store/index.js @@ -2,7 +2,7 @@ import { createStore } from 'vuex'; import { householdMove, fetchHouseholdSuggestionByAccompanyingPeriod, fetchAddressSuggestionByPerson} from './../api.js'; import { fetchResults } from 'ChillMainAssets/lib/api/apiMethods.js' import { fetchHouseholdByAddressReference } from 'ChillPersonAssets/lib/household.js'; -import { datetimeToISO } from 'ChillMainAssets/chill/js/date.js'; +import { datetimeToISO, dateToISO, ISOToDate } from 'ChillMainAssets/chill/js/date.js'; const debug = process.env.NODE_ENV !== 'production'; @@ -30,7 +30,7 @@ const store = createStore({ } return 0; }), - startDate: new Date(), + startDate: dateToISO(new Date()), /** * Indicates if the destination is: * @@ -278,7 +278,7 @@ const store = createStore({ type: conc.person.type }, start_date: { - datetime: datetimeToISO(state.startDate) + datetime: datetimeToISO(ISOToDate(state.startDate)) } }; From 65e6471a02ac72453c79151188025915755b3e08 Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Wed, 6 Apr 2022 11:26:04 +0200 Subject: [PATCH 40/79] fix datepicker for social action edit form. still a problem with the display of already set evaluation dates... need to be transformed to correct format to display --- .../vuejs/AccompanyingCourseWorkEdit/App.vue | 8 ++++---- .../components/FormEvaluation.vue | 12 ++++++------ .../vuejs/AccompanyingCourseWorkEdit/store.js | 16 ++++++++-------- 3 files changed, 18 insertions(+), 18 deletions(-) diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourseWorkEdit/App.vue b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourseWorkEdit/App.vue index bcfa53e45..668385b8a 100644 --- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourseWorkEdit/App.vue +++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourseWorkEdit/App.vue @@ -439,18 +439,18 @@ export default { ]), startDate: { get() { - return dateToISO(this.$store.state.startDate); + return this.$store.state.startDate; }, set(v) { - this.$store.commit('setStartDate', ISOToDate(v)); + this.$store.commit('setStartDate', v); } }, endDate: { get() { - return dateToISO(this.$store.state.endDate); + return this.$store.state.endDate; }, set(v) { - this.$store.commit('setEndDate', ISOToDate(v)); + this.$store.commit('setEndDate', v); } }, note: { diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourseWorkEdit/components/FormEvaluation.vue b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourseWorkEdit/components/FormEvaluation.vue index 53e2b72f3..cad070de3 100644 --- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourseWorkEdit/components/FormEvaluation.vue +++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourseWorkEdit/components/FormEvaluation.vue @@ -309,26 +309,26 @@ export default { }, startDate: { get() { - return dateToISO(this.evaluation.startDate); + return this.evaluation.startDate; }, set(v) { - this.$store.commit('setEvaluationStartDate', { key: this.evaluation.key, date: ISOToDate(v) }); + this.$store.commit('setEvaluationStartDate', { key: this.evaluation.key, date: v }); } }, endDate: { get() { - return dateToISO(this.evaluation.endDate); + return this.evaluation.endDate; }, set(v) { - this.$store.commit('setEvaluationEndDate', { key: this.evaluation.key, date: ISOToDate(v) }); + this.$store.commit('setEvaluationEndDate', { key: this.evaluation.key, date: v }); } }, maxDate: { get() { - return dateToISO(this.evaluation.maxDate); + return this.evaluation.maxDate; }, set(v) { - this.$store.commit('setEvaluationMaxDate', { key: this.evaluation.key, date: ISOToDate(v) }); + this.$store.commit('setEvaluationMaxDate', { key: this.evaluation.key, date: v }); } }, warningInterval: { diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourseWorkEdit/store.js b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourseWorkEdit/store.js index 4ce0b8ebe..0bfe61d94 100644 --- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourseWorkEdit/store.js +++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourseWorkEdit/store.js @@ -1,5 +1,5 @@ import { createStore } from 'vuex'; -import { datetimeToISO, ISOToDatetime, intervalDaysToISO, intervalISOToDays } from 'ChillMainAssets/chill/js/date.js'; +import { dateToISO, ISOToDate, datetimeToISO, ISOToDatetime, intervalDaysToISO, intervalISOToDays } from 'ChillMainAssets/chill/js/date.js'; import { findSocialActionsBySocialIssue } from 'ChillPersonAssets/vuejs/_api/SocialWorkSocialAction.js'; import { create } from 'ChillPersonAssets/vuejs/_api/AccompanyingCourseWork.js'; import { fetchResults, makeFetch } from 'ChillMainAssets/lib/api/apiMethods.js'; @@ -13,9 +13,9 @@ const store = createStore({ state: { work: window.accompanyingCourseWork, startDate: window.accompanyingCourseWork.startDate !== null ? - ISOToDatetime(window.accompanyingCourseWork.startDate.datetime) : null, + dateToISO(new Date(window.accompanyingCourseWork.startDate.datetime)) : null, endDate: window.accompanyingCourseWork.endDate !== null ? - ISOToDatetime(window.accompanyingCourseWork.endDate.datetime) : null, + dateToISO(new Date(window.accompanyingCourseWork.endDate.datetime)) : null, note: window.accompanyingCourseWork.note, goalsPicked: window.accompanyingCourseWork.goals, goalsForAction: [], @@ -73,10 +73,10 @@ const store = createStore({ type: 'accompanying_period_work', id: state.work.id, startDate: state.startDate === null ? null : { - datetime: datetimeToISO(state.startDate) + datetime: datetimeToISO(ISOToDate(state.startDate)) }, endDate: state.endDate === null ? null : { - datetime: datetimeToISO(state.endDate) + datetime: datetimeToISO(ISOToDate(state.endDate)) }, note: state.note, persons: state.personsPicked.map(p => ({id: p.id, type: p.type})), @@ -110,9 +110,9 @@ const store = createStore({ id: e.evaluation.id, type: e.evaluation.type }, - startDate: e.startDate !== null ? { datetime: datetimeToISO(e.startDate) } : null, - endDate: e.endDate !== null ? { datetime: datetimeToISO(e.endDate) } : null, - maxDate: e.maxDate !== null ? { datetime: datetimeToISO(e.maxDate) } : null, + startDate: e.startDate !== null ? { datetime: datetimeToISO(ISOToDate(e.startDate)) } : null, + endDate: e.endDate !== null ? { datetime: datetimeToISO(ISOToDate(e.endDate)) } : null, + maxDate: e.maxDate !== null ? { datetime: datetimeToISO(ISOToDate(e.maxDate)) } : null, warningInterval: intervalDaysToISO(e.warningInterval), comment: e.comment, documents: e.documents From bc550ea42aa1d13447ef0f0d658cdf6f51e2c349 Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Tue, 19 Apr 2022 15:09:25 +0200 Subject: [PATCH 41/79] updating openingdate parcours fixed --- .../components/StartDate.vue | 26 ++++++++++++++----- .../vuejs/AccompanyingCourse/js/i18n.js | 2 +- .../vuejs/AccompanyingCourse/store/index.js | 6 +---- 3 files changed, 21 insertions(+), 13 deletions(-) diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/components/StartDate.vue b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/components/StartDate.vue index 349581452..b6a0344e8 100644 --- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/components/StartDate.vue +++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/components/StartDate.vue @@ -5,9 +5,9 @@
- -
- +
+ +
@@ -23,10 +23,12 @@ import { mapState, mapGetters } from 'vuex'; export default { name: 'startDate', methods: { - updateStartDate(event) { - const date = event.target.value; - // console.log(date) + updateStartDate(e) { + e.preventDefault(); + const date = e.target.previousSibling.value; + this.$store.dispatch('updateStartDate', date) + .then(this.$toast.open({type: 'success', message: this.$t('startdate.update')})) .catch(({name, violations}) => { if (name === 'ValidationException' || name === 'AccessException') { violations.forEach((violation) => this.$toast.open({message: violation})); @@ -43,4 +45,14 @@ export default { } } - \ No newline at end of file + + + \ No newline at end of file diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/js/i18n.js b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/js/i18n.js index f1e2de958..a3a8ede2d 100644 --- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/js/i18n.js +++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/js/i18n.js @@ -153,7 +153,7 @@ const appMessages = { }, startdate: { change: "Date d'ouverture", - date: "Date d'ouverture", + update: "La nouvelle date d'ouverture a été bien enregistrée" }, // catch errors 'Error while updating AccompanyingPeriod Course.': "Erreur du serveur lors de la mise à jour du parcours d'accompagnement.", diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/store/index.js b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/store/index.js index 06a3606ab..5d73aa2ed 100644 --- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/store/index.js +++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/store/index.js @@ -322,7 +322,6 @@ let initPromise = (root) => Promise.all([getScopesPromise(root), accompanyingCou } }, updateStartDate(state, date) { - console.log('new state date', date) state.accompanyingCourse.openingDate = date; } }, @@ -814,11 +813,8 @@ let initPromise = (root) => Promise.all([getScopesPromise(root), accompanyingCou }) }, updateStartDate({commit}, payload) { - console.log('payload', payload) - const date = ISOToDate(payload); const url = `/api/1.0/person/accompanying-course/${id}.json`; - const body = { type: "accompanying_period", openingDate: { datetime: datetimeToISO(date) }}; - console.log('body', body) + const body = { type: "accompanying_period", openingDate: { datetime: datetimeToISO(ISOToDate(payload)) }}; return makeFetch('PATCH', url, body) .then((response) => { commit('updateStartDate', response.openingDate); From 0ce23230da611069b094b90f2a554233df3df069 Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Wed, 20 Apr 2022 13:32:51 +0200 Subject: [PATCH 42/79] fix evaluation datepickers in edit --- .../vuejs/AccompanyingCourseWorkEdit/App.vue | 10 +-- .../components/FormEvaluation.vue | 81 ++++++++++--------- .../vuejs/AccompanyingCourseWorkEdit/store.js | 7 +- 3 files changed, 50 insertions(+), 48 deletions(-) diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourseWorkEdit/App.vue b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourseWorkEdit/App.vue index 668385b8a..bab64018a 100644 --- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourseWorkEdit/App.vue +++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourseWorkEdit/App.vue @@ -521,12 +521,12 @@ export default { this.$store.commit('removeReferrer', u); }, goToGenerateWorkflow({link}) { - console.log('save before leave to generate workflow') - const callback = (data) => { - window.location.assign(link); - }; + // console.log('save before leave to generate workflow') + const callback = (data) => { + window.location.assign(link); + }; - return this.$store.dispatch('submit', callback) + return this.$store.dispatch('submit', callback) .catch(e => { console.log(e); throw e; }); }, submit() { diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourseWorkEdit/components/FormEvaluation.vue b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourseWorkEdit/components/FormEvaluation.vue index cad070de3..ca0d16eec 100644 --- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourseWorkEdit/components/FormEvaluation.vue +++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourseWorkEdit/components/FormEvaluation.vue @@ -298,38 +298,39 @@ export default { } }, computed: { - ...mapState([ - 'isPosting' - ]), + ...mapState([ + 'isPosting' + ]), getTemplatesAvailables() { - return this.$store.getters.getTemplatesAvailablesForEvaluation(this.evaluation.evaluation); + return this.$store.getters.getTemplatesAvailablesForEvaluation(this.evaluation.evaluation); }, canGenerate() { - return !this.$store.state.isPosting && this.template !== null; + return !this.$store.state.isPosting && this.template !== null; }, startDate: { - get() { - return this.evaluation.startDate; - }, - set(v) { - this.$store.commit('setEvaluationStartDate', { key: this.evaluation.key, date: v }); - } + get() { + console.log('evaluation', this.evaluation); + return this.evaluation.startDate; + }, + set(v) { + this.$store.commit('setEvaluationStartDate', { key: this.evaluation.key, date: v }); + } }, endDate: { - get() { - return this.evaluation.endDate; - }, - set(v) { - this.$store.commit('setEvaluationEndDate', { key: this.evaluation.key, date: v }); - } + get() { + return this.evaluation.endDate; + }, + set(v) { + this.$store.commit('setEvaluationEndDate', { key: this.evaluation.key, date: v }); + } }, maxDate: { - get() { - return this.evaluation.maxDate; - }, - set(v) { - this.$store.commit('setEvaluationMaxDate', { key: this.evaluation.key, date: v }); - } + get() { + return this.evaluation.maxDate; + }, + set(v) { + this.$store.commit('setEvaluationMaxDate', { key: this.evaluation.key, date: v }); + } }, warningInterval: { get() { return this.evaluation.warningInterval; }, @@ -344,7 +345,7 @@ export default { ISOToDatetime, canEditDocument(document) { return 'storedObject' in document ? - this.mime.includes(document.storedObject.type) && document.storedObject.keyInfos.length === 0 : false; + this.mime.includes(document.storedObject.type) && document.storedObject.keyInfos.length === 0 : false; }, listAllStatus() { console.log('load all status'); @@ -360,16 +361,16 @@ export default { }, buildEditLink(storedObject) { return `/wopi/edit/${storedObject.uuid}?returnPath=` + encodeURIComponent( - window.location.pathname + window.location.search + window.location.hash); + window.location.pathname + window.location.search + window.location.hash); }, submitBeforeGenerate({template}) { - const callback = (data) => { - let evaluationId = data.accompanyingPeriodWorkEvaluations.find(e => e.key === this.evaluation.key).id; + const callback = (data) => { + let evaluationId = data.accompanyingPeriodWorkEvaluations.find(e => e.key === this.evaluation.key).id; - window.location.assign(buildLink(template, evaluationId, 'Chill\\PersonBundle\\Entity\\AccompanyingPeriod\\AccompanyingPeriodWorkEvaluation')); - }; + window.location.assign(buildLink(template, evaluationId, 'Chill\\PersonBundle\\Entity\\AccompanyingPeriod\\AccompanyingPeriodWorkEvaluation')); + }; - return this.$store.dispatch('submit', callback).catch(e => { console.log(e); throw e; }); + return this.$store.dispatch('submit', callback).catch(e => { console.log(e); throw e; }); }, onInputDocumentTitle(event) { const id = Number(event.target.id); @@ -395,20 +396,20 @@ export default { }, removeDocument(document) { if (window.confirm("Êtes-vous sûr·e de vouloir supprimer le document qui a pour titre \"" + document.title +"\" ?")) { - this.$store.commit('removeDocument', {key: this.evaluation.key, document: document}); + this.$store.commit('removeDocument', {key: this.evaluation.key, document: document}); } }, goToGenerateWorkflowEvaluationDocument({event, link, workflowName, payload}) { - const callback = (data) => { - let evaluation = data.accompanyingPeriodWorkEvaluations.find(e => e.key === this.evaluation.key); - let updatedDocument = evaluation.documents.find(d => d.key === payload.doc.key); - window.location.assign(buildLinkCreate(workflowName, - 'Chill\\PersonBundle\\Entity\\AccompanyingPeriod\\AccompanyingPeriodWorkEvaluationDocument', updatedDocument.id)); - }; + const callback = (data) => { + let evaluation = data.accompanyingPeriodWorkEvaluations.find(e => e.key === this.evaluation.key); + let updatedDocument = evaluation.documents.find(d => d.key === payload.doc.key); + window.location.assign(buildLinkCreate(workflowName, + 'Chill\\PersonBundle\\Entity\\AccompanyingPeriod\\AccompanyingPeriodWorkEvaluationDocument', updatedDocument.id)); + }; - return this.$store.dispatch('submit', callback) - .catch(e => { console.log(e); throw e; }); - }, + return this.$store.dispatch('submit', callback) + .catch(e => { console.log(e); throw e; }); + }, }, } diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourseWorkEdit/store.js b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourseWorkEdit/store.js index 0bfe61d94..570a3b670 100644 --- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourseWorkEdit/store.js +++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourseWorkEdit/store.js @@ -132,9 +132,9 @@ const store = createStore({ var k = Object.assign(e, { key: index, editEvaluation: false, - startDate: e.startDate !== null ? ISOToDatetime(e.startDate.datetime) : null, - endDate: e.endDate !== null ? ISOToDatetime(e.endDate.datetime) : null, - maxDate: e.maxDate !== null ? ISOToDatetime(e.maxDate.datetime) : null, + startDate: e.startDate !== null ? dateToISO(new Date(e.startDate.datetime)) : null, + endDate: e.endDate !== null ? dateToISO(new Date(e.endDate.datetime)) : null, + maxDate: e.maxDate !== null ? dateToISO(new Date(e.maxDate.datetime)) : null, warningInterval: e.warningInterval !== null ? intervalISOToDays(e.warningInterval) : null, documents: e.documents.map((d, docIndex) => { return Object.assign(d, { @@ -264,6 +264,7 @@ const store = createStore({ .startDate = date; }, setEvaluationEndDate(state, {key, date}) { + console.log('commit date', date) state.evaluationsPicked.find(e => e.key === key) .endDate = date; }, From ad1e7b576cfefe67976709d2aaff262b5b8cb964 Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Wed, 20 Apr 2022 13:58:45 +0200 Subject: [PATCH 43/79] remove success toast for parcours startdate + take empty string values into account for action dates --- .../public/vuejs/AccompanyingCourse/components/StartDate.vue | 3 +-- .../public/vuejs/AccompanyingCourseWorkEdit/store.js | 5 +++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/components/StartDate.vue b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/components/StartDate.vue index b6a0344e8..564fc74b7 100644 --- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/components/StartDate.vue +++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/components/StartDate.vue @@ -28,14 +28,13 @@ export default { const date = e.target.previousSibling.value; this.$store.dispatch('updateStartDate', date) - .then(this.$toast.open({type: 'success', message: this.$t('startdate.update')})) .catch(({name, violations}) => { if (name === 'ValidationException' || name === 'AccessException') { violations.forEach((violation) => this.$toast.open({message: violation})); } else { this.$toast.open({message: 'An error occurred'}) } - }); + }) }, }, computed: { diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourseWorkEdit/store.js b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourseWorkEdit/store.js index 570a3b670..77cc4800e 100644 --- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourseWorkEdit/store.js +++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourseWorkEdit/store.js @@ -69,13 +69,14 @@ const store = createStore({ return []; }, buildPayload(state) { + console.log('end date', state.endDate); return { type: 'accompanying_period_work', id: state.work.id, - startDate: state.startDate === null ? null : { + startDate: state.startDate === null || state.startDate === '' ? null : { datetime: datetimeToISO(ISOToDate(state.startDate)) }, - endDate: state.endDate === null ? null : { + endDate: state.endDate === null || state.endDate === '' ? null : { datetime: datetimeToISO(ISOToDate(state.endDate)) }, note: state.note, From be77c3729b7700b5827482d9346d544dd7dca62e Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Wed, 20 Apr 2022 14:09:28 +0200 Subject: [PATCH 44/79] take empty date strings into account --- .../public/vuejs/AccompanyingCourse/store/index.js | 3 ++- .../public/vuejs/AccompanyingCourseWorkEdit/store.js | 6 +++--- .../public/vuejs/HouseholdMembersEditor/store/index.js | 2 +- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/store/index.js b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/store/index.js index 5d73aa2ed..57415565b 100644 --- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/store/index.js +++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/store/index.js @@ -814,7 +814,8 @@ let initPromise = (root) => Promise.all([getScopesPromise(root), accompanyingCou }, updateStartDate({commit}, payload) { const url = `/api/1.0/person/accompanying-course/${id}.json`; - const body = { type: "accompanying_period", openingDate: { datetime: datetimeToISO(ISOToDate(payload)) }}; + const date = payload === null || payload === '' ? null : { datetime: datetimeToISO(ISOToDate(payload)) } + const body = { type: "accompanying_period", openingDate: date}; return makeFetch('PATCH', url, body) .then((response) => { commit('updateStartDate', response.openingDate); diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourseWorkEdit/store.js b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourseWorkEdit/store.js index 77cc4800e..502704716 100644 --- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourseWorkEdit/store.js +++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourseWorkEdit/store.js @@ -111,9 +111,9 @@ const store = createStore({ id: e.evaluation.id, type: e.evaluation.type }, - startDate: e.startDate !== null ? { datetime: datetimeToISO(ISOToDate(e.startDate)) } : null, - endDate: e.endDate !== null ? { datetime: datetimeToISO(ISOToDate(e.endDate)) } : null, - maxDate: e.maxDate !== null ? { datetime: datetimeToISO(ISOToDate(e.maxDate)) } : null, + startDate: e.startDate === null || e.startDate === '' ? null : { datetime: datetimeToISO(ISOToDate(e.startDate)) }, + endDate: e.endDate === null || e.endDate === '' ? null : { datetime: datetimeToISO(ISOToDate(e.endDate)) }, + maxDate: e.maxDate === null || e.maxDate === '' ? null : { datetime: datetimeToISO(ISOToDate(e.maxDate)) }, warningInterval: intervalDaysToISO(e.warningInterval), comment: e.comment, documents: e.documents diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/HouseholdMembersEditor/store/index.js b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/HouseholdMembersEditor/store/index.js index 87e465a8d..75b3c215f 100644 --- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/HouseholdMembersEditor/store/index.js +++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/HouseholdMembersEditor/store/index.js @@ -278,7 +278,7 @@ const store = createStore({ type: conc.person.type }, start_date: { - datetime: datetimeToISO(ISOToDate(state.startDate)) + datetime: state.startDate === null || state.startDate === '' ? null : datetimeToISO(ISOToDate(state.startDate)) } }; From 92d394b6695055d322c46c9e675d5e6d077e7c07 Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Wed, 20 Apr 2022 14:22:35 +0200 Subject: [PATCH 45/79] changelog updated --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0f26e64a1..626d41658 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,7 @@ and this project adheres to * [Activity form] invert 'incoming' and 'receiving' in Activity form * [Activity form] keep the same order for 'attendee' field in new and edit form * [list with period] use "sameas" test operator to introduce requestor in list +* [Datepickers] datepickers fixed when using keyboard to enter date (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/545) ## Test releases From b24de76d77f56f8e5b5c04d5056692b6641bb979 Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Wed, 20 Apr 2022 15:16:26 +0200 Subject: [PATCH 46/79] display agents traitants --- CHANGELOG.md | 2 +- .../AccompanyingCourseWork/_item.html.twig | 32 +++++++++---------- ...st_recent_by_accompanying_period.html.twig | 9 ++++++ .../translations/messages.fr.yml | 2 +- 4 files changed, 27 insertions(+), 18 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 459f95005..44915aa63 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,7 +16,7 @@ and this project adheres to * [list with period] use "sameas" test operator to introduce requestor in list * [notification email on course designation] allow raw string in email content generation * [Accompanying period work] list evaluations associated to a work by startDate, and then by id, from the most recent to older - +* [social_action] Display 'agents traitants' in parcours resumé and social action list (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/568) ## Test releases diff --git a/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourseWork/_item.html.twig b/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourseWork/_item.html.twig index 8ff8a0617..3d4f46425 100644 --- a/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourseWork/_item.html.twig +++ b/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourseWork/_item.html.twig @@ -25,22 +25,6 @@
- {% if w.createdBy %} -
-
-

{{ 'Referrers'|trans }}

-
-
-

- {% for u in w.referrers %} - {{ u|chill_entity_render_box }} - {% if not loop.last %}, {% endif %} - {% endfor %} -

-
-
- {% endif %} - {%- if w.persons -%}
@@ -78,6 +62,22 @@
{% endif %} + {%- if w.referrers -%} +
+
+

{{ 'Referrers'|trans }}

+
+
+ {% for u in w.referrers %} + + {{ u|chill_entity_render_box }} + {% if not loop.last %}, {% endif %} + + {% endfor %} +
+
+ {% endif %} + {%- if w.socialAction.issue -%}
diff --git a/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourseWork/list_recent_by_accompanying_period.html.twig b/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourseWork/list_recent_by_accompanying_period.html.twig index 7f2fb0177..4621cb97a 100644 --- a/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourseWork/list_recent_by_accompanying_period.html.twig +++ b/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourseWork/list_recent_by_accompanying_period.html.twig @@ -28,6 +28,15 @@ {{ w.handlingThierParty|chill_entity_render_box }} {% endif %} + {% if w.referrers %} +
  • + {{ 'Referrers'|trans ~ ' : ' }} + {% for u in w.referrers %} + {{ u|chill_entity_render_box }} + {% if not loop.last %}, {% endif %} + {% endfor %} +
  • + {% endif %}
  • {{ 'Participants'|trans ~ ' : ' }} {% for p in w.persons %} diff --git a/src/Bundle/ChillPersonBundle/translations/messages.fr.yml b/src/Bundle/ChillPersonBundle/translations/messages.fr.yml index c6baf9513..535985d23 100644 --- a/src/Bundle/ChillPersonBundle/translations/messages.fr.yml +++ b/src/Bundle/ChillPersonBundle/translations/messages.fr.yml @@ -214,7 +214,7 @@ No requestor: Pas de demandeur No resources: "Pas d'interlocuteurs privilégiés" Persons associated: Usagers concernés Referrer: Référent -Referrers: Référents +Referrers: Agents traitants Some peoples does not belong to any household currently. Add them to an household soon: Certaines personnes n'appartiennent à aucun ménage actuellement. Renseignez leur ménage dès que possible. Add to household now: Ajouter à un ménage Any resource for this accompanying course: Aucun interlocuteur privilégié pour ce parcours From c6be7955fd3eb1669e3bae5c791b424cfd4817f3 Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Thu, 21 Apr 2022 13:59:45 +0200 Subject: [PATCH 47/79] remove save button datepicker parcours. set timeout --- .../components/StartDate.vue | 64 ++++++++++++++----- 1 file changed, 48 insertions(+), 16 deletions(-) diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/components/StartDate.vue b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/components/StartDate.vue index b33447b25..c987150be 100644 --- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/components/StartDate.vue +++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/components/StartDate.vue @@ -6,8 +6,7 @@
    - - +
    @@ -17,31 +16,64 @@