From 9b06ccc3e6466fe4f315ee9c6b21af8f4c3735e8 Mon Sep 17 00:00:00 2001 From: nobohan Date: Mon, 7 Mar 2022 11:13:11 +0100 Subject: [PATCH 01/51] 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/51] 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/51] 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/51] 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/51] 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 2628e58ea0476e90e3850143398fe413c15bd6a6 Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Thu, 10 Mar 2022 12:28:17 +0100 Subject: [PATCH 06/51] document title added + concerned users --- .../Workflow/_evaluation_document.html.twig | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/src/Bundle/ChillPersonBundle/Resources/views/Workflow/_evaluation_document.html.twig b/src/Bundle/ChillPersonBundle/Resources/views/Workflow/_evaluation_document.html.twig index 488f31661..addc619f7 100644 --- a/src/Bundle/ChillPersonBundle/Resources/views/Workflow/_evaluation_document.html.twig +++ b/src/Bundle/ChillPersonBundle/Resources/views/Workflow/_evaluation_document.html.twig @@ -1,5 +1,10 @@
+
+ {% for d in evaluation.documents %} +

{{ d.title }}

+ {% endfor %} +

@@ -20,6 +25,24 @@

+
+
+

+ {{ 'Participants'|trans }} +

+
+
+ {% for p in evaluation.accompanyingPeriodWork.persons %} + {% include '@ChillMain/OnTheFly/_insert_vue_onthefly.html.twig' with { + targetEntity: { name: 'person', id: p.id }, + action: 'show', + displayBadge: true, + buttonText: p|chill_entity_render_string, + isDead: p.deathdate is not null + } %} + {% endfor %} +
+
From bf2d9acc5a67991c9a0df240de68f32b900c470b Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Thu, 10 Mar 2022 14:03:37 +0100 Subject: [PATCH 07/51] correction of template, display title linked to workflow doc --- .../Resources/views/Workflow/_evaluation_document.html.twig | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/Bundle/ChillPersonBundle/Resources/views/Workflow/_evaluation_document.html.twig b/src/Bundle/ChillPersonBundle/Resources/views/Workflow/_evaluation_document.html.twig index addc619f7..bd37226cc 100644 --- a/src/Bundle/ChillPersonBundle/Resources/views/Workflow/_evaluation_document.html.twig +++ b/src/Bundle/ChillPersonBundle/Resources/views/Workflow/_evaluation_document.html.twig @@ -1,9 +1,7 @@
- {% for d in evaluation.documents %} -

{{ d.title }}

- {% endfor %} +

{{ doc.title }}

From 9284a4bc29e22a8a81c340026e364e910f37b1e5 Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Thu, 10 Mar 2022 14:30:19 +0100 Subject: [PATCH 08/51] ACL added and buttons to download and edit document --- .../views/Workflow/_evaluation_document.html.twig | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/Bundle/ChillPersonBundle/Resources/views/Workflow/_evaluation_document.html.twig b/src/Bundle/ChillPersonBundle/Resources/views/Workflow/_evaluation_document.html.twig index bd37226cc..398b5221e 100644 --- a/src/Bundle/ChillPersonBundle/Resources/views/Workflow/_evaluation_document.html.twig +++ b/src/Bundle/ChillPersonBundle/Resources/views/Workflow/_evaluation_document.html.twig @@ -1,7 +1,9 @@ +{%- import "@ChillDocStore/Macro/macro.html.twig" as m -%} +
-

{{ doc.title }}

+

{{ doc.title }}

git st

@@ -113,12 +115,19 @@

{% if display_action is defined and display_action == true %} - {# TODO add acl #} + {% if is_granted('CHILL_MAIN_ACCOMPANYING_PERIOD_WORK_UPDATE', evaluation.accompanyingPeriodWork) %}
    +
  • {{ m.download_button(doc.storedObject, doc.title) }}
  • + {# {% if chill_document_is_editable(doc.storedObject) %} #} +
  • + {{ doc.storedObject|chill_document_edit_button }} +
  • + {# {% endif %} #}
  • {{ 'Show'|trans }}
+ {% endif %} {% endif %} From 0a2730540e7e01179bcaeb0f16dac2394c370581 Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Thu, 10 Mar 2022 14:45:43 +0100 Subject: [PATCH 09/51] lost text removed plus condition to editing file uncommented --- .../Resources/views/Workflow/_evaluation_document.html.twig | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Bundle/ChillPersonBundle/Resources/views/Workflow/_evaluation_document.html.twig b/src/Bundle/ChillPersonBundle/Resources/views/Workflow/_evaluation_document.html.twig index 398b5221e..2e05a6648 100644 --- a/src/Bundle/ChillPersonBundle/Resources/views/Workflow/_evaluation_document.html.twig +++ b/src/Bundle/ChillPersonBundle/Resources/views/Workflow/_evaluation_document.html.twig @@ -3,7 +3,7 @@
-

{{ doc.title }}

git st +

{{ doc.title }}

@@ -118,11 +118,11 @@ {% if is_granted('CHILL_MAIN_ACCOMPANYING_PERIOD_WORK_UPDATE', evaluation.accompanyingPeriodWork) %}

+
+
    @@ -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 41/51] 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 42/51] 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 43/51] 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 44/51] 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 45/51] 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 46/51] 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 47/51] 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 @@