From 5f35a42fe351888ba786bf2a316f3be8f04aa3fd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Thu, 24 Mar 2022 22:09:12 +0100 Subject: [PATCH 01/12] allow phonumber helper to format null value --- .../Phonenumber/PhoneNumberHelperInterface.php | 2 +- .../ChillMainBundle/Phonenumber/PhonenumberHelper.php | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/Bundle/ChillMainBundle/Phonenumber/PhoneNumberHelperInterface.php b/src/Bundle/ChillMainBundle/Phonenumber/PhoneNumberHelperInterface.php index 1ed67d967..12e74550e 100644 --- a/src/Bundle/ChillMainBundle/Phonenumber/PhoneNumberHelperInterface.php +++ b/src/Bundle/ChillMainBundle/Phonenumber/PhoneNumberHelperInterface.php @@ -22,7 +22,7 @@ use libphonenumber\PhoneNumber; */ interface PhoneNumberHelperInterface { - public function format(PhoneNumber $phoneNumber): string; + public function format(?PhoneNumber $phoneNumber = null): string; /** * Get type (mobile, landline, ...) for phone number. diff --git a/src/Bundle/ChillMainBundle/Phonenumber/PhonenumberHelper.php b/src/Bundle/ChillMainBundle/Phonenumber/PhonenumberHelper.php index 22f580d78..fa1b097c8 100644 --- a/src/Bundle/ChillMainBundle/Phonenumber/PhonenumberHelper.php +++ b/src/Bundle/ChillMainBundle/Phonenumber/PhonenumberHelper.php @@ -78,8 +78,12 @@ final class PhonenumberHelper implements PhoneNumberHelperInterface * * @throws NumberParseException */ - public function format(PhoneNumber $phoneNumber): string + public function format(?PhoneNumber $phoneNumber = null): string { + if (null === $phoneNumber) { + return ''; + } + return $this->phoneNumberUtil ->formatOutOfCountryCallingNumber($phoneNumber, $this->config['default_carrier_code']); } From ea66db07a448aee271c0b8fd8d5cea6f3c565b68 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Thu, 24 Mar 2022 22:10:07 +0100 Subject: [PATCH 02/12] fix cs --- .../ChillActivityBundle/Form/ActivityType.php | 8 +- .../Authorization/AccompanyingPeriodVoter.php | 4 +- .../Entity/ThirdParty.php | 2 +- .../migrations/Version20220324175549.php | 86 ++++++++++--------- 4 files changed, 53 insertions(+), 47 deletions(-) diff --git a/src/Bundle/ChillActivityBundle/Form/ActivityType.php b/src/Bundle/ChillActivityBundle/Form/ActivityType.php index 3a772d878..1e1daead5 100644 --- a/src/Bundle/ChillActivityBundle/Form/ActivityType.php +++ b/src/Bundle/ChillActivityBundle/Form/ActivityType.php @@ -126,7 +126,7 @@ class ActivityType extends AbstractType if ($activityType->isVisible('socialIssues') && $accompanyingPeriod) { $builder->add('socialIssues', HiddenType::class, [ - 'required' => $activityType->getSocialIssuesVisible() === 2 + 'required' => $activityType->getSocialIssuesVisible() === 2, ]); $builder->get('socialIssues') ->addModelTransformer(new CallbackTransformer( @@ -154,7 +154,7 @@ class ActivityType extends AbstractType if ($activityType->isVisible('socialActions') && $accompanyingPeriod) { $builder->add('socialActions', HiddenType::class, [ - 'required' => $activityType->getSocialActionsVisible() === 2 + 'required' => $activityType->getSocialActionsVisible() === 2, ]); $builder->get('socialActions') ->addModelTransformer(new CallbackTransformer( @@ -344,8 +344,8 @@ class ActivityType extends AbstractType if ($activityType->isVisible('location')) { $builder->add('location', HiddenType::class, [ - 'required' => $activityType->getLocationVisible() === 2 - ]) + 'required' => $activityType->getLocationVisible() === 2, + ]) ->get('location') ->addModelTransformer(new CallbackTransformer( static function (?Location $location): string { diff --git a/src/Bundle/ChillPersonBundle/Security/Authorization/AccompanyingPeriodVoter.php b/src/Bundle/ChillPersonBundle/Security/Authorization/AccompanyingPeriodVoter.php index a1166da25..9a2ee860d 100644 --- a/src/Bundle/ChillPersonBundle/Security/Authorization/AccompanyingPeriodVoter.php +++ b/src/Bundle/ChillPersonBundle/Security/Authorization/AccompanyingPeriodVoter.php @@ -131,8 +131,8 @@ class AccompanyingPeriodVoter extends AbstractChillVoter implements ProvideRoleH } if (in_array($attribute, [ - self::SEE, self::SEE_DETAILS, self::EDIT - ])) { + self::SEE, self::SEE_DETAILS, self::EDIT, + ], true)) { if ($subject->getUser() === $token->getUser()) { return true; } diff --git a/src/Bundle/ChillThirdPartyBundle/Entity/ThirdParty.php b/src/Bundle/ChillThirdPartyBundle/Entity/ThirdParty.php index d7efce10c..16260ec97 100644 --- a/src/Bundle/ChillThirdPartyBundle/Entity/ThirdParty.php +++ b/src/Bundle/ChillThirdPartyBundle/Entity/ThirdParty.php @@ -198,7 +198,7 @@ class ThirdParty implements TrackCreationInterface, TrackUpdateInterface private ?string $email = null; /** - * @ORM\Column(name="firstname", type="text", options={"default":""}) + * @ORM\Column(name="firstname", type="text", options={"default": ""}) * @Groups({"read", "write", "docgen:read", "docgen:read:3party:parent"}) */ private string $firstname = ''; diff --git a/src/Bundle/ChillThirdPartyBundle/migrations/Version20220324175549.php b/src/Bundle/ChillThirdPartyBundle/migrations/Version20220324175549.php index e31b950d4..ae91699aa 100644 --- a/src/Bundle/ChillThirdPartyBundle/migrations/Version20220324175549.php +++ b/src/Bundle/ChillThirdPartyBundle/migrations/Version20220324175549.php @@ -1,5 +1,12 @@ addSql(" + CREATE OR REPLACE FUNCTION chill_3party.canonicalize() RETURNS TRIGGER + LANGUAGE plpgsql + AS + $$ + BEGIN + NEW.canonicalized = + UNACCENT( + LOWER( + NEW.name || + CASE WHEN COALESCE(NEW.name_company, '') <> '' THEN ' ' ELSE '' END || + COALESCE(NEW.name_company, '') || + CASE WHEN COALESCE(NEW.acronym, '') <> '' THEN ' ' ELSE '' END || + COALESCE(NEW.acronym, '') + ) + ) + ; + + return NEW; + END + $$ + "); + $this->addSql(" + UPDATE chill_3party.third_party + SET canonicalized = + UNACCENT( + LOWER( + name || + CASE WHEN COALESCE(name_company, '') <> '' THEN ' ' ELSE '' END || + COALESCE(name_company, '') || + CASE WHEN COALESCE(acronym, '') <> '' THEN ' ' ELSE '' END || + COALESCE(acronym, '') + ) + ) + "); + } + public function getDescription(): string { return 'indexing of firstname on third parties'; @@ -55,45 +101,5 @@ final class Version20220324175549 extends AbstractMigration END $$ "); - - } - - public function down(Schema $schema): void - { - $this->addSql(" - CREATE OR REPLACE FUNCTION chill_3party.canonicalize() RETURNS TRIGGER - LANGUAGE plpgsql - AS - $$ - BEGIN - NEW.canonicalized = - UNACCENT( - LOWER( - NEW.name || - CASE WHEN COALESCE(NEW.name_company, '') <> '' THEN ' ' ELSE '' END || - COALESCE(NEW.name_company, '') || - CASE WHEN COALESCE(NEW.acronym, '') <> '' THEN ' ' ELSE '' END || - COALESCE(NEW.acronym, '') - ) - ) - ; - - return NEW; - END - $$ - "); - $this->addSql(" - UPDATE chill_3party.third_party - SET canonicalized = - UNACCENT( - LOWER( - name || - CASE WHEN COALESCE(name_company, '') <> '' THEN ' ' ELSE '' END || - COALESCE(name_company, '') || - CASE WHEN COALESCE(acronym, '') <> '' THEN ' ' ELSE '' END || - COALESCE(acronym, '') - ) - ) - "); } } From 9dca42e2429850044f82295310a7033fb5be73a5 Mon Sep 17 00:00:00 2001 From: nobohan Date: Fri, 25 Mar 2022 10:44:15 +0100 Subject: [PATCH 03/12] correct notification for workflow display bug --- .../Resources/views/Workflow/_notification_include.html.twig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Bundle/ChillMainBundle/Resources/views/Workflow/_notification_include.html.twig b/src/Bundle/ChillMainBundle/Resources/views/Workflow/_notification_include.html.twig index 221ddf4b4..b8f942af0 100644 --- a/src/Bundle/ChillMainBundle/Resources/views/Workflow/_notification_include.html.twig +++ b/src/Bundle/ChillMainBundle/Resources/views/Workflow/_notification_include.html.twig @@ -2,7 +2,7 @@

{{ 'workflow_'|trans }}

- {% include handler.templateTitle(entity_workflow) with handler.templateTitleData(entity_workflow)|merge({ + {% include handler.template(entity_workflow) with handler.templateData(entity_workflow)|merge({ 'description': true, 'breadcrumb': true, 'add_classes': 'ms-3 h3' From 89064f55a1a98084b0642c916b679f696fbf8574 Mon Sep 17 00:00:00 2001 From: nobohan Date: Fri, 25 Mar 2022 11:36:51 +0100 Subject: [PATCH 04/12] Accompanying course evaluation documents: disable the WOPI edit link if mimetype not supported --- .../components/FormEvaluation.vue | 82 ++++++++++++++++++- 1 file changed, 79 insertions(+), 3 deletions(-) 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 ca3d8b397..181592ba4 100644 --- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourseWorkEdit/components/FormEvaluation.vue +++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourseWorkEdit/components/FormEvaluation.vue @@ -113,9 +113,8 @@ :storedObject="d.storedObject" > - -
  • +
  • @@ -220,7 +219,79 @@ export default { maxFiles: 1, maxPostSize: 15000000, required: false, - } + }, + mime: [ + // TODO temporary hardcoded. to be replaced by twig extension or a collabora server query + 'application/clarisworks', + 'application/coreldraw', + 'application/macwriteii', + 'application/msword', + 'application/vnd.lotus-1-2-3', + 'application/vnd.ms-excel', + 'application/vnd.ms-excel.sheet.binary.macroEnabled.12', + 'application/vnd.ms-excel.sheet.macroEnabled.12', + 'application/vnd.ms-excel.template.macroEnabled.12', + 'application/vnd.ms-powerpoint', + 'application/vnd.ms-powerpoint.presentation.macroEnabled.12', + 'application/vnd.ms-powerpoint.template.macroEnabled.12', + 'application/vnd.ms-visio.drawing', + 'application/vnd.ms-word.document.macroEnabled.12', + 'application/vnd.ms-word.template.macroEnabled.12', + 'application/vnd.ms-works', + 'application/vnd.oasis.opendocument.chart', + 'application/vnd.oasis.opendocument.formula', + 'application/vnd.oasis.opendocument.graphics', + 'application/vnd.oasis.opendocument.graphics-flat-xml', + 'application/vnd.oasis.opendocument.graphics-template', + 'application/vnd.oasis.opendocument.presentation', + 'application/vnd.oasis.opendocument.presentation-flat-xml', + 'application/vnd.oasis.opendocument.presentation-template', + 'application/vnd.oasis.opendocument.spreadsheet', + 'application/vnd.oasis.opendocument.spreadsheet-flat-xml', + 'application/vnd.oasis.opendocument.spreadsheet-template', + 'application/vnd.oasis.opendocument.text', + 'application/vnd.oasis.opendocument.text-flat-xml', + 'application/vnd.oasis.opendocument.text-master', + 'application/vnd.oasis.opendocument.text-master-template', + 'application/vnd.oasis.opendocument.text-template', + 'application/vnd.oasis.opendocument.text-web', + 'application/vnd.openxmlformats-officedocument.presentationml.presentation', + 'application/vnd.openxmlformats-officedocument.presentationml.slideshow', + 'application/vnd.openxmlformats-officedocument.presentationml.template', + 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', + 'application/vnd.openxmlformats-officedocument.spreadsheetml.template', + 'application/vnd.openxmlformats-officedocument.wordprocessingml.document', + 'application/vnd.openxmlformats-officedocument.wordprocessingml.template', + 'application/vnd.sun.xml.calc', + 'application/vnd.sun.xml.calc.template', + 'application/vnd.sun.xml.chart', + 'application/vnd.sun.xml.draw', + 'application/vnd.sun.xml.draw.template', + 'application/vnd.sun.xml.impress', + 'application/vnd.sun.xml.impress.template', + 'application/vnd.sun.xml.math', + 'application/vnd.sun.xml.writer', + 'application/vnd.sun.xml.writer.global', + 'application/vnd.sun.xml.writer.template', + 'application/vnd.visio', + 'application/vnd.visio2013', + 'application/vnd.wordperfect', + 'application/x-abiword', + 'application/x-aportisdoc', + 'application/x-dbase', + 'application/x-dif-document', + 'application/x-fictionbook+xml', + 'application/x-gnumeric', + 'application/x-hwp', + 'application/x-iwork-keynote-sffkey', + 'application/x-iwork-numbers-sffnumbers', + 'application/x-iwork-pages-sffpages', + 'application/x-mspublisher', + 'application/x-mswrite', + 'application/x-pagemaker', + 'application/x-sony-bbeb', + 'application/x-t602', + ] } }, computed: { @@ -268,6 +339,11 @@ export default { }, methods: { ISOToDatetime, + canEditDocument(document) { + console.log(document); + return 'storedObject' in document ? + this.mime.includes(document.storedObject.type) : false; + }, listAllStatus() { console.log('load all status'); let url = `/api/`; From cff126953ed128faf030328963781908a00e6f07 Mon Sep 17 00:00:00 2001 From: nobohan Date: Fri, 25 Mar 2022 11:45:13 +0100 Subject: [PATCH 05/12] Accompanying course evaluation documents: disable the WOPI edit link if no keyInfos --- .../AccompanyingCourseWorkEdit/components/FormEvaluation.vue | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) 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 181592ba4..e368f51b7 100644 --- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourseWorkEdit/components/FormEvaluation.vue +++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourseWorkEdit/components/FormEvaluation.vue @@ -340,9 +340,8 @@ export default { methods: { ISOToDatetime, canEditDocument(document) { - console.log(document); return 'storedObject' in document ? - this.mime.includes(document.storedObject.type) : false; + this.mime.includes(document.storedObject.type) && document.storedObject.keyInfos.length !== 0 : false; }, listAllStatus() { console.log('load all status'); From f36fc0ba6099790e4c3af3aec267208a6b416252 Mon Sep 17 00:00:00 2001 From: nobohan Date: Fri, 25 Mar 2022 11:46:57 +0100 Subject: [PATCH 06/12] upd CHANGELOG --- CHANGELOG.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1a3031354..a7bcfdf3e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,9 @@ and this project adheres to ## Unreleased +* [person] Accompanying course evaluation documents: disable the WOPI edit link if mimetype not supported and if no keyInfos +(https://gitlab.com/champs-libres/departement-de-la-vendee/accent-suivi-developpement/-/issues/585) + * [activity] display error messages above the form in creating a new location (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/481) * [activity] show required field in activity edit/new by an asterix in the vuejs fields (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/494) * [ACL] fix allow to see the course, event if the scope'course does not contains the scope's user From b423821ae97426aa86b4bde27f78a3d4888594df Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Fri, 25 Mar 2022 13:10:40 +0100 Subject: [PATCH 07/12] check existence of form before using it --- .../Controller/DocGeneratorTemplateController.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Bundle/ChillDocGeneratorBundle/Controller/DocGeneratorTemplateController.php b/src/Bundle/ChillDocGeneratorBundle/Controller/DocGeneratorTemplateController.php index 8913951e6..e5324a6cf 100644 --- a/src/Bundle/ChillDocGeneratorBundle/Controller/DocGeneratorTemplateController.php +++ b/src/Bundle/ChillDocGeneratorBundle/Controller/DocGeneratorTemplateController.php @@ -283,7 +283,7 @@ final class DocGeneratorTemplateController extends AbstractController } $datas = $context->getData($template, $entity, $contextGenerationData); - if ($isTest && $form['show_data']->getData()) { + if ($isTest && isset($form) && $form['show_data']->getData()) { // very ugly hack... dd($datas); } From d11eebefae26ec4baeffd3bf52ef6cc2846ab971 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Fri, 25 Mar 2022 13:11:03 +0100 Subject: [PATCH 08/12] fix some authorization check in menu --- .../Menu/AccompanyingCourseMenuBuilder.php | 2 ++ .../Menu/AccompanyingCourseMenuBuilder.php | 24 +++++++++++-------- .../Authorization/AccompanyingPeriodVoter.php | 23 ++++++++++++++++++ .../ChillTaskBundle/Menu/MenuBuilder.php | 5 +++- 4 files changed, 43 insertions(+), 11 deletions(-) diff --git a/src/Bundle/ChillCalendarBundle/Menu/AccompanyingCourseMenuBuilder.php b/src/Bundle/ChillCalendarBundle/Menu/AccompanyingCourseMenuBuilder.php index eca770fe0..cc365b62d 100644 --- a/src/Bundle/ChillCalendarBundle/Menu/AccompanyingCourseMenuBuilder.php +++ b/src/Bundle/ChillCalendarBundle/Menu/AccompanyingCourseMenuBuilder.php @@ -41,12 +41,14 @@ class AccompanyingCourseMenuBuilder implements LocalMenuBuilderInterface $period = $parameters['accompanyingCourse']; if (AccompanyingPeriod::STEP_DRAFT !== $period->getStep()) { + /* $menu->addChild($this->translator->trans('Calendar'), [ 'route' => 'chill_calendar_calendar_list', 'routeParameters' => [ 'accompanying_period_id' => $period->getId(), ], ]) ->setExtras(['order' => 35]); + */ } } diff --git a/src/Bundle/ChillPersonBundle/Menu/AccompanyingCourseMenuBuilder.php b/src/Bundle/ChillPersonBundle/Menu/AccompanyingCourseMenuBuilder.php index 929fb2ae0..34667d636 100644 --- a/src/Bundle/ChillPersonBundle/Menu/AccompanyingCourseMenuBuilder.php +++ b/src/Bundle/ChillPersonBundle/Menu/AccompanyingCourseMenuBuilder.php @@ -96,23 +96,27 @@ class AccompanyingCourseMenuBuilder implements LocalMenuBuilderInterface $workflow = $this->registry->get($period, 'accompanying_period_lifecycle'); - if (null !== $period->getClosingDate()) { + if ($this->security->isGranted(AccompanyingPeriodVoter::EDIT, $period)) { + if ($workflow->can($period, 'close')) { + $menu->addChild($this->translator->trans('Close Accompanying Course'), [ + 'route' => 'chill_person_accompanying_course_close', + 'routeParameters' => [ + 'accompanying_period_id' => $period->getId(), + ],]) + ->setExtras(['order' => 99999]); + } + } + + if (null !== $period->getClosingDate() + && $this->security->isGranted(AccompanyingPeriodVoter::RE_OPEN_COURSE, $period)) { $menu->addChild($this->translator->trans('Re-open accompanying course'), [ 'route' => 'chill_person_accompanying_course_reopen', 'routeParameters' => [ 'accompanying_period_id' => $period->getId(), - ], ]) + ],]) ->setExtras(['order' => 99998]); } - if ($workflow->can($period, 'close')) { - $menu->addChild($this->translator->trans('Close Accompanying Course'), [ - 'route' => 'chill_person_accompanying_course_close', - 'routeParameters' => [ - 'accompanying_period_id' => $period->getId(), - ], ]) - ->setExtras(['order' => 99999]); - } } public static function getMenuIds(): array diff --git a/src/Bundle/ChillPersonBundle/Security/Authorization/AccompanyingPeriodVoter.php b/src/Bundle/ChillPersonBundle/Security/Authorization/AccompanyingPeriodVoter.php index a1166da25..2e896c471 100644 --- a/src/Bundle/ChillPersonBundle/Security/Authorization/AccompanyingPeriodVoter.php +++ b/src/Bundle/ChillPersonBundle/Security/Authorization/AccompanyingPeriodVoter.php @@ -34,12 +34,23 @@ class AccompanyingPeriodVoter extends AbstractChillVoter implements ProvideRoleH self::FULL, self::TOGGLE_CONFIDENTIAL_ALL, self::TOGGLE_INTENSITY, + self::RE_OPEN_COURSE, ]; public const CREATE = 'CHILL_PERSON_ACCOMPANYING_PERIOD_CREATE'; + /** + * role to DELETE the course + * + * Will be true only for the creator, and if the course is still at DRAFT step. + */ public const DELETE = 'CHILL_PERSON_ACCOMPANYING_PERIOD_DELETE'; + /** + * role to EDIT the course. + * + * If the course is closed, it will be always false. + */ public const EDIT = 'CHILL_PERSON_ACCOMPANYING_PERIOD_UPDATE'; /** @@ -56,6 +67,14 @@ class AccompanyingPeriodVoter extends AbstractChillVoter implements ProvideRoleH */ public const SEE_DETAILS = 'CHILL_PERSON_ACCOMPANYING_PERIOD_SEE_DETAILS'; + /** + * Reopen a closed course. + * + * This forward to the EDIT role, without taking into account that the course + * is closed + */ + public const RE_OPEN_COURSE = 'CHILL_PERSON_ACCOMPANYING_PERIOD_REOPEN'; + public const TOGGLE_CONFIDENTIAL = 'CHILL_PERSON_ACCOMPANYING_PERIOD_TOGGLE_CONFIDENTIAL'; /** @@ -116,6 +135,10 @@ class AccompanyingPeriodVoter extends AbstractChillVoter implements ProvideRoleH if (in_array($attribute, [self::EDIT, self::DELETE], true)) { return false; } + + if (self::RE_OPEN_COURSE === $attribute) { + return $this->voterHelper->voteOnAttribute(self::EDIT, $subject, $token); + } } if (AccompanyingPeriod::STEP_DRAFT === $subject->getStep()) { diff --git a/src/Bundle/ChillTaskBundle/Menu/MenuBuilder.php b/src/Bundle/ChillTaskBundle/Menu/MenuBuilder.php index 170f3eb54..47503f052 100644 --- a/src/Bundle/ChillTaskBundle/Menu/MenuBuilder.php +++ b/src/Bundle/ChillTaskBundle/Menu/MenuBuilder.php @@ -12,6 +12,7 @@ declare(strict_types=1); namespace Chill\TaskBundle\Menu; use Chill\MainBundle\Routing\LocalMenuBuilderInterface; +use Chill\PersonBundle\Entity\AccompanyingPeriod; use Chill\TaskBundle\Security\Authorization\TaskVoter; use Knp\Menu\MenuItem; use LogicException; @@ -40,9 +41,11 @@ class MenuBuilder implements LocalMenuBuilderInterface public function buildAccompanyingCourseMenu($menu, $parameters) { + /** @var AccompanyingPeriod $course */ $course = $parameters['accompanyingCourse']; - if ($this->authorizationChecker->isGranted(TaskVoter::SHOW, $course)) { + if ($this->authorizationChecker->isGranted(TaskVoter::SHOW, $course) + && AccompanyingPeriod::STEP_DRAFT !== $course->getStep()) { $menu->addChild( $this->translator->trans('Tasks'), [ From c99a967fb9e7c79cecf9f679c282d1cff874bb3b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Fri, 25 Mar 2022 13:35:52 +0100 Subject: [PATCH 09/12] slightly improvve the render box for workflow in notification --- .../views/Workflow/_notification_include.html.twig | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/Bundle/ChillMainBundle/Resources/views/Workflow/_notification_include.html.twig b/src/Bundle/ChillMainBundle/Resources/views/Workflow/_notification_include.html.twig index b8f942af0..558207818 100644 --- a/src/Bundle/ChillMainBundle/Resources/views/Workflow/_notification_include.html.twig +++ b/src/Bundle/ChillMainBundle/Resources/views/Workflow/_notification_include.html.twig @@ -1,12 +1,11 @@ +

    + {{ 'workflow_'|trans }} +

    +
    -

    - {{ 'workflow_'|trans }} -

    {% include handler.template(entity_workflow) with handler.templateData(entity_workflow)|merge({ 'description': true, 'breadcrumb': true, - 'add_classes': 'ms-3 h3' + 'add_classes': '' }) %} - -
    From e68c12e0e7cd80b022c363d514f9605eecffccbf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Fri, 25 Mar 2022 13:39:27 +0100 Subject: [PATCH 10/12] fix cs --- .../ChillActivityBundle/Form/ActivityType.php | 8 +- .../Menu/AccompanyingCourseMenuBuilder.php | 2 +- .../Entity/Person/PersonResource.php | 1 - .../Menu/AccompanyingCourseMenuBuilder.php | 5 +- .../Authorization/AccompanyingPeriodVoter.php | 22 ++--- .../Entity/ThirdParty.php | 2 +- .../migrations/Version20220324175549.php | 86 ++++++++++--------- 7 files changed, 65 insertions(+), 61 deletions(-) diff --git a/src/Bundle/ChillActivityBundle/Form/ActivityType.php b/src/Bundle/ChillActivityBundle/Form/ActivityType.php index 3a772d878..1e1daead5 100644 --- a/src/Bundle/ChillActivityBundle/Form/ActivityType.php +++ b/src/Bundle/ChillActivityBundle/Form/ActivityType.php @@ -126,7 +126,7 @@ class ActivityType extends AbstractType if ($activityType->isVisible('socialIssues') && $accompanyingPeriod) { $builder->add('socialIssues', HiddenType::class, [ - 'required' => $activityType->getSocialIssuesVisible() === 2 + 'required' => $activityType->getSocialIssuesVisible() === 2, ]); $builder->get('socialIssues') ->addModelTransformer(new CallbackTransformer( @@ -154,7 +154,7 @@ class ActivityType extends AbstractType if ($activityType->isVisible('socialActions') && $accompanyingPeriod) { $builder->add('socialActions', HiddenType::class, [ - 'required' => $activityType->getSocialActionsVisible() === 2 + 'required' => $activityType->getSocialActionsVisible() === 2, ]); $builder->get('socialActions') ->addModelTransformer(new CallbackTransformer( @@ -344,8 +344,8 @@ class ActivityType extends AbstractType if ($activityType->isVisible('location')) { $builder->add('location', HiddenType::class, [ - 'required' => $activityType->getLocationVisible() === 2 - ]) + 'required' => $activityType->getLocationVisible() === 2, + ]) ->get('location') ->addModelTransformer(new CallbackTransformer( static function (?Location $location): string { diff --git a/src/Bundle/ChillCalendarBundle/Menu/AccompanyingCourseMenuBuilder.php b/src/Bundle/ChillCalendarBundle/Menu/AccompanyingCourseMenuBuilder.php index cc365b62d..3bf1850a4 100644 --- a/src/Bundle/ChillCalendarBundle/Menu/AccompanyingCourseMenuBuilder.php +++ b/src/Bundle/ChillCalendarBundle/Menu/AccompanyingCourseMenuBuilder.php @@ -48,7 +48,7 @@ class AccompanyingCourseMenuBuilder implements LocalMenuBuilderInterface 'accompanying_period_id' => $period->getId(), ], ]) ->setExtras(['order' => 35]); - */ + */ } } diff --git a/src/Bundle/ChillPersonBundle/Entity/Person/PersonResource.php b/src/Bundle/ChillPersonBundle/Entity/Person/PersonResource.php index 73bd23106..b1022cf4c 100644 --- a/src/Bundle/ChillPersonBundle/Entity/Person/PersonResource.php +++ b/src/Bundle/ChillPersonBundle/Entity/Person/PersonResource.php @@ -232,7 +232,6 @@ class PersonResource implements TrackCreationInterface, TrackUpdateInterface } if (null !== $this->person && $this->person === $this->personOwner) { - $context->buildViolation('You cannot associate a resource with the same person') ->addViolation(); } diff --git a/src/Bundle/ChillPersonBundle/Menu/AccompanyingCourseMenuBuilder.php b/src/Bundle/ChillPersonBundle/Menu/AccompanyingCourseMenuBuilder.php index 34667d636..57be8fecf 100644 --- a/src/Bundle/ChillPersonBundle/Menu/AccompanyingCourseMenuBuilder.php +++ b/src/Bundle/ChillPersonBundle/Menu/AccompanyingCourseMenuBuilder.php @@ -102,7 +102,7 @@ class AccompanyingCourseMenuBuilder implements LocalMenuBuilderInterface 'route' => 'chill_person_accompanying_course_close', 'routeParameters' => [ 'accompanying_period_id' => $period->getId(), - ],]) + ], ]) ->setExtras(['order' => 99999]); } } @@ -113,10 +113,9 @@ class AccompanyingCourseMenuBuilder implements LocalMenuBuilderInterface 'route' => 'chill_person_accompanying_course_reopen', 'routeParameters' => [ 'accompanying_period_id' => $period->getId(), - ],]) + ], ]) ->setExtras(['order' => 99998]); } - } public static function getMenuIds(): array diff --git a/src/Bundle/ChillPersonBundle/Security/Authorization/AccompanyingPeriodVoter.php b/src/Bundle/ChillPersonBundle/Security/Authorization/AccompanyingPeriodVoter.php index 2e896c471..e53d40eee 100644 --- a/src/Bundle/ChillPersonBundle/Security/Authorization/AccompanyingPeriodVoter.php +++ b/src/Bundle/ChillPersonBundle/Security/Authorization/AccompanyingPeriodVoter.php @@ -40,7 +40,7 @@ class AccompanyingPeriodVoter extends AbstractChillVoter implements ProvideRoleH public const CREATE = 'CHILL_PERSON_ACCOMPANYING_PERIOD_CREATE'; /** - * role to DELETE the course + * role to DELETE the course. * * Will be true only for the creator, and if the course is still at DRAFT step. */ @@ -58,6 +58,14 @@ class AccompanyingPeriodVoter extends AbstractChillVoter implements ProvideRoleH */ public const FULL = 'CHILL_PERSON_ACCOMPANYING_PERIOD_FULL'; + /** + * Reopen a closed course. + * + * This forward to the EDIT role, without taking into account that the course + * is closed + */ + public const RE_OPEN_COURSE = 'CHILL_PERSON_ACCOMPANYING_PERIOD_REOPEN'; + public const SEE = 'CHILL_PERSON_ACCOMPANYING_PERIOD_SEE'; /** @@ -67,14 +75,6 @@ class AccompanyingPeriodVoter extends AbstractChillVoter implements ProvideRoleH */ public const SEE_DETAILS = 'CHILL_PERSON_ACCOMPANYING_PERIOD_SEE_DETAILS'; - /** - * Reopen a closed course. - * - * This forward to the EDIT role, without taking into account that the course - * is closed - */ - public const RE_OPEN_COURSE = 'CHILL_PERSON_ACCOMPANYING_PERIOD_REOPEN'; - public const TOGGLE_CONFIDENTIAL = 'CHILL_PERSON_ACCOMPANYING_PERIOD_TOGGLE_CONFIDENTIAL'; /** @@ -154,8 +154,8 @@ class AccompanyingPeriodVoter extends AbstractChillVoter implements ProvideRoleH } if (in_array($attribute, [ - self::SEE, self::SEE_DETAILS, self::EDIT - ])) { + self::SEE, self::SEE_DETAILS, self::EDIT, + ], true)) { if ($subject->getUser() === $token->getUser()) { return true; } diff --git a/src/Bundle/ChillThirdPartyBundle/Entity/ThirdParty.php b/src/Bundle/ChillThirdPartyBundle/Entity/ThirdParty.php index d7efce10c..16260ec97 100644 --- a/src/Bundle/ChillThirdPartyBundle/Entity/ThirdParty.php +++ b/src/Bundle/ChillThirdPartyBundle/Entity/ThirdParty.php @@ -198,7 +198,7 @@ class ThirdParty implements TrackCreationInterface, TrackUpdateInterface private ?string $email = null; /** - * @ORM\Column(name="firstname", type="text", options={"default":""}) + * @ORM\Column(name="firstname", type="text", options={"default": ""}) * @Groups({"read", "write", "docgen:read", "docgen:read:3party:parent"}) */ private string $firstname = ''; diff --git a/src/Bundle/ChillThirdPartyBundle/migrations/Version20220324175549.php b/src/Bundle/ChillThirdPartyBundle/migrations/Version20220324175549.php index e31b950d4..ae91699aa 100644 --- a/src/Bundle/ChillThirdPartyBundle/migrations/Version20220324175549.php +++ b/src/Bundle/ChillThirdPartyBundle/migrations/Version20220324175549.php @@ -1,5 +1,12 @@ addSql(" + CREATE OR REPLACE FUNCTION chill_3party.canonicalize() RETURNS TRIGGER + LANGUAGE plpgsql + AS + $$ + BEGIN + NEW.canonicalized = + UNACCENT( + LOWER( + NEW.name || + CASE WHEN COALESCE(NEW.name_company, '') <> '' THEN ' ' ELSE '' END || + COALESCE(NEW.name_company, '') || + CASE WHEN COALESCE(NEW.acronym, '') <> '' THEN ' ' ELSE '' END || + COALESCE(NEW.acronym, '') + ) + ) + ; + + return NEW; + END + $$ + "); + $this->addSql(" + UPDATE chill_3party.third_party + SET canonicalized = + UNACCENT( + LOWER( + name || + CASE WHEN COALESCE(name_company, '') <> '' THEN ' ' ELSE '' END || + COALESCE(name_company, '') || + CASE WHEN COALESCE(acronym, '') <> '' THEN ' ' ELSE '' END || + COALESCE(acronym, '') + ) + ) + "); + } + public function getDescription(): string { return 'indexing of firstname on third parties'; @@ -55,45 +101,5 @@ final class Version20220324175549 extends AbstractMigration END $$ "); - - } - - public function down(Schema $schema): void - { - $this->addSql(" - CREATE OR REPLACE FUNCTION chill_3party.canonicalize() RETURNS TRIGGER - LANGUAGE plpgsql - AS - $$ - BEGIN - NEW.canonicalized = - UNACCENT( - LOWER( - NEW.name || - CASE WHEN COALESCE(NEW.name_company, '') <> '' THEN ' ' ELSE '' END || - COALESCE(NEW.name_company, '') || - CASE WHEN COALESCE(NEW.acronym, '') <> '' THEN ' ' ELSE '' END || - COALESCE(NEW.acronym, '') - ) - ) - ; - - return NEW; - END - $$ - "); - $this->addSql(" - UPDATE chill_3party.third_party - SET canonicalized = - UNACCENT( - LOWER( - name || - CASE WHEN COALESCE(name_company, '') <> '' THEN ' ' ELSE '' END || - COALESCE(name_company, '') || - CASE WHEN COALESCE(acronym, '') <> '' THEN ' ' ELSE '' END || - COALESCE(acronym, '') - ) - ) - "); } } From c1e972963f904e3339a4d2624b4407d0c27641ad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Fri, 25 Mar 2022 14:03:43 +0100 Subject: [PATCH 11/12] invert condition with key infos --- .../AccompanyingCourseWorkEdit/components/FormEvaluation.vue | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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 e368f51b7..eff62bbbb 100644 --- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourseWorkEdit/components/FormEvaluation.vue +++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourseWorkEdit/components/FormEvaluation.vue @@ -341,7 +341,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'); @@ -415,4 +415,4 @@ export default { font-weight: bold; font-size: 1rem; } - \ No newline at end of file + From bdcb135adbe50745b97d8e26695fd9050781e724 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Fri, 25 Mar 2022 15:48:30 +0100 Subject: [PATCH 12/12] re-introduce link to create user --- .../ChillMainBundle/Resources/views/User/index.html.twig | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/Bundle/ChillMainBundle/Resources/views/User/index.html.twig b/src/Bundle/ChillMainBundle/Resources/views/User/index.html.twig index 5a558b6a0..83a82f140 100644 --- a/src/Bundle/ChillMainBundle/Resources/views/User/index.html.twig +++ b/src/Bundle/ChillMainBundle/Resources/views/User/index.html.twig @@ -59,4 +59,10 @@ {{ chill_pagination(paginator) }} -{% endblock %} \ No newline at end of file + + +{% endblock %}