From 9b06ccc3e6466fe4f315ee9c6b21af8f4c3735e8 Mon Sep 17 00:00:00 2001 From: nobohan Date: Mon, 7 Mar 2022 11:13:11 +0100 Subject: [PATCH 01/64] user admin: use flex-table and flex-bloc in twig --- .../Resources/views/User/index.html.twig | 88 +++++++++---------- 1 file changed, 44 insertions(+), 44 deletions(-) diff --git a/src/Bundle/ChillMainBundle/Resources/views/User/index.html.twig b/src/Bundle/ChillMainBundle/Resources/views/User/index.html.twig index 53bd89482..a1f55e7d3 100644 --- a/src/Bundle/ChillMainBundle/Resources/views/User/index.html.twig +++ b/src/Bundle/ChillMainBundle/Resources/views/User/index.html.twig @@ -1,60 +1,60 @@ {% extends '@ChillMain/Admin/Permission/layout_crud_permission_index.html.twig' %} {% block admin_content -%} - {% embed '@ChillMain/CRUD/_index.html.twig' %} - {% block table_entities_thead_tr %} - {{ 'crud.admin_user.index.is_active'|trans }} - {{ 'crud.admin_user.index.usernames'|trans }} - {{ 'crud.admin_user.index.mains'|trans }} -   - {% endblock %} - {% block table_entities_tbody %} - {% for entity in entities %} - - + +

{{"Users"|trans}}

+ {% for entity in entities %} +
+
+
+
+ {{ entity.label }} {% if entity.isEnabled %} {% else %} {% endif %} - - - {{ entity.username }} -
- {{ entity.label }} -
- {{ entity.email }} - - +
+
{{ entity.email }}
+
+
+
+ login: {{ entity.username|e('html_attr') }} +
+
{% if entity.userJob %} - {{ entity.userJob.label|localize_translatable_string }} -
+ {{ entity.userJob.label|localize_translatable_string }} {% endif %} +
+
+
+
{% if entity.mainScope %} - {{ entity.mainScope.name|localize_translatable_string }} -
+ {{ entity.mainScope.name|localize_translatable_string }} {% endif %} {% if entity.mainCenter %} - {{ entity.mainCenter.name }} + , {{ entity.mainCenter.name }} {% endif %} - - -
    +
+
+
+
    +
  • + +
  • +
  • + +
  • + {% if is_granted('ROLE_ALLOWED_TO_SWITCH') %}
  • - +
  • -
  • - -
  • - {% if is_granted('ROLE_ALLOWED_TO_SWITCH') %} -
  • - -
  • - {% endif %} -
- - - {% endfor %} - {% endblock %} - {% endembed %} -{% endblock %} + {% endif %} + +
+
+ +
+ {% endfor %} + +{% endblock %} \ No newline at end of file From 17e83deb55f7e652acaaec5c5031e655fa539345 Mon Sep 17 00:00:00 2001 From: nobohan Date: Tue, 8 Mar 2022 09:46:41 +0100 Subject: [PATCH 02/64] User admin: put pagination --- src/Bundle/ChillMainBundle/Resources/views/User/index.html.twig | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/Bundle/ChillMainBundle/Resources/views/User/index.html.twig b/src/Bundle/ChillMainBundle/Resources/views/User/index.html.twig index a1f55e7d3..5a558b6a0 100644 --- a/src/Bundle/ChillMainBundle/Resources/views/User/index.html.twig +++ b/src/Bundle/ChillMainBundle/Resources/views/User/index.html.twig @@ -57,4 +57,6 @@ {% endfor %} + {{ chill_pagination(paginator) }} + {% endblock %} \ No newline at end of file From 492c22d1b7582e0d4e70c87d0da37daad1f33cfe Mon Sep 17 00:00:00 2001 From: nobohan Date: Thu, 10 Mar 2022 08:40:11 +0100 Subject: [PATCH 03/64] AccompanyingPeriodWork: add referrers field --- .../AccompanyingPeriodWork.php | 34 ++++++++++++++++ .../migrations/Version20220310063629.php | 40 +++++++++++++++++++ 2 files changed, 74 insertions(+) create mode 100644 src/Bundle/ChillPersonBundle/migrations/Version20220310063629.php diff --git a/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod/AccompanyingPeriodWork.php b/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod/AccompanyingPeriodWork.php index ed00c8611..f9f9f46e1 100644 --- a/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod/AccompanyingPeriodWork.php +++ b/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod/AccompanyingPeriodWork.php @@ -142,6 +142,15 @@ class AccompanyingPeriodWork implements AccompanyingPeriodLinkedWithSocialIssues */ private Collection $persons; + /** + * @ORM\ManyToMany(targetEntity=User::class) + * @ORM\JoinTable(name="chill_person_accompanying_period_work_referrer") + * @Serializer\Groups({"read", "docgen:read", "read:accompanyingPeriodWork:light"}) + * @Serializer\Groups({"accompanying_period_work:edit"}) + * @Serializer\Groups({"accompanying_period_work:create"}) + */ + private Collection $referrers; + /** * @ORM\ManyToMany(targetEntity=Result::class, inversedBy="accompanyingPeriodWorks") * @ORM\JoinTable(name="chill_person_accompanying_period_work_result") @@ -196,6 +205,7 @@ class AccompanyingPeriodWork implements AccompanyingPeriodLinkedWithSocialIssues $this->thirdParties = new ArrayCollection(); $this->persons = new ArrayCollection(); $this->accompanyingPeriodWorkEvaluations = new ArrayCollection(); + $this->referrers = new ArrayCollection(); } public function addAccompanyingPeriodWorkEvaluation(AccompanyingPeriodWorkEvaluation $evaluation): self @@ -497,4 +507,28 @@ class AccompanyingPeriodWork implements AccompanyingPeriodLinkedWithSocialIssues return $this; } + + /** + * @return Collection|User[] + */ + public function getReferrers(): Collection + { + return $this->referrers; + } + + public function addReferrer(User $referrer): self + { + if (!$this->referrers->contains($referrer)) { + $this->referrers[] = $referrer; + } + + return $this; + } + + public function removeReferrer(User $referrer): self + { + $this->referrers->removeElement($referrer); + + return $this; + } } diff --git a/src/Bundle/ChillPersonBundle/migrations/Version20220310063629.php b/src/Bundle/ChillPersonBundle/migrations/Version20220310063629.php new file mode 100644 index 000000000..0d56ff4b1 --- /dev/null +++ b/src/Bundle/ChillPersonBundle/migrations/Version20220310063629.php @@ -0,0 +1,40 @@ +addSql('CREATE TABLE chill_person_accompanying_period_work_referrer (accompanyingperiodwork_id INT NOT NULL, user_id INT NOT NULL, PRIMARY KEY(accompanyingperiodwork_id, user_id))'); + $this->addSql('CREATE INDEX IDX_3619F5EBB99F6060 ON chill_person_accompanying_period_work_referrer (accompanyingperiodwork_id)'); + $this->addSql('CREATE INDEX IDX_3619F5EBA76ED395 ON chill_person_accompanying_period_work_referrer (user_id)'); + $this->addSql('ALTER TABLE chill_person_accompanying_period_work_referrer ADD CONSTRAINT FK_3619F5EBB99F6060 FOREIGN KEY (accompanyingperiodwork_id) REFERENCES chill_person_accompanying_period_work (id) ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE'); + $this->addSql('ALTER TABLE chill_person_accompanying_period_work_referrer ADD CONSTRAINT FK_3619F5EBA76ED395 FOREIGN KEY (user_id) REFERENCES users (id) ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE'); + } + + public function down(Schema $schema): void + { + $this->addSql('DROP TABLE chill_person_accompanying_period_work_referrer'); + } +} From 55a65ee6e9b20516868ef3a406062cbb376959d9 Mon Sep 17 00:00:00 2001 From: nobohan Date: Thu, 10 Mar 2022 10:32:20 +0100 Subject: [PATCH 04/64] accompanyingPeriodWork: add referrer in vuejs form --- .../vuejs/AccompanyingCourseWorkEdit/App.vue | 75 ++++++++++++++++++- .../vuejs/AccompanyingCourseWorkEdit/store.js | 18 ++++- 2 files changed, 91 insertions(+), 2 deletions(-) diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourseWorkEdit/App.vue b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourseWorkEdit/App.vue index a0d88d1bf..1f895708b 100644 --- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourseWorkEdit/App.vue +++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourseWorkEdit/App.vue @@ -151,6 +151,40 @@ +
+

{{ $t('referrers') }}

+ +
+

{{ $t('no_referrers') }}

+
+ +
+
+
+ + {{ u.text }} + + +
+
+
+ +
    +
  • + + +
  • +
+
+

{{ $t('handling_thirdparty') }}

@@ -289,7 +323,6 @@ import PersonText from 'ChillPersonAssets/vuejs/_components/Entity/PersonText.vu import {buildLinkCreate} from 'ChillMainAssets/lib/entity-workflow/api.js'; import { makeFetch } from 'ChillMainAssets/lib/api/apiMethods'; - const i18n = { messages: { fr: { @@ -322,6 +355,10 @@ const i18n = { available_evaluations_text: "Évaluations disponibles pour ajout :", no_evaluations_available: "Aucune évaluation disponible", no_goals_available: "Aucun objectif disponible", + referrers: "Agents traitants", + no_referrers: "Aucun agent traitant", + choose_referrers: "Choisir des agents traitants", + remove_referrer: "Enlever l'agent" } } }; @@ -370,6 +407,17 @@ export default { } }, }, + referrerPicker: { + key: 'referrer', + options: { + type: ['user'], + priority: null, + uniq: false, + button: { + display: false + } + }, + }, }; }, computed: { @@ -381,6 +429,7 @@ export default { 'personsReachables', 'handlingThirdParty', 'thirdParties', + 'referrers', 'isPosting', 'errors', 'templatesAvailablesForAction', @@ -389,6 +438,7 @@ export default { 'hasResultsForAction', 'hasHandlingThirdParty', 'hasThirdParties', + 'hasReferrers' ]), startDate: { get() { @@ -465,6 +515,14 @@ export default { removeThirdParty(t) { this.$store.commit('removeThirdParty', t); }, + addReferrers({selected, modal}) { + this.$store.commit('addReferrers', selected.map(r => r.result)); + this.$refs.referrerPicker.resetSearch(); + modal.showModal = false; + }, + removeReferrer(u) { + this.$store.commit('removeReferrer', u); + }, goToGenerateWorkflow({link}) { console.log('save before leave to generate workflow') const callback = (data) => { @@ -521,6 +579,7 @@ div#workEditor { "objectives objectives" "evaluations evaluations" "persons persons" + "referrers referrers" "handling handling" "tparties tparties" "errors errors"; @@ -543,6 +602,8 @@ div#workEditor { grid-area: handling; } #thirdParties { grid-area: tparties; } + #referrers { + grid-area: referrers; } #errors { grid-area: errors; } @@ -657,5 +718,17 @@ div#workEditor { } } +.referrer { + margin-bottom: 0.4rem; + .referrer-close-btn { + margin-left: 0.4rem; + margin-right: 0.4rem; + button { + height: 1.45rem; + min-width: 1.45rem; + font-size: 0.4rem; + } + } +} diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourseWorkEdit/store.js b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourseWorkEdit/store.js index 7f96843e5..f53c9d246 100644 --- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourseWorkEdit/store.js +++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourseWorkEdit/store.js @@ -31,6 +31,7 @@ const store = createStore({ .map(p => p.person), handlingThirdParty: window.accompanyingCourseWork.handlingThierParty, thirdParties: window.accompanyingCourseWork.thirdParties, + referrers: window.accompanyingCourseWork.referrers, isPosting: false, errors: [], }, @@ -54,6 +55,9 @@ const store = createStore({ hasHandlingThirdParty(state) { return state.handlingThirdParty !== null; }, + hasReferrers(state) { + return state.referrers.length > 0; + }, hasThirdParties(state) { return state.thirdParties.length > 0; }, @@ -82,6 +86,7 @@ const store = createStore({ }, results: state.resultsPicked.map(r => ({id: r.id, type: r.type})), thirdParties: state.thirdParties.map(t => ({id: t.id, type: t.type})), + referrers: state.referrers.map(t => ({id: t.id, type: t.type})), goals: state.goalsPicked.map(g => { let o = { type: g.type, @@ -302,6 +307,18 @@ const store = createStore({ state.thirdParties = state.thirdParties .filter(t => t.id !== thirdParty.id); }, + addReferrers(state, referrers) { + let ids = state.referrers.map(t => t.id); + let unexistings = referrers.filter(t => !ids.includes(t.id)); + + for (let i in unexistings) { + state.referrers.push(unexistings[i]); + } + }, + removeReferrer(state, user) { + state.referrers = state.referrers + .filter(u => u.id !== user.id); + }, setErrors(state, errors) { state.errors = errors; }, @@ -315,7 +332,6 @@ const store = createStore({ }, actions: { updateThirdParty({ commit }, payload) { - console.log(payload); commit('updateThirdParty', payload); }, getReachablesGoalsForAction({ getters, commit, dispatch }) { From da650fa1f2df82f77d9f7eb04e474b53fa4e7d8a Mon Sep 17 00:00:00 2001 From: nobohan Date: Thu, 10 Mar 2022 10:53:40 +0100 Subject: [PATCH 05/64] AccompanyingPeriodWork: add doctrine event listener to add logged user to referrers collection --- .../AccompanyingPeriodWorkEventListener.php | 31 +++++++++++++++++++ .../services/doctrineEventListener.yaml | 10 ++++++ 2 files changed, 41 insertions(+) create mode 100644 src/Bundle/ChillPersonBundle/EventListener/AccompanyingPeriodWorkEventListener.php diff --git a/src/Bundle/ChillPersonBundle/EventListener/AccompanyingPeriodWorkEventListener.php b/src/Bundle/ChillPersonBundle/EventListener/AccompanyingPeriodWorkEventListener.php new file mode 100644 index 000000000..ab767802f --- /dev/null +++ b/src/Bundle/ChillPersonBundle/EventListener/AccompanyingPeriodWorkEventListener.php @@ -0,0 +1,31 @@ +security = $security; + } + + public function prePersistAccompanyingPeriodWork(AccompanyingPeriodWork $work): void + { + $work->addReferrer($this->security->getUser()); + } +} diff --git a/src/Bundle/ChillPersonBundle/config/services/doctrineEventListener.yaml b/src/Bundle/ChillPersonBundle/config/services/doctrineEventListener.yaml index f75243d02..dbf6fc16d 100644 --- a/src/Bundle/ChillPersonBundle/config/services/doctrineEventListener.yaml +++ b/src/Bundle/ChillPersonBundle/config/services/doctrineEventListener.yaml @@ -12,3 +12,13 @@ services: event: 'prePersist' entity: 'Chill\PersonBundle\Entity\PersonAltName' method: 'prePersistAltName' + + Chill\PersonBundle\EventListener\AccompanyingPeriodWorkEventListener: + autoconfigure: true + autowire: true + tags: + - + name: 'doctrine.orm.entity_listener' + event: 'prePersist' + entity: 'Chill\PersonBundle\Entity\AccompanyingPeriod\AccompanyingPeriodWork' + method: 'prePersistAccompanyingPeriodWork' \ No newline at end of file From 137eb184d032fab85af030cd3f721c1b179b5809 Mon Sep 17 00:00:00 2001 From: nobohan Date: Thu, 10 Mar 2022 16:18:59 +0100 Subject: [PATCH 06/64] accompanying period work: display referrers in the list of work --- .../Resources/views/AccompanyingCourseWork/_item.html.twig | 7 +++++-- src/Bundle/ChillPersonBundle/translations/messages.fr.yml | 1 + 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourseWork/_item.html.twig b/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourseWork/_item.html.twig index d7e4f4e96..6287b158d 100644 --- a/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourseWork/_item.html.twig +++ b/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourseWork/_item.html.twig @@ -28,11 +28,14 @@ {% if w.createdBy %}
-

{{ 'Referrer'|trans }}

+

{{ 'Referrers'|trans }}

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

diff --git a/src/Bundle/ChillPersonBundle/translations/messages.fr.yml b/src/Bundle/ChillPersonBundle/translations/messages.fr.yml index e4265fca0..be008e276 100644 --- a/src/Bundle/ChillPersonBundle/translations/messages.fr.yml +++ b/src/Bundle/ChillPersonBundle/translations/messages.fr.yml @@ -213,6 +213,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 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 690a443bdbb361d5a69f895edbd9c371b40aecd3 Mon Sep 17 00:00:00 2001 From: nobohan Date: Thu, 10 Mar 2022 16:25:05 +0100 Subject: [PATCH 07/64] fix code style for AccompanyingPeriodWork - referrers --- .../AccompanyingPeriodWork.php | 48 +++++++++---------- .../AccompanyingPeriodWorkEventListener.php | 3 +- .../migrations/Version20220310063629.php | 12 ++--- 3 files changed, 31 insertions(+), 32 deletions(-) diff --git a/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod/AccompanyingPeriodWork.php b/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod/AccompanyingPeriodWork.php index f9f9f46e1..95ec008d9 100644 --- a/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod/AccompanyingPeriodWork.php +++ b/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod/AccompanyingPeriodWork.php @@ -237,6 +237,15 @@ class AccompanyingPeriodWork implements AccompanyingPeriodLinkedWithSocialIssues return $this; } + public function addReferrer(User $referrer): self + { + if (!$this->referrers->contains($referrer)) { + $this->referrers[] = $referrer; + } + + return $this; + } + public function addResult(Result $result): self { if (!$this->results->contains($result)) { @@ -318,6 +327,14 @@ class AccompanyingPeriodWork implements AccompanyingPeriodLinkedWithSocialIssues return $this->persons; } + /** + * @return Collection|User[] + */ + public function getReferrers(): Collection + { + return $this->referrers; + } + /** * @return Collection|Result[] */ @@ -392,6 +409,13 @@ class AccompanyingPeriodWork implements AccompanyingPeriodLinkedWithSocialIssues return $this; } + public function removeReferrer(User $referrer): self + { + $this->referrers->removeElement($referrer); + + return $this; + } + public function removeResult(Result $result): self { $this->results->removeElement($result); @@ -507,28 +531,4 @@ class AccompanyingPeriodWork implements AccompanyingPeriodLinkedWithSocialIssues return $this; } - - /** - * @return Collection|User[] - */ - public function getReferrers(): Collection - { - return $this->referrers; - } - - public function addReferrer(User $referrer): self - { - if (!$this->referrers->contains($referrer)) { - $this->referrers[] = $referrer; - } - - return $this; - } - - public function removeReferrer(User $referrer): self - { - $this->referrers->removeElement($referrer); - - return $this; - } } diff --git a/src/Bundle/ChillPersonBundle/EventListener/AccompanyingPeriodWorkEventListener.php b/src/Bundle/ChillPersonBundle/EventListener/AccompanyingPeriodWorkEventListener.php index ab767802f..c9b11ea71 100644 --- a/src/Bundle/ChillPersonBundle/EventListener/AccompanyingPeriodWorkEventListener.php +++ b/src/Bundle/ChillPersonBundle/EventListener/AccompanyingPeriodWorkEventListener.php @@ -11,12 +11,11 @@ declare(strict_types=1); namespace Chill\PersonBundle\EventListener; -use Symfony\Component\Security\Core\Security; use Chill\PersonBundle\Entity\AccompanyingPeriod\AccompanyingPeriodWork; +use Symfony\Component\Security\Core\Security; class AccompanyingPeriodWorkEventListener { - private Security $security; public function __construct(Security $security) diff --git a/src/Bundle/ChillPersonBundle/migrations/Version20220310063629.php b/src/Bundle/ChillPersonBundle/migrations/Version20220310063629.php index 0d56ff4b1..2b4c171a2 100644 --- a/src/Bundle/ChillPersonBundle/migrations/Version20220310063629.php +++ b/src/Bundle/ChillPersonBundle/migrations/Version20220310063629.php @@ -15,10 +15,15 @@ use Doctrine\DBAL\Schema\Schema; use Doctrine\Migrations\AbstractMigration; /** - * Add referrers to AccompanyingPeriodWork + * Add referrers to AccompanyingPeriodWork. */ final class Version20220310063629 extends AbstractMigration { + public function down(Schema $schema): void + { + $this->addSql('DROP TABLE chill_person_accompanying_period_work_referrer'); + } + public function getDescription(): string { return 'Add referrers to AccompanyingPeriodWork'; @@ -32,9 +37,4 @@ final class Version20220310063629 extends AbstractMigration $this->addSql('ALTER TABLE chill_person_accompanying_period_work_referrer ADD CONSTRAINT FK_3619F5EBB99F6060 FOREIGN KEY (accompanyingperiodwork_id) REFERENCES chill_person_accompanying_period_work (id) ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE'); $this->addSql('ALTER TABLE chill_person_accompanying_period_work_referrer ADD CONSTRAINT FK_3619F5EBA76ED395 FOREIGN KEY (user_id) REFERENCES users (id) ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE'); } - - public function down(Schema $schema): void - { - $this->addSql('DROP TABLE chill_person_accompanying_period_work_referrer'); - } } From ba668d3b9df92d6d0f0ab9170187aec69c94e6be Mon Sep 17 00:00:00 2001 From: nobohan Date: Thu, 10 Mar 2022 16:27:03 +0100 Subject: [PATCH 08/64] upd CHANGELOG --- CHANGELOG.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 885068bc0..c0fc082df 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,9 @@ and this project adheres to ## Unreleased +* [person] AccompanyingPeriodWork: add referrers to work, add doctrine event listener to add logged user to referrers collection and display a referrers list in work list (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/502) + + * [main] filter user job in undispatch acc period to assign (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/472) * [person] Add url in accompanying period work evaluations entity and form (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/476) * [person] Add document generation in admin and in person/{id}/document (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/464) From dbe186547f1c61a06db779491dc40bfd2e99705f Mon Sep 17 00:00:00 2001 From: nobohan Date: Sun, 13 Mar 2022 22:31:26 +0100 Subject: [PATCH 09/64] AccompanyingCourseWorkEdit: replace document by a new one --- .../components/FormEvaluation.vue | 25 ++++++++++++++++++- .../vuejs/AccompanyingCourseWorkEdit/store.js | 17 +++++++++++++ 2 files changed, 41 insertions(+), 1 deletion(-) 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 24e1c202f..2e31c0669 100644 --- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourseWorkEdit/components/FormEvaluation.vue +++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourseWorkEdit/components/FormEvaluation.vue @@ -84,6 +84,8 @@

Créé par {{ d.createdBy.text }}
Le {{ $d(ISOToDatetime(d.createdAt.datetime), 'long') }}

+ +
  • @@ -98,6 +100,14 @@ @go-to-generate-workflow="goToGenerateWorkflowEvaluationDocument" >
  • +
  • + + +
  • @@ -176,7 +186,8 @@ const i18n = { document_upload: "Téléverser un document", document_title: "Titre du document", template_title: "Nom du template", - browse: "Ajouter un document" + browse: "Ajouter un document", + replace: "Remplacer" } } }; @@ -285,6 +296,18 @@ export default { }; this.$store.commit('addDocument', {key: this.evaluation.key, document: document}); }, + replaceDocument(oldDocument, storedObject) { + + console.log(oldDocument); + console.log(storedObject); + //console.log(oldDocument) how to get the old document? + let document = { + type: 'accompanying_period_work_evaluation_document', + storedObject: storedObject, + title: oldDocument.title + }; + this.$store.commit('replaceDocument', {key: this.evaluation.key, document: document, oldDocument: oldDocument}); + }, 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}); diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourseWorkEdit/store.js b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourseWorkEdit/store.js index 7f96843e5..18d6847f1 100644 --- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourseWorkEdit/store.js +++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourseWorkEdit/store.js @@ -221,6 +221,20 @@ const store = createStore({ evaluations.documents = evaluations.documents.filter(d => d.key !== document.key); }, + replaceDocument(state, payload) { + console.log('payload', payload) + console.log(state.evaluationsPicked) + let evaluations = state.evaluationsPicked.find(e => e.key === payload.key); + console.log(evaluations) + if (evaluations === undefined) { + return; + } + + //Add document with map + evaluations.documents = evaluations.documents.map(d => d.key === payload.oldDocument.key ? payload.document : d); //TODO no key on documents! + console.log(evaluations) + + }, addEvaluation(state, evaluation) { let e = { type: "accompanying_period_work_evaluation", @@ -408,6 +422,9 @@ const store = createStore({ removeDocument({commit}, payload) { commit('removeDocument', payload); }, + replaceDocument({commit}, payload) { + commit('replaceDocument', payload); + }, submit({ getters, state, commit }, callback) { let payload = getters.buildPayload, From 6eac6044cd6a69147abe51149db24ef68eb912f4 Mon Sep 17 00:00:00 2001 From: nobohan Date: Mon, 14 Mar 2022 10:42:16 +0100 Subject: [PATCH 10/64] AccompanyingCourseWorkEdit: replace document by a new one (working now) --- .../components/FormEvaluation.vue | 4 --- .../vuejs/AccompanyingCourseWorkEdit/store.js | 25 ++++++++++--------- 2 files changed, 13 insertions(+), 16 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 2e31c0669..7fe9bd278 100644 --- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourseWorkEdit/components/FormEvaluation.vue +++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourseWorkEdit/components/FormEvaluation.vue @@ -297,10 +297,6 @@ export default { this.$store.commit('addDocument', {key: this.evaluation.key, document: document}); }, replaceDocument(oldDocument, storedObject) { - - console.log(oldDocument); - console.log(storedObject); - //console.log(oldDocument) how to get the old document? let document = { type: 'accompanying_period_work_evaluation_document', storedObject: storedObject, diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourseWorkEdit/store.js b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourseWorkEdit/store.js index 18d6847f1..893d3663a 100644 --- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourseWorkEdit/store.js +++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourseWorkEdit/store.js @@ -213,27 +213,28 @@ const store = createStore({ })); }, removeDocument(state, {key, document}) { - let evaluations = state.evaluationsPicked.find(e => e.key === key); + let evaluation = state.evaluationsPicked.find(e => e.key === key); - if (evaluations === undefined) { + if (evaluation === undefined) { return; } - evaluations.documents = evaluations.documents.filter(d => d.key !== document.key); + evaluation.documents = evaluation.documents.filter(d => d.key !== document.key); }, replaceDocument(state, payload) { - console.log('payload', payload) - console.log(state.evaluationsPicked) - let evaluations = state.evaluationsPicked.find(e => e.key === payload.key); - console.log(evaluations) - if (evaluations === undefined) { + let evaluation = state.evaluationsPicked.find(e => e.key === payload.key); + if (evaluation === undefined) { return; } - //Add document with map - evaluations.documents = evaluations.documents.map(d => d.key === payload.oldDocument.key ? payload.document : d); //TODO no key on documents! - console.log(evaluations) - + let newDocument = Object.assign( + payload.document, { + key: evaluation.documents.length + 1, + workflows_availables: state.work.workflows_availables_evaluation_documents, + workflows: [], + } + ); + evaluation.documents = evaluation.documents.map(d => d.id === payload.oldDocument.id ? newDocument : d); }, addEvaluation(state, evaluation) { let e = { From 9f0ab5aee74c21d9138539b7259452e0ef60f4c1 Mon Sep 17 00:00:00 2001 From: nobohan Date: Mon, 14 Mar 2022 10:43:28 +0100 Subject: [PATCH 11/64] upd CHANGELOG --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 885068bc0..fa50b6389 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,8 @@ and this project adheres to ## Unreleased +* [person] AccompanyingCourseWorkEdit: replace document by a new one (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/511) + * [main] filter user job in undispatch acc period to assign (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/472) * [person] Add url in accompanying period work evaluations entity and form (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/476) * [person] Add document generation in admin and in person/{id}/document (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/464) From 1beae4d7135b67ebcf32b2edc41132d4b754e291 Mon Sep 17 00:00:00 2001 From: nobohan Date: Mon, 14 Mar 2022 14:42:04 +0100 Subject: [PATCH 12/64] AccompanyingCourseWorkEdit: download existing documents --- .../Entity/StoredObject.php | 4 +- .../public/module/async_upload/downloader.js | 3 +- .../public/module/async_upload/uploader.js | 4 +- .../_components/AddAsyncUploadDownloader.vue | 45 +++++++++++++++++++ .../components/FormEvaluation.vue | 13 +++++- 5 files changed, 63 insertions(+), 6 deletions(-) create mode 100644 src/Bundle/ChillDocStoreBundle/Resources/public/vuejs/_components/AddAsyncUploadDownloader.vue diff --git a/src/Bundle/ChillDocStoreBundle/Entity/StoredObject.php b/src/Bundle/ChillDocStoreBundle/Entity/StoredObject.php index c512dba73..78387e7fe 100644 --- a/src/Bundle/ChillDocStoreBundle/Entity/StoredObject.php +++ b/src/Bundle/ChillDocStoreBundle/Entity/StoredObject.php @@ -61,13 +61,13 @@ class StoredObject implements AsyncFileInterface, Document /** * @var int[] * @ORM\Column(type="json", name="iv") - * @Serializer\Groups({"write"}) + * @Serializer\Groups({"read", "write"}) */ private array $iv = []; /** * @ORM\Column(type="json", name="key") - * @Serializer\Groups({"write"}) + * @Serializer\Groups({"read", "write"}) */ private array $keyInfos = []; diff --git a/src/Bundle/ChillDocStoreBundle/Resources/public/module/async_upload/downloader.js b/src/Bundle/ChillDocStoreBundle/Resources/public/module/async_upload/downloader.js index 4c82a8e4b..0e889c373 100644 --- a/src/Bundle/ChillDocStoreBundle/Resources/public/module/async_upload/downloader.js +++ b/src/Bundle/ChillDocStoreBundle/Resources/public/module/async_upload/downloader.js @@ -73,6 +73,7 @@ var download = (button) => { button.type = mimeType; button.textContent = labelReady; if (hasFilename) { + button.download = filename; if (extension !== false) { button.download = button.download + '.' + extension; @@ -92,4 +93,4 @@ window.addEventListener('load', function(e) { initializeButtons(e.target); }); -module.exports = initializeButtons; +export { initializeButtons, download }; \ No newline at end of file diff --git a/src/Bundle/ChillDocStoreBundle/Resources/public/module/async_upload/uploader.js b/src/Bundle/ChillDocStoreBundle/Resources/public/module/async_upload/uploader.js index 35871245b..5def6a0b2 100644 --- a/src/Bundle/ChillDocStoreBundle/Resources/public/module/async_upload/uploader.js +++ b/src/Bundle/ChillDocStoreBundle/Resources/public/module/async_upload/uploader.js @@ -1,6 +1,6 @@ var algo = 'AES-CBC'; import Dropzone from 'dropzone'; -var initializeDownload = require('./downloader.js'); +import { initializeButtons } from './downloader.js'; /** @@ -359,7 +359,7 @@ var insertDownloadButton = (zone, zoneData) => { addBelowButton(newButton, zone, zoneData); //zone.appendChild(newButton); - initializeDownload(zone); + initializeButtons(zone); }; window.addEventListener('load', function(e) { diff --git a/src/Bundle/ChillDocStoreBundle/Resources/public/vuejs/_components/AddAsyncUploadDownloader.vue b/src/Bundle/ChillDocStoreBundle/Resources/public/vuejs/_components/AddAsyncUploadDownloader.vue new file mode 100644 index 000000000..781c47d6f --- /dev/null +++ b/src/Bundle/ChillDocStoreBundle/Resources/public/vuejs/_components/AddAsyncUploadDownloader.vue @@ -0,0 +1,45 @@ + + + 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 7fe9bd278..ec412842e 100644 --- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourseWorkEdit/components/FormEvaluation.vue +++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourseWorkEdit/components/FormEvaluation.vue @@ -108,6 +108,14 @@ > +
  • + + + +
  • @@ -162,6 +170,7 @@ import { mapGetters, mapState } from 'vuex'; import PickTemplate from 'ChillDocGeneratorAssets/vuejs/_components/PickTemplate.vue'; import {buildLink} from 'ChillDocGeneratorAssets/lib/document-generator'; import AddAsyncUpload from 'ChillDocStoreAssets/vuejs/_components/AddAsyncUpload.vue'; +import AddAsyncUploadDownloader from 'ChillDocStoreAssets/vuejs/_components/AddAsyncUploadDownloader.vue'; import ListWorkflowModal from 'ChillMainAssets/vuejs/_components/EntityWorkflow/ListWorkflowModal.vue'; import {buildLinkCreate} from 'ChillMainAssets/lib/entity-workflow/api.js'; @@ -187,7 +196,8 @@ const i18n = { document_title: "Titre du document", template_title: "Nom du template", browse: "Ajouter un document", - replace: "Remplacer" + replace: "Remplacer", + download: "Télécharger le fichier existant" } } }; @@ -199,6 +209,7 @@ export default { ckeditor: CKEditor.component, PickTemplate, AddAsyncUpload, + AddAsyncUploadDownloader, ListWorkflowModal, }, i18n, From 369397bf4f6649e47bed54e32d2273cff583aed0 Mon Sep 17 00:00:00 2001 From: nobohan Date: Mon, 14 Mar 2022 14:42:53 +0100 Subject: [PATCH 13/64] upd CHANGELOG --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index fa50b6389..13ae858ba 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,7 @@ and this project adheres to ## Unreleased +* [person] AccompanyingCourseWorkEdit: download existing documents (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/512) * [person] AccompanyingCourseWorkEdit: replace document by a new one (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/511) * [main] filter user job in undispatch acc period to assign (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/472) From 82052f5d70b557b6c1438c1eaaa3328b6bf0dce0 Mon Sep 17 00:00:00 2001 From: nobohan Date: Mon, 14 Mar 2022 15:13:21 +0100 Subject: [PATCH 14/64] AccompanyingCourseWorkEdit: fix setting title of document with a fresh upload --- .../components/FormEvaluation.vue | 6 ++++-- .../public/vuejs/AccompanyingCourseWorkEdit/store.js | 7 ++++++- 2 files changed, 10 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 ec412842e..2b380a7ec 100644 --- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourseWorkEdit/components/FormEvaluation.vue +++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourseWorkEdit/components/FormEvaluation.vue @@ -65,7 +65,7 @@
    {{ $t('Documents') }} :
    -
    +
    @@ -75,6 +75,7 @@ type="text" :value="d.title" :id="d.id" + :data-key="i" @input="onInputDocumentTitle"/>
    @@ -296,8 +297,9 @@ export default { }, onInputDocumentTitle(event) { const id = Number(event.target.id); + const key = Number(event.target.dataset.key) + 1; const title = event.target.value; - this.$store.commit('updateDocumentTitle', {id: id, evaluationKey: this.evaluation.key, title: title}); + this.$store.commit('updateDocumentTitle', {id: id, key: key, evaluationKey: this.evaluation.key, title: title}); }, addDocument(storedObject) { let document = { diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourseWorkEdit/store.js b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourseWorkEdit/store.js index 893d3663a..2ea9b48e0 100644 --- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourseWorkEdit/store.js +++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourseWorkEdit/store.js @@ -324,8 +324,13 @@ const store = createStore({ state.isPosting = st; }, updateDocumentTitle(state, payload) { - state.evaluationsPicked.find(e => e.key === payload.evaluationKey) + if (payload.id === 0) { + state.evaluationsPicked.find(e => e.key === payload.evaluationKey) + .documents.find(d => d.key === payload.key).title = payload.title; + } else { + state.evaluationsPicked.find(e => e.key === payload.evaluationKey) .documents.find(d => d.id === payload.id).title = payload.title; + } } }, actions: { From 387b7c2fbd04d26a49f4143586928accebc4094d Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Wed, 16 Mar 2022 11:36:46 +0100 Subject: [PATCH 15/64] first commit --- .../UserAccompanyingPeriodController.php | 65 ++++++++++++++++++- .../AccompanyingPeriodRepository.php | 10 +++ 2 files changed, 74 insertions(+), 1 deletion(-) diff --git a/src/Bundle/ChillPersonBundle/Controller/UserAccompanyingPeriodController.php b/src/Bundle/ChillPersonBundle/Controller/UserAccompanyingPeriodController.php index 321f212d5..774b272c5 100644 --- a/src/Bundle/ChillPersonBundle/Controller/UserAccompanyingPeriodController.php +++ b/src/Bundle/ChillPersonBundle/Controller/UserAccompanyingPeriodController.php @@ -11,11 +11,17 @@ declare(strict_types=1); namespace Chill\PersonBundle\Controller; +use Chill\MainBundle\Entity\User; use Chill\MainBundle\Pagination\PaginatorFactory; +use Chill\PersonBundle\Entity\AccompanyingPeriod; use Chill\PersonBundle\Repository\AccompanyingPeriodRepository; +use Doctrine\ORM\EntityRepository; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; +use Symfony\Component\Form\FormInterface; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\Routing\Annotation\Route; +use Symfony\Component\Security\Core\Exception\AccessDeniedException; +use Symfony\Component\Security\Core\Security; class UserAccompanyingPeriodController extends AbstractController { @@ -23,10 +29,13 @@ class UserAccompanyingPeriodController extends AbstractController private PaginatorFactory $paginatorFactory; - public function __construct(AccompanyingPeriodRepository $accompanyingPeriodRepository, PaginatorFactory $paginatorFactory) + private Security $security; + + public function __construct(AccompanyingPeriodRepository $accompanyingPeriodRepository, PaginatorFactory $paginatorFactory, Security $security) { $this->accompanyingPeriodRepository = $accompanyingPeriodRepository; $this->paginatorFactory = $paginatorFactory; + $this->security = $security; } /** @@ -68,4 +77,58 @@ class UserAccompanyingPeriodController extends AbstractController 'pagination' => $pagination, ]); } + + /** + * @Route("/{_locale}/person/accompanying-periods/my/drafts", name="chill_person_accompanying_period_draft_user") + */ + public function listConfirmedAction(Request $request) + { + if (!$this->security->isGranted('ROLE_USER') || !$this->security->getUser() instanceof User) { + throw new AccessDeniedException(); + } + + $form = $this->buildUserSelectionForm(); + + $form->handleRequest($request); + if ($form->isSubmitted() && $form->isValid()) { + $user = $_POST['user']; + + $periods = $this->getDoctrine()->getRepository(AccompanyingPeriod::class)->findConfirmedByUser($user); + + return $this->render('@ChillPerson/AccompanyingPeriod/user_reassign_periods_list.html.twig', [ + 'accompanyingPeriods' => $periods, + ]); + } + + return $this->render('@ChillPerson/AccompanyingPeriod/user_reassign_periods_list.html.twig', [ + 'form' => $form + ]); + } + + private function buildUserSelectionForm(): FormInterface + { + $data = [ + 'users' => [], + ]; + + $builder = $this->formFactory->createBuilder(FormType::class, $data, [ + 'method' => 'get', 'csrf_protection' => false]); + + $builder + ->add('users', EntityType::class, [ + 'class' => User::class, + 'query_builder' => function (EntityRepository $er) { + $qb = $er->createQueryBuilder('u'); + return $qb; + }, + 'choice_label' => function(User $u) { + return $u->getUsername(); + }, + 'multiple' => false, + 'label' => 'User', + 'required' => false, + ]); + + return $builder->getForm(); + } } diff --git a/src/Bundle/ChillPersonBundle/Repository/AccompanyingPeriodRepository.php b/src/Bundle/ChillPersonBundle/Repository/AccompanyingPeriodRepository.php index 122b658bd..ab7006fd8 100644 --- a/src/Bundle/ChillPersonBundle/Repository/AccompanyingPeriodRepository.php +++ b/src/Bundle/ChillPersonBundle/Repository/AccompanyingPeriodRepository.php @@ -78,6 +78,16 @@ final class AccompanyingPeriodRepository implements ObjectRepository ->getResult(); } + public function findConfirmedByUser(User $user) + { + $qb = $this->createQueryBuilder('ap'); + $qb->where($qb->expr()->eq('ap.user', ':user')) + ->andWhere('ap.step', 'CONFIRMED') + ->setParameter('user', $user); + + return $qb; + } + public function findOneBy(array $criteria): ?AccompanyingPeriod { return $this->findOneBy($criteria); From 97731b0a9b6a1b926fdbb963e4bea993eb5d7bf8 Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Thu, 17 Mar 2022 12:28:00 +0100 Subject: [PATCH 16/64] controller + template made to list confirmed parcours for a specific user --- .../Repository/UserRepository.php | 5 + .../ReassignAccompanyingPeriodController.php | 108 ++++++++++++++++++ .../UserAccompanyingPeriodController.php | 65 +---------- .../AccompanyingPeriodACLAwareRepository.php | 23 ++++ .../reassign_list.html.twig | 80 +++++++++++++ .../config/services/controller.yaml | 5 + 6 files changed, 222 insertions(+), 64 deletions(-) create mode 100644 src/Bundle/ChillPersonBundle/Controller/ReassignAccompanyingPeriodController.php create mode 100644 src/Bundle/ChillPersonBundle/Resources/views/AccompanyingPeriod/reassign_list.html.twig diff --git a/src/Bundle/ChillMainBundle/Repository/UserRepository.php b/src/Bundle/ChillMainBundle/Repository/UserRepository.php index fc3a6e187..56a82de3d 100644 --- a/src/Bundle/ChillMainBundle/Repository/UserRepository.php +++ b/src/Bundle/ChillMainBundle/Repository/UserRepository.php @@ -32,6 +32,11 @@ final class UserRepository implements ObjectRepository $this->repository = $entityManager->getRepository(User::class); } + public function createQueryBuilder(string $alias, ?string $indexBy = null): QueryBuilder + { + return $this->repository->createQueryBuilder($alias, $indexBy); + } + public function countBy(array $criteria): int { return $this->repository->count($criteria); diff --git a/src/Bundle/ChillPersonBundle/Controller/ReassignAccompanyingPeriodController.php b/src/Bundle/ChillPersonBundle/Controller/ReassignAccompanyingPeriodController.php new file mode 100644 index 000000000..66a460199 --- /dev/null +++ b/src/Bundle/ChillPersonBundle/Controller/ReassignAccompanyingPeriodController.php @@ -0,0 +1,108 @@ +accompanyingPeriodACLAwareRepository = $accompanyingPeriodACLAwareRepository; + $this->engine = $engine; + $this->formFactory = $formFactory; + $this->paginatorFactory = $paginatorFactory; + $this->security = $security; + $this->userRepository = $userRepository; + } + + /** + * @Route("/{_locale}/person/accompanying-periods/reassign", name="chill_course_list_reassign") + */ + public function listAction(Request $request): Response + { + if (!$this->security->isGranted('ROLE_USER') || !$this->security->getUser() instanceof User) { + throw new AccessDeniedException(); + } + + $form = $this->buildFilterForm(); + + $form->handleRequest($request); + + // $total = $this->accompanyingPeriodACLAwareRepository->countByUserConfirmed( + // $form['jobs']->getData(), + // $form['services']->getData(), + // $form['locations']->getData(), + // ); + // $paginator = $this->paginatorFactory->create($total); + $periods = $this->accompanyingPeriodACLAwareRepository + ->findByUserConfirmed( + $form['user']->getData(), + 1, + 1 + ); + + return new Response( + $this->engine->render('@ChillPerson/AccompanyingPeriod/reassign_list.html.twig', [ + // 'paginator' => $paginator, + 'periods' => $periods, + 'form' => $form->createView() + ]) + ); + } + + private function buildFilterForm(): FormInterface + { + $builder = $this->formFactory->createBuilder(FormType::class, [ + 'method' => 'get', 'csrf_protection' => false]); + + $builder + ->add('user', EntityType::class, [ + 'class' => User::class, + 'query_builder' => function () { + $qb = $this->userRepository->createQueryBuilder('u'); + + $qb->where('u.enabled = true') + ->orderBy('u.username', 'ASC'); + + return $qb; + }, + 'choice_label' => function (User $u) { + return $u->getUsername(); + }, + 'multiple' => false, + 'label' => 'User', + 'required' => false, + ]); + + return $builder->getForm(); + } + +} \ No newline at end of file diff --git a/src/Bundle/ChillPersonBundle/Controller/UserAccompanyingPeriodController.php b/src/Bundle/ChillPersonBundle/Controller/UserAccompanyingPeriodController.php index 774b272c5..321f212d5 100644 --- a/src/Bundle/ChillPersonBundle/Controller/UserAccompanyingPeriodController.php +++ b/src/Bundle/ChillPersonBundle/Controller/UserAccompanyingPeriodController.php @@ -11,17 +11,11 @@ declare(strict_types=1); namespace Chill\PersonBundle\Controller; -use Chill\MainBundle\Entity\User; use Chill\MainBundle\Pagination\PaginatorFactory; -use Chill\PersonBundle\Entity\AccompanyingPeriod; use Chill\PersonBundle\Repository\AccompanyingPeriodRepository; -use Doctrine\ORM\EntityRepository; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; -use Symfony\Component\Form\FormInterface; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\Routing\Annotation\Route; -use Symfony\Component\Security\Core\Exception\AccessDeniedException; -use Symfony\Component\Security\Core\Security; class UserAccompanyingPeriodController extends AbstractController { @@ -29,13 +23,10 @@ class UserAccompanyingPeriodController extends AbstractController private PaginatorFactory $paginatorFactory; - private Security $security; - - public function __construct(AccompanyingPeriodRepository $accompanyingPeriodRepository, PaginatorFactory $paginatorFactory, Security $security) + public function __construct(AccompanyingPeriodRepository $accompanyingPeriodRepository, PaginatorFactory $paginatorFactory) { $this->accompanyingPeriodRepository = $accompanyingPeriodRepository; $this->paginatorFactory = $paginatorFactory; - $this->security = $security; } /** @@ -77,58 +68,4 @@ class UserAccompanyingPeriodController extends AbstractController 'pagination' => $pagination, ]); } - - /** - * @Route("/{_locale}/person/accompanying-periods/my/drafts", name="chill_person_accompanying_period_draft_user") - */ - public function listConfirmedAction(Request $request) - { - if (!$this->security->isGranted('ROLE_USER') || !$this->security->getUser() instanceof User) { - throw new AccessDeniedException(); - } - - $form = $this->buildUserSelectionForm(); - - $form->handleRequest($request); - if ($form->isSubmitted() && $form->isValid()) { - $user = $_POST['user']; - - $periods = $this->getDoctrine()->getRepository(AccompanyingPeriod::class)->findConfirmedByUser($user); - - return $this->render('@ChillPerson/AccompanyingPeriod/user_reassign_periods_list.html.twig', [ - 'accompanyingPeriods' => $periods, - ]); - } - - return $this->render('@ChillPerson/AccompanyingPeriod/user_reassign_periods_list.html.twig', [ - 'form' => $form - ]); - } - - private function buildUserSelectionForm(): FormInterface - { - $data = [ - 'users' => [], - ]; - - $builder = $this->formFactory->createBuilder(FormType::class, $data, [ - 'method' => 'get', 'csrf_protection' => false]); - - $builder - ->add('users', EntityType::class, [ - 'class' => User::class, - 'query_builder' => function (EntityRepository $er) { - $qb = $er->createQueryBuilder('u'); - return $qb; - }, - 'choice_label' => function(User $u) { - return $u->getUsername(); - }, - 'multiple' => false, - 'label' => 'User', - 'required' => false, - ]); - - return $builder->getForm(); - } } diff --git a/src/Bundle/ChillPersonBundle/Repository/AccompanyingPeriodACLAwareRepository.php b/src/Bundle/ChillPersonBundle/Repository/AccompanyingPeriodACLAwareRepository.php index 6e6c3ca44..735227ced 100644 --- a/src/Bundle/ChillPersonBundle/Repository/AccompanyingPeriodACLAwareRepository.php +++ b/src/Bundle/ChillPersonBundle/Repository/AccompanyingPeriodACLAwareRepository.php @@ -11,6 +11,7 @@ declare(strict_types=1); namespace Chill\PersonBundle\Repository; +use Chill\MainBundle\Entity\User; use Chill\MainBundle\Security\Authorization\AuthorizationHelper; use Chill\MainBundle\Security\Resolver\CenterResolverDispatcherInterface; use Chill\PersonBundle\Entity\AccompanyingPeriod; @@ -92,4 +93,26 @@ final class AccompanyingPeriodACLAwareRepository implements AccompanyingPeriodAC return $qb->getQuery()->getResult(); } + + /** + * @return array|AccompanyingPeriod[] + */ + public function findByUserConfirmed(?User $user, int $limit, int $offset): array + { + if (null === $user) { + return []; + } + + $qb = $this->accompanyingPeriodRepository->createQueryBuilder('ap'); + + $qb->where($qb->expr()->eq('ap.user', ':user')) + ->andWhere( + $qb->expr()->eq('ap.step', ':confirmed') + ) + ->setParameter('user', $user) + ->setParameter('confirmed', AccompanyingPeriod::STEP_CONFIRMED); + + return $qb->getQuery()->getResult(); + + } } diff --git a/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingPeriod/reassign_list.html.twig b/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingPeriod/reassign_list.html.twig new file mode 100644 index 000000000..673b8a36d --- /dev/null +++ b/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingPeriod/reassign_list.html.twig @@ -0,0 +1,80 @@ +{% extends 'ChillMainBundle::layout.html.twig' %} + +{% block title "Liste de parcours à réassigner" %} + +{% block js %} + {{ encore_entry_script_tags('mod_set_referrer') }} +{% endblock %} + +{% block css %} + {{ encore_entry_link_tags('mod_set_referrer') }} +{% endblock %} + +{# {% macro period_meta(period) %} + {% if is_granted('CHILL_PERSON_ACCOMPANYING_PERIOD_UPDATE', period) %} +
    + {% set job_id = null %} + {% if period.job is defined %} + {% set job_id = period.job.id %} + {% endif %} + +
    + {% endif %} +{% endmacro %} #} + +{% macro period_actions(period) %} + {% if is_granted('CHILL_PERSON_ACCOMPANYING_PERIOD_SEE', period) %} +
  • + +
  • + {% endif %} +{% endmacro %} + +{% import _self as m %} + +{% block content %} +
    +

    {{ block('title') }}

    + + {{ form_start(form) }} +
    +
    + {{ form_label(form.user ) }} + {{ form_widget(form.user, {'attr': {'class': 'select2'}}) }} +
    +
    + +
      +
    • + +
    • +
    + + {{ form_end(form) }} + + {% if form.user.vars.value is empty %} +

    Choisissez un référent pour afficher ses parcours.

    + {% elseif periods|length == 0 and form.user.vars.value is not empty %} +

    Aucun parcour à réassigner pour cet utilisateur.

    + {% else %} +

    Amount of parcours à réassigner (calculé ce jour à {{ null|format_time('medium') }})

    + +
    + {% for period in periods %} + {% include '@ChillPerson/AccompanyingPeriod/_list_item.html.twig' with {'period': period, + 'recordAction': m.period_actions(period) } %} + {% endfor %} +
    + {% endif %} + + {# {{ chill_pagination(paginator) }} #} + +
    +{% endblock %} + diff --git a/src/Bundle/ChillPersonBundle/config/services/controller.yaml b/src/Bundle/ChillPersonBundle/config/services/controller.yaml index 22d58ccbe..67c724093 100644 --- a/src/Bundle/ChillPersonBundle/config/services/controller.yaml +++ b/src/Bundle/ChillPersonBundle/config/services/controller.yaml @@ -41,6 +41,11 @@ services: autowire: true tags: ['controller.service_arguments'] + Chill\PersonBundle\Controller\ReassignAccompanyingPeriodController: + autoconfigure: true + autowire: true + tags: ['controller.service_arguments'] + Chill\PersonBundle\Controller\PersonApiController: arguments: $authorizationHelper: '@Chill\MainBundle\Security\Authorization\AuthorizationHelper' From 6adb647ccc1cd9d760e7b714d3642e6eb313ed2d Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Thu, 17 Mar 2022 12:31:44 +0100 Subject: [PATCH 17/64] changelog updated --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 96685b5f0..e0f20e6b0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -45,6 +45,7 @@ and this project adheres to * [contact] add contact button color changed plus the pipe at the side removed (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/506) * [household] create-edit household composition placed in separate page to avoid confusion (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/505) * [blur] Improved positioning of toggle icon (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/486) +* [parcours] List of parcours for a specific user so they can be reassigned in case of absence (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/509) ## Test releases From 72ba2c6bca7ade11464bb4f03abca9429efc0e16 Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Thu, 17 Mar 2022 14:13:21 +0100 Subject: [PATCH 18/64] paginator added + phpcsfixes --- .../Repository/UserRepository.php | 10 ++--- .../ReassignAccompanyingPeriodController.php | 35 ++++++++++-------- .../AccompanyingPeriodACLAwareRepository.php | 37 ++++++++++++++----- .../reassign_list.html.twig | 15 ++++---- 4 files changed, 61 insertions(+), 36 deletions(-) diff --git a/src/Bundle/ChillMainBundle/Repository/UserRepository.php b/src/Bundle/ChillMainBundle/Repository/UserRepository.php index 56a82de3d..0616878ff 100644 --- a/src/Bundle/ChillMainBundle/Repository/UserRepository.php +++ b/src/Bundle/ChillMainBundle/Repository/UserRepository.php @@ -32,11 +32,6 @@ final class UserRepository implements ObjectRepository $this->repository = $entityManager->getRepository(User::class); } - public function createQueryBuilder(string $alias, ?string $indexBy = null): QueryBuilder - { - return $this->repository->createQueryBuilder($alias, $indexBy); - } - public function countBy(array $criteria): int { return $this->repository->count($criteria); @@ -56,6 +51,11 @@ final class UserRepository implements ObjectRepository return (int) $qb->getQuery()->getSingleScalarResult(); } + public function createQueryBuilder(string $alias, ?string $indexBy = null): QueryBuilder + { + return $this->repository->createQueryBuilder($alias, $indexBy); + } + public function find($id, $lockMode = null, $lockVersion = null): ?User { return $this->repository->find($id, $lockMode, $lockVersion); diff --git a/src/Bundle/ChillPersonBundle/Controller/ReassignAccompanyingPeriodController.php b/src/Bundle/ChillPersonBundle/Controller/ReassignAccompanyingPeriodController.php index 66a460199..04e38da13 100644 --- a/src/Bundle/ChillPersonBundle/Controller/ReassignAccompanyingPeriodController.php +++ b/src/Bundle/ChillPersonBundle/Controller/ReassignAccompanyingPeriodController.php @@ -1,11 +1,19 @@ handleRequest($request); - // $total = $this->accompanyingPeriodACLAwareRepository->countByUserConfirmed( - // $form['jobs']->getData(), - // $form['services']->getData(), - // $form['locations']->getData(), - // ); - // $paginator = $this->paginatorFactory->create($total); + $total = $this->accompanyingPeriodACLAwareRepository->countByUserConfirmed( + $form['user']->getData() + ); + $paginator = $this->paginatorFactory->create($total); $periods = $this->accompanyingPeriodACLAwareRepository ->findByUserConfirmed( $form['user']->getData(), - 1, - 1 + $paginator->getItemsPerPage(), + $paginator->getCurrentPageFirstItemNumber() ); return new Response( $this->engine->render('@ChillPerson/AccompanyingPeriod/reassign_list.html.twig', [ - // 'paginator' => $paginator, + 'paginator' => $paginator, 'periods' => $periods, - 'form' => $form->createView() + 'form' => $form->createView(), ]) ); } @@ -81,7 +87,7 @@ class ReassignAccompanyingPeriodController extends AbstractController private function buildFilterForm(): FormInterface { $builder = $this->formFactory->createBuilder(FormType::class, [ - 'method' => 'get', 'csrf_protection' => false]); + 'method' => 'get', 'csrf_protection' => false, ]); $builder ->add('user', EntityType::class, [ @@ -94,7 +100,7 @@ class ReassignAccompanyingPeriodController extends AbstractController return $qb; }, - 'choice_label' => function (User $u) { + 'choice_label' => static function (User $u) { return $u->getUsername(); }, 'multiple' => false, @@ -104,5 +110,4 @@ class ReassignAccompanyingPeriodController extends AbstractController return $builder->getForm(); } - -} \ No newline at end of file +} diff --git a/src/Bundle/ChillPersonBundle/Repository/AccompanyingPeriodACLAwareRepository.php b/src/Bundle/ChillPersonBundle/Repository/AccompanyingPeriodACLAwareRepository.php index 735227ced..47e1ee441 100644 --- a/src/Bundle/ChillPersonBundle/Repository/AccompanyingPeriodACLAwareRepository.php +++ b/src/Bundle/ChillPersonBundle/Repository/AccompanyingPeriodACLAwareRepository.php @@ -42,6 +42,33 @@ final class AccompanyingPeriodACLAwareRepository implements AccompanyingPeriodAC $this->centerResolverDispatcher = $centerResolverDispatcher; } + public function buildQueryByUser(?User $user) + { + $qb = $this->accompanyingPeriodRepository->createQueryBuilder('ap'); + + $qb->where($qb->expr()->eq('ap.user', ':user')) + ->andWhere( + $qb->expr()->eq('ap.step', ':confirmed'), + $qb->expr()->eq('ap.confidential', 'false') + ) + ->setParameter('user', $user) + ->setParameter('confirmed', AccompanyingPeriod::STEP_CONFIRMED); + + return $qb; + } + + public function countByUserConfirmed(?User $user) + { + if (null === $user) { + return 0; + } + + return $this->buildQueryByUser($user) + ->select('COUNT(ap)') + ->getQuery() + ->getSingleScalarResult(); + } + public function findByPerson( Person $person, string $role, @@ -103,16 +130,8 @@ final class AccompanyingPeriodACLAwareRepository implements AccompanyingPeriodAC return []; } - $qb = $this->accompanyingPeriodRepository->createQueryBuilder('ap'); - - $qb->where($qb->expr()->eq('ap.user', ':user')) - ->andWhere( - $qb->expr()->eq('ap.step', ':confirmed') - ) - ->setParameter('user', $user) - ->setParameter('confirmed', AccompanyingPeriod::STEP_CONFIRMED); + $qb = $this->buildQueryByUser($user); return $qb->getQuery()->getResult(); - } } diff --git a/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingPeriod/reassign_list.html.twig b/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingPeriod/reassign_list.html.twig index 673b8a36d..d7e11f6ee 100644 --- a/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingPeriod/reassign_list.html.twig +++ b/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingPeriod/reassign_list.html.twig @@ -1,6 +1,6 @@ {% extends 'ChillMainBundle::layout.html.twig' %} -{% block title "Liste de parcours à réassigner" %} +{% block title "Liste de parcours à réassigner pour un utilisateur" %} {% block js %} {{ encore_entry_script_tags('mod_set_referrer') }} @@ -10,7 +10,7 @@ {{ encore_entry_link_tags('mod_set_referrer') }} {% endblock %} -{# {% macro period_meta(period) %} +{% macro period_meta(period) %} {% if is_granted('CHILL_PERSON_ACCOMPANYING_PERIOD_UPDATE', period) %}
    {% set job_id = null %} @@ -24,7 +24,8 @@ >
    {% endif %} -{% endmacro %} #} +{% endmacro %} + {% macro period_actions(period) %} {% if is_granted('CHILL_PERSON_ACCOMPANYING_PERIOD_SEE', period) %} @@ -61,19 +62,19 @@ {% if form.user.vars.value is empty %}

    Choisissez un référent pour afficher ses parcours.

    {% elseif periods|length == 0 and form.user.vars.value is not empty %} -

    Aucun parcour à réassigner pour cet utilisateur.

    +

    Aucun parcours actifs pour ce référent.

    {% else %} -

    Amount of parcours à réassigner (calculé ce jour à {{ null|format_time('medium') }})

    +

    {{ paginator.totalItems }} parcours à réassigner (calculé ce jour à {{ null|format_time('medium') }})

    {% for period in periods %} {% include '@ChillPerson/AccompanyingPeriod/_list_item.html.twig' with {'period': period, - 'recordAction': m.period_actions(period) } %} + 'recordAction': m.period_actions(period), 'itemMeta': m.period_meta(period) } %} {% endfor %}
    {% endif %} - {# {{ chill_pagination(paginator) }} #} + {{ chill_pagination(paginator) }}
    {% endblock %} From 5e0a69310887183d1c434ddbe0a73790c7c2ddf0 Mon Sep 17 00:00:00 2001 From: nobohan Date: Thu, 17 Mar 2022 17:51:25 +0100 Subject: [PATCH 19/64] commentembeddable: add a condition for the early return in normalisation --- .../Serializer/Normalizer/CommentEmbeddableDocGenNormalizer.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Bundle/ChillMainBundle/Serializer/Normalizer/CommentEmbeddableDocGenNormalizer.php b/src/Bundle/ChillMainBundle/Serializer/Normalizer/CommentEmbeddableDocGenNormalizer.php index bd812e036..f5b10b9d8 100644 --- a/src/Bundle/ChillMainBundle/Serializer/Normalizer/CommentEmbeddableDocGenNormalizer.php +++ b/src/Bundle/ChillMainBundle/Serializer/Normalizer/CommentEmbeddableDocGenNormalizer.php @@ -39,7 +39,7 @@ class CommentEmbeddableDocGenNormalizer implements ContextAwareNormalizerInterfa */ public function normalize($object, ?string $format = null, array $context = []): array { - if (null === $object) { + if (null === $object or (null === $object->getComment() and null === $object->getUserId() and null === $object->getDate())) { return [ 'comment' => '', 'isNull' => true, From e7299bac4a58edae4e48e7af39b47d7e69304ce6 Mon Sep 17 00:00:00 2001 From: nobohan Date: Thu, 17 Mar 2022 19:07:11 +0100 Subject: [PATCH 20/64] person: add person ressource to person docgen normaliser --- .../Entity/Person/PersonResource.php | 21 +++++++++++++++++++ .../Normalizer/PersonDocGenNormalizer.php | 8 ++++++- 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/src/Bundle/ChillPersonBundle/Entity/Person/PersonResource.php b/src/Bundle/ChillPersonBundle/Entity/Person/PersonResource.php index 3cd82680e..0eeb6a293 100644 --- a/src/Bundle/ChillPersonBundle/Entity/Person/PersonResource.php +++ b/src/Bundle/ChillPersonBundle/Entity/Person/PersonResource.php @@ -117,6 +117,27 @@ class PersonResource implements TrackCreationInterface, TrackUpdateInterface return $this->person; } + /** + * @Groups({"read"}) + */ + public function getResourceKind(): string + { + if ($this->getPerson() instanceof Person) { + return 'person'; + } + + if ($this->getThirdParty() instanceof ThirdParty) { + return 'thirdparty'; + } + + if (null !== $this->getFreeText()) { + return 'freetext'; + } + + return 'none'; + } + + public function getPersonOwner(): ?Person { return $this->personOwner; diff --git a/src/Bundle/ChillPersonBundle/Serializer/Normalizer/PersonDocGenNormalizer.php b/src/Bundle/ChillPersonBundle/Serializer/Normalizer/PersonDocGenNormalizer.php index c6d132992..c463bfd23 100644 --- a/src/Bundle/ChillPersonBundle/Serializer/Normalizer/PersonDocGenNormalizer.php +++ b/src/Bundle/ChillPersonBundle/Serializer/Normalizer/PersonDocGenNormalizer.php @@ -18,6 +18,7 @@ use Chill\MainBundle\Templating\TranslatableStringHelper; use Chill\PersonBundle\Entity\Household\Household; use Chill\PersonBundle\Entity\Person; use Chill\PersonBundle\Entity\PersonAltName; +use Chill\PersonBundle\Repository\PersonResourceRepository; use Chill\PersonBundle\Repository\Relationships\RelationshipRepository; use Chill\PersonBundle\Templating\Entity\PersonRenderInterface; use DateTimeInterface; @@ -41,6 +42,8 @@ class PersonDocGenNormalizer implements private RelationshipRepository $relationshipRepository; + private PersonResourceRepository $personResourceRepository; + private TranslatableStringHelper $translatableStringHelper; private TranslatorInterface $translator; @@ -48,11 +51,13 @@ class PersonDocGenNormalizer implements public function __construct( PersonRenderInterface $personRender, RelationshipRepository $relationshipRepository, + PersonResourceRepository $personResourceRepository, TranslatorInterface $translator, TranslatableStringHelper $translatableStringHelper ) { $this->personRender = $personRender; $this->relationshipRepository = $relationshipRepository; + $this->personResourceRepository = $personResourceRepository; $this->translator = $translator; $this->translatableStringHelper = $translatableStringHelper; } @@ -104,8 +109,9 @@ class PersonDocGenNormalizer implements 'memo' => $person->getMemo(), 'numberOfChildren' => (string) $person->getNumberOfChildren(), 'address' => $this->normalizer->normalize($person->getCurrentPersonAddress(), $format, $addressContext), + 'resources' => $this->personResourceRepository->findBy(['personOwner' => $person]), ]; - + dump($data); if ($context['docgen:person:with-household'] ?? false) { $data['household'] = $this->normalizer->normalize( $person->getCurrentHousehold(), From 3b8c329ff6cc5f80fb86c1282d5bb0bd31a67315 Mon Sep 17 00:00:00 2001 From: nobohan Date: Thu, 17 Mar 2022 19:08:13 +0100 Subject: [PATCH 21/64] upd CHANGELOG --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index ff62b029c..b84ec4e80 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,7 @@ and this project adheres to ## Unreleased +* [person] add person ressource to person docgen normaliser (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/517) * [person] AccompanyingPeriodWorkEvaluation: fix circular reference when serialising (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/495) * [person] order accompanying period by opening date in search persons, person and household period lists (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/493) * [parcours] autosave of the pinned comment for draft accompanying course (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/477) From 73dd97f7d3ddc33ad31e1b37655b335ef32b123e Mon Sep 17 00:00:00 2001 From: nobohan Date: Fri, 18 Mar 2022 13:58:20 +0100 Subject: [PATCH 22/64] upd CHANGELOG --- CHANGELOG.md | 1 + .../ChillActivityBundle/Controller/ActivityController.php | 7 ++++--- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ff62b029c..17471fcdd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,7 @@ and this project adheres to ## Unreleased +* [activity] Add return path the document generation (https://gitlab.com/champs-libres/departement-de-la-vendee/accent-suivi-developpement/-/issues/553) * [person] AccompanyingPeriodWorkEvaluation: fix circular reference when serialising (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/495) * [person] order accompanying period by opening date in search persons, person and household period lists (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/493) * [parcours] autosave of the pinned comment for draft accompanying course (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/477) diff --git a/src/Bundle/ChillActivityBundle/Controller/ActivityController.php b/src/Bundle/ChillActivityBundle/Controller/ActivityController.php index 3858979ef..6bf4f1d0d 100644 --- a/src/Bundle/ChillActivityBundle/Controller/ActivityController.php +++ b/src/Bundle/ChillActivityBundle/Controller/ActivityController.php @@ -220,6 +220,9 @@ final class ActivityController extends AbstractController $this->entityManager->persist($entity); $this->entityManager->flush(); + $params = $this->buildParamsToUrl($person, $accompanyingPeriod); + $params['id'] = $entity->getId(); + if ($form->has('gendocTemplateId') && null !== $form['gendocTemplateId']->getData()) { return $this->redirectToRoute( 'chill_docgenerator_generate_from_template', @@ -227,15 +230,13 @@ final class ActivityController extends AbstractController 'template' => $form->get('gendocTemplateId')->getData(), 'entityClassName' => Activity::class, 'entityId' => $entity->getId(), + 'returnPath' => $this->generateUrl('chill_activity_activity_edit', $params) ] ); } $this->addFlash('success', $this->get('translator')->trans('Success : activity updated!')); - $params = $this->buildParamsToUrl($person, $accompanyingPeriod); - $params['id'] = $entity->getId(); - return $this->redirectToRoute('chill_activity_activity_show', $params); } From 215b85972570dd89311e372654556d6796f82fae Mon Sep 17 00:00:00 2001 From: nobohan Date: Fri, 18 Mar 2022 15:25:45 +0100 Subject: [PATCH 23/64] activity: hide delete button from asyncupload and add delete buttons from chill collection --- src/Bundle/ChillActivityBundle/Form/ActivityType.php | 1 + .../Resources/public/page/edit_activity/index.scss | 5 +++++ .../views/Activity/editAccompanyingCourse.html.twig | 1 + src/Bundle/ChillActivityBundle/chill.webpack.config.js | 2 ++ 4 files changed, 9 insertions(+) create mode 100644 src/Bundle/ChillActivityBundle/Resources/public/page/edit_activity/index.scss diff --git a/src/Bundle/ChillActivityBundle/Form/ActivityType.php b/src/Bundle/ChillActivityBundle/Form/ActivityType.php index 6f935ad99..891eb8577 100644 --- a/src/Bundle/ChillActivityBundle/Form/ActivityType.php +++ b/src/Bundle/ChillActivityBundle/Form/ActivityType.php @@ -305,6 +305,7 @@ class ActivityType extends AbstractType 'label' => $activityType->getLabel('documents'), 'required' => $activityType->isRequired('documents'), 'allow_add' => true, + 'allow_delete' => true, 'button_add_label' => 'activity.Insert a document', 'button_remove_label' => 'activity.Remove a document', 'empty_collection_explain' => 'No documents', diff --git a/src/Bundle/ChillActivityBundle/Resources/public/page/edit_activity/index.scss b/src/Bundle/ChillActivityBundle/Resources/public/page/edit_activity/index.scss new file mode 100644 index 000000000..fc384742a --- /dev/null +++ b/src/Bundle/ChillActivityBundle/Resources/public/page/edit_activity/index.scss @@ -0,0 +1,5 @@ +div.chill-dropzone__below-zone { + a.btn-delete { + display: none; + } +} \ No newline at end of file diff --git a/src/Bundle/ChillActivityBundle/Resources/views/Activity/editAccompanyingCourse.html.twig b/src/Bundle/ChillActivityBundle/Resources/views/Activity/editAccompanyingCourse.html.twig index b278c0300..d0359e223 100644 --- a/src/Bundle/ChillActivityBundle/Resources/views/Activity/editAccompanyingCourse.html.twig +++ b/src/Bundle/ChillActivityBundle/Resources/views/Activity/editAccompanyingCourse.html.twig @@ -30,4 +30,5 @@ {{ parent() }} {{ encore_entry_link_tags('mod_async_upload') }} {{ encore_entry_link_tags('vue_activity') }} + {{ encore_entry_link_tags('page_edit_activity') }} {% endblock %} diff --git a/src/Bundle/ChillActivityBundle/chill.webpack.config.js b/src/Bundle/ChillActivityBundle/chill.webpack.config.js index f312e8a19..eec983920 100644 --- a/src/Bundle/ChillActivityBundle/chill.webpack.config.js +++ b/src/Bundle/ChillActivityBundle/chill.webpack.config.js @@ -7,5 +7,7 @@ module.exports = function(encore, entries) ChillActivityAssets: __dirname + '/Resources/public' }); + encore.addEntry('page_edit_activity', __dirname + '/Resources/public/page/edit_activity/index.scss'); + encore.addEntry('vue_activity', __dirname + '/Resources/public/vuejs/Activity/index.js'); }; From 9c353669ead5fd133f29f411353695790a012097 Mon Sep 17 00:00:00 2001 From: nobohan Date: Fri, 18 Mar 2022 16:11:09 +0100 Subject: [PATCH 24/64] activity: fix delete button for documents --- CHANGELOG.md | 1 + .../Resources/public/page/edit_activity/index.scss | 13 ++++++++++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 17471fcdd..027eff683 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,7 @@ and this project adheres to ## Unreleased +* [activity] Fix delete button for document (https://gitlab.com/champs-libres/departement-de-la-vendee/accent-suivi-developpement/-/issues/554) * [activity] Add return path the document generation (https://gitlab.com/champs-libres/departement-de-la-vendee/accent-suivi-developpement/-/issues/553) * [person] AccompanyingPeriodWorkEvaluation: fix circular reference when serialising (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/495) * [person] order accompanying period by opening date in search persons, person and household period lists (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/493) diff --git a/src/Bundle/ChillActivityBundle/Resources/public/page/edit_activity/index.scss b/src/Bundle/ChillActivityBundle/Resources/public/page/edit_activity/index.scss index fc384742a..16e66eadb 100644 --- a/src/Bundle/ChillActivityBundle/Resources/public/page/edit_activity/index.scss +++ b/src/Bundle/ChillActivityBundle/Resources/public/page/edit_activity/index.scss @@ -2,4 +2,15 @@ div.chill-dropzone__below-zone { a.btn-delete { display: none; } -} \ No newline at end of file +} + +// do it in js does not work +// document.addEventListener('DOMContentLoaded', e => { +// const dropzoneBelow = document.querySelectorAll('div.chill-dropzone__below-zone'); +// dropzoneBelow.forEach( +// d => { +// const a = d.querySelector('a.btn-delete'); +// d.removeChild(a); +// } +// ) +// }); From dbc604d84a1b61b761ff5a78c8ddb96b241aab04 Mon Sep 17 00:00:00 2001 From: nobohan Date: Fri, 18 Mar 2022 17:02:35 +0100 Subject: [PATCH 25/64] AccompanyingCourseWorkEdit: download existing documents --- CHANGELOG.md | 2 ++ .../public/vuejs/AccompanyingCourseWorkEdit/store.js | 6 ++---- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 13ae858ba..885af7493 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,8 @@ and this project adheres to ## Unreleased + +* [person] AccompanyingCourseWorkEdit: fix deleting evaluation documents (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/546) * [person] AccompanyingCourseWorkEdit: download existing documents (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/512) * [person] AccompanyingCourseWorkEdit: replace document by a new one (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/511) diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourseWorkEdit/store.js b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourseWorkEdit/store.js index 2ea9b48e0..359e7afad 100644 --- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourseWorkEdit/store.js +++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourseWorkEdit/store.js @@ -131,9 +131,9 @@ const store = createStore({ endDate: e.endDate !== null ? ISOToDatetime(e.endDate.datetime) : null, maxDate: e.maxDate !== null ? ISOToDatetime(e.maxDate.datetime) : null, warningInterval: e.warningInterval !== null ? intervalISOToDays(e.warningInterval) : null, - documents: e.documents.map((d, dindex) => { + documents: e.documents.map((d, docIndex) => { return Object.assign(d, { - key: index + key: docIndex }); }), }); @@ -214,11 +214,9 @@ const store = createStore({ }, removeDocument(state, {key, document}) { let evaluation = state.evaluationsPicked.find(e => e.key === key); - if (evaluation === undefined) { return; } - evaluation.documents = evaluation.documents.filter(d => d.key !== document.key); }, replaceDocument(state, payload) { From caaa25ef8eed3f7dc54c740936122823648b5371 Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Sat, 19 Mar 2022 12:08:20 +0100 Subject: [PATCH 26/64] controller action to create parcours from within household + link added in template --- .../AccompanyingCourseController.php | 35 +++++++++++++++++++ .../Household/accompanying_period.html.twig | 7 ++-- 2 files changed, 38 insertions(+), 4 deletions(-) diff --git a/src/Bundle/ChillPersonBundle/Controller/AccompanyingCourseController.php b/src/Bundle/ChillPersonBundle/Controller/AccompanyingCourseController.php index aa3c5f512..b15f8adb9 100644 --- a/src/Bundle/ChillPersonBundle/Controller/AccompanyingCourseController.php +++ b/src/Bundle/ChillPersonBundle/Controller/AccompanyingCourseController.php @@ -13,6 +13,7 @@ namespace Chill\PersonBundle\Controller; use Chill\ActivityBundle\Entity\Activity; use Chill\PersonBundle\Entity\AccompanyingPeriod; +use Chill\PersonBundle\Entity\Household\Household; use Chill\PersonBundle\Entity\Person; use Chill\PersonBundle\Form\AccompanyingCourseType; use Chill\PersonBundle\Repository\AccompanyingPeriod\AccompanyingPeriodWorkRepository; @@ -279,6 +280,40 @@ class AccompanyingCourseController extends Controller ]); } + /** + * @Route("/{_locale}/person/household/parcours/new", name="chill_household_accompanying_course_new") + */ + public function newHouseholdParcoursAction(Request $request): Response + { + $period = new AccompanyingPeriod(); + $em = $this->getDoctrine()->getManager(); + + if ($request->query->has('household_id')) { + $householdId = $request->query->get('household_id'); + + $household = $em->getRepository(Household::class)->find($householdId); + $members = $household->getCurrentMembers(); + + if (null !== $members) { + foreach ($members as $m) { + $period->addPerson($m->getPerson()); + } + } + } + + $userLocation = $this->getUser()->getCurrentLocation(); + $period->setAdministrativeLocation($userLocation); + + $this->denyAccessUnlessGranted(AccompanyingPeriodVoter::CREATE, $period); + + $em->persist($period); + $em->flush(); + + return $this->redirectToRoute('chill_person_accompanying_course_edit', [ + 'accompanying_period_id' => $period->getId(), + ]); + } + /** * @Route("/{_locale}/parcours/{accompanying_period_id}/open", name="chill_person_accompanying_course_reopen") * @ParamConverter("accompanyingCourse", options={"id": "accompanying_period_id"}) diff --git a/src/Bundle/ChillPersonBundle/Resources/views/Household/accompanying_period.html.twig b/src/Bundle/ChillPersonBundle/Resources/views/Household/accompanying_period.html.twig index 5a8d2acf8..9cc323274 100644 --- a/src/Bundle/ChillPersonBundle/Resources/views/Household/accompanying_period.html.twig +++ b/src/Bundle/ChillPersonBundle/Resources/views/Household/accompanying_period.html.twig @@ -46,13 +46,12 @@ {{ 'Household summary'|trans }} - {#
  • - - {{ 'Create an accompanying period'|trans }} + + {{ 'Create an accompanying period'|trans }}
  • - #}
From a2daeff38427722201d42a9210dbfb16de89e878 Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Sat, 19 Mar 2022 12:10:47 +0100 Subject: [PATCH 27/64] csfixes --- .../ChillMainBundle/Command/LoadPostalCodesCommand.php | 5 +++-- .../Serializer/Normalizer/PhonenumberNormalizer.php | 9 ++++----- .../Menu/AccompanyingCourseMenuBuilder.php | 2 +- .../views/Household/accompanying_period.html.twig | 1 + ...anyingPeriodWorkEvaluationDocumentWorkflowHandler.php | 2 +- 5 files changed, 10 insertions(+), 9 deletions(-) diff --git a/src/Bundle/ChillMainBundle/Command/LoadPostalCodesCommand.php b/src/Bundle/ChillMainBundle/Command/LoadPostalCodesCommand.php index 5d577a0b4..bc4616b7b 100644 --- a/src/Bundle/ChillMainBundle/Command/LoadPostalCodesCommand.php +++ b/src/Bundle/ChillMainBundle/Command/LoadPostalCodesCommand.php @@ -26,6 +26,7 @@ use Symfony\Component\Filesystem\Filesystem; use Symfony\Component\Validator\Validator\ValidatorInterface; use function count; +use function strlen; class LoadPostalCodesCommand extends Command { @@ -118,11 +119,11 @@ class LoadPostalCodesCommand extends Command private function addPostalCode($row, OutputInterface $output) { - if($row[2] == 'FR' && strlen($row[0]) == 4) { + if ('FR' === $row[2] && strlen($row[0]) === 4) { // CP in FRANCE are on 5 digit // For CP starting with a zero, the starting zero can be remove if stored as number in a csv // add a zero if CP from FR and on 4 digit - $row[0] = '0'.$row[0]; + $row[0] = '0' . $row[0]; } if ($output->getVerbosity() >= OutputInterface::VERBOSITY_VERBOSE) { diff --git a/src/Bundle/ChillMainBundle/Serializer/Normalizer/PhonenumberNormalizer.php b/src/Bundle/ChillMainBundle/Serializer/Normalizer/PhonenumberNormalizer.php index 677199ad4..7eb323754 100644 --- a/src/Bundle/ChillMainBundle/Serializer/Normalizer/PhonenumberNormalizer.php +++ b/src/Bundle/ChillMainBundle/Serializer/Normalizer/PhonenumberNormalizer.php @@ -18,7 +18,6 @@ use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface; use Symfony\Component\Serializer\Exception\UnexpectedValueException; use Symfony\Component\Serializer\Normalizer\ContextAwareNormalizerInterface; use Symfony\Component\Serializer\Normalizer\DenormalizerInterface; -use Symfony\Component\Serializer\Normalizer\NormalizerInterface; class PhonenumberNormalizer implements ContextAwareNormalizerInterface, DenormalizerInterface { @@ -54,7 +53,7 @@ class PhonenumberNormalizer implements ContextAwareNormalizerInterface, Denormal public function normalize($object, ?string $format = null, array $context = []): string { - if ($format === 'docgen' && null === $object) { + if ('docgen' === $format && null === $object) { return ''; } @@ -68,13 +67,13 @@ class PhonenumberNormalizer implements ContextAwareNormalizerInterface, Denormal public function supportsNormalization($data, ?string $format = null, array $context = []): bool { - if ($data instanceof PhoneNumber && $format === 'json') { + if ($data instanceof PhoneNumber && 'json' === $format) { return true; } - if ($format === 'docgen' && ( + if ('docgen' === $format && ( $data instanceof PhoneNumber || PhoneNumber::class === ($context['docgen:expects'] ?? null) - )) { + )) { return true; } diff --git a/src/Bundle/ChillPersonBundle/Menu/AccompanyingCourseMenuBuilder.php b/src/Bundle/ChillPersonBundle/Menu/AccompanyingCourseMenuBuilder.php index 8f1ecb0d1..929fb2ae0 100644 --- a/src/Bundle/ChillPersonBundle/Menu/AccompanyingCourseMenuBuilder.php +++ b/src/Bundle/ChillPersonBundle/Menu/AccompanyingCourseMenuBuilder.php @@ -75,7 +75,7 @@ class AccompanyingCourseMenuBuilder implements LocalMenuBuilderInterface 'accompanying_period_id' => $period->getId(), ], ]) ->setExtras(['order' => 30]); - */ + */ $menu->addChild($this->translator->trans('Accompanying Course Comment'), [ 'route' => 'chill_person_accompanying_period_comment_list', diff --git a/src/Bundle/ChillPersonBundle/Resources/views/Household/accompanying_period.html.twig b/src/Bundle/ChillPersonBundle/Resources/views/Household/accompanying_period.html.twig index 9cc323274..a793ac37a 100644 --- a/src/Bundle/ChillPersonBundle/Resources/views/Household/accompanying_period.html.twig +++ b/src/Bundle/ChillPersonBundle/Resources/views/Household/accompanying_period.html.twig @@ -46,6 +46,7 @@ {{ 'Household summary'|trans }} + {# TODO: add ACL to check if user is allowed to edit household? #}
  • diff --git a/src/Bundle/ChillPersonBundle/Workflow/AccompanyingPeriodWorkEvaluationDocumentWorkflowHandler.php b/src/Bundle/ChillPersonBundle/Workflow/AccompanyingPeriodWorkEvaluationDocumentWorkflowHandler.php index d7a196a6c..d7ce1ed4b 100644 --- a/src/Bundle/ChillPersonBundle/Workflow/AccompanyingPeriodWorkEvaluationDocumentWorkflowHandler.php +++ b/src/Bundle/ChillPersonBundle/Workflow/AccompanyingPeriodWorkEvaluationDocumentWorkflowHandler.php @@ -62,7 +62,7 @@ class AccompanyingPeriodWorkEvaluationDocumentWorkflowHandler implements EntityW 'workflow.Doc for evaluation (n°%eval%)', ['%eval%' => $entityWorkflow->getRelatedEntityId()] ) . ' (' . $this->translatableStringHelper->localize($doc->getAccompanyingPeriodWorkEvaluation() - ->getEvaluation()->getTitle()).') '.$doc->getTitle(); + ->getEvaluation()->getTitle()) . ') ' . $doc->getTitle(); } public function getRelatedEntity(EntityWorkflow $entityWorkflow): ?AccompanyingPeriodWorkEvaluationDocument From 72f69f0f82b90ffb5557bf6033dc2760195fdc7e Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Sat, 19 Mar 2022 12:11:49 +0100 Subject: [PATCH 28/64] changelog updated --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index e74bd2abe..e87917d96 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -48,6 +48,7 @@ and this project adheres to * [blur] Improved positioning of toggle icon (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/486) * [thirdparty] Thirdparty view page, english text translated (https://gitlab.com/champs-libres/departement-de-la-vendee/accent-suivi-developpement/-/issues/534) * [social_action] Translation changed in evaluation section (https://gitlab.com/champs-libres/departement-de-la-vendee/accent-suivi-developpement/-/issues/512) +* [household] Within parcours listing page of household add create button (https://gitlab.com/champs-libres/departement-de-la-vendee/accent-suivi-developpement/-/issues/560) ## Test releases From 15af0203fff262f1c0fc8bc100ad5cc4f1657433 Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Mon, 21 Mar 2022 10:21:12 +0100 Subject: [PATCH 29/64] add menu entry in section menu --- .../Menu/SectionMenuBuilder.php | 18 ++++++++++-------- .../translations/messages.fr.yml | 1 + 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/src/Bundle/ChillPersonBundle/Menu/SectionMenuBuilder.php b/src/Bundle/ChillPersonBundle/Menu/SectionMenuBuilder.php index 04f989d84..4635eb4fc 100644 --- a/src/Bundle/ChillPersonBundle/Menu/SectionMenuBuilder.php +++ b/src/Bundle/ChillPersonBundle/Menu/SectionMenuBuilder.php @@ -22,15 +22,9 @@ use Symfony\Contracts\Translation\TranslatorInterface; */ class SectionMenuBuilder implements LocalMenuBuilderInterface { - /** - * @var AuthorizationCheckerInterface - */ - protected $authorizationChecker; + protected AuthorizationCheckerInterface $authorizationChecker; - /** - * @var TranslatorInterface - */ - protected $translator; + protected TranslatorInterface $translator; /** * SectionMenuBuilder constructor. @@ -63,6 +57,14 @@ class SectionMenuBuilder implements LocalMenuBuilderInterface 'order' => 11, 'icons' => ['plus'], ]); + + $menu->addChild($this->translator->trans('Accompanying courses of users'), [ + 'route' => 'chill_course_list_reassign', + ]) + ->setExtras([ + 'order' => 12, + 'icons' => ['task'], + ]); } public static function getMenuIds(): array diff --git a/src/Bundle/ChillPersonBundle/translations/messages.fr.yml b/src/Bundle/ChillPersonBundle/translations/messages.fr.yml index bc238570d..57fc039b8 100644 --- a/src/Bundle/ChillPersonBundle/translations/messages.fr.yml +++ b/src/Bundle/ChillPersonBundle/translations/messages.fr.yml @@ -194,6 +194,7 @@ No accompanying user: Aucun accompagnant No data given: Pas d'information Participants: Personnes impliquées Create an accompanying course: Créer un parcours +Accompanying courses of users: Parcours des utilisateurs This accompanying course is still a draft: Ce parcours est encore à l'état brouillon. Associated peoples: Usagers concernés Resources: Interlocuteurs privilégiés From a06a0788c146b69d9d1e67f86eceea0548c0564b Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Mon, 21 Mar 2022 10:22:28 +0100 Subject: [PATCH 30/64] csfixes --- .../ChillMainBundle/Command/LoadPostalCodesCommand.php | 5 +++-- .../Serializer/Normalizer/PhonenumberNormalizer.php | 9 ++++----- .../Menu/AccompanyingCourseMenuBuilder.php | 2 +- ...anyingPeriodWorkEvaluationDocumentWorkflowHandler.php | 2 +- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/Bundle/ChillMainBundle/Command/LoadPostalCodesCommand.php b/src/Bundle/ChillMainBundle/Command/LoadPostalCodesCommand.php index 5d577a0b4..bc4616b7b 100644 --- a/src/Bundle/ChillMainBundle/Command/LoadPostalCodesCommand.php +++ b/src/Bundle/ChillMainBundle/Command/LoadPostalCodesCommand.php @@ -26,6 +26,7 @@ use Symfony\Component\Filesystem\Filesystem; use Symfony\Component\Validator\Validator\ValidatorInterface; use function count; +use function strlen; class LoadPostalCodesCommand extends Command { @@ -118,11 +119,11 @@ class LoadPostalCodesCommand extends Command private function addPostalCode($row, OutputInterface $output) { - if($row[2] == 'FR' && strlen($row[0]) == 4) { + if ('FR' === $row[2] && strlen($row[0]) === 4) { // CP in FRANCE are on 5 digit // For CP starting with a zero, the starting zero can be remove if stored as number in a csv // add a zero if CP from FR and on 4 digit - $row[0] = '0'.$row[0]; + $row[0] = '0' . $row[0]; } if ($output->getVerbosity() >= OutputInterface::VERBOSITY_VERBOSE) { diff --git a/src/Bundle/ChillMainBundle/Serializer/Normalizer/PhonenumberNormalizer.php b/src/Bundle/ChillMainBundle/Serializer/Normalizer/PhonenumberNormalizer.php index 677199ad4..7eb323754 100644 --- a/src/Bundle/ChillMainBundle/Serializer/Normalizer/PhonenumberNormalizer.php +++ b/src/Bundle/ChillMainBundle/Serializer/Normalizer/PhonenumberNormalizer.php @@ -18,7 +18,6 @@ use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface; use Symfony\Component\Serializer\Exception\UnexpectedValueException; use Symfony\Component\Serializer\Normalizer\ContextAwareNormalizerInterface; use Symfony\Component\Serializer\Normalizer\DenormalizerInterface; -use Symfony\Component\Serializer\Normalizer\NormalizerInterface; class PhonenumberNormalizer implements ContextAwareNormalizerInterface, DenormalizerInterface { @@ -54,7 +53,7 @@ class PhonenumberNormalizer implements ContextAwareNormalizerInterface, Denormal public function normalize($object, ?string $format = null, array $context = []): string { - if ($format === 'docgen' && null === $object) { + if ('docgen' === $format && null === $object) { return ''; } @@ -68,13 +67,13 @@ class PhonenumberNormalizer implements ContextAwareNormalizerInterface, Denormal public function supportsNormalization($data, ?string $format = null, array $context = []): bool { - if ($data instanceof PhoneNumber && $format === 'json') { + if ($data instanceof PhoneNumber && 'json' === $format) { return true; } - if ($format === 'docgen' && ( + if ('docgen' === $format && ( $data instanceof PhoneNumber || PhoneNumber::class === ($context['docgen:expects'] ?? null) - )) { + )) { return true; } diff --git a/src/Bundle/ChillPersonBundle/Menu/AccompanyingCourseMenuBuilder.php b/src/Bundle/ChillPersonBundle/Menu/AccompanyingCourseMenuBuilder.php index 8f1ecb0d1..929fb2ae0 100644 --- a/src/Bundle/ChillPersonBundle/Menu/AccompanyingCourseMenuBuilder.php +++ b/src/Bundle/ChillPersonBundle/Menu/AccompanyingCourseMenuBuilder.php @@ -75,7 +75,7 @@ class AccompanyingCourseMenuBuilder implements LocalMenuBuilderInterface 'accompanying_period_id' => $period->getId(), ], ]) ->setExtras(['order' => 30]); - */ + */ $menu->addChild($this->translator->trans('Accompanying Course Comment'), [ 'route' => 'chill_person_accompanying_period_comment_list', diff --git a/src/Bundle/ChillPersonBundle/Workflow/AccompanyingPeriodWorkEvaluationDocumentWorkflowHandler.php b/src/Bundle/ChillPersonBundle/Workflow/AccompanyingPeriodWorkEvaluationDocumentWorkflowHandler.php index d7a196a6c..d7ce1ed4b 100644 --- a/src/Bundle/ChillPersonBundle/Workflow/AccompanyingPeriodWorkEvaluationDocumentWorkflowHandler.php +++ b/src/Bundle/ChillPersonBundle/Workflow/AccompanyingPeriodWorkEvaluationDocumentWorkflowHandler.php @@ -62,7 +62,7 @@ class AccompanyingPeriodWorkEvaluationDocumentWorkflowHandler implements EntityW 'workflow.Doc for evaluation (n°%eval%)', ['%eval%' => $entityWorkflow->getRelatedEntityId()] ) . ' (' . $this->translatableStringHelper->localize($doc->getAccompanyingPeriodWorkEvaluation() - ->getEvaluation()->getTitle()).') '.$doc->getTitle(); + ->getEvaluation()->getTitle()) . ') ' . $doc->getTitle(); } public function getRelatedEntity(EntityWorkflow $entityWorkflow): ?AccompanyingPeriodWorkEvaluationDocument From fced8ef4b70c076b7083ff359bbaab56f2caf32e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Mon, 21 Mar 2022 11:34:54 +0100 Subject: [PATCH 31/64] try to fix test with null id --- .../Normalizer/HouseholdNormalizerTest.php | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/Bundle/ChillPersonBundle/Tests/Serializer/Normalizer/HouseholdNormalizerTest.php b/src/Bundle/ChillPersonBundle/Tests/Serializer/Normalizer/HouseholdNormalizerTest.php index ac015155b..102108f90 100644 --- a/src/Bundle/ChillPersonBundle/Tests/Serializer/Normalizer/HouseholdNormalizerTest.php +++ b/src/Bundle/ChillPersonBundle/Tests/Serializer/Normalizer/HouseholdNormalizerTest.php @@ -16,6 +16,8 @@ use Chill\PersonBundle\Entity\Household\HouseholdMember; use Chill\PersonBundle\Entity\Household\Position; use Chill\PersonBundle\Entity\Person; use DateTimeImmutable; +use Doctrine\ORM\EntityManagerInterface; +use Prophecy\PhpUnit\ProphecyTrait; use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase; use Symfony\Component\Serializer\Normalizer\NormalizerInterface; @@ -27,15 +29,22 @@ final class HouseholdNormalizerTest extends KernelTestCase { private ?NormalizerInterface $normalizer; + private EntityManagerInterface $entityManager; + + private array $toDelete; + protected function setUp(): void { self::bootKernel(); $this->normalizer = self::$container->get(NormalizerInterface::class); + $this->entityManager = self::$container->get(EntityManagerInterface::class); } public function testNormalizationRecursive() { $person = new Person(); + $person->setFirstName('ok')->setLastName('ok'); + $this->entityManager->persist($person); $member = new HouseholdMember(); $household = new Household(); $position = (new Position()) @@ -44,7 +53,9 @@ final class HouseholdNormalizerTest extends KernelTestCase $member->setPerson($person) ->setStartDate(new DateTimeImmutable('1 year ago')) - ->setEndDate(new DateTimeImmutable('1 month ago')); + ->setEndDate(new DateTimeImmutable('1 month ago')) + ->setPosition($position) + ; $household->addMember($member); From 99276dc41c893434b2908c71f94f6c6e3cb97716 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Mon, 21 Mar 2022 11:35:50 +0100 Subject: [PATCH 32/64] fix cs --- .../ChillMainBundle/Command/LoadPostalCodesCommand.php | 5 +++-- .../Serializer/Normalizer/PhonenumberNormalizer.php | 9 ++++----- .../Menu/AccompanyingCourseMenuBuilder.php | 2 +- ...anyingPeriodWorkEvaluationDocumentWorkflowHandler.php | 2 +- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/Bundle/ChillMainBundle/Command/LoadPostalCodesCommand.php b/src/Bundle/ChillMainBundle/Command/LoadPostalCodesCommand.php index 5d577a0b4..bc4616b7b 100644 --- a/src/Bundle/ChillMainBundle/Command/LoadPostalCodesCommand.php +++ b/src/Bundle/ChillMainBundle/Command/LoadPostalCodesCommand.php @@ -26,6 +26,7 @@ use Symfony\Component\Filesystem\Filesystem; use Symfony\Component\Validator\Validator\ValidatorInterface; use function count; +use function strlen; class LoadPostalCodesCommand extends Command { @@ -118,11 +119,11 @@ class LoadPostalCodesCommand extends Command private function addPostalCode($row, OutputInterface $output) { - if($row[2] == 'FR' && strlen($row[0]) == 4) { + if ('FR' === $row[2] && strlen($row[0]) === 4) { // CP in FRANCE are on 5 digit // For CP starting with a zero, the starting zero can be remove if stored as number in a csv // add a zero if CP from FR and on 4 digit - $row[0] = '0'.$row[0]; + $row[0] = '0' . $row[0]; } if ($output->getVerbosity() >= OutputInterface::VERBOSITY_VERBOSE) { diff --git a/src/Bundle/ChillMainBundle/Serializer/Normalizer/PhonenumberNormalizer.php b/src/Bundle/ChillMainBundle/Serializer/Normalizer/PhonenumberNormalizer.php index 677199ad4..7eb323754 100644 --- a/src/Bundle/ChillMainBundle/Serializer/Normalizer/PhonenumberNormalizer.php +++ b/src/Bundle/ChillMainBundle/Serializer/Normalizer/PhonenumberNormalizer.php @@ -18,7 +18,6 @@ use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface; use Symfony\Component\Serializer\Exception\UnexpectedValueException; use Symfony\Component\Serializer\Normalizer\ContextAwareNormalizerInterface; use Symfony\Component\Serializer\Normalizer\DenormalizerInterface; -use Symfony\Component\Serializer\Normalizer\NormalizerInterface; class PhonenumberNormalizer implements ContextAwareNormalizerInterface, DenormalizerInterface { @@ -54,7 +53,7 @@ class PhonenumberNormalizer implements ContextAwareNormalizerInterface, Denormal public function normalize($object, ?string $format = null, array $context = []): string { - if ($format === 'docgen' && null === $object) { + if ('docgen' === $format && null === $object) { return ''; } @@ -68,13 +67,13 @@ class PhonenumberNormalizer implements ContextAwareNormalizerInterface, Denormal public function supportsNormalization($data, ?string $format = null, array $context = []): bool { - if ($data instanceof PhoneNumber && $format === 'json') { + if ($data instanceof PhoneNumber && 'json' === $format) { return true; } - if ($format === 'docgen' && ( + if ('docgen' === $format && ( $data instanceof PhoneNumber || PhoneNumber::class === ($context['docgen:expects'] ?? null) - )) { + )) { return true; } diff --git a/src/Bundle/ChillPersonBundle/Menu/AccompanyingCourseMenuBuilder.php b/src/Bundle/ChillPersonBundle/Menu/AccompanyingCourseMenuBuilder.php index 8f1ecb0d1..929fb2ae0 100644 --- a/src/Bundle/ChillPersonBundle/Menu/AccompanyingCourseMenuBuilder.php +++ b/src/Bundle/ChillPersonBundle/Menu/AccompanyingCourseMenuBuilder.php @@ -75,7 +75,7 @@ class AccompanyingCourseMenuBuilder implements LocalMenuBuilderInterface 'accompanying_period_id' => $period->getId(), ], ]) ->setExtras(['order' => 30]); - */ + */ $menu->addChild($this->translator->trans('Accompanying Course Comment'), [ 'route' => 'chill_person_accompanying_period_comment_list', diff --git a/src/Bundle/ChillPersonBundle/Workflow/AccompanyingPeriodWorkEvaluationDocumentWorkflowHandler.php b/src/Bundle/ChillPersonBundle/Workflow/AccompanyingPeriodWorkEvaluationDocumentWorkflowHandler.php index d7a196a6c..d7ce1ed4b 100644 --- a/src/Bundle/ChillPersonBundle/Workflow/AccompanyingPeriodWorkEvaluationDocumentWorkflowHandler.php +++ b/src/Bundle/ChillPersonBundle/Workflow/AccompanyingPeriodWorkEvaluationDocumentWorkflowHandler.php @@ -62,7 +62,7 @@ class AccompanyingPeriodWorkEvaluationDocumentWorkflowHandler implements EntityW 'workflow.Doc for evaluation (n°%eval%)', ['%eval%' => $entityWorkflow->getRelatedEntityId()] ) . ' (' . $this->translatableStringHelper->localize($doc->getAccompanyingPeriodWorkEvaluation() - ->getEvaluation()->getTitle()).') '.$doc->getTitle(); + ->getEvaluation()->getTitle()) . ') ' . $doc->getTitle(); } public function getRelatedEntity(EntityWorkflow $entityWorkflow): ?AccompanyingPeriodWorkEvaluationDocument From 2c55cfe1dc01bef84e1b211f54f5526a6af57ac3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Mon, 21 Mar 2022 11:41:16 +0100 Subject: [PATCH 33/64] by default, translate menu items --- .../ChillMainBundle/Resources/views/Menu/verticalMenu.html.twig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Bundle/ChillMainBundle/Resources/views/Menu/verticalMenu.html.twig b/src/Bundle/ChillMainBundle/Resources/views/Menu/verticalMenu.html.twig index 51be6c2c3..e15e64374 100644 --- a/src/Bundle/ChillMainBundle/Resources/views/Menu/verticalMenu.html.twig +++ b/src/Bundle/ChillMainBundle/Resources/views/Menu/verticalMenu.html.twig @@ -27,7 +27,7 @@ {% for menu in menus %} - {{ menu.label|upper }} + {{ menu.label|trans|upper }} {% endfor %}
  • From bdb07a3a053bd7dfc767184d0c3e67b15f5ef0f6 Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Mon, 21 Mar 2022 12:10:03 +0100 Subject: [PATCH 34/64] options added to create person or parcours and to access global history --- .../ChillMainExtension.php | 5 +++ .../DependencyInjection/Configuration.php | 3 ++ .../MenuBuilder/SectionMenuBuilder.php | 34 +++++++++---------- .../ChillPersonExtension.php | 10 ++++++ .../DependencyInjection/Configuration.php | 6 ++++ .../Menu/SectionMenuBuilder.php | 32 ++++++++--------- 6 files changed, 56 insertions(+), 34 deletions(-) diff --git a/src/Bundle/ChillMainBundle/DependencyInjection/ChillMainExtension.php b/src/Bundle/ChillMainBundle/DependencyInjection/ChillMainExtension.php index 09668f0e3..62a3d80d8 100644 --- a/src/Bundle/ChillMainBundle/DependencyInjection/ChillMainExtension.php +++ b/src/Bundle/ChillMainBundle/DependencyInjection/ChillMainExtension.php @@ -114,6 +114,11 @@ class ChillMainExtension extends Extension implements $config['available_countries'] ); + $container->setParameter( + 'chill_main.access_global_history', + $config['access_global_history'] + ); + $container->setParameter( 'chill_main.routing.resources', $config['routing']['resources'] diff --git a/src/Bundle/ChillMainBundle/DependencyInjection/Configuration.php b/src/Bundle/ChillMainBundle/DependencyInjection/Configuration.php index be8baf79a..7ced6aac6 100644 --- a/src/Bundle/ChillMainBundle/DependencyInjection/Configuration.php +++ b/src/Bundle/ChillMainBundle/DependencyInjection/Configuration.php @@ -113,6 +113,9 @@ class Configuration implements ConfigurationInterface ->end() ->end() ->end() + ->booleanNode('access_global_history') + ->defaultTrue() + ->end() ->arrayNode('redis') ->children() ->scalarNode('host') diff --git a/src/Bundle/ChillMainBundle/Routing/MenuBuilder/SectionMenuBuilder.php b/src/Bundle/ChillMainBundle/Routing/MenuBuilder/SectionMenuBuilder.php index 1a5ae9afe..03ae20a37 100644 --- a/src/Bundle/ChillMainBundle/Routing/MenuBuilder/SectionMenuBuilder.php +++ b/src/Bundle/ChillMainBundle/Routing/MenuBuilder/SectionMenuBuilder.php @@ -14,6 +14,7 @@ namespace Chill\MainBundle\Routing\MenuBuilder; use Chill\MainBundle\Routing\LocalMenuBuilderInterface; use Chill\MainBundle\Security\Authorization\ChillExportVoter; use Knp\Menu\MenuItem; +use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface; use Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface; use Symfony\Contracts\Translation\TranslatorInterface; @@ -22,23 +23,20 @@ use Symfony\Contracts\Translation\TranslatorInterface; */ class SectionMenuBuilder implements LocalMenuBuilderInterface { - /** - * @var AuthorizationCheckerInterface - */ - protected $authorizationChecker; + protected AuthorizationCheckerInterface $authorizationChecker; - /** - * @var TranslatorInterface - */ - protected $translator; + protected TranslatorInterface $translator; + + protected ParameterBagInterface $parameterBag; /** * SectionMenuBuilder constructor. */ - public function __construct(AuthorizationCheckerInterface $authorizationChecker, TranslatorInterface $translator) + public function __construct(AuthorizationCheckerInterface $authorizationChecker, TranslatorInterface $translator, ParameterBagInterface $parameterBag) { $this->authorizationChecker = $authorizationChecker; $this->translator = $translator; + $this->parameterBag = $parameterBag; } /** @@ -54,14 +52,16 @@ class SectionMenuBuilder implements LocalMenuBuilderInterface 'order' => 0, ]); - $menu->addChild($this->translator->trans('Global timeline'), [ - 'route' => 'chill_center_timeline', - ]) - ->setExtras( - [ - 'order' => 10, - ] - ); + if ($this->parameterBag->get('chill_main.access_global_history')) { + $menu->addChild($this->translator->trans('Global timeline'), [ + 'route' => 'chill_center_timeline', + ]) + ->setExtras( + [ + 'order' => 10, + ] + ); + } if ($this->authorizationChecker->isGranted(ChillExportVoter::EXPORT)) { $menu->addChild($this->translator->trans('Export Menu'), [ diff --git a/src/Bundle/ChillPersonBundle/DependencyInjection/ChillPersonExtension.php b/src/Bundle/ChillPersonBundle/DependencyInjection/ChillPersonExtension.php index 1f85e4ad0..6d2bf6d18 100644 --- a/src/Bundle/ChillPersonBundle/DependencyInjection/ChillPersonExtension.php +++ b/src/Bundle/ChillPersonBundle/DependencyInjection/ChillPersonExtension.php @@ -59,6 +59,16 @@ class ChillPersonExtension extends Extension implements PrependExtensionInterfac $config['allow_multiple_simultaneous_accompanying_periods'] ); + $container->setParameter( + 'chill_person.create_person_allowed', + $config['create_person_allowed'] + ); + + $container->setParameter( + 'chill_person.create_parcours_allowed', + $config['create_parcours_allowed'] + ); + // register all configuration in a unique parameter $container->setParameter('chill_person', $config); diff --git a/src/Bundle/ChillPersonBundle/DependencyInjection/Configuration.php b/src/Bundle/ChillPersonBundle/DependencyInjection/Configuration.php index 8a0cab301..7b483a633 100644 --- a/src/Bundle/ChillPersonBundle/DependencyInjection/Configuration.php +++ b/src/Bundle/ChillPersonBundle/DependencyInjection/Configuration.php @@ -62,6 +62,12 @@ class Configuration implements ConfigurationInterface ->end() // children for 'validation', parent = validation ->end() //validation, parent = children of root ->end() // children of root, parent = root + ->booleanNode('create_person_allowed') + ->defaultTrue() + ->end() + ->booleanNode('create_parcours_allowed') + ->defaultTrue() + ->end() ->arrayNode('person_fields') ->canBeDisabled() ->children() diff --git a/src/Bundle/ChillPersonBundle/Menu/SectionMenuBuilder.php b/src/Bundle/ChillPersonBundle/Menu/SectionMenuBuilder.php index 04f989d84..75f3346ff 100644 --- a/src/Bundle/ChillPersonBundle/Menu/SectionMenuBuilder.php +++ b/src/Bundle/ChillPersonBundle/Menu/SectionMenuBuilder.php @@ -14,6 +14,7 @@ namespace Chill\PersonBundle\Menu; use Chill\MainBundle\Routing\LocalMenuBuilderInterface; use Chill\PersonBundle\Security\Authorization\PersonVoter; use Knp\Menu\MenuItem; +use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface; use Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface; use Symfony\Contracts\Translation\TranslatorInterface; @@ -22,23 +23,18 @@ use Symfony\Contracts\Translation\TranslatorInterface; */ class SectionMenuBuilder implements LocalMenuBuilderInterface { - /** - * @var AuthorizationCheckerInterface - */ - protected $authorizationChecker; + protected AuthorizationCheckerInterface $authorizationChecker; - /** - * @var TranslatorInterface - */ - protected $translator; + protected TranslatorInterface $translator; /** * SectionMenuBuilder constructor. */ - public function __construct(AuthorizationCheckerInterface $authorizationChecker, TranslatorInterface $translator) + public function __construct(AuthorizationCheckerInterface $authorizationChecker, TranslatorInterface $translator, ParameterBagInterface $parameterBag) { $this->authorizationChecker = $authorizationChecker; $this->translator = $translator; + $this->parameterBag = $parameterBag; } /** @@ -46,7 +42,7 @@ class SectionMenuBuilder implements LocalMenuBuilderInterface */ public function buildMenu($menuId, MenuItem $menu, array $parameters) { - if ($this->authorizationChecker->isGranted(PersonVoter::CREATE)) { + if ($this->authorizationChecker->isGranted(PersonVoter::CREATE) && $this->parameterBag->get('chill_person.create_person_allowed')) { $menu->addChild($this->translator->trans('Add a person'), [ 'route' => 'chill_person_new', ]) @@ -56,13 +52,15 @@ class SectionMenuBuilder implements LocalMenuBuilderInterface ]); } - $menu->addChild($this->translator->trans('Create an accompanying course'), [ - 'route' => 'chill_person_accompanying_course_new', - ]) - ->setExtras([ - 'order' => 11, - 'icons' => ['plus'], - ]); + if ($this->parameterBag->get('chill_person.create_parcours_allowed')) { + $menu->addChild($this->translator->trans('Create an accompanying course'), [ + 'route' => 'chill_person_accompanying_course_new', + ]) + ->setExtras([ + 'order' => 11, + 'icons' => ['plus'], + ]); + } } public static function getMenuIds(): array From 9b97b03d4257d25528a660bc0a329b5f7ec923af Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Mon, 21 Mar 2022 12:16:49 +0100 Subject: [PATCH 35/64] csfixes --- .../ChillMainBundle/Command/LoadPostalCodesCommand.php | 5 +++-- .../Routing/MenuBuilder/SectionMenuBuilder.php | 4 ++-- .../Serializer/Normalizer/PhonenumberNormalizer.php | 9 ++++----- .../Menu/AccompanyingCourseMenuBuilder.php | 2 +- ...anyingPeriodWorkEvaluationDocumentWorkflowHandler.php | 2 +- 5 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/Bundle/ChillMainBundle/Command/LoadPostalCodesCommand.php b/src/Bundle/ChillMainBundle/Command/LoadPostalCodesCommand.php index 5d577a0b4..bc4616b7b 100644 --- a/src/Bundle/ChillMainBundle/Command/LoadPostalCodesCommand.php +++ b/src/Bundle/ChillMainBundle/Command/LoadPostalCodesCommand.php @@ -26,6 +26,7 @@ use Symfony\Component\Filesystem\Filesystem; use Symfony\Component\Validator\Validator\ValidatorInterface; use function count; +use function strlen; class LoadPostalCodesCommand extends Command { @@ -118,11 +119,11 @@ class LoadPostalCodesCommand extends Command private function addPostalCode($row, OutputInterface $output) { - if($row[2] == 'FR' && strlen($row[0]) == 4) { + if ('FR' === $row[2] && strlen($row[0]) === 4) { // CP in FRANCE are on 5 digit // For CP starting with a zero, the starting zero can be remove if stored as number in a csv // add a zero if CP from FR and on 4 digit - $row[0] = '0'.$row[0]; + $row[0] = '0' . $row[0]; } if ($output->getVerbosity() >= OutputInterface::VERBOSITY_VERBOSE) { diff --git a/src/Bundle/ChillMainBundle/Routing/MenuBuilder/SectionMenuBuilder.php b/src/Bundle/ChillMainBundle/Routing/MenuBuilder/SectionMenuBuilder.php index 03ae20a37..10acf2d6c 100644 --- a/src/Bundle/ChillMainBundle/Routing/MenuBuilder/SectionMenuBuilder.php +++ b/src/Bundle/ChillMainBundle/Routing/MenuBuilder/SectionMenuBuilder.php @@ -25,10 +25,10 @@ class SectionMenuBuilder implements LocalMenuBuilderInterface { protected AuthorizationCheckerInterface $authorizationChecker; - protected TranslatorInterface $translator; - protected ParameterBagInterface $parameterBag; + protected TranslatorInterface $translator; + /** * SectionMenuBuilder constructor. */ diff --git a/src/Bundle/ChillMainBundle/Serializer/Normalizer/PhonenumberNormalizer.php b/src/Bundle/ChillMainBundle/Serializer/Normalizer/PhonenumberNormalizer.php index 677199ad4..7eb323754 100644 --- a/src/Bundle/ChillMainBundle/Serializer/Normalizer/PhonenumberNormalizer.php +++ b/src/Bundle/ChillMainBundle/Serializer/Normalizer/PhonenumberNormalizer.php @@ -18,7 +18,6 @@ use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface; use Symfony\Component\Serializer\Exception\UnexpectedValueException; use Symfony\Component\Serializer\Normalizer\ContextAwareNormalizerInterface; use Symfony\Component\Serializer\Normalizer\DenormalizerInterface; -use Symfony\Component\Serializer\Normalizer\NormalizerInterface; class PhonenumberNormalizer implements ContextAwareNormalizerInterface, DenormalizerInterface { @@ -54,7 +53,7 @@ class PhonenumberNormalizer implements ContextAwareNormalizerInterface, Denormal public function normalize($object, ?string $format = null, array $context = []): string { - if ($format === 'docgen' && null === $object) { + if ('docgen' === $format && null === $object) { return ''; } @@ -68,13 +67,13 @@ class PhonenumberNormalizer implements ContextAwareNormalizerInterface, Denormal public function supportsNormalization($data, ?string $format = null, array $context = []): bool { - if ($data instanceof PhoneNumber && $format === 'json') { + if ($data instanceof PhoneNumber && 'json' === $format) { return true; } - if ($format === 'docgen' && ( + if ('docgen' === $format && ( $data instanceof PhoneNumber || PhoneNumber::class === ($context['docgen:expects'] ?? null) - )) { + )) { return true; } diff --git a/src/Bundle/ChillPersonBundle/Menu/AccompanyingCourseMenuBuilder.php b/src/Bundle/ChillPersonBundle/Menu/AccompanyingCourseMenuBuilder.php index 8f1ecb0d1..929fb2ae0 100644 --- a/src/Bundle/ChillPersonBundle/Menu/AccompanyingCourseMenuBuilder.php +++ b/src/Bundle/ChillPersonBundle/Menu/AccompanyingCourseMenuBuilder.php @@ -75,7 +75,7 @@ class AccompanyingCourseMenuBuilder implements LocalMenuBuilderInterface 'accompanying_period_id' => $period->getId(), ], ]) ->setExtras(['order' => 30]); - */ + */ $menu->addChild($this->translator->trans('Accompanying Course Comment'), [ 'route' => 'chill_person_accompanying_period_comment_list', diff --git a/src/Bundle/ChillPersonBundle/Workflow/AccompanyingPeriodWorkEvaluationDocumentWorkflowHandler.php b/src/Bundle/ChillPersonBundle/Workflow/AccompanyingPeriodWorkEvaluationDocumentWorkflowHandler.php index d7a196a6c..d7ce1ed4b 100644 --- a/src/Bundle/ChillPersonBundle/Workflow/AccompanyingPeriodWorkEvaluationDocumentWorkflowHandler.php +++ b/src/Bundle/ChillPersonBundle/Workflow/AccompanyingPeriodWorkEvaluationDocumentWorkflowHandler.php @@ -62,7 +62,7 @@ class AccompanyingPeriodWorkEvaluationDocumentWorkflowHandler implements EntityW 'workflow.Doc for evaluation (n°%eval%)', ['%eval%' => $entityWorkflow->getRelatedEntityId()] ) . ' (' . $this->translatableStringHelper->localize($doc->getAccompanyingPeriodWorkEvaluation() - ->getEvaluation()->getTitle()).') '.$doc->getTitle(); + ->getEvaluation()->getTitle()) . ') ' . $doc->getTitle(); } public function getRelatedEntity(EntityWorkflow $entityWorkflow): ?AccompanyingPeriodWorkEvaluationDocument From 3aaecc8630ba0835600e5bd300bc771e93bf796b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Mon, 21 Mar 2022 12:32:40 +0100 Subject: [PATCH 36/64] set creator as referrer for works --- .../ChillPersonBundle/migrations/Version20220310063629.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/Bundle/ChillPersonBundle/migrations/Version20220310063629.php b/src/Bundle/ChillPersonBundle/migrations/Version20220310063629.php index 2b4c171a2..9e6f0c332 100644 --- a/src/Bundle/ChillPersonBundle/migrations/Version20220310063629.php +++ b/src/Bundle/ChillPersonBundle/migrations/Version20220310063629.php @@ -36,5 +36,7 @@ final class Version20220310063629 extends AbstractMigration $this->addSql('CREATE INDEX IDX_3619F5EBA76ED395 ON chill_person_accompanying_period_work_referrer (user_id)'); $this->addSql('ALTER TABLE chill_person_accompanying_period_work_referrer ADD CONSTRAINT FK_3619F5EBB99F6060 FOREIGN KEY (accompanyingperiodwork_id) REFERENCES chill_person_accompanying_period_work (id) ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE'); $this->addSql('ALTER TABLE chill_person_accompanying_period_work_referrer ADD CONSTRAINT FK_3619F5EBA76ED395 FOREIGN KEY (user_id) REFERENCES users (id) ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE'); + $this->addSql('INSERT INTO chill_person_accompanying_period_work_referrer (accompanyingperiodwork_id, user_id) + SELECT id, createdby_id FROM postgres.public.chill_person_accompanying_period_work'); } } From 8f462da6278aa7357e85ace8fac96a77444ffaab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Mon, 21 Mar 2022 12:32:46 +0100 Subject: [PATCH 37/64] fix cs --- .../Serializer/Normalizer/HouseholdNormalizerTest.php | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/Bundle/ChillPersonBundle/Tests/Serializer/Normalizer/HouseholdNormalizerTest.php b/src/Bundle/ChillPersonBundle/Tests/Serializer/Normalizer/HouseholdNormalizerTest.php index 102108f90..c67e07b5e 100644 --- a/src/Bundle/ChillPersonBundle/Tests/Serializer/Normalizer/HouseholdNormalizerTest.php +++ b/src/Bundle/ChillPersonBundle/Tests/Serializer/Normalizer/HouseholdNormalizerTest.php @@ -17,7 +17,6 @@ use Chill\PersonBundle\Entity\Household\Position; use Chill\PersonBundle\Entity\Person; use DateTimeImmutable; use Doctrine\ORM\EntityManagerInterface; -use Prophecy\PhpUnit\ProphecyTrait; use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase; use Symfony\Component\Serializer\Normalizer\NormalizerInterface; @@ -27,10 +26,10 @@ use Symfony\Component\Serializer\Normalizer\NormalizerInterface; */ final class HouseholdNormalizerTest extends KernelTestCase { - private ?NormalizerInterface $normalizer; - private EntityManagerInterface $entityManager; + private ?NormalizerInterface $normalizer; + private array $toDelete; protected function setUp(): void @@ -54,8 +53,7 @@ final class HouseholdNormalizerTest extends KernelTestCase $member->setPerson($person) ->setStartDate(new DateTimeImmutable('1 year ago')) ->setEndDate(new DateTimeImmutable('1 month ago')) - ->setPosition($position) - ; + ->setPosition($position); $household->addMember($member); From cb35aed20291053bd8b110169b6465cf238e1cb9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Mon, 21 Mar 2022 12:45:20 +0100 Subject: [PATCH 38/64] use remove-items UI api for listing referrers --- .../vuejs/AccompanyingCourseWorkEdit/App.vue | 26 ++++--------------- 1 file changed, 5 insertions(+), 21 deletions(-) diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourseWorkEdit/App.vue b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourseWorkEdit/App.vue index c6db11fd3..7f6cadca0 100644 --- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourseWorkEdit/App.vue +++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourseWorkEdit/App.vue @@ -159,16 +159,13 @@
    -
    -
    - +
      +
    • + {{ u.text }} - -
    -
    + +
      @@ -718,17 +715,4 @@ div#workEditor { } } -.referrer { - margin-bottom: 0.4rem; - .referrer-close-btn { - margin-left: 0.4rem; - margin-right: 0.4rem; - button { - height: 1.45rem; - min-width: 1.45rem; - font-size: 0.4rem; - } - } -} - From b6b6c25b3bc58c73e0a6d45671423a39116be690 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Mon, 21 Mar 2022 12:54:50 +0100 Subject: [PATCH 39/64] adapt queries for listing near recents evaluation and work on homepage, taking care of referrers --- .../AccompanyingPeriodWorkEvaluationRepository.php | 7 +++++-- .../AccompanyingPeriodWorkRepository.php | 7 +++++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/Bundle/ChillPersonBundle/Repository/AccompanyingPeriod/AccompanyingPeriodWorkEvaluationRepository.php b/src/Bundle/ChillPersonBundle/Repository/AccompanyingPeriod/AccompanyingPeriodWorkEvaluationRepository.php index 3178aa6e2..3273e3a7d 100644 --- a/src/Bundle/ChillPersonBundle/Repository/AccompanyingPeriod/AccompanyingPeriodWorkEvaluationRepository.php +++ b/src/Bundle/ChillPersonBundle/Repository/AccompanyingPeriod/AccompanyingPeriodWorkEvaluationRepository.php @@ -87,9 +87,12 @@ class AccompanyingPeriodWorkEvaluationRepository implements ObjectRepository ->join('work.accompanyingPeriod', 'period') ->where( $qb->expr()->andX( - $qb->expr()->eq('period.user', ':user'), $qb->expr()->isNull('e.endDate'), - $qb->expr()->gte(':now', $qb->expr()->diff('e.maxDate', 'e.warningInterval')) + $qb->expr()->gte(':now', $qb->expr()->diff('e.maxDate', 'e.warningInterval')), + $qb->expr()->orX( + $qb->expr()->eq('period.user', ':user'), + $qb->expr()->isMemberOf(':user', 'work.referrers') + ) ) ) ->setParameters([ diff --git a/src/Bundle/ChillPersonBundle/Repository/AccompanyingPeriod/AccompanyingPeriodWorkRepository.php b/src/Bundle/ChillPersonBundle/Repository/AccompanyingPeriod/AccompanyingPeriodWorkRepository.php index 9e67da458..dd27cf434 100644 --- a/src/Bundle/ChillPersonBundle/Repository/AccompanyingPeriod/AccompanyingPeriodWorkRepository.php +++ b/src/Bundle/ChillPersonBundle/Repository/AccompanyingPeriod/AccompanyingPeriodWorkRepository.php @@ -159,9 +159,12 @@ final class AccompanyingPeriodWorkRepository implements ObjectRepository ->join('w.accompanyingPeriod', 'period') ->where( $qb->expr()->andX( - $qb->expr()->eq('period.user', ':user'), $qb->expr()->gte('w.endDate', ':since'), - $qb->expr()->lte('w.startDate', ':until') + $qb->expr()->lte('w.startDate', ':until'), + $qb->expr()->orX( + $qb->expr()->eq('period.user', ':user'), + $qb->expr()->isMemberOf(':user', 'w.referrers') + ) ) ) ->setParameters([ From 293efc03b41dafdf006f8ba99513ce4256c94cd3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Mon, 21 Mar 2022 13:35:14 +0100 Subject: [PATCH 40/64] fixes for reasign list * use existing method in UserRepository and use a method instead of building a query outside of the repository; * use renderString to render users * fix building of filter form (add $data). This make the use of the method "get" instead of post --- .../Repository/UserRepository.php | 5 ---- .../ReassignAccompanyingPeriodController.php | 24 +++++++++---------- .../reassign_list.html.twig | 4 ++-- 3 files changed, 14 insertions(+), 19 deletions(-) diff --git a/src/Bundle/ChillMainBundle/Repository/UserRepository.php b/src/Bundle/ChillMainBundle/Repository/UserRepository.php index 0616878ff..fc3a6e187 100644 --- a/src/Bundle/ChillMainBundle/Repository/UserRepository.php +++ b/src/Bundle/ChillMainBundle/Repository/UserRepository.php @@ -51,11 +51,6 @@ final class UserRepository implements ObjectRepository return (int) $qb->getQuery()->getSingleScalarResult(); } - public function createQueryBuilder(string $alias, ?string $indexBy = null): QueryBuilder - { - return $this->repository->createQueryBuilder($alias, $indexBy); - } - public function find($id, $lockMode = null, $lockVersion = null): ?User { return $this->repository->find($id, $lockMode, $lockVersion); diff --git a/src/Bundle/ChillPersonBundle/Controller/ReassignAccompanyingPeriodController.php b/src/Bundle/ChillPersonBundle/Controller/ReassignAccompanyingPeriodController.php index 04e38da13..24de2d7db 100644 --- a/src/Bundle/ChillPersonBundle/Controller/ReassignAccompanyingPeriodController.php +++ b/src/Bundle/ChillPersonBundle/Controller/ReassignAccompanyingPeriodController.php @@ -14,6 +14,7 @@ namespace Chill\PersonBundle\Controller; use Chill\MainBundle\Entity\User; use Chill\MainBundle\Pagination\PaginatorFactory; use Chill\MainBundle\Repository\UserRepository; +use Chill\MainBundle\Templating\Entity\UserRender; use Chill\PersonBundle\Repository\AccompanyingPeriodACLAwareRepository; use Symfony\Bridge\Doctrine\Form\Type\EntityType; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; @@ -39,9 +40,11 @@ class ReassignAccompanyingPeriodController extends AbstractController private Security $security; + private UserRender $userRender; + private UserRepository $userRepository; - public function __construct(AccompanyingPeriodACLAwareRepository $accompanyingPeriodACLAwareRepository, UserRepository $userRepository, EngineInterface $engine, FormFactoryInterface $formFactory, PaginatorFactory $paginatorFactory, Security $security) + public function __construct(AccompanyingPeriodACLAwareRepository $accompanyingPeriodACLAwareRepository, UserRepository $userRepository, EngineInterface $engine, FormFactoryInterface $formFactory, PaginatorFactory $paginatorFactory, Security $security, UserRender $userRender) { $this->accompanyingPeriodACLAwareRepository = $accompanyingPeriodACLAwareRepository; $this->engine = $engine; @@ -49,6 +52,7 @@ class ReassignAccompanyingPeriodController extends AbstractController $this->paginatorFactory = $paginatorFactory; $this->security = $security; $this->userRepository = $userRepository; + $this->userRender = $userRender; } /** @@ -86,22 +90,18 @@ class ReassignAccompanyingPeriodController extends AbstractController private function buildFilterForm(): FormInterface { - $builder = $this->formFactory->createBuilder(FormType::class, [ + $data = [ + 'user' => null, + ]; + $builder = $this->formFactory->createBuilder(FormType::class, $data, [ 'method' => 'get', 'csrf_protection' => false, ]); $builder ->add('user', EntityType::class, [ 'class' => User::class, - 'query_builder' => function () { - $qb = $this->userRepository->createQueryBuilder('u'); - - $qb->where('u.enabled = true') - ->orderBy('u.username', 'ASC'); - - return $qb; - }, - 'choice_label' => static function (User $u) { - return $u->getUsername(); + 'choices' => $this->userRepository->findByActive(['username' => 'ASC']), + 'choice_label' => function (User $u) { + return $this->userRender->renderString($u, []); }, 'multiple' => false, 'label' => 'User', diff --git a/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingPeriod/reassign_list.html.twig b/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingPeriod/reassign_list.html.twig index d7e11f6ee..55b932751 100644 --- a/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingPeriod/reassign_list.html.twig +++ b/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingPeriod/reassign_list.html.twig @@ -42,8 +42,8 @@

      {{ block('title') }}

      {{ form_start(form) }} -
      -
      +
      +
      {{ form_label(form.user ) }} {{ form_widget(form.user, {'attr': {'class': 'select2'}}) }}
      From ac9e55e2fc47c10c3413f5d90b49139f0e304cc2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Mon, 21 Mar 2022 14:54:01 +0100 Subject: [PATCH 41/64] fix methods for accompanying period repository acl aware * add method to interface * delegate ACL to another method --- .../ReassignAccompanyingPeriodController.php | 10 ++++--- .../AccompanyingPeriodACLAwareRepository.php | 27 +++++++++++++------ ...nyingPeriodACLAwareRepositoryInterface.php | 5 ++++ .../reassign_list.html.twig | 7 ++--- .../translations/messages.fr.yml | 5 ++++ 5 files changed, 39 insertions(+), 15 deletions(-) diff --git a/src/Bundle/ChillPersonBundle/Controller/ReassignAccompanyingPeriodController.php b/src/Bundle/ChillPersonBundle/Controller/ReassignAccompanyingPeriodController.php index 24de2d7db..ac5b6dfab 100644 --- a/src/Bundle/ChillPersonBundle/Controller/ReassignAccompanyingPeriodController.php +++ b/src/Bundle/ChillPersonBundle/Controller/ReassignAccompanyingPeriodController.php @@ -16,6 +16,7 @@ use Chill\MainBundle\Pagination\PaginatorFactory; use Chill\MainBundle\Repository\UserRepository; use Chill\MainBundle\Templating\Entity\UserRender; use Chill\PersonBundle\Repository\AccompanyingPeriodACLAwareRepository; +use Chill\PersonBundle\Repository\AccompanyingPeriodACLAwareRepositoryInterface; use Symfony\Bridge\Doctrine\Form\Type\EntityType; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Component\Form\Extension\Core\Type\FormType; @@ -30,7 +31,7 @@ use Symfony\Component\Templating\EngineInterface; class ReassignAccompanyingPeriodController extends AbstractController { - private AccompanyingPeriodACLAwareRepository $accompanyingPeriodACLAwareRepository; + private AccompanyingPeriodACLAwareRepositoryInterface $accompanyingPeriodACLAwareRepository; private EngineInterface $engine; @@ -44,7 +45,7 @@ class ReassignAccompanyingPeriodController extends AbstractController private UserRepository $userRepository; - public function __construct(AccompanyingPeriodACLAwareRepository $accompanyingPeriodACLAwareRepository, UserRepository $userRepository, EngineInterface $engine, FormFactoryInterface $formFactory, PaginatorFactory $paginatorFactory, Security $security, UserRender $userRender) + public function __construct(AccompanyingPeriodACLAwareRepositoryInterface $accompanyingPeriodACLAwareRepository, UserRepository $userRepository, EngineInterface $engine, FormFactoryInterface $formFactory, PaginatorFactory $paginatorFactory, Security $security, UserRender $userRender) { $this->accompanyingPeriodACLAwareRepository = $accompanyingPeriodACLAwareRepository; $this->engine = $engine; @@ -68,13 +69,14 @@ class ReassignAccompanyingPeriodController extends AbstractController $form->handleRequest($request); - $total = $this->accompanyingPeriodACLAwareRepository->countByUserConfirmed( + $total = $this->accompanyingPeriodACLAwareRepository->countByUserOpenedAccompanyingPeriod( $form['user']->getData() ); $paginator = $this->paginatorFactory->create($total); $periods = $this->accompanyingPeriodACLAwareRepository - ->findByUserConfirmed( + ->findByUserOpenedAccompanyingPeriod( $form['user']->getData(), + ['openingDate' => 'ASC'], $paginator->getItemsPerPage(), $paginator->getCurrentPageFirstItemNumber() ); diff --git a/src/Bundle/ChillPersonBundle/Repository/AccompanyingPeriodACLAwareRepository.php b/src/Bundle/ChillPersonBundle/Repository/AccompanyingPeriodACLAwareRepository.php index 47e1ee441..f4c9a52a3 100644 --- a/src/Bundle/ChillPersonBundle/Repository/AccompanyingPeriodACLAwareRepository.php +++ b/src/Bundle/ChillPersonBundle/Repository/AccompanyingPeriodACLAwareRepository.php @@ -42,28 +42,32 @@ final class AccompanyingPeriodACLAwareRepository implements AccompanyingPeriodAC $this->centerResolverDispatcher = $centerResolverDispatcher; } - public function buildQueryByUser(?User $user) + public function buildQueryOpenedAccompanyingCourseByUser(?User $user) { $qb = $this->accompanyingPeriodRepository->createQueryBuilder('ap'); $qb->where($qb->expr()->eq('ap.user', ':user')) ->andWhere( - $qb->expr()->eq('ap.step', ':confirmed'), - $qb->expr()->eq('ap.confidential', 'false') + $qb->expr()->neq('ap.step', ':draft'), + $qb->expr()->orX( + $qb->expr()->isNull('ap.closingDate'), + $qb->expr()->gt('ap.closingDate', ':now') + ) ) ->setParameter('user', $user) - ->setParameter('confirmed', AccompanyingPeriod::STEP_CONFIRMED); + ->setParameter('now', new \DateTime('now')) + ->setParameter('draft', AccompanyingPeriod::STEP_DRAFT); return $qb; } - public function countByUserConfirmed(?User $user) + public function countByUserOpenedAccompanyingPeriod(?User $user): int { if (null === $user) { return 0; } - return $this->buildQueryByUser($user) + return $this->buildQueryOpenedAccompanyingCourseByUser($user) ->select('COUNT(ap)') ->getQuery() ->getSingleScalarResult(); @@ -124,13 +128,20 @@ final class AccompanyingPeriodACLAwareRepository implements AccompanyingPeriodAC /** * @return array|AccompanyingPeriod[] */ - public function findByUserConfirmed(?User $user, int $limit, int $offset): array + public function findByUserOpenedAccompanyingPeriod(?User $user, array $orderBy = [], int $limit = 0, int $offset = 50): array { if (null === $user) { return []; } - $qb = $this->buildQueryByUser($user); + $qb = $this->buildQueryOpenedAccompanyingCourseByUser($user); + + $qb->setFirstResult($offset) + ->setMaxResults($limit); + + foreach ($orderBy as $field => $direction) { + $qb->addOrderBy('ap.'.$field, $direction); + } return $qb->getQuery()->getResult(); } diff --git a/src/Bundle/ChillPersonBundle/Repository/AccompanyingPeriodACLAwareRepositoryInterface.php b/src/Bundle/ChillPersonBundle/Repository/AccompanyingPeriodACLAwareRepositoryInterface.php index 778e8d8fe..0c5af217f 100644 --- a/src/Bundle/ChillPersonBundle/Repository/AccompanyingPeriodACLAwareRepositoryInterface.php +++ b/src/Bundle/ChillPersonBundle/Repository/AccompanyingPeriodACLAwareRepositoryInterface.php @@ -11,6 +11,7 @@ declare(strict_types=1); namespace Chill\PersonBundle\Repository; +use Chill\MainBundle\Entity\User; use Chill\PersonBundle\Entity\Person; interface AccompanyingPeriodACLAwareRepositoryInterface @@ -22,4 +23,8 @@ interface AccompanyingPeriodACLAwareRepositoryInterface ?int $limit = null, ?int $offset = null ): array; + + public function findByUserOpenedAccompanyingPeriod(?User $user, array $orderBy = [], int $limit = 0, int $offset = 50): array; + + public function countByUserOpenedAccompanyingPeriod(?User $user): int; } diff --git a/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingPeriod/reassign_list.html.twig b/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingPeriod/reassign_list.html.twig index 55b932751..87166d990 100644 --- a/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingPeriod/reassign_list.html.twig +++ b/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingPeriod/reassign_list.html.twig @@ -1,6 +1,6 @@ {% extends 'ChillMainBundle::layout.html.twig' %} -{% block title "Liste de parcours à réassigner pour un utilisateur" %} +{% block title 'period_by_user_list.Period by user'|trans %} {% block js %} {{ encore_entry_script_tags('mod_set_referrer') }} @@ -60,9 +60,10 @@ {{ form_end(form) }} {% if form.user.vars.value is empty %} -

      Choisissez un référent pour afficher ses parcours.

      +

      {{ 'period_by_user_list.Pick a user'|trans }}

      {% elseif periods|length == 0 and form.user.vars.value is not empty %} -

      Aucun parcours actifs pour ce référent.

      +

      {{ 'period_by_user_list.Any course or no authorization to see them'|trans }}

      + {% else %}

      {{ paginator.totalItems }} parcours à réassigner (calculé ce jour à {{ null|format_time('medium') }})

      diff --git a/src/Bundle/ChillPersonBundle/translations/messages.fr.yml b/src/Bundle/ChillPersonBundle/translations/messages.fr.yml index bb5e5e846..d6e739632 100644 --- a/src/Bundle/ChillPersonBundle/translations/messages.fr.yml +++ b/src/Bundle/ChillPersonBundle/translations/messages.fr.yml @@ -579,3 +579,8 @@ My accompanying periods in draft: Mes parcours brouillons workflow: Doc for evaluation (n°%eval%): Document de l'évaluation n°%eval% + +period_by_user_list: + Period by user: Parcours d'accompagnement par utilisateur + Pick a user: Choisissez un utilisateur pour obtenir la liste de ses parcours + Any course or no authorization to see them: Aucun parcours pour ce référent, ou aucun droit pour visualiser les parcours de ce référent. From efeda81e05e148e48c103402a9ec5d227b10e279 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Mon, 21 Mar 2022 15:17:33 +0100 Subject: [PATCH 42/64] do not add referrer if user is null --- .../EventListener/AccompanyingPeriodWorkEventListener.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/Bundle/ChillPersonBundle/EventListener/AccompanyingPeriodWorkEventListener.php b/src/Bundle/ChillPersonBundle/EventListener/AccompanyingPeriodWorkEventListener.php index c9b11ea71..95ab71d4b 100644 --- a/src/Bundle/ChillPersonBundle/EventListener/AccompanyingPeriodWorkEventListener.php +++ b/src/Bundle/ChillPersonBundle/EventListener/AccompanyingPeriodWorkEventListener.php @@ -25,6 +25,8 @@ class AccompanyingPeriodWorkEventListener public function prePersistAccompanyingPeriodWork(AccompanyingPeriodWork $work): void { - $work->addReferrer($this->security->getUser()); + if (null !== $this->security->getUser()) { + $work->addReferrer($this->security->getUser()); + } } } From 704392a729471bf2ed0b363e4b670710f8eb5fa6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Mon, 21 Mar 2022 15:21:29 +0100 Subject: [PATCH 43/64] do not add referrer if user is null (fix condition) --- .../EventListener/AccompanyingPeriodWorkEventListener.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Bundle/ChillPersonBundle/EventListener/AccompanyingPeriodWorkEventListener.php b/src/Bundle/ChillPersonBundle/EventListener/AccompanyingPeriodWorkEventListener.php index 95ab71d4b..83f9ca460 100644 --- a/src/Bundle/ChillPersonBundle/EventListener/AccompanyingPeriodWorkEventListener.php +++ b/src/Bundle/ChillPersonBundle/EventListener/AccompanyingPeriodWorkEventListener.php @@ -11,6 +11,7 @@ declare(strict_types=1); namespace Chill\PersonBundle\EventListener; +use Chill\MainBundle\Entity\User; use Chill\PersonBundle\Entity\AccompanyingPeriod\AccompanyingPeriodWork; use Symfony\Component\Security\Core\Security; @@ -25,7 +26,7 @@ class AccompanyingPeriodWorkEventListener public function prePersistAccompanyingPeriodWork(AccompanyingPeriodWork $work): void { - if (null !== $this->security->getUser()) { + if ($this->security->getUser() instanceof User) { $work->addReferrer($this->security->getUser()); } } From 11d57094e80919d371d44880d44f7aedc035230b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Mon, 21 Mar 2022 15:22:40 +0100 Subject: [PATCH 44/64] fix cs --- .../Controller/ReassignAccompanyingPeriodController.php | 1 - .../Repository/AccompanyingPeriodACLAwareRepository.php | 7 ++++--- .../AccompanyingPeriodACLAwareRepositoryInterface.php | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/Bundle/ChillPersonBundle/Controller/ReassignAccompanyingPeriodController.php b/src/Bundle/ChillPersonBundle/Controller/ReassignAccompanyingPeriodController.php index ac5b6dfab..4abf5e93c 100644 --- a/src/Bundle/ChillPersonBundle/Controller/ReassignAccompanyingPeriodController.php +++ b/src/Bundle/ChillPersonBundle/Controller/ReassignAccompanyingPeriodController.php @@ -15,7 +15,6 @@ use Chill\MainBundle\Entity\User; use Chill\MainBundle\Pagination\PaginatorFactory; use Chill\MainBundle\Repository\UserRepository; use Chill\MainBundle\Templating\Entity\UserRender; -use Chill\PersonBundle\Repository\AccompanyingPeriodACLAwareRepository; use Chill\PersonBundle\Repository\AccompanyingPeriodACLAwareRepositoryInterface; use Symfony\Bridge\Doctrine\Form\Type\EntityType; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; diff --git a/src/Bundle/ChillPersonBundle/Repository/AccompanyingPeriodACLAwareRepository.php b/src/Bundle/ChillPersonBundle/Repository/AccompanyingPeriodACLAwareRepository.php index f4c9a52a3..8efd60e58 100644 --- a/src/Bundle/ChillPersonBundle/Repository/AccompanyingPeriodACLAwareRepository.php +++ b/src/Bundle/ChillPersonBundle/Repository/AccompanyingPeriodACLAwareRepository.php @@ -16,8 +16,9 @@ use Chill\MainBundle\Security\Authorization\AuthorizationHelper; use Chill\MainBundle\Security\Resolver\CenterResolverDispatcherInterface; use Chill\PersonBundle\Entity\AccompanyingPeriod; use Chill\PersonBundle\Entity\Person; -use Symfony\Component\Security\Core\Security; +use DateTime; +use Symfony\Component\Security\Core\Security; use function count; final class AccompanyingPeriodACLAwareRepository implements AccompanyingPeriodACLAwareRepositoryInterface @@ -55,7 +56,7 @@ final class AccompanyingPeriodACLAwareRepository implements AccompanyingPeriodAC ) ) ->setParameter('user', $user) - ->setParameter('now', new \DateTime('now')) + ->setParameter('now', new DateTime('now')) ->setParameter('draft', AccompanyingPeriod::STEP_DRAFT); return $qb; @@ -140,7 +141,7 @@ final class AccompanyingPeriodACLAwareRepository implements AccompanyingPeriodAC ->setMaxResults($limit); foreach ($orderBy as $field => $direction) { - $qb->addOrderBy('ap.'.$field, $direction); + $qb->addOrderBy('ap.' . $field, $direction); } return $qb->getQuery()->getResult(); diff --git a/src/Bundle/ChillPersonBundle/Repository/AccompanyingPeriodACLAwareRepositoryInterface.php b/src/Bundle/ChillPersonBundle/Repository/AccompanyingPeriodACLAwareRepositoryInterface.php index 0c5af217f..a02ec27c6 100644 --- a/src/Bundle/ChillPersonBundle/Repository/AccompanyingPeriodACLAwareRepositoryInterface.php +++ b/src/Bundle/ChillPersonBundle/Repository/AccompanyingPeriodACLAwareRepositoryInterface.php @@ -16,6 +16,8 @@ use Chill\PersonBundle\Entity\Person; interface AccompanyingPeriodACLAwareRepositoryInterface { + public function countByUserOpenedAccompanyingPeriod(?User $user): int; + public function findByPerson( Person $person, string $role, @@ -25,6 +27,4 @@ interface AccompanyingPeriodACLAwareRepositoryInterface ): array; public function findByUserOpenedAccompanyingPeriod(?User $user, array $orderBy = [], int $limit = 0, int $offset = 50): array; - - public function countByUserOpenedAccompanyingPeriod(?User $user): int; } From 2ce8b1110dc69c7c11001a3b666b192b0d1618f4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Mon, 21 Mar 2022 16:13:02 +0100 Subject: [PATCH 45/64] allow to change color for asyncupload button --- .../vuejs/_components/AddAsyncUpload.vue | 27 +++++++++++++++---- .../vuejs/AccompanyingCourseWorkEdit/App.vue | 2 +- .../components/AddEvaluation.vue | 5 ++-- .../components/FormEvaluation.vue | 1 + 4 files changed, 27 insertions(+), 8 deletions(-) diff --git a/src/Bundle/ChillDocStoreBundle/Resources/public/vuejs/_components/AddAsyncUpload.vue b/src/Bundle/ChillDocStoreBundle/Resources/public/vuejs/_components/AddAsyncUpload.vue index ebd2ab4b4..634e9ed45 100644 --- a/src/Bundle/ChillDocStoreBundle/Resources/public/vuejs/_components/AddAsyncUpload.vue +++ b/src/Bundle/ChillDocStoreBundle/Resources/public/vuejs/_components/AddAsyncUpload.vue @@ -1,5 +1,5 @@