From bf4e036b7f147f350d4e3ec8550f39275662c4f8 Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Fri, 10 Feb 2023 11:53:08 +0100 Subject: [PATCH 01/37] FEATURE [eval][duration] property added to an to save the time spent working on evaluation --- .../AccompanyingPeriodWorkEvaluation.php | 17 ++++++++++++ .../migrations/Version20230210104424.php | 26 +++++++++++++++++++ 2 files changed, 43 insertions(+) create mode 100644 src/Bundle/ChillPersonBundle/migrations/Version20230210104424.php diff --git a/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod/AccompanyingPeriodWorkEvaluation.php b/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod/AccompanyingPeriodWorkEvaluation.php index 078ef0c3c..39266b57e 100644 --- a/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod/AccompanyingPeriodWorkEvaluation.php +++ b/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod/AccompanyingPeriodWorkEvaluation.php @@ -160,6 +160,11 @@ class AccompanyingPeriodWorkEvaluation implements TrackCreationInterface, TrackU */ private ?DateInterval $warningInterval = null; + /** + * @ORM\Column(type="time", nullable=true) + */ + private ?DateTimeInterface $timeSpent = null; + public function __construct() { $this->documents = new ArrayCollection(); @@ -265,6 +270,11 @@ class AccompanyingPeriodWorkEvaluation implements TrackCreationInterface, TrackU return $this->warningInterval; } + public function getTimeSpent(): ?DateTimeInterface + { + return $this->timeSpent; + } + public function removeDocument(AccompanyingPeriodWorkEvaluationDocument $document): self { $this->documents->removeElement($document); @@ -322,6 +332,13 @@ class AccompanyingPeriodWorkEvaluation implements TrackCreationInterface, TrackU return $this; } + public function setTimeSpent(?DateTimeInterface $timeSpent): self + { + $this->timeSpent = $timeSpent; + + return $this; + } + public function setEvaluation(?Evaluation $evaluation): AccompanyingPeriodWorkEvaluation { if ( diff --git a/src/Bundle/ChillPersonBundle/migrations/Version20230210104424.php b/src/Bundle/ChillPersonBundle/migrations/Version20230210104424.php new file mode 100644 index 000000000..ea18e9adf --- /dev/null +++ b/src/Bundle/ChillPersonBundle/migrations/Version20230210104424.php @@ -0,0 +1,26 @@ +addSql('ALTER TABLE chill_person_accompanying_period_work_evaluation ADD timeSpent TIME(0) WITHOUT TIME ZONE DEFAULT NULL'); + } + + public function down(Schema $schema): void + { + $this->addSql('ALTER TABLE chill_person_accompanying_period_work_evaluation DROP timeSpent'); + } +} From 8a6b2354bd413bc0c3472edff76cb3939edee181 Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Fri, 10 Feb 2023 12:58:31 +0100 Subject: [PATCH 02/37] FEATURE [vue][form] incorporating the timeSpent field in the vue form --- .../components/FormEvaluation.vue | 34 +++++++++++++++++++ .../vuejs/AccompanyingCourseWorkEdit/store.js | 4 +++ 2 files changed, 38 insertions(+) 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 4bf9e1a8a..c8101b2ba 100644 --- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourseWorkEdit/components/FormEvaluation.vue +++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourseWorkEdit/components/FormEvaluation.vue @@ -49,6 +49,19 @@ +
+ +
+ +
+
+
@@ -190,6 +203,7 @@ const i18n = { evaluation_choose_a_template: "Choisir un modèle", evaluation_add_a_document: "Ajouter un document", evaluation_add: "Ajouter une évaluation", + evaluation_time_spent: "Temps de rédaction", Documents: "Documents", document_add: "Générer ou téléverser un document", document_upload: "Téléverser un document", @@ -223,6 +237,22 @@ export default { maxPostSize: 15000000, required: false, }, + timeSpentChoices: [ + { text: '1 minute', value: 60 }, { text: '2 minutes', value: 120 }, + { text: '3 minutes', value: 180 }, { text: '4 minutes', value: 240 }, + { text: '5 minutes', value: 300 }, { text: '10 minutes', value: 600 }, + { text: '15 minutes', value: 900 },{ text: '20 minutes', value: 1200 }, + { text: '25 minutes', value: 1500 }, { text: '30 minutes', value: 1800 }, + { text: '45 minutes', value: 2700 },{ text: '1 hour', value: 3600 }, + { text: '1 hour 15 minutes', value: 4500 }, { text: '1 hour 30 minutes', value: 5400 }, + { text: '1 hour 45 minutes', value: 6300 }, { text: '2 hours', value: 7200 }, + { text: '2 hours 30 minutes', value: 9000 }, { text: '3 hours', value: 10800 }, + { text: '3 hours 30 minutes', value: 12600 },{ text: '4 hours', value: 14400 }, + { text: '4 hours 30 minutes', value: 16200 },{ text: '5 hours', value: 18000 }, + { text: '5 hours 30 minutes', value: 19800 },{ text: '6 hours', value: 21600 }, + { text: '6 hours 30 minutes', value: 23400 },{ text: '7 hours', value: 25200 }, + { text: '7 hours 30 minutes', value: 27000 },{ text: '8 hours', value: 28800 }, + ] } }, computed: { @@ -264,6 +294,10 @@ export default { get() { return this.evaluation.warningInterval; }, set(v) { this.$store.commit('setEvaluationWarningInterval', { key: this.evaluation.key, days: v }); } }, + timeSpent: { + get() { return this.timeSpentChoices }, + set(v) { this.$store.commit('setEvaluationTimeSpent', { key: this.evaluation.key, time: v}) } + }, comment: { get() { return this.evaluation.comment; }, set(v) { this.$store.commit('setEvaluationComment', { key: this.evaluation.key, comment: v }); } diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourseWorkEdit/store.js b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourseWorkEdit/store.js index acbe51981..ee011ae28 100644 --- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourseWorkEdit/store.js +++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourseWorkEdit/store.js @@ -286,6 +286,10 @@ const store = createStore({ state.evaluationsPicked.find(e => e.key === key) .warningInterval = days; }, + setEvaluationTimeSpent(state, {key, time}) { + state.evaluationsPicked.find(e => e.key === key) + .timeSpent = time; + }, setEvaluationComment(state, {key, comment}) { state.evaluationsPicked.find(e => e.key === key) .comment = comment; From 4a62c2e167063c6f00b2a463626cace282333a51 Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Wed, 15 Feb 2023 11:17:59 +0100 Subject: [PATCH 03/37] FEATURE [evaluation][serialization] add new time spent property to serialization --- .../AccompanyingPeriod/AccompanyingPeriodWorkEvaluation.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod/AccompanyingPeriodWorkEvaluation.php b/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod/AccompanyingPeriodWorkEvaluation.php index 39266b57e..9cb26b4c3 100644 --- a/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod/AccompanyingPeriodWorkEvaluation.php +++ b/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod/AccompanyingPeriodWorkEvaluation.php @@ -162,6 +162,9 @@ class AccompanyingPeriodWorkEvaluation implements TrackCreationInterface, TrackU /** * @ORM\Column(type="time", nullable=true) + * @Serializer\Groups({"read", "docgen:read"}) + * @Serializer\Groups({"write"}) + * @Serializer\Groups({"accompanying_period_work_evaluation:create"}) */ private ?DateTimeInterface $timeSpent = null; From 80a88fc00c533bc9282f3b1294200875a86a7acb Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Wed, 15 Feb 2023 11:28:05 +0100 Subject: [PATCH 04/37] FEATURE [timespent][type] change type of time spent to integer --- .../AccompanyingPeriodWorkEvaluation.php | 8 ++++---- .../migrations/Version20230210104424.php | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod/AccompanyingPeriodWorkEvaluation.php b/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod/AccompanyingPeriodWorkEvaluation.php index 9cb26b4c3..8780f7d17 100644 --- a/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod/AccompanyingPeriodWorkEvaluation.php +++ b/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod/AccompanyingPeriodWorkEvaluation.php @@ -161,12 +161,12 @@ class AccompanyingPeriodWorkEvaluation implements TrackCreationInterface, TrackU private ?DateInterval $warningInterval = null; /** - * @ORM\Column(type="time", nullable=true) + * @ORM\Column(type="integer", nullable=true) * @Serializer\Groups({"read", "docgen:read"}) * @Serializer\Groups({"write"}) * @Serializer\Groups({"accompanying_period_work_evaluation:create"}) */ - private ?DateTimeInterface $timeSpent = null; + private ?int $timeSpent = null; public function __construct() { @@ -273,7 +273,7 @@ class AccompanyingPeriodWorkEvaluation implements TrackCreationInterface, TrackU return $this->warningInterval; } - public function getTimeSpent(): ?DateTimeInterface + public function getTimeSpent(): ?int { return $this->timeSpent; } @@ -335,7 +335,7 @@ class AccompanyingPeriodWorkEvaluation implements TrackCreationInterface, TrackU return $this; } - public function setTimeSpent(?DateTimeInterface $timeSpent): self + public function setTimeSpent(?int $timeSpent): self { $this->timeSpent = $timeSpent; diff --git a/src/Bundle/ChillPersonBundle/migrations/Version20230210104424.php b/src/Bundle/ChillPersonBundle/migrations/Version20230210104424.php index ea18e9adf..ec802a993 100644 --- a/src/Bundle/ChillPersonBundle/migrations/Version20230210104424.php +++ b/src/Bundle/ChillPersonBundle/migrations/Version20230210104424.php @@ -16,7 +16,7 @@ final class Version20230210104424 extends AbstractMigration public function up(Schema $schema): void { - $this->addSql('ALTER TABLE chill_person_accompanying_period_work_evaluation ADD timeSpent TIME(0) WITHOUT TIME ZONE DEFAULT NULL'); + $this->addSql('ALTER TABLE chill_person_accompanying_period_work_evaluation ADD timeSpent INT DEFAULT NULL'); } public function down(Schema $schema): void From a5f4eabc341e149a1fb8239e8e5cf208dc59c28d Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Wed, 15 Feb 2023 11:50:05 +0100 Subject: [PATCH 05/37] FEATURE [store][component] final adjustments to methods to post time spent --- .../components/FormEvaluation.vue | 6 ++++-- .../public/vuejs/AccompanyingCourseWorkEdit/store.js | 5 ++++- 2 files changed, 8 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 c8101b2ba..13f02e4d6 100644 --- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourseWorkEdit/components/FormEvaluation.vue +++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourseWorkEdit/components/FormEvaluation.vue @@ -55,7 +55,8 @@
@@ -204,6 +205,7 @@ const i18n = { evaluation_add_a_document: "Ajouter un document", evaluation_add: "Ajouter une évaluation", evaluation_time_spent: "Temps de rédaction", + select_time_spent: "Indiquez le temps de rédaction", Documents: "Documents", document_add: "Générer ou téléverser un document", document_upload: "Téléverser un document", @@ -295,7 +297,7 @@ export default { set(v) { this.$store.commit('setEvaluationWarningInterval', { key: this.evaluation.key, days: v }); } }, timeSpent: { - get() { return this.timeSpentChoices }, + get() { return this.evaluation.timeSpent }, set(v) { this.$store.commit('setEvaluationTimeSpent', { key: this.evaluation.key, time: v}) } }, comment: { diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourseWorkEdit/store.js b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourseWorkEdit/store.js index ee011ae28..5c610fa50 100644 --- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourseWorkEdit/store.js +++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourseWorkEdit/store.js @@ -116,6 +116,7 @@ const store = createStore({ endDate: e.endDate === null || e.endDate === '' ? null : { datetime: datetimeToISO(ISOToDate(e.endDate)) }, maxDate: e.maxDate === null || e.maxDate === '' ? null : { datetime: datetimeToISO(ISOToDate(e.maxDate)) }, warningInterval: intervalDaysToISO(e.warningInterval), + timeSpent: e.timeSpent, comment: e.comment, documents: e.documents }; @@ -138,6 +139,7 @@ const store = createStore({ endDate: e.endDate !== null ? dateToISO(new Date(e.endDate.datetime)) : null, maxDate: e.maxDate !== null ? dateToISO(new Date(e.maxDate.datetime)) : null, warningInterval: e.warningInterval !== null ? intervalISOToDays(e.warningInterval) : null, + timeSpent: e.timeSpent !== null ? e.timeSpent : null, documents: e.documents.map((d, docIndex) => { return Object.assign(d, { key: docIndex @@ -258,6 +260,7 @@ const store = createStore({ endDate: null, maxDate: null, warningInterval: null, + timeSpent: null, comment: "", editEvaluation: true, workflows_availables: state.work.workflows_availables_evaluation, @@ -471,7 +474,7 @@ const store = createStore({ ; commit('setIsPosting', true); - console.log('payload', payload); + console.log('the social action', payload); return makeFetch('PUT', url, payload) .then(data => { From f75f6719bc43839e81e150c81e02577f8bdc3b68 Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Fri, 10 Feb 2023 11:53:08 +0100 Subject: [PATCH 06/37] FEATURE [eval][duration] property added to an to save the time spent working on evaluation --- .../AccompanyingPeriodWorkEvaluation.php | 17 ++++++++++++ .../migrations/Version20230210104424.php | 26 +++++++++++++++++++ 2 files changed, 43 insertions(+) create mode 100644 src/Bundle/ChillPersonBundle/migrations/Version20230210104424.php diff --git a/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod/AccompanyingPeriodWorkEvaluation.php b/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod/AccompanyingPeriodWorkEvaluation.php index 078ef0c3c..39266b57e 100644 --- a/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod/AccompanyingPeriodWorkEvaluation.php +++ b/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod/AccompanyingPeriodWorkEvaluation.php @@ -160,6 +160,11 @@ class AccompanyingPeriodWorkEvaluation implements TrackCreationInterface, TrackU */ private ?DateInterval $warningInterval = null; + /** + * @ORM\Column(type="time", nullable=true) + */ + private ?DateTimeInterface $timeSpent = null; + public function __construct() { $this->documents = new ArrayCollection(); @@ -265,6 +270,11 @@ class AccompanyingPeriodWorkEvaluation implements TrackCreationInterface, TrackU return $this->warningInterval; } + public function getTimeSpent(): ?DateTimeInterface + { + return $this->timeSpent; + } + public function removeDocument(AccompanyingPeriodWorkEvaluationDocument $document): self { $this->documents->removeElement($document); @@ -322,6 +332,13 @@ class AccompanyingPeriodWorkEvaluation implements TrackCreationInterface, TrackU return $this; } + public function setTimeSpent(?DateTimeInterface $timeSpent): self + { + $this->timeSpent = $timeSpent; + + return $this; + } + public function setEvaluation(?Evaluation $evaluation): AccompanyingPeriodWorkEvaluation { if ( diff --git a/src/Bundle/ChillPersonBundle/migrations/Version20230210104424.php b/src/Bundle/ChillPersonBundle/migrations/Version20230210104424.php new file mode 100644 index 000000000..ea18e9adf --- /dev/null +++ b/src/Bundle/ChillPersonBundle/migrations/Version20230210104424.php @@ -0,0 +1,26 @@ +addSql('ALTER TABLE chill_person_accompanying_period_work_evaluation ADD timeSpent TIME(0) WITHOUT TIME ZONE DEFAULT NULL'); + } + + public function down(Schema $schema): void + { + $this->addSql('ALTER TABLE chill_person_accompanying_period_work_evaluation DROP timeSpent'); + } +} From 08b3d476a7cf1c973e1c129c6636e403f5b4a398 Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Fri, 10 Feb 2023 12:58:31 +0100 Subject: [PATCH 07/37] FEATURE [vue][form] incorporating the timeSpent field in the vue form --- .../components/FormEvaluation.vue | 34 +++++++++++++++++++ .../vuejs/AccompanyingCourseWorkEdit/store.js | 4 +++ 2 files changed, 38 insertions(+) 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 4bf9e1a8a..c8101b2ba 100644 --- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourseWorkEdit/components/FormEvaluation.vue +++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourseWorkEdit/components/FormEvaluation.vue @@ -49,6 +49,19 @@
+
+ +
+ +
+
+
@@ -190,6 +203,7 @@ const i18n = { evaluation_choose_a_template: "Choisir un modèle", evaluation_add_a_document: "Ajouter un document", evaluation_add: "Ajouter une évaluation", + evaluation_time_spent: "Temps de rédaction", Documents: "Documents", document_add: "Générer ou téléverser un document", document_upload: "Téléverser un document", @@ -223,6 +237,22 @@ export default { maxPostSize: 15000000, required: false, }, + timeSpentChoices: [ + { text: '1 minute', value: 60 }, { text: '2 minutes', value: 120 }, + { text: '3 minutes', value: 180 }, { text: '4 minutes', value: 240 }, + { text: '5 minutes', value: 300 }, { text: '10 minutes', value: 600 }, + { text: '15 minutes', value: 900 },{ text: '20 minutes', value: 1200 }, + { text: '25 minutes', value: 1500 }, { text: '30 minutes', value: 1800 }, + { text: '45 minutes', value: 2700 },{ text: '1 hour', value: 3600 }, + { text: '1 hour 15 minutes', value: 4500 }, { text: '1 hour 30 minutes', value: 5400 }, + { text: '1 hour 45 minutes', value: 6300 }, { text: '2 hours', value: 7200 }, + { text: '2 hours 30 minutes', value: 9000 }, { text: '3 hours', value: 10800 }, + { text: '3 hours 30 minutes', value: 12600 },{ text: '4 hours', value: 14400 }, + { text: '4 hours 30 minutes', value: 16200 },{ text: '5 hours', value: 18000 }, + { text: '5 hours 30 minutes', value: 19800 },{ text: '6 hours', value: 21600 }, + { text: '6 hours 30 minutes', value: 23400 },{ text: '7 hours', value: 25200 }, + { text: '7 hours 30 minutes', value: 27000 },{ text: '8 hours', value: 28800 }, + ] } }, computed: { @@ -264,6 +294,10 @@ export default { get() { return this.evaluation.warningInterval; }, set(v) { this.$store.commit('setEvaluationWarningInterval', { key: this.evaluation.key, days: v }); } }, + timeSpent: { + get() { return this.timeSpentChoices }, + set(v) { this.$store.commit('setEvaluationTimeSpent', { key: this.evaluation.key, time: v}) } + }, comment: { get() { return this.evaluation.comment; }, set(v) { this.$store.commit('setEvaluationComment', { key: this.evaluation.key, comment: v }); } diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourseWorkEdit/store.js b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourseWorkEdit/store.js index acbe51981..ee011ae28 100644 --- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourseWorkEdit/store.js +++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourseWorkEdit/store.js @@ -286,6 +286,10 @@ const store = createStore({ state.evaluationsPicked.find(e => e.key === key) .warningInterval = days; }, + setEvaluationTimeSpent(state, {key, time}) { + state.evaluationsPicked.find(e => e.key === key) + .timeSpent = time; + }, setEvaluationComment(state, {key, comment}) { state.evaluationsPicked.find(e => e.key === key) .comment = comment; From 8957f3fed4c577e18a51508e16accc4cbb24d370 Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Wed, 15 Feb 2023 11:17:59 +0100 Subject: [PATCH 08/37] FEATURE [evaluation][serialization] add new time spent property to serialization --- .../AccompanyingPeriod/AccompanyingPeriodWorkEvaluation.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod/AccompanyingPeriodWorkEvaluation.php b/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod/AccompanyingPeriodWorkEvaluation.php index 39266b57e..9cb26b4c3 100644 --- a/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod/AccompanyingPeriodWorkEvaluation.php +++ b/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod/AccompanyingPeriodWorkEvaluation.php @@ -162,6 +162,9 @@ class AccompanyingPeriodWorkEvaluation implements TrackCreationInterface, TrackU /** * @ORM\Column(type="time", nullable=true) + * @Serializer\Groups({"read", "docgen:read"}) + * @Serializer\Groups({"write"}) + * @Serializer\Groups({"accompanying_period_work_evaluation:create"}) */ private ?DateTimeInterface $timeSpent = null; From e528e4f57ac04d9730607e315128ce72ffc809c6 Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Wed, 15 Feb 2023 11:28:05 +0100 Subject: [PATCH 09/37] FEATURE [timespent][type] change type of time spent to integer --- .../AccompanyingPeriodWorkEvaluation.php | 8 ++++---- .../migrations/Version20230210104424.php | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod/AccompanyingPeriodWorkEvaluation.php b/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod/AccompanyingPeriodWorkEvaluation.php index 9cb26b4c3..8780f7d17 100644 --- a/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod/AccompanyingPeriodWorkEvaluation.php +++ b/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod/AccompanyingPeriodWorkEvaluation.php @@ -161,12 +161,12 @@ class AccompanyingPeriodWorkEvaluation implements TrackCreationInterface, TrackU private ?DateInterval $warningInterval = null; /** - * @ORM\Column(type="time", nullable=true) + * @ORM\Column(type="integer", nullable=true) * @Serializer\Groups({"read", "docgen:read"}) * @Serializer\Groups({"write"}) * @Serializer\Groups({"accompanying_period_work_evaluation:create"}) */ - private ?DateTimeInterface $timeSpent = null; + private ?int $timeSpent = null; public function __construct() { @@ -273,7 +273,7 @@ class AccompanyingPeriodWorkEvaluation implements TrackCreationInterface, TrackU return $this->warningInterval; } - public function getTimeSpent(): ?DateTimeInterface + public function getTimeSpent(): ?int { return $this->timeSpent; } @@ -335,7 +335,7 @@ class AccompanyingPeriodWorkEvaluation implements TrackCreationInterface, TrackU return $this; } - public function setTimeSpent(?DateTimeInterface $timeSpent): self + public function setTimeSpent(?int $timeSpent): self { $this->timeSpent = $timeSpent; diff --git a/src/Bundle/ChillPersonBundle/migrations/Version20230210104424.php b/src/Bundle/ChillPersonBundle/migrations/Version20230210104424.php index ea18e9adf..ec802a993 100644 --- a/src/Bundle/ChillPersonBundle/migrations/Version20230210104424.php +++ b/src/Bundle/ChillPersonBundle/migrations/Version20230210104424.php @@ -16,7 +16,7 @@ final class Version20230210104424 extends AbstractMigration public function up(Schema $schema): void { - $this->addSql('ALTER TABLE chill_person_accompanying_period_work_evaluation ADD timeSpent TIME(0) WITHOUT TIME ZONE DEFAULT NULL'); + $this->addSql('ALTER TABLE chill_person_accompanying_period_work_evaluation ADD timeSpent INT DEFAULT NULL'); } public function down(Schema $schema): void From 9ff116797acdfc8f81236b7ca858c9532cbd5a78 Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Wed, 15 Feb 2023 11:50:05 +0100 Subject: [PATCH 10/37] FEATURE [store][component] final adjustments to methods to post time spent --- .../components/FormEvaluation.vue | 6 ++++-- .../public/vuejs/AccompanyingCourseWorkEdit/store.js | 5 ++++- 2 files changed, 8 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 c8101b2ba..13f02e4d6 100644 --- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourseWorkEdit/components/FormEvaluation.vue +++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourseWorkEdit/components/FormEvaluation.vue @@ -55,7 +55,8 @@
@@ -204,6 +205,7 @@ const i18n = { evaluation_add_a_document: "Ajouter un document", evaluation_add: "Ajouter une évaluation", evaluation_time_spent: "Temps de rédaction", + select_time_spent: "Indiquez le temps de rédaction", Documents: "Documents", document_add: "Générer ou téléverser un document", document_upload: "Téléverser un document", @@ -295,7 +297,7 @@ export default { set(v) { this.$store.commit('setEvaluationWarningInterval', { key: this.evaluation.key, days: v }); } }, timeSpent: { - get() { return this.timeSpentChoices }, + get() { return this.evaluation.timeSpent }, set(v) { this.$store.commit('setEvaluationTimeSpent', { key: this.evaluation.key, time: v}) } }, comment: { diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourseWorkEdit/store.js b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourseWorkEdit/store.js index ee011ae28..5c610fa50 100644 --- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourseWorkEdit/store.js +++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourseWorkEdit/store.js @@ -116,6 +116,7 @@ const store = createStore({ endDate: e.endDate === null || e.endDate === '' ? null : { datetime: datetimeToISO(ISOToDate(e.endDate)) }, maxDate: e.maxDate === null || e.maxDate === '' ? null : { datetime: datetimeToISO(ISOToDate(e.maxDate)) }, warningInterval: intervalDaysToISO(e.warningInterval), + timeSpent: e.timeSpent, comment: e.comment, documents: e.documents }; @@ -138,6 +139,7 @@ const store = createStore({ endDate: e.endDate !== null ? dateToISO(new Date(e.endDate.datetime)) : null, maxDate: e.maxDate !== null ? dateToISO(new Date(e.maxDate.datetime)) : null, warningInterval: e.warningInterval !== null ? intervalISOToDays(e.warningInterval) : null, + timeSpent: e.timeSpent !== null ? e.timeSpent : null, documents: e.documents.map((d, docIndex) => { return Object.assign(d, { key: docIndex @@ -258,6 +260,7 @@ const store = createStore({ endDate: null, maxDate: null, warningInterval: null, + timeSpent: null, comment: "", editEvaluation: true, workflows_availables: state.work.workflows_availables_evaluation, @@ -471,7 +474,7 @@ const store = createStore({ ; commit('setIsPosting', true); - console.log('payload', payload); + console.log('the social action', payload); return makeFetch('PUT', url, payload) .then(data => { From 8b517f169f309e56985c123bceb5f4f072036c67 Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Fri, 24 Feb 2023 17:17:35 +0100 Subject: [PATCH 11/37] FEATURE [suggested][entities] add suggested entities option to dynamic picker types --- src/Bundle/ChillMainBundle/Form/Type/PickUserDynamicType.php | 4 +++- .../ChillPersonBundle/Form/Type/PickPersonDynamicType.php | 4 +++- .../Form/Type/PickThirdpartyDynamicType.php | 4 +++- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/Bundle/ChillMainBundle/Form/Type/PickUserDynamicType.php b/src/Bundle/ChillMainBundle/Form/Type/PickUserDynamicType.php index 2fbfdcf11..9a2c1fbb4 100644 --- a/src/Bundle/ChillMainBundle/Form/Type/PickUserDynamicType.php +++ b/src/Bundle/ChillMainBundle/Form/Type/PickUserDynamicType.php @@ -46,6 +46,7 @@ class PickUserDynamicType extends AbstractType $view->vars['multiple'] = $options['multiple']; $view->vars['types'] = ['user']; $view->vars['uniqid'] = uniqid('pick_user_dyn'); + $view->vars['suggested'] = $this->serializer->serialize($options['suggested'], 'json', ['groups' => 'read']); } public function configureOptions(OptionsResolver $resolver) @@ -53,7 +54,8 @@ class PickUserDynamicType extends AbstractType $resolver ->setDefault('multiple', false) ->setAllowedTypes('multiple', ['bool']) - ->setDefault('compound', false); + ->setDefault('compound', false) + ->setDefault('suggested', null); } public function getBlockPrefix() diff --git a/src/Bundle/ChillPersonBundle/Form/Type/PickPersonDynamicType.php b/src/Bundle/ChillPersonBundle/Form/Type/PickPersonDynamicType.php index b0be9dd27..91e46d193 100644 --- a/src/Bundle/ChillPersonBundle/Form/Type/PickPersonDynamicType.php +++ b/src/Bundle/ChillPersonBundle/Form/Type/PickPersonDynamicType.php @@ -45,6 +45,7 @@ class PickPersonDynamicType extends AbstractType $view->vars['multiple'] = $options['multiple']; $view->vars['types'] = ['person']; $view->vars['uniqid'] = uniqid('pick_user_dyn'); + $view->vars['suggested'] = $this->serializer->serialize($options['suggested'], 'json', ['groups' => 'read']); } public function configureOptions(OptionsResolver $resolver) @@ -52,7 +53,8 @@ class PickPersonDynamicType extends AbstractType $resolver ->setDefault('multiple', false) ->setAllowedTypes('multiple', ['bool']) - ->setDefault('compound', false); + ->setDefault('compound', false) + ->setDefault('suggested', null); } public function getBlockPrefix() diff --git a/src/Bundle/ChillThirdPartyBundle/Form/Type/PickThirdpartyDynamicType.php b/src/Bundle/ChillThirdPartyBundle/Form/Type/PickThirdpartyDynamicType.php index ada4064eb..d813918f7 100644 --- a/src/Bundle/ChillThirdPartyBundle/Form/Type/PickThirdpartyDynamicType.php +++ b/src/Bundle/ChillThirdPartyBundle/Form/Type/PickThirdpartyDynamicType.php @@ -45,6 +45,7 @@ class PickThirdpartyDynamicType extends AbstractType $view->vars['multiple'] = $options['multiple']; $view->vars['types'] = ['thirdparty']; $view->vars['uniqid'] = uniqid('pick_user_dyn'); + $view->vars['suggested'] = $this->serializer->serialize($options['suggested'], 'json', ['groups' => 'read']); } public function configureOptions(OptionsResolver $resolver) @@ -52,7 +53,8 @@ class PickThirdpartyDynamicType extends AbstractType $resolver ->setDefault('multiple', false) ->setAllowedTypes('multiple', ['bool']) - ->setDefault('compound', false); + ->setDefault('compound', false) + ->setDefault('suggested', null); } public function getBlockPrefix() From 9e6579a1769379485f7b0c671298179751067336 Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Fri, 24 Feb 2023 17:20:35 +0100 Subject: [PATCH 12/37] [workflow][method] add method to get involved/suggested users --- ...AccompanyingCourseDocumentWorkflowHandler.php | 10 ++++++++++ .../Entity/Workflow/EntityWorkflow.php | 16 ++++++++++++++++ .../Workflow/EntityWorkflowHandlerInterface.php | 5 +++++ ...riodWorkEvaluationDocumentWorkflowHandler.php | 15 +++++++++++++++ ...anyingPeriodWorkEvaluationWorkflowHandler.php | 14 ++++++++++++++ .../AccompanyingPeriodWorkWorkflowHandler.php | 13 +++++++++++++ 6 files changed, 73 insertions(+) diff --git a/src/Bundle/ChillDocStoreBundle/Workflow/AccompanyingCourseDocumentWorkflowHandler.php b/src/Bundle/ChillDocStoreBundle/Workflow/AccompanyingCourseDocumentWorkflowHandler.php index 96787a6fc..ec714aa74 100644 --- a/src/Bundle/ChillDocStoreBundle/Workflow/AccompanyingCourseDocumentWorkflowHandler.php +++ b/src/Bundle/ChillDocStoreBundle/Workflow/AccompanyingCourseDocumentWorkflowHandler.php @@ -95,6 +95,16 @@ class AccompanyingCourseDocumentWorkflowHandler implements EntityWorkflowHandler return null; } + public function getSuggestedUsers(EntityWorkflow $entityWorkflow): array + { + $suggestedUsers = $entityWorkflow->getUsersInvolved(); + + $referrer = $this->getRelatedEntity($entityWorkflow)->getCourse()->getUser(); + $suggestedUsers[$referrer->getId()] = $referrer; + + return $suggestedUsers; + } + public function getTemplate(EntityWorkflow $entityWorkflow, array $options = []): string { return '@ChillDocStore/AccompanyingCourseDocument/_workflow.html.twig'; diff --git a/src/Bundle/ChillMainBundle/Entity/Workflow/EntityWorkflow.php b/src/Bundle/ChillMainBundle/Entity/Workflow/EntityWorkflow.php index c448ea19e..62e6bac0f 100644 --- a/src/Bundle/ChillMainBundle/Entity/Workflow/EntityWorkflow.php +++ b/src/Bundle/ChillMainBundle/Entity/Workflow/EntityWorkflow.php @@ -348,6 +348,22 @@ class EntityWorkflow implements TrackCreationInterface, TrackUpdateInterface return $this->transitionningStep; } + /** + * @return User[] + */ + public function getUsersInvolved(): array + { + $usersInvolved = []; + + foreach ($this->steps as $step) { + foreach ($step->getDestUser() as $u) { + $usersInvolved[$u->getId()] = $u; + } + } + + return $usersInvolved; + } + public function getWorkflowName(): string { return $this->workflowName; diff --git a/src/Bundle/ChillMainBundle/Workflow/EntityWorkflowHandlerInterface.php b/src/Bundle/ChillMainBundle/Workflow/EntityWorkflowHandlerInterface.php index 5058fed7c..73e260c37 100644 --- a/src/Bundle/ChillMainBundle/Workflow/EntityWorkflowHandlerInterface.php +++ b/src/Bundle/ChillMainBundle/Workflow/EntityWorkflowHandlerInterface.php @@ -36,6 +36,11 @@ interface EntityWorkflowHandlerInterface */ public function getRoleShow(EntityWorkflow $entityWorkflow): ?string; + /** + * @return User[] + */ + public function getSuggestedUsers(EntityWorkflow $entityWorkflow): array; + public function getTemplate(EntityWorkflow $entityWorkflow, array $options = []): string; public function getTemplateData(EntityWorkflow $entityWorkflow, array $options = []): array; diff --git a/src/Bundle/ChillPersonBundle/Workflow/AccompanyingPeriodWorkEvaluationDocumentWorkflowHandler.php b/src/Bundle/ChillPersonBundle/Workflow/AccompanyingPeriodWorkEvaluationDocumentWorkflowHandler.php index 735463fc2..2c78e2099 100644 --- a/src/Bundle/ChillPersonBundle/Workflow/AccompanyingPeriodWorkEvaluationDocumentWorkflowHandler.php +++ b/src/Bundle/ChillPersonBundle/Workflow/AccompanyingPeriodWorkEvaluationDocumentWorkflowHandler.php @@ -97,6 +97,21 @@ class AccompanyingPeriodWorkEvaluationDocumentWorkflowHandler implements EntityW return AccompanyingPeriodWorkEvaluationDocumentVoter::SEE; } + public function getSuggestedUsers(EntityWorkflow $entityWorkflow): array + { + $suggestedUsers = $entityWorkflow->getUsersInvolved(); + + $referrer = $this->getRelatedEntity($entityWorkflow) + ->getAccompanyingPeriodWorkEvaluation() + ->getAccompanyingPeriodWork() + ->getAccompanyingPeriod() + ->getUser(); + + $suggestedUsers[$referrer->getId()] = $referrer; + + return $suggestedUsers; + } + public function getTemplate(EntityWorkflow $entityWorkflow, array $options = []): string { return '@ChillPerson/Workflow/_evaluation_document.html.twig'; diff --git a/src/Bundle/ChillPersonBundle/Workflow/AccompanyingPeriodWorkEvaluationWorkflowHandler.php b/src/Bundle/ChillPersonBundle/Workflow/AccompanyingPeriodWorkEvaluationWorkflowHandler.php index 25edce03b..a6d9fc9b4 100644 --- a/src/Bundle/ChillPersonBundle/Workflow/AccompanyingPeriodWorkEvaluationWorkflowHandler.php +++ b/src/Bundle/ChillPersonBundle/Workflow/AccompanyingPeriodWorkEvaluationWorkflowHandler.php @@ -87,6 +87,20 @@ class AccompanyingPeriodWorkEvaluationWorkflowHandler implements EntityWorkflowH return AccompanyingPeriodWorkEvaluationVoter::SEE; } + public function getSuggestedUsers(EntityWorkflow $entityWorkflow): array + { + $suggestedUsers = $entityWorkflow->getUsersInvolved(); + + $referrer = $this->getRelatedEntity($entityWorkflow) + ->getAccompanyingPeriodWork() + ->getAccompanyingPeriod() + ->getUser(); + + $suggestedUsers[$referrer->getId()] = $referrer; + + return $suggestedUsers; + } + public function getTemplate(EntityWorkflow $entityWorkflow, array $options = []): string { return '@ChillPerson/Workflow/_evaluation.html.twig'; diff --git a/src/Bundle/ChillPersonBundle/Workflow/AccompanyingPeriodWorkWorkflowHandler.php b/src/Bundle/ChillPersonBundle/Workflow/AccompanyingPeriodWorkWorkflowHandler.php index b6829ab77..142a57229 100644 --- a/src/Bundle/ChillPersonBundle/Workflow/AccompanyingPeriodWorkWorkflowHandler.php +++ b/src/Bundle/ChillPersonBundle/Workflow/AccompanyingPeriodWorkWorkflowHandler.php @@ -94,6 +94,19 @@ class AccompanyingPeriodWorkWorkflowHandler implements EntityWorkflowHandlerInte return null; } + public function getSuggestedUsers(EntityWorkflow $entityWorkflow): array + { + $suggestedUsers = $entityWorkflow->getUsersInvolved(); + + $referrer = $this->getRelatedEntity($entityWorkflow) + ->getAccompanyingPeriod() + ->getUser(); + + $suggestedUsers[$referrer->getId()] = $referrer; + + return $suggestedUsers; + } + public function getTemplate(EntityWorkflow $entityWorkflow, array $options = []): string { return '@ChillPerson/Workflow/_accompanying_period_work.html.twig'; From 365df4f3babd1a399e769880998e2c4936e25b4e Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Fri, 24 Feb 2023 17:22:41 +0100 Subject: [PATCH 13/37] [form][controller] pass suggested users on to workflow form --- .../Controller/WorkflowController.php | 16 ++++++++++++++-- .../ChillMainBundle/Form/WorkflowStepType.php | 2 ++ 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/src/Bundle/ChillMainBundle/Controller/WorkflowController.php b/src/Bundle/ChillMainBundle/Controller/WorkflowController.php index 17b5db75e..0f00a177f 100644 --- a/src/Bundle/ChillMainBundle/Controller/WorkflowController.php +++ b/src/Bundle/ChillMainBundle/Controller/WorkflowController.php @@ -30,6 +30,7 @@ use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpKernel\Exception\BadRequestHttpException; use Symfony\Component\Routing\Annotation\Route; use Symfony\Component\Security\Core\Exception\AccessDeniedException; +use Symfony\Component\Security\Core\Security; use Symfony\Component\Validator\Validator\ValidatorInterface; use Symfony\Component\Workflow\Registry; use Symfony\Component\Workflow\TransitionBlocker; @@ -48,11 +49,13 @@ class WorkflowController extends AbstractController private Registry $registry; + private Security $security; + private TranslatorInterface $translator; private ValidatorInterface $validator; - public function __construct(EntityWorkflowManager $entityWorkflowManager, EntityWorkflowRepository $entityWorkflowRepository, ValidatorInterface $validator, PaginatorFactory $paginatorFactory, Registry $registry, EntityManagerInterface $entityManager, TranslatorInterface $translator) + public function __construct(EntityWorkflowManager $entityWorkflowManager, EntityWorkflowRepository $entityWorkflowRepository, ValidatorInterface $validator, PaginatorFactory $paginatorFactory, Registry $registry, EntityManagerInterface $entityManager, TranslatorInterface $translator, Security $security) { $this->entityWorkflowManager = $entityWorkflowManager; $this->entityWorkflowRepository = $entityWorkflowRepository; @@ -61,6 +64,7 @@ class WorkflowController extends AbstractController $this->registry = $registry; $this->entityManager = $entityManager; $this->translator = $translator; + $this->security = $security; } /** @@ -291,10 +295,18 @@ class WorkflowController extends AbstractController if (count($workflow->getEnabledTransitions($entityWorkflow)) > 0) { // possible transition + + $usersInvolved = $entityWorkflow->getUsersInvolved(); + $currentUserFound = array_search($this->security->getUser(), $usersInvolved, true); + + if (false !== $currentUserFound) { + unset($usersInvolved[$currentUserFound]); + } + $transitionForm = $this->createForm( WorkflowStepType::class, $entityWorkflow->getCurrentStep(), - ['transition' => true, 'entity_workflow' => $entityWorkflow] + ['transition' => true, 'entity_workflow' => $entityWorkflow, 'suggested_users' => $usersInvolved] ); $transitionForm->handleRequest($request); diff --git a/src/Bundle/ChillMainBundle/Form/WorkflowStepType.php b/src/Bundle/ChillMainBundle/Form/WorkflowStepType.php index e01c7d4b6..23f932844 100644 --- a/src/Bundle/ChillMainBundle/Form/WorkflowStepType.php +++ b/src/Bundle/ChillMainBundle/Form/WorkflowStepType.php @@ -154,6 +154,7 @@ class WorkflowStepType extends AbstractType 'label' => 'workflow.dest for next steps', 'multiple' => true, 'mapped' => false, + 'suggested' => $options['suggested_users'], ]) ->add('future_dest_emails', ChillCollectionType::class, [ 'label' => 'workflow.dest by email', @@ -200,6 +201,7 @@ class WorkflowStepType extends AbstractType ->setAllowedTypes('transition', 'bool') ->setRequired('entity_workflow') ->setAllowedTypes('entity_workflow', EntityWorkflow::class) + ->setDefault('suggested_users', []) ->setDefault('constraints', [ new Callback( function ($step, ExecutionContextInterface $context, $payload) { From 73af63a2b589e3826538252ad50ab76e49617597 Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Fri, 24 Feb 2023 17:24:42 +0100 Subject: [PATCH 14/37] [data][twig] pass suggested users to vue component through twig template data attribute --- .../ChillMainBundle/Resources/views/Form/fields.html.twig | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Bundle/ChillMainBundle/Resources/views/Form/fields.html.twig b/src/Bundle/ChillMainBundle/Resources/views/Form/fields.html.twig index 15d7625dd..2a9015746 100644 --- a/src/Bundle/ChillMainBundle/Resources/views/Form/fields.html.twig +++ b/src/Bundle/ChillMainBundle/Resources/views/Form/fields.html.twig @@ -249,7 +249,7 @@ {% block pick_entity_dynamic_widget %} -
+
{% endblock %} {% block pick_postal_code_widget %} @@ -269,4 +269,4 @@ {{ form_errors(form.fixedDate) }}
-{% endblock %} \ No newline at end of file +{% endblock %} From c5fc6d4aadaaa7570ee33e3ca2f2928c38a36cb8 Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Fri, 24 Feb 2023 17:25:28 +0100 Subject: [PATCH 15/37] [vue][suggested users] add suggested users in vue component and write create/remove logic --- .../public/module/pick-entity/index.js | 5 + .../public/vuejs/PickEntity/PickEntity.vue | 105 ++++++++++-------- 2 files changed, 64 insertions(+), 46 deletions(-) diff --git a/src/Bundle/ChillMainBundle/Resources/public/module/pick-entity/index.js b/src/Bundle/ChillMainBundle/Resources/public/module/pick-entity/index.js index 890929c35..bb9cc744c 100644 --- a/src/Bundle/ChillMainBundle/Resources/public/module/pick-entity/index.js +++ b/src/Bundle/ChillMainBundle/Resources/public/module/pick-entity/index.js @@ -23,8 +23,11 @@ function loadDynamicPicker(element) { (input.value === '[]' || input.value === '') ? null : [ JSON.parse(input.value) ] ) + suggested = null !== JSON.parse(el.dataset.suggested) ? JSON.parse(el.dataset.suggested) : null ; + console.log('suggested', suggested) + if (!isMultiple) { if (input.value === '[]'){ input.value = null; @@ -37,6 +40,7 @@ function loadDynamicPicker(element) { ':types="types" ' + ':picked="picked" ' + ':uniqid="uniqid" ' + + ':suggested="suggested" ' + '@addNewEntity="addNewEntity" ' + '@removeEntity="removeEntity">', components: { @@ -48,6 +52,7 @@ function loadDynamicPicker(element) { types: JSON.parse(el.dataset.types), picked: picked === null ? [] : picked, uniqid: el.dataset.uniqid, + suggested: suggested } }, methods: { diff --git a/src/Bundle/ChillMainBundle/Resources/public/vuejs/PickEntity/PickEntity.vue b/src/Bundle/ChillMainBundle/Resources/public/vuejs/PickEntity/PickEntity.vue index e121ca950..02b53a6d3 100644 --- a/src/Bundle/ChillMainBundle/Resources/public/vuejs/PickEntity/PickEntity.vue +++ b/src/Bundle/ChillMainBundle/Resources/public/vuejs/PickEntity/PickEntity.vue @@ -17,6 +17,9 @@ +
    +
  • {{ s.text }}
  • +
From f07aaecc3dbcd4cd9fa1f807c1548a1a027aefd8 Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Wed, 1 Mar 2023 17:54:36 +0100 Subject: [PATCH 16/37] FEATURE [export][eval] add timespent field to the list_evaluation export. Value in minutes --- src/Bundle/ChillPersonBundle/Export/Export/ListEvaluation.php | 4 ++++ src/Bundle/ChillPersonBundle/translations/messages.fr.yml | 1 + 2 files changed, 5 insertions(+) diff --git a/src/Bundle/ChillPersonBundle/Export/Export/ListEvaluation.php b/src/Bundle/ChillPersonBundle/Export/Export/ListEvaluation.php index e7d1e5dfd..010618733 100644 --- a/src/Bundle/ChillPersonBundle/Export/Export/ListEvaluation.php +++ b/src/Bundle/ChillPersonBundle/Export/Export/ListEvaluation.php @@ -47,6 +47,7 @@ class ListEvaluation implements ListInterface, GroupedExportInterface 'endDate', 'maxDate', 'warningInterval', + 'timeSpent', 'acpw_id', 'acpw_startDate', 'acpw_endDate', @@ -295,6 +296,9 @@ class ListEvaluation implements ListInterface, GroupedExportInterface $qb->addSelect(sprintf('workeval.%s AS %s', $field, $field)); } + // add the time spent field + $qb->addSelect('(workeval.timeSpent / 60) AS timeSpent'); + // those with identity foreach (['createdBy', 'updatedBy'] as $field) { $qb->addSelect(sprintf('IDENTITY(workeval.%s) AS %s', $field, $field)); diff --git a/src/Bundle/ChillPersonBundle/translations/messages.fr.yml b/src/Bundle/ChillPersonBundle/translations/messages.fr.yml index 808ce5257..91347341f 100644 --- a/src/Bundle/ChillPersonBundle/translations/messages.fr.yml +++ b/src/Bundle/ChillPersonBundle/translations/messages.fr.yml @@ -1139,6 +1139,7 @@ export: updatedAt: Date de modification createdBy: Créé par updatedBy: Modifié par + timeSpent: Temps de rédaction (minutes) acpw: List of accompanying period works: Liste des actions List description: Génère une liste des actions d'accompagnement, filtrée sur différents paramètres. From ef3b41fa90d7f813fd22b31851fc515da1d19e62 Mon Sep 17 00:00:00 2001 From: Mathieu Jaumotte Date: Tue, 7 Mar 2023 10:54:36 +0100 Subject: [PATCH 17/37] Fixed template horizontal form theme for ckeditor comments fields with fullWidth parameter Notes: The 'fullwidth' parameter allow to force enlarge textarea ckeditor field, escaping horizontal bootstrap theme position rule (4/12 - 8/12) --- .../ChillMainBundle/Form/Type/CommentType.php | 7 +- .../Form/Type/ScopePickerType.php | 7 +- .../Resources/views/Form/fields.html.twig | 64 +++++++++---------- 3 files changed, 32 insertions(+), 46 deletions(-) diff --git a/src/Bundle/ChillMainBundle/Form/Type/CommentType.php b/src/Bundle/ChillMainBundle/Form/Type/CommentType.php index 9b8fc4701..542a429c6 100644 --- a/src/Bundle/ChillMainBundle/Form/Type/CommentType.php +++ b/src/Bundle/ChillMainBundle/Form/Type/CommentType.php @@ -56,12 +56,7 @@ class CommentType extends AbstractType public function buildView(FormView $view, FormInterface $form, array $options) { - $view->vars = array_replace( - $view->vars, - [ - 'fullWidth' => true, - ] - ); + $view->vars['fullWidth'] = true; } public function configureOptions(OptionsResolver $resolver) diff --git a/src/Bundle/ChillMainBundle/Form/Type/ScopePickerType.php b/src/Bundle/ChillMainBundle/Form/Type/ScopePickerType.php index f65677dc7..79ed6df40 100644 --- a/src/Bundle/ChillMainBundle/Form/Type/ScopePickerType.php +++ b/src/Bundle/ChillMainBundle/Form/Type/ScopePickerType.php @@ -95,12 +95,7 @@ class ScopePickerType extends AbstractType public function buildView(FormView $view, FormInterface $form, array $options) { - $view->vars = array_replace( - $view->vars, - [ - 'fullWidth' => true, - ] - ); + $view->vars['fullWidth'] = true; } public function configureOptions(OptionsResolver $resolver) diff --git a/src/Bundle/ChillMainBundle/Resources/views/Form/fields.html.twig b/src/Bundle/ChillMainBundle/Resources/views/Form/fields.html.twig index 15d7625dd..83958b22e 100644 --- a/src/Bundle/ChillMainBundle/Resources/views/Form/fields.html.twig +++ b/src/Bundle/ChillMainBundle/Resources/views/Form/fields.html.twig @@ -18,41 +18,42 @@ {% block form_row %} {% apply spaceless %} - {% if form.vars.fullWidth is not defined or form.vars.fullWidth == false %}
-
+ {% if attr.class is not defined or ('cf-title' not in attr.class and 'cf-fields' not in attr.class ) %} + {{ form_label(form) }} {% endif %} - {% endapply %}"> - {% if attr.class is not defined or ('cf-title' not in attr.class and 'cf-fields' not in attr.class ) %} - {{ form_label(form) }} +
+
+ {{ form_widget(form) }} + {{ form_errors(form) }} +
+ {% else %} +
{{ form_label(form) }}
+
{{ form_widget(form) }}
{% endif %} -
-
- {{ form_widget(form) }} - {{ form_errors(form) }} -
- {% else %} - {{ form_widget(form) }} - {% endif %} {% endapply %} {% endblock form_row %} @@ -210,11 +211,6 @@ {% endfor %} {% endblock %} -{% block comment_row %} - {{ form_label(form) }} - {{ form_row(form) }} -{% endblock %} - {% block comment_widget %} {% for entry in form %} {{ form_widget(entry) }} From 9d1703ccba9d33ce2984c5815871e542d2dffa40 Mon Sep 17 00:00:00 2001 From: Mathieu Jaumotte Date: Tue, 7 Mar 2023 15:58:18 +0100 Subject: [PATCH 18/37] remove comment --- .../ChillMainBundle/Resources/views/Form/fields.html.twig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Bundle/ChillMainBundle/Resources/views/Form/fields.html.twig b/src/Bundle/ChillMainBundle/Resources/views/Form/fields.html.twig index 83958b22e..5a577fecd 100644 --- a/src/Bundle/ChillMainBundle/Resources/views/Form/fields.html.twig +++ b/src/Bundle/ChillMainBundle/Resources/views/Form/fields.html.twig @@ -20,7 +20,7 @@ {% apply spaceless %}
- {% if form.vars.fullWidth is not defined or form.vars.fullWidth == false %} {# here #} + {% if form.vars.fullWidth is not defined or form.vars.fullWidth == false %}
+
    +

    hello {{ Object.keys(suggested) }}

  • {{ s.text }}
@@ -55,7 +56,7 @@ export default { }, suggested: { type: Array, - default: null + default: [] } }, emits: ['addNewEntity', 'removeEntity'], diff --git a/src/Bundle/ChillPersonBundle/Form/Type/PickPersonDynamicType.php b/src/Bundle/ChillPersonBundle/Form/Type/PickPersonDynamicType.php index 91e46d193..c0955b3ad 100644 --- a/src/Bundle/ChillPersonBundle/Form/Type/PickPersonDynamicType.php +++ b/src/Bundle/ChillPersonBundle/Form/Type/PickPersonDynamicType.php @@ -54,7 +54,7 @@ class PickPersonDynamicType extends AbstractType ->setDefault('multiple', false) ->setAllowedTypes('multiple', ['bool']) ->setDefault('compound', false) - ->setDefault('suggested', null); + ->setDefault('suggested', []); } public function getBlockPrefix() diff --git a/src/Bundle/ChillPersonBundle/Workflow/AccompanyingPeriodWorkEvaluationDocumentWorkflowHandler.php b/src/Bundle/ChillPersonBundle/Workflow/AccompanyingPeriodWorkEvaluationDocumentWorkflowHandler.php index 2c78e2099..500daab6f 100644 --- a/src/Bundle/ChillPersonBundle/Workflow/AccompanyingPeriodWorkEvaluationDocumentWorkflowHandler.php +++ b/src/Bundle/ChillPersonBundle/Workflow/AccompanyingPeriodWorkEvaluationDocumentWorkflowHandler.php @@ -107,7 +107,7 @@ class AccompanyingPeriodWorkEvaluationDocumentWorkflowHandler implements EntityW ->getAccompanyingPeriod() ->getUser(); - $suggestedUsers[$referrer->getId()] = $referrer; + $suggestedUsers[spl_object_hash($referrer)] = $referrer; return $suggestedUsers; } diff --git a/src/Bundle/ChillPersonBundle/Workflow/AccompanyingPeriodWorkEvaluationWorkflowHandler.php b/src/Bundle/ChillPersonBundle/Workflow/AccompanyingPeriodWorkEvaluationWorkflowHandler.php index a6d9fc9b4..db67ef045 100644 --- a/src/Bundle/ChillPersonBundle/Workflow/AccompanyingPeriodWorkEvaluationWorkflowHandler.php +++ b/src/Bundle/ChillPersonBundle/Workflow/AccompanyingPeriodWorkEvaluationWorkflowHandler.php @@ -96,7 +96,7 @@ class AccompanyingPeriodWorkEvaluationWorkflowHandler implements EntityWorkflowH ->getAccompanyingPeriod() ->getUser(); - $suggestedUsers[$referrer->getId()] = $referrer; + $suggestedUsers[spl_object_hash($referrer)] = $referrer; return $suggestedUsers; } diff --git a/src/Bundle/ChillPersonBundle/Workflow/AccompanyingPeriodWorkWorkflowHandler.php b/src/Bundle/ChillPersonBundle/Workflow/AccompanyingPeriodWorkWorkflowHandler.php index 142a57229..75ad04cfb 100644 --- a/src/Bundle/ChillPersonBundle/Workflow/AccompanyingPeriodWorkWorkflowHandler.php +++ b/src/Bundle/ChillPersonBundle/Workflow/AccompanyingPeriodWorkWorkflowHandler.php @@ -102,7 +102,7 @@ class AccompanyingPeriodWorkWorkflowHandler implements EntityWorkflowHandlerInte ->getAccompanyingPeriod() ->getUser(); - $suggestedUsers[$referrer->getId()] = $referrer; + $suggestedUsers[spl_object_hash($referrer)] = $referrer; return $suggestedUsers; } diff --git a/src/Bundle/ChillThirdPartyBundle/Form/Type/PickThirdpartyDynamicType.php b/src/Bundle/ChillThirdPartyBundle/Form/Type/PickThirdpartyDynamicType.php index d813918f7..2e282a31b 100644 --- a/src/Bundle/ChillThirdPartyBundle/Form/Type/PickThirdpartyDynamicType.php +++ b/src/Bundle/ChillThirdPartyBundle/Form/Type/PickThirdpartyDynamicType.php @@ -54,7 +54,7 @@ class PickThirdpartyDynamicType extends AbstractType ->setDefault('multiple', false) ->setAllowedTypes('multiple', ['bool']) ->setDefault('compound', false) - ->setDefault('suggested', null); + ->setDefault('suggested', []); } public function getBlockPrefix() From d1e8e6c18e4ace26f56777335e999c9b45967f51 Mon Sep 17 00:00:00 2001 From: Mathieu Jaumotte Date: Mon, 30 Jan 2023 14:35:48 +0100 Subject: [PATCH 20/37] simplify alterquery --- .../SocialWorkTypeFilter.php | 32 ++++++------------- 1 file changed, 9 insertions(+), 23 deletions(-) diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/SocialWorkFilters/SocialWorkTypeFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/SocialWorkFilters/SocialWorkTypeFilter.php index efc005be0..ba4eaf6b8 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/SocialWorkFilters/SocialWorkTypeFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/SocialWorkFilters/SocialWorkTypeFilter.php @@ -52,18 +52,10 @@ class SocialWorkTypeFilter implements FilterInterface public function alterQuery(QueryBuilder $qb, $data) { - $where = $qb->getDQLPart('where'); - if (count($data['actionType']) > 0) { - $clause = $qb->expr()->in('acpw.socialAction', ':actionType'); - - if ($where instanceof Andx) { - $where->add($clause); - } else { - $where = $qb->expr()->andX($clause); - } - - $qb->setParameter('actionType', $data['actionType']); + $qb + ->andWhere($qb->expr()->in('acpw.socialAction', ':actionType')) + ->setParameter('actionType', $data['actionType']); } if (count($data['goal']) > 0) { @@ -71,11 +63,9 @@ class SocialWorkTypeFilter implements FilterInterface $qb->join('acpw.goals', 'goal'); } - $where->add( - $qb->expr()->in('goal.id', ':goals') - ); - - $qb->setParameter('goals', $data['goal']); + $qb + ->andWhere($qb->expr()->in('goal.id', ':goals')) + ->setParameter('goals', $data['goal']); } if (count($data['result']) > 0) { @@ -83,14 +73,10 @@ class SocialWorkTypeFilter implements FilterInterface $qb->join('acpw.results', 'result'); } - $where->add( - $qb->expr()->in('result.id', ':results') - ); - - $qb->setParameter('results', $data['result']); + $qb + ->andWhere($qb->expr()->in('result.id', ':results')) + ->setParameter('results', $data['result']); } - - $qb->add('where', $where); } public function applyOn(): string From d893e3a664503116ad12db38b93ef626434891b0 Mon Sep 17 00:00:00 2001 From: Mathieu Jaumotte Date: Mon, 13 Mar 2023 15:40:51 +0100 Subject: [PATCH 21/37] Fixed: [export] query in goal and results filter https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/700 --- .../SocialWorkTypeFilter.php | 35 +++++++++++-------- 1 file changed, 21 insertions(+), 14 deletions(-) diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/SocialWorkFilters/SocialWorkTypeFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/SocialWorkFilters/SocialWorkTypeFilter.php index ba4eaf6b8..a59220d74 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/SocialWorkFilters/SocialWorkTypeFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/SocialWorkFilters/SocialWorkTypeFilter.php @@ -19,7 +19,6 @@ use Chill\PersonBundle\Entity\SocialWork\SocialAction; use Chill\PersonBundle\Export\Declarations; use Chill\PersonBundle\Templating\Entity\SocialActionRender; use Doctrine\ORM\EntityManagerInterface; -use Doctrine\ORM\Query\Expr\Andx; use Doctrine\ORM\QueryBuilder; use Symfony\Component\Form\CallbackTransformer; use Symfony\Component\Form\Extension\Core\Type\HiddenType; @@ -59,23 +58,31 @@ class SocialWorkTypeFilter implements FilterInterface } if (count($data['goal']) > 0) { - if (!in_array('goal', $qb->getAllAliases(), true)) { - $qb->join('acpw.goals', 'goal'); + if (!in_array('acpw_goal', $qb->getAllAliases(), true)) { + $qb->join('acpw.goals', 'acpw_goal'); } - $qb - ->andWhere($qb->expr()->in('goal.id', ':goals')) - ->setParameter('goals', $data['goal']); - } + $orX = $qb->expr()->orX(); + foreach ($data['goal'] as $goal) { - if (count($data['result']) > 0) { - if (!in_array('result', $qb->getAllAliases(), true)) { - $qb->join('acpw.results', 'result'); + /** @var Goal $goal */ + $andX = $qb->expr()->andX(); + $andX->add($qb->expr()->eq('acpw_goal.goal', $goalId = ':goal_'.uniqid())); + $qb->setParameter($goalId, $goal); + + if (count($data['result']) > 0) { + $orXResult = $qb->expr()->orX(); + foreach ($data['result'] as $result) { + + /** @var Result $result */ + $orXResult->add($qb->expr()->isMemberOf($resultId = ':result_'.uniqid(), 'acpw_goal.results')); + $qb->setParameter($resultId, $result); + } + $andX->add($orXResult); + } + $orX->add($andX); } - - $qb - ->andWhere($qb->expr()->in('result.id', ':results')) - ->setParameter('results', $data['result']); + $qb->andWhere($orX); } } From bbddf7813e04f65d0ce2b1279a37a9937e403411 Mon Sep 17 00:00:00 2001 From: Mathieu Jaumotte Date: Mon, 13 Mar 2023 16:18:20 +0100 Subject: [PATCH 22/37] Fix block form_row in form theme templates, comparing more cases. See this note https://gitlab.com/Chill-Projet/chill-bundles/-/merge_requests/502#note_1311993084 --- .../ChillMainBundle/Form/Type/PrivateCommentType.php | 2 +- .../bootstrap5/bootstrap_5_horizontal_layout.html.twig | 3 ++- .../Resources/views/Form/fields.html.twig | 9 ++++++++- 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/Bundle/ChillMainBundle/Form/Type/PrivateCommentType.php b/src/Bundle/ChillMainBundle/Form/Type/PrivateCommentType.php index 2ab318d9c..5c29f4d42 100644 --- a/src/Bundle/ChillMainBundle/Form/Type/PrivateCommentType.php +++ b/src/Bundle/ChillMainBundle/Form/Type/PrivateCommentType.php @@ -39,7 +39,7 @@ class PrivateCommentType extends AbstractType $builder ->add('comments', ChillTextareaType::class, [ 'disable_editor' => $options['disable_editor'], - 'label' => false, + 'label' => $options['label'], ]) ->setDataMapper($this->dataMapper); } diff --git a/src/Bundle/ChillMainBundle/Resources/views/Form/bootstrap5/bootstrap_5_horizontal_layout.html.twig b/src/Bundle/ChillMainBundle/Resources/views/Form/bootstrap5/bootstrap_5_horizontal_layout.html.twig index f4a2c3294..1afdbb2c9 100644 --- a/src/Bundle/ChillMainBundle/Resources/views/Form/bootstrap5/bootstrap_5_horizontal_layout.html.twig +++ b/src/Bundle/ChillMainBundle/Resources/views/Form/bootstrap5/bootstrap_5_horizontal_layout.html.twig @@ -68,7 +68,8 @@ {{- form_errors(form) -}}
{% else %} -
+
{{- form_label(form) -}}
+
{{- form_widget(form, widget_attr) -}} {{- form_help(form) -}} {{- form_errors(form) -}} diff --git a/src/Bundle/ChillMainBundle/Resources/views/Form/fields.html.twig b/src/Bundle/ChillMainBundle/Resources/views/Form/fields.html.twig index 5a577fecd..dfa851eed 100644 --- a/src/Bundle/ChillMainBundle/Resources/views/Form/fields.html.twig +++ b/src/Bundle/ChillMainBundle/Resources/views/Form/fields.html.twig @@ -56,6 +56,10 @@
{% endapply %} {% endblock form_row %} +{# + The block 'form_row' above may be removed ! + Read this note: https://gitlab.com/Chill-Projet/chill-bundles/-/merge_requests/502#note_1311993084 +#} {% block choice_widget_expanded %} {% apply spaceless %} @@ -201,7 +205,6 @@ {% block private_comment_row %} - {{ form_label(form) }} {{ form_row(form) }} {% endblock %} @@ -211,6 +214,10 @@ {% endfor %} {% endblock %} +{% block comment_row %} + {{ form_row(form) }} +{% endblock %} + {% block comment_widget %} {% for entry in form %} {{ form_widget(entry) }} From 3821bc3a70d7e51b92a6bec66d1b699b9874ebf4 Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Wed, 15 Mar 2023 09:37:28 +0100 Subject: [PATCH 23/37] FIX [review] implement changes based on review --- .../Form/Type/PickUserDynamicType.php | 11 +++++++++-- .../public/module/pick-entity/index.js | 19 +++++++++++-------- .../public/vuejs/PickEntity/PickEntity.vue | 14 +++++--------- .../Resources/views/Form/fields.html.twig | 6 +++++- .../Form/Type/PickPersonDynamicType.php | 13 ++++++++++--- .../Form/Type/PickThirdpartyDynamicType.php | 11 +++++++++-- 6 files changed, 49 insertions(+), 25 deletions(-) diff --git a/src/Bundle/ChillMainBundle/Form/Type/PickUserDynamicType.php b/src/Bundle/ChillMainBundle/Form/Type/PickUserDynamicType.php index 6bfd95fe8..de54d071a 100644 --- a/src/Bundle/ChillMainBundle/Form/Type/PickUserDynamicType.php +++ b/src/Bundle/ChillMainBundle/Form/Type/PickUserDynamicType.php @@ -19,6 +19,7 @@ use Symfony\Component\Form\FormInterface; use Symfony\Component\Form\FormView; use Symfony\Component\OptionsResolver\OptionsResolver; use Symfony\Component\Serializer\Normalizer\DenormalizerInterface; +use Symfony\Component\Serializer\Normalizer\NormalizerInterface; use Symfony\Component\Serializer\SerializerInterface; /** @@ -28,12 +29,15 @@ class PickUserDynamicType extends AbstractType { private DenormalizerInterface $denormalizer; + private NormalizerInterface $normalizer; + private SerializerInterface $serializer; - public function __construct(DenormalizerInterface $denormalizer, SerializerInterface $serializer) + public function __construct(DenormalizerInterface $denormalizer, SerializerInterface $serializer, NormalizerInterface $normalizer) { $this->denormalizer = $denormalizer; $this->serializer = $serializer; + $this->normalizer = $normalizer; } public function buildForm(FormBuilderInterface $builder, array $options) @@ -46,7 +50,10 @@ class PickUserDynamicType extends AbstractType $view->vars['multiple'] = $options['multiple']; $view->vars['types'] = ['user']; $view->vars['uniqid'] = uniqid('pick_user_dyn'); - $view->vars['suggested'] = $this->serializer->serialize($options['suggested'], 'json', ['groups' => 'read']); + + foreach ($options['suggested'] as $user) { + $view->vars['suggested'][spl_object_hash($user)] = $this->normalizer->normalize($user, 'json', ['groups' => 'read']); + } } public function configureOptions(OptionsResolver $resolver) diff --git a/src/Bundle/ChillMainBundle/Resources/public/module/pick-entity/index.js b/src/Bundle/ChillMainBundle/Resources/public/module/pick-entity/index.js index 41330c186..ce9c66145 100644 --- a/src/Bundle/ChillMainBundle/Resources/public/module/pick-entity/index.js +++ b/src/Bundle/ChillMainBundle/Resources/public/module/pick-entity/index.js @@ -23,12 +23,7 @@ function loadDynamicPicker(element) { (input.value === '[]' || input.value === '') ? null : [ JSON.parse(input.value) ] ) - suggested = JSON.parse('[' + el.dataset.suggested + ']'); - // suggested = suggested[0]; - - console.log(typeof suggested) - // console.log(el.dataset.suggested) - console.log('suggested', typeof suggested[0]) + suggested = JSON.parse(el.dataset.suggested); if (!isMultiple) { if (input.value === '[]'){ @@ -58,13 +53,18 @@ function loadDynamicPicker(element) { } }, methods: { - addNewEntity(entity) { + addNewEntity({entity, isSuggested = false}) { if (this.multiple) { if (!this.picked.some(el => { return el.type === entity.type && el.id === entity.id; })) { this.picked.push(entity); input.value = JSON.stringify(this.picked); + console.log(entity) + if (isSuggested) { + const indexToRemove = this.suggested.findIndex(e => e.id === entity.id) + this.suggested.splice(indexToRemove, 1); + } } } else { if (!this.picked.some(el => { @@ -76,9 +76,12 @@ function loadDynamicPicker(element) { } } }, - removeEntity(entity) { + removeEntity({entity, isSuggested = false}) { this.picked = this.picked.filter(e => !(e.type === entity.type && e.id === entity.id)); input.value = JSON.stringify(this.picked); + if (isSuggested) { + this.suggested.push(entity); + } }, } }) diff --git a/src/Bundle/ChillMainBundle/Resources/public/vuejs/PickEntity/PickEntity.vue b/src/Bundle/ChillMainBundle/Resources/public/vuejs/PickEntity/PickEntity.vue index 23a904b14..7d6d0bd83 100644 --- a/src/Bundle/ChillMainBundle/Resources/public/vuejs/PickEntity/PickEntity.vue +++ b/src/Bundle/ChillMainBundle/Resources/public/vuejs/PickEntity/PickEntity.vue @@ -17,8 +17,7 @@ -
    -

    hello {{ Object.keys(suggested) }}

    +
    • {{ s.text }}
    @@ -105,14 +104,12 @@ export default { }, methods: { addNewSuggested(entity) { - this.$emit('addNewEntity', entity); - const indexToRemove = this.suggested.findIndex(e => e.id === entity.id) - this.suggested.splice(indexToRemove, 1); + this.$emit('addNewEntity', {entity: entity, isSuggested: true}); }, addNewEntity({ selected, modal }) { selected.forEach((item) => { - this.$emit('addNewEntity', item.result); - }, this + this.$emit('addNewEntity', { entity: item.result }); + }, this ); this.$refs.addPersons.resetSearch(); // to cast child method modal.showModal = false; @@ -121,8 +118,7 @@ export default { if (!this.$props.removableIfSet) { return; } - this.$emit('removeEntity', entity); - this.suggested.push(entity); + this.$emit('removeEntity',{ entity: entity, isSuggested: true }); } }, } diff --git a/src/Bundle/ChillMainBundle/Resources/views/Form/fields.html.twig b/src/Bundle/ChillMainBundle/Resources/views/Form/fields.html.twig index 2a9015746..96c194a76 100644 --- a/src/Bundle/ChillMainBundle/Resources/views/Form/fields.html.twig +++ b/src/Bundle/ChillMainBundle/Resources/views/Form/fields.html.twig @@ -249,7 +249,11 @@ {% block pick_entity_dynamic_widget %} -
    +
    {% endblock %} {% block pick_postal_code_widget %} diff --git a/src/Bundle/ChillPersonBundle/Form/Type/PickPersonDynamicType.php b/src/Bundle/ChillPersonBundle/Form/Type/PickPersonDynamicType.php index c0955b3ad..3a875f8aa 100644 --- a/src/Bundle/ChillPersonBundle/Form/Type/PickPersonDynamicType.php +++ b/src/Bundle/ChillPersonBundle/Form/Type/PickPersonDynamicType.php @@ -18,21 +18,25 @@ use Symfony\Component\Form\FormInterface; use Symfony\Component\Form\FormView; use Symfony\Component\OptionsResolver\OptionsResolver; use Symfony\Component\Serializer\Normalizer\DenormalizerInterface; +use Symfony\Component\Serializer\Normalizer\NormalizerInterface; use Symfony\Component\Serializer\SerializerInterface; /** - * Pick user dymically, using vuejs module "AddPerson". + * m* Pick user dymically, using vuejs module "AddPerson". */ class PickPersonDynamicType extends AbstractType { private DenormalizerInterface $denormalizer; + private DenormalizerInterface $normalizer; + private SerializerInterface $serializer; - public function __construct(DenormalizerInterface $denormalizer, SerializerInterface $serializer) + public function __construct(DenormalizerInterface $denormalizer, SerializerInterface $serializer, NormalizerInterface $normalizer) { $this->denormalizer = $denormalizer; $this->serializer = $serializer; + $this->normalizer = $normalizer; } public function buildForm(FormBuilderInterface $builder, array $options) @@ -45,7 +49,10 @@ class PickPersonDynamicType extends AbstractType $view->vars['multiple'] = $options['multiple']; $view->vars['types'] = ['person']; $view->vars['uniqid'] = uniqid('pick_user_dyn'); - $view->vars['suggested'] = $this->serializer->serialize($options['suggested'], 'json', ['groups' => 'read']); + + foreach ($options['suggested'] as $person) { + $view->vars['suggested'][spl_object_hash($person)] = $this->normalizer->normalize($person, 'json', ['groups' => 'read']); + } } public function configureOptions(OptionsResolver $resolver) diff --git a/src/Bundle/ChillThirdPartyBundle/Form/Type/PickThirdpartyDynamicType.php b/src/Bundle/ChillThirdPartyBundle/Form/Type/PickThirdpartyDynamicType.php index 2e282a31b..7d5625ec6 100644 --- a/src/Bundle/ChillThirdPartyBundle/Form/Type/PickThirdpartyDynamicType.php +++ b/src/Bundle/ChillThirdPartyBundle/Form/Type/PickThirdpartyDynamicType.php @@ -18,6 +18,7 @@ use Symfony\Component\Form\FormInterface; use Symfony\Component\Form\FormView; use Symfony\Component\OptionsResolver\OptionsResolver; use Symfony\Component\Serializer\Normalizer\DenormalizerInterface; +use Symfony\Component\Serializer\Normalizer\NormalizerInterface; use Symfony\Component\Serializer\SerializerInterface; /** @@ -27,12 +28,15 @@ class PickThirdpartyDynamicType extends AbstractType { private DenormalizerInterface $denormalizer; + private NormalizerInterface $normalizer; + private SerializerInterface $serializer; - public function __construct(DenormalizerInterface $denormalizer, SerializerInterface $serializer) + public function __construct(DenormalizerInterface $denormalizer, SerializerInterface $serializer, NormalizerInterface $normalizer) { $this->denormalizer = $denormalizer; $this->serializer = $serializer; + $this->normalizer = $normalizer; } public function buildForm(FormBuilderInterface $builder, array $options) @@ -45,7 +49,10 @@ class PickThirdpartyDynamicType extends AbstractType $view->vars['multiple'] = $options['multiple']; $view->vars['types'] = ['thirdparty']; $view->vars['uniqid'] = uniqid('pick_user_dyn'); - $view->vars['suggested'] = $this->serializer->serialize($options['suggested'], 'json', ['groups' => 'read']); + + foreach ($options['suggested'] as $tp) { + $view->vars['suggested'][spl_object_hash($tp)] = $this->normalizer->normalize($tp, 'json', ['groups' => 'read']); + } } public function configureOptions(OptionsResolver $resolver) From 9c589b929611badd02e179eb7836f4a7daa0e899 Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Fri, 24 Feb 2023 17:17:35 +0100 Subject: [PATCH 24/37] FEATURE [suggested][entities] add suggested entities option to dynamic picker types --- src/Bundle/ChillMainBundle/Form/Type/PickUserDynamicType.php | 4 +++- .../ChillPersonBundle/Form/Type/PickPersonDynamicType.php | 4 +++- .../Form/Type/PickThirdpartyDynamicType.php | 4 +++- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/Bundle/ChillMainBundle/Form/Type/PickUserDynamicType.php b/src/Bundle/ChillMainBundle/Form/Type/PickUserDynamicType.php index 2fbfdcf11..9a2c1fbb4 100644 --- a/src/Bundle/ChillMainBundle/Form/Type/PickUserDynamicType.php +++ b/src/Bundle/ChillMainBundle/Form/Type/PickUserDynamicType.php @@ -46,6 +46,7 @@ class PickUserDynamicType extends AbstractType $view->vars['multiple'] = $options['multiple']; $view->vars['types'] = ['user']; $view->vars['uniqid'] = uniqid('pick_user_dyn'); + $view->vars['suggested'] = $this->serializer->serialize($options['suggested'], 'json', ['groups' => 'read']); } public function configureOptions(OptionsResolver $resolver) @@ -53,7 +54,8 @@ class PickUserDynamicType extends AbstractType $resolver ->setDefault('multiple', false) ->setAllowedTypes('multiple', ['bool']) - ->setDefault('compound', false); + ->setDefault('compound', false) + ->setDefault('suggested', null); } public function getBlockPrefix() diff --git a/src/Bundle/ChillPersonBundle/Form/Type/PickPersonDynamicType.php b/src/Bundle/ChillPersonBundle/Form/Type/PickPersonDynamicType.php index b0be9dd27..91e46d193 100644 --- a/src/Bundle/ChillPersonBundle/Form/Type/PickPersonDynamicType.php +++ b/src/Bundle/ChillPersonBundle/Form/Type/PickPersonDynamicType.php @@ -45,6 +45,7 @@ class PickPersonDynamicType extends AbstractType $view->vars['multiple'] = $options['multiple']; $view->vars['types'] = ['person']; $view->vars['uniqid'] = uniqid('pick_user_dyn'); + $view->vars['suggested'] = $this->serializer->serialize($options['suggested'], 'json', ['groups' => 'read']); } public function configureOptions(OptionsResolver $resolver) @@ -52,7 +53,8 @@ class PickPersonDynamicType extends AbstractType $resolver ->setDefault('multiple', false) ->setAllowedTypes('multiple', ['bool']) - ->setDefault('compound', false); + ->setDefault('compound', false) + ->setDefault('suggested', null); } public function getBlockPrefix() diff --git a/src/Bundle/ChillThirdPartyBundle/Form/Type/PickThirdpartyDynamicType.php b/src/Bundle/ChillThirdPartyBundle/Form/Type/PickThirdpartyDynamicType.php index ada4064eb..d813918f7 100644 --- a/src/Bundle/ChillThirdPartyBundle/Form/Type/PickThirdpartyDynamicType.php +++ b/src/Bundle/ChillThirdPartyBundle/Form/Type/PickThirdpartyDynamicType.php @@ -45,6 +45,7 @@ class PickThirdpartyDynamicType extends AbstractType $view->vars['multiple'] = $options['multiple']; $view->vars['types'] = ['thirdparty']; $view->vars['uniqid'] = uniqid('pick_user_dyn'); + $view->vars['suggested'] = $this->serializer->serialize($options['suggested'], 'json', ['groups' => 'read']); } public function configureOptions(OptionsResolver $resolver) @@ -52,7 +53,8 @@ class PickThirdpartyDynamicType extends AbstractType $resolver ->setDefault('multiple', false) ->setAllowedTypes('multiple', ['bool']) - ->setDefault('compound', false); + ->setDefault('compound', false) + ->setDefault('suggested', null); } public function getBlockPrefix() From 4c7a16587bbcc79e0f46688e719d3b79475780fb Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Fri, 24 Feb 2023 17:20:35 +0100 Subject: [PATCH 25/37] [workflow][method] add method to get involved/suggested users --- ...AccompanyingCourseDocumentWorkflowHandler.php | 10 ++++++++++ .../Entity/Workflow/EntityWorkflow.php | 16 ++++++++++++++++ .../Workflow/EntityWorkflowHandlerInterface.php | 5 +++++ ...riodWorkEvaluationDocumentWorkflowHandler.php | 15 +++++++++++++++ ...anyingPeriodWorkEvaluationWorkflowHandler.php | 14 ++++++++++++++ .../AccompanyingPeriodWorkWorkflowHandler.php | 13 +++++++++++++ 6 files changed, 73 insertions(+) diff --git a/src/Bundle/ChillDocStoreBundle/Workflow/AccompanyingCourseDocumentWorkflowHandler.php b/src/Bundle/ChillDocStoreBundle/Workflow/AccompanyingCourseDocumentWorkflowHandler.php index 96787a6fc..ec714aa74 100644 --- a/src/Bundle/ChillDocStoreBundle/Workflow/AccompanyingCourseDocumentWorkflowHandler.php +++ b/src/Bundle/ChillDocStoreBundle/Workflow/AccompanyingCourseDocumentWorkflowHandler.php @@ -95,6 +95,16 @@ class AccompanyingCourseDocumentWorkflowHandler implements EntityWorkflowHandler return null; } + public function getSuggestedUsers(EntityWorkflow $entityWorkflow): array + { + $suggestedUsers = $entityWorkflow->getUsersInvolved(); + + $referrer = $this->getRelatedEntity($entityWorkflow)->getCourse()->getUser(); + $suggestedUsers[$referrer->getId()] = $referrer; + + return $suggestedUsers; + } + public function getTemplate(EntityWorkflow $entityWorkflow, array $options = []): string { return '@ChillDocStore/AccompanyingCourseDocument/_workflow.html.twig'; diff --git a/src/Bundle/ChillMainBundle/Entity/Workflow/EntityWorkflow.php b/src/Bundle/ChillMainBundle/Entity/Workflow/EntityWorkflow.php index c448ea19e..62e6bac0f 100644 --- a/src/Bundle/ChillMainBundle/Entity/Workflow/EntityWorkflow.php +++ b/src/Bundle/ChillMainBundle/Entity/Workflow/EntityWorkflow.php @@ -348,6 +348,22 @@ class EntityWorkflow implements TrackCreationInterface, TrackUpdateInterface return $this->transitionningStep; } + /** + * @return User[] + */ + public function getUsersInvolved(): array + { + $usersInvolved = []; + + foreach ($this->steps as $step) { + foreach ($step->getDestUser() as $u) { + $usersInvolved[$u->getId()] = $u; + } + } + + return $usersInvolved; + } + public function getWorkflowName(): string { return $this->workflowName; diff --git a/src/Bundle/ChillMainBundle/Workflow/EntityWorkflowHandlerInterface.php b/src/Bundle/ChillMainBundle/Workflow/EntityWorkflowHandlerInterface.php index 5058fed7c..73e260c37 100644 --- a/src/Bundle/ChillMainBundle/Workflow/EntityWorkflowHandlerInterface.php +++ b/src/Bundle/ChillMainBundle/Workflow/EntityWorkflowHandlerInterface.php @@ -36,6 +36,11 @@ interface EntityWorkflowHandlerInterface */ public function getRoleShow(EntityWorkflow $entityWorkflow): ?string; + /** + * @return User[] + */ + public function getSuggestedUsers(EntityWorkflow $entityWorkflow): array; + public function getTemplate(EntityWorkflow $entityWorkflow, array $options = []): string; public function getTemplateData(EntityWorkflow $entityWorkflow, array $options = []): array; diff --git a/src/Bundle/ChillPersonBundle/Workflow/AccompanyingPeriodWorkEvaluationDocumentWorkflowHandler.php b/src/Bundle/ChillPersonBundle/Workflow/AccompanyingPeriodWorkEvaluationDocumentWorkflowHandler.php index 735463fc2..2c78e2099 100644 --- a/src/Bundle/ChillPersonBundle/Workflow/AccompanyingPeriodWorkEvaluationDocumentWorkflowHandler.php +++ b/src/Bundle/ChillPersonBundle/Workflow/AccompanyingPeriodWorkEvaluationDocumentWorkflowHandler.php @@ -97,6 +97,21 @@ class AccompanyingPeriodWorkEvaluationDocumentWorkflowHandler implements EntityW return AccompanyingPeriodWorkEvaluationDocumentVoter::SEE; } + public function getSuggestedUsers(EntityWorkflow $entityWorkflow): array + { + $suggestedUsers = $entityWorkflow->getUsersInvolved(); + + $referrer = $this->getRelatedEntity($entityWorkflow) + ->getAccompanyingPeriodWorkEvaluation() + ->getAccompanyingPeriodWork() + ->getAccompanyingPeriod() + ->getUser(); + + $suggestedUsers[$referrer->getId()] = $referrer; + + return $suggestedUsers; + } + public function getTemplate(EntityWorkflow $entityWorkflow, array $options = []): string { return '@ChillPerson/Workflow/_evaluation_document.html.twig'; diff --git a/src/Bundle/ChillPersonBundle/Workflow/AccompanyingPeriodWorkEvaluationWorkflowHandler.php b/src/Bundle/ChillPersonBundle/Workflow/AccompanyingPeriodWorkEvaluationWorkflowHandler.php index 25edce03b..a6d9fc9b4 100644 --- a/src/Bundle/ChillPersonBundle/Workflow/AccompanyingPeriodWorkEvaluationWorkflowHandler.php +++ b/src/Bundle/ChillPersonBundle/Workflow/AccompanyingPeriodWorkEvaluationWorkflowHandler.php @@ -87,6 +87,20 @@ class AccompanyingPeriodWorkEvaluationWorkflowHandler implements EntityWorkflowH return AccompanyingPeriodWorkEvaluationVoter::SEE; } + public function getSuggestedUsers(EntityWorkflow $entityWorkflow): array + { + $suggestedUsers = $entityWorkflow->getUsersInvolved(); + + $referrer = $this->getRelatedEntity($entityWorkflow) + ->getAccompanyingPeriodWork() + ->getAccompanyingPeriod() + ->getUser(); + + $suggestedUsers[$referrer->getId()] = $referrer; + + return $suggestedUsers; + } + public function getTemplate(EntityWorkflow $entityWorkflow, array $options = []): string { return '@ChillPerson/Workflow/_evaluation.html.twig'; diff --git a/src/Bundle/ChillPersonBundle/Workflow/AccompanyingPeriodWorkWorkflowHandler.php b/src/Bundle/ChillPersonBundle/Workflow/AccompanyingPeriodWorkWorkflowHandler.php index b6829ab77..142a57229 100644 --- a/src/Bundle/ChillPersonBundle/Workflow/AccompanyingPeriodWorkWorkflowHandler.php +++ b/src/Bundle/ChillPersonBundle/Workflow/AccompanyingPeriodWorkWorkflowHandler.php @@ -94,6 +94,19 @@ class AccompanyingPeriodWorkWorkflowHandler implements EntityWorkflowHandlerInte return null; } + public function getSuggestedUsers(EntityWorkflow $entityWorkflow): array + { + $suggestedUsers = $entityWorkflow->getUsersInvolved(); + + $referrer = $this->getRelatedEntity($entityWorkflow) + ->getAccompanyingPeriod() + ->getUser(); + + $suggestedUsers[$referrer->getId()] = $referrer; + + return $suggestedUsers; + } + public function getTemplate(EntityWorkflow $entityWorkflow, array $options = []): string { return '@ChillPerson/Workflow/_accompanying_period_work.html.twig'; From 1195564adbbc37ce7352f8e871ade9586f8d3df6 Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Fri, 24 Feb 2023 17:22:41 +0100 Subject: [PATCH 26/37] [form][controller] pass suggested users on to workflow form --- .../Controller/WorkflowController.php | 16 ++++++++++++++-- .../ChillMainBundle/Form/WorkflowStepType.php | 2 ++ 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/src/Bundle/ChillMainBundle/Controller/WorkflowController.php b/src/Bundle/ChillMainBundle/Controller/WorkflowController.php index 17b5db75e..0f00a177f 100644 --- a/src/Bundle/ChillMainBundle/Controller/WorkflowController.php +++ b/src/Bundle/ChillMainBundle/Controller/WorkflowController.php @@ -30,6 +30,7 @@ use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpKernel\Exception\BadRequestHttpException; use Symfony\Component\Routing\Annotation\Route; use Symfony\Component\Security\Core\Exception\AccessDeniedException; +use Symfony\Component\Security\Core\Security; use Symfony\Component\Validator\Validator\ValidatorInterface; use Symfony\Component\Workflow\Registry; use Symfony\Component\Workflow\TransitionBlocker; @@ -48,11 +49,13 @@ class WorkflowController extends AbstractController private Registry $registry; + private Security $security; + private TranslatorInterface $translator; private ValidatorInterface $validator; - public function __construct(EntityWorkflowManager $entityWorkflowManager, EntityWorkflowRepository $entityWorkflowRepository, ValidatorInterface $validator, PaginatorFactory $paginatorFactory, Registry $registry, EntityManagerInterface $entityManager, TranslatorInterface $translator) + public function __construct(EntityWorkflowManager $entityWorkflowManager, EntityWorkflowRepository $entityWorkflowRepository, ValidatorInterface $validator, PaginatorFactory $paginatorFactory, Registry $registry, EntityManagerInterface $entityManager, TranslatorInterface $translator, Security $security) { $this->entityWorkflowManager = $entityWorkflowManager; $this->entityWorkflowRepository = $entityWorkflowRepository; @@ -61,6 +64,7 @@ class WorkflowController extends AbstractController $this->registry = $registry; $this->entityManager = $entityManager; $this->translator = $translator; + $this->security = $security; } /** @@ -291,10 +295,18 @@ class WorkflowController extends AbstractController if (count($workflow->getEnabledTransitions($entityWorkflow)) > 0) { // possible transition + + $usersInvolved = $entityWorkflow->getUsersInvolved(); + $currentUserFound = array_search($this->security->getUser(), $usersInvolved, true); + + if (false !== $currentUserFound) { + unset($usersInvolved[$currentUserFound]); + } + $transitionForm = $this->createForm( WorkflowStepType::class, $entityWorkflow->getCurrentStep(), - ['transition' => true, 'entity_workflow' => $entityWorkflow] + ['transition' => true, 'entity_workflow' => $entityWorkflow, 'suggested_users' => $usersInvolved] ); $transitionForm->handleRequest($request); diff --git a/src/Bundle/ChillMainBundle/Form/WorkflowStepType.php b/src/Bundle/ChillMainBundle/Form/WorkflowStepType.php index e01c7d4b6..23f932844 100644 --- a/src/Bundle/ChillMainBundle/Form/WorkflowStepType.php +++ b/src/Bundle/ChillMainBundle/Form/WorkflowStepType.php @@ -154,6 +154,7 @@ class WorkflowStepType extends AbstractType 'label' => 'workflow.dest for next steps', 'multiple' => true, 'mapped' => false, + 'suggested' => $options['suggested_users'], ]) ->add('future_dest_emails', ChillCollectionType::class, [ 'label' => 'workflow.dest by email', @@ -200,6 +201,7 @@ class WorkflowStepType extends AbstractType ->setAllowedTypes('transition', 'bool') ->setRequired('entity_workflow') ->setAllowedTypes('entity_workflow', EntityWorkflow::class) + ->setDefault('suggested_users', []) ->setDefault('constraints', [ new Callback( function ($step, ExecutionContextInterface $context, $payload) { From 1198133a7f391a1c18f018cdacce0ce805f7e0c5 Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Fri, 24 Feb 2023 17:24:42 +0100 Subject: [PATCH 27/37] [data][twig] pass suggested users to vue component through twig template data attribute --- .../ChillMainBundle/Resources/views/Form/fields.html.twig | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Bundle/ChillMainBundle/Resources/views/Form/fields.html.twig b/src/Bundle/ChillMainBundle/Resources/views/Form/fields.html.twig index 15d7625dd..2a9015746 100644 --- a/src/Bundle/ChillMainBundle/Resources/views/Form/fields.html.twig +++ b/src/Bundle/ChillMainBundle/Resources/views/Form/fields.html.twig @@ -249,7 +249,7 @@ {% block pick_entity_dynamic_widget %} -
    +
    {% endblock %} {% block pick_postal_code_widget %} @@ -269,4 +269,4 @@ {{ form_errors(form.fixedDate) }}
-{% endblock %} \ No newline at end of file +{% endblock %} From 5319991a6f8e3fb194078bfac9ed945770dfe45a Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Fri, 24 Feb 2023 17:25:28 +0100 Subject: [PATCH 28/37] [vue][suggested users] add suggested users in vue component and write create/remove logic --- .../public/module/pick-entity/index.js | 5 + .../public/vuejs/PickEntity/PickEntity.vue | 105 ++++++++++-------- 2 files changed, 64 insertions(+), 46 deletions(-) diff --git a/src/Bundle/ChillMainBundle/Resources/public/module/pick-entity/index.js b/src/Bundle/ChillMainBundle/Resources/public/module/pick-entity/index.js index 890929c35..bb9cc744c 100644 --- a/src/Bundle/ChillMainBundle/Resources/public/module/pick-entity/index.js +++ b/src/Bundle/ChillMainBundle/Resources/public/module/pick-entity/index.js @@ -23,8 +23,11 @@ function loadDynamicPicker(element) { (input.value === '[]' || input.value === '') ? null : [ JSON.parse(input.value) ] ) + suggested = null !== JSON.parse(el.dataset.suggested) ? JSON.parse(el.dataset.suggested) : null ; + console.log('suggested', suggested) + if (!isMultiple) { if (input.value === '[]'){ input.value = null; @@ -37,6 +40,7 @@ function loadDynamicPicker(element) { ':types="types" ' + ':picked="picked" ' + ':uniqid="uniqid" ' + + ':suggested="suggested" ' + '@addNewEntity="addNewEntity" ' + '@removeEntity="removeEntity">', components: { @@ -48,6 +52,7 @@ function loadDynamicPicker(element) { types: JSON.parse(el.dataset.types), picked: picked === null ? [] : picked, uniqid: el.dataset.uniqid, + suggested: suggested } }, methods: { diff --git a/src/Bundle/ChillMainBundle/Resources/public/vuejs/PickEntity/PickEntity.vue b/src/Bundle/ChillMainBundle/Resources/public/vuejs/PickEntity/PickEntity.vue index e121ca950..02b53a6d3 100644 --- a/src/Bundle/ChillMainBundle/Resources/public/vuejs/PickEntity/PickEntity.vue +++ b/src/Bundle/ChillMainBundle/Resources/public/vuejs/PickEntity/PickEntity.vue @@ -17,6 +17,9 @@ +
    +
  • {{ s.text }}
  • +
From 67e68ac149ceb51e3d3815fea9b6cdc1e217c4fa Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Fri, 10 Mar 2023 12:56:05 +0100 Subject: [PATCH 29/37] FIX [review] processing review, but stuck at transformation of json string to array --- .../AccompanyingCourseDocumentWorkflowHandler.php | 2 +- .../ChillMainBundle/Entity/Workflow/EntityWorkflow.php | 2 +- .../ChillMainBundle/Form/Type/PickUserDynamicType.php | 2 +- .../Resources/public/module/pick-entity/index.js | 8 +++++--- .../Resources/public/vuejs/PickEntity/PickEntity.vue | 5 +++-- .../ChillPersonBundle/Form/Type/PickPersonDynamicType.php | 2 +- ...panyingPeriodWorkEvaluationDocumentWorkflowHandler.php | 2 +- .../AccompanyingPeriodWorkEvaluationWorkflowHandler.php | 2 +- .../Workflow/AccompanyingPeriodWorkWorkflowHandler.php | 2 +- .../Form/Type/PickThirdpartyDynamicType.php | 2 +- 10 files changed, 16 insertions(+), 13 deletions(-) diff --git a/src/Bundle/ChillDocStoreBundle/Workflow/AccompanyingCourseDocumentWorkflowHandler.php b/src/Bundle/ChillDocStoreBundle/Workflow/AccompanyingCourseDocumentWorkflowHandler.php index ec714aa74..c538bd107 100644 --- a/src/Bundle/ChillDocStoreBundle/Workflow/AccompanyingCourseDocumentWorkflowHandler.php +++ b/src/Bundle/ChillDocStoreBundle/Workflow/AccompanyingCourseDocumentWorkflowHandler.php @@ -100,7 +100,7 @@ class AccompanyingCourseDocumentWorkflowHandler implements EntityWorkflowHandler $suggestedUsers = $entityWorkflow->getUsersInvolved(); $referrer = $this->getRelatedEntity($entityWorkflow)->getCourse()->getUser(); - $suggestedUsers[$referrer->getId()] = $referrer; + $suggestedUsers[spl_object_hash($referrer)] = $referrer; return $suggestedUsers; } diff --git a/src/Bundle/ChillMainBundle/Entity/Workflow/EntityWorkflow.php b/src/Bundle/ChillMainBundle/Entity/Workflow/EntityWorkflow.php index 62e6bac0f..99aba07fd 100644 --- a/src/Bundle/ChillMainBundle/Entity/Workflow/EntityWorkflow.php +++ b/src/Bundle/ChillMainBundle/Entity/Workflow/EntityWorkflow.php @@ -357,7 +357,7 @@ class EntityWorkflow implements TrackCreationInterface, TrackUpdateInterface foreach ($this->steps as $step) { foreach ($step->getDestUser() as $u) { - $usersInvolved[$u->getId()] = $u; + $usersInvolved[spl_object_hash($u)] = $u; } } diff --git a/src/Bundle/ChillMainBundle/Form/Type/PickUserDynamicType.php b/src/Bundle/ChillMainBundle/Form/Type/PickUserDynamicType.php index 9a2c1fbb4..6bfd95fe8 100644 --- a/src/Bundle/ChillMainBundle/Form/Type/PickUserDynamicType.php +++ b/src/Bundle/ChillMainBundle/Form/Type/PickUserDynamicType.php @@ -55,7 +55,7 @@ class PickUserDynamicType extends AbstractType ->setDefault('multiple', false) ->setAllowedTypes('multiple', ['bool']) ->setDefault('compound', false) - ->setDefault('suggested', null); + ->setDefault('suggested', []); } public function getBlockPrefix() diff --git a/src/Bundle/ChillMainBundle/Resources/public/module/pick-entity/index.js b/src/Bundle/ChillMainBundle/Resources/public/module/pick-entity/index.js index bb9cc744c..41330c186 100644 --- a/src/Bundle/ChillMainBundle/Resources/public/module/pick-entity/index.js +++ b/src/Bundle/ChillMainBundle/Resources/public/module/pick-entity/index.js @@ -23,10 +23,12 @@ function loadDynamicPicker(element) { (input.value === '[]' || input.value === '') ? null : [ JSON.parse(input.value) ] ) - suggested = null !== JSON.parse(el.dataset.suggested) ? JSON.parse(el.dataset.suggested) : null - ; + suggested = JSON.parse('[' + el.dataset.suggested + ']'); + // suggested = suggested[0]; - console.log('suggested', suggested) + console.log(typeof suggested) + // console.log(el.dataset.suggested) + console.log('suggested', typeof suggested[0]) if (!isMultiple) { if (input.value === '[]'){ diff --git a/src/Bundle/ChillMainBundle/Resources/public/vuejs/PickEntity/PickEntity.vue b/src/Bundle/ChillMainBundle/Resources/public/vuejs/PickEntity/PickEntity.vue index 02b53a6d3..23a904b14 100644 --- a/src/Bundle/ChillMainBundle/Resources/public/vuejs/PickEntity/PickEntity.vue +++ b/src/Bundle/ChillMainBundle/Resources/public/vuejs/PickEntity/PickEntity.vue @@ -17,7 +17,8 @@ -
    +
      +

      hello {{ Object.keys(suggested) }}

    • {{ s.text }}
    @@ -55,7 +56,7 @@ export default { }, suggested: { type: Array, - default: null + default: [] } }, emits: ['addNewEntity', 'removeEntity'], diff --git a/src/Bundle/ChillPersonBundle/Form/Type/PickPersonDynamicType.php b/src/Bundle/ChillPersonBundle/Form/Type/PickPersonDynamicType.php index 91e46d193..c0955b3ad 100644 --- a/src/Bundle/ChillPersonBundle/Form/Type/PickPersonDynamicType.php +++ b/src/Bundle/ChillPersonBundle/Form/Type/PickPersonDynamicType.php @@ -54,7 +54,7 @@ class PickPersonDynamicType extends AbstractType ->setDefault('multiple', false) ->setAllowedTypes('multiple', ['bool']) ->setDefault('compound', false) - ->setDefault('suggested', null); + ->setDefault('suggested', []); } public function getBlockPrefix() diff --git a/src/Bundle/ChillPersonBundle/Workflow/AccompanyingPeriodWorkEvaluationDocumentWorkflowHandler.php b/src/Bundle/ChillPersonBundle/Workflow/AccompanyingPeriodWorkEvaluationDocumentWorkflowHandler.php index 2c78e2099..500daab6f 100644 --- a/src/Bundle/ChillPersonBundle/Workflow/AccompanyingPeriodWorkEvaluationDocumentWorkflowHandler.php +++ b/src/Bundle/ChillPersonBundle/Workflow/AccompanyingPeriodWorkEvaluationDocumentWorkflowHandler.php @@ -107,7 +107,7 @@ class AccompanyingPeriodWorkEvaluationDocumentWorkflowHandler implements EntityW ->getAccompanyingPeriod() ->getUser(); - $suggestedUsers[$referrer->getId()] = $referrer; + $suggestedUsers[spl_object_hash($referrer)] = $referrer; return $suggestedUsers; } diff --git a/src/Bundle/ChillPersonBundle/Workflow/AccompanyingPeriodWorkEvaluationWorkflowHandler.php b/src/Bundle/ChillPersonBundle/Workflow/AccompanyingPeriodWorkEvaluationWorkflowHandler.php index a6d9fc9b4..db67ef045 100644 --- a/src/Bundle/ChillPersonBundle/Workflow/AccompanyingPeriodWorkEvaluationWorkflowHandler.php +++ b/src/Bundle/ChillPersonBundle/Workflow/AccompanyingPeriodWorkEvaluationWorkflowHandler.php @@ -96,7 +96,7 @@ class AccompanyingPeriodWorkEvaluationWorkflowHandler implements EntityWorkflowH ->getAccompanyingPeriod() ->getUser(); - $suggestedUsers[$referrer->getId()] = $referrer; + $suggestedUsers[spl_object_hash($referrer)] = $referrer; return $suggestedUsers; } diff --git a/src/Bundle/ChillPersonBundle/Workflow/AccompanyingPeriodWorkWorkflowHandler.php b/src/Bundle/ChillPersonBundle/Workflow/AccompanyingPeriodWorkWorkflowHandler.php index 142a57229..75ad04cfb 100644 --- a/src/Bundle/ChillPersonBundle/Workflow/AccompanyingPeriodWorkWorkflowHandler.php +++ b/src/Bundle/ChillPersonBundle/Workflow/AccompanyingPeriodWorkWorkflowHandler.php @@ -102,7 +102,7 @@ class AccompanyingPeriodWorkWorkflowHandler implements EntityWorkflowHandlerInte ->getAccompanyingPeriod() ->getUser(); - $suggestedUsers[$referrer->getId()] = $referrer; + $suggestedUsers[spl_object_hash($referrer)] = $referrer; return $suggestedUsers; } diff --git a/src/Bundle/ChillThirdPartyBundle/Form/Type/PickThirdpartyDynamicType.php b/src/Bundle/ChillThirdPartyBundle/Form/Type/PickThirdpartyDynamicType.php index d813918f7..2e282a31b 100644 --- a/src/Bundle/ChillThirdPartyBundle/Form/Type/PickThirdpartyDynamicType.php +++ b/src/Bundle/ChillThirdPartyBundle/Form/Type/PickThirdpartyDynamicType.php @@ -54,7 +54,7 @@ class PickThirdpartyDynamicType extends AbstractType ->setDefault('multiple', false) ->setAllowedTypes('multiple', ['bool']) ->setDefault('compound', false) - ->setDefault('suggested', null); + ->setDefault('suggested', []); } public function getBlockPrefix() From 1a3d66213b63be5bebeda47eed81afa092dc9b65 Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Wed, 15 Mar 2023 09:37:28 +0100 Subject: [PATCH 30/37] FIX [review] implement changes based on review --- .../Form/Type/PickUserDynamicType.php | 11 +++++++++-- .../public/module/pick-entity/index.js | 19 +++++++++++-------- .../public/vuejs/PickEntity/PickEntity.vue | 14 +++++--------- .../Resources/views/Form/fields.html.twig | 6 +++++- .../Form/Type/PickPersonDynamicType.php | 13 ++++++++++--- .../Form/Type/PickThirdpartyDynamicType.php | 11 +++++++++-- 6 files changed, 49 insertions(+), 25 deletions(-) diff --git a/src/Bundle/ChillMainBundle/Form/Type/PickUserDynamicType.php b/src/Bundle/ChillMainBundle/Form/Type/PickUserDynamicType.php index 6bfd95fe8..de54d071a 100644 --- a/src/Bundle/ChillMainBundle/Form/Type/PickUserDynamicType.php +++ b/src/Bundle/ChillMainBundle/Form/Type/PickUserDynamicType.php @@ -19,6 +19,7 @@ use Symfony\Component\Form\FormInterface; use Symfony\Component\Form\FormView; use Symfony\Component\OptionsResolver\OptionsResolver; use Symfony\Component\Serializer\Normalizer\DenormalizerInterface; +use Symfony\Component\Serializer\Normalizer\NormalizerInterface; use Symfony\Component\Serializer\SerializerInterface; /** @@ -28,12 +29,15 @@ class PickUserDynamicType extends AbstractType { private DenormalizerInterface $denormalizer; + private NormalizerInterface $normalizer; + private SerializerInterface $serializer; - public function __construct(DenormalizerInterface $denormalizer, SerializerInterface $serializer) + public function __construct(DenormalizerInterface $denormalizer, SerializerInterface $serializer, NormalizerInterface $normalizer) { $this->denormalizer = $denormalizer; $this->serializer = $serializer; + $this->normalizer = $normalizer; } public function buildForm(FormBuilderInterface $builder, array $options) @@ -46,7 +50,10 @@ class PickUserDynamicType extends AbstractType $view->vars['multiple'] = $options['multiple']; $view->vars['types'] = ['user']; $view->vars['uniqid'] = uniqid('pick_user_dyn'); - $view->vars['suggested'] = $this->serializer->serialize($options['suggested'], 'json', ['groups' => 'read']); + + foreach ($options['suggested'] as $user) { + $view->vars['suggested'][spl_object_hash($user)] = $this->normalizer->normalize($user, 'json', ['groups' => 'read']); + } } public function configureOptions(OptionsResolver $resolver) diff --git a/src/Bundle/ChillMainBundle/Resources/public/module/pick-entity/index.js b/src/Bundle/ChillMainBundle/Resources/public/module/pick-entity/index.js index 41330c186..ce9c66145 100644 --- a/src/Bundle/ChillMainBundle/Resources/public/module/pick-entity/index.js +++ b/src/Bundle/ChillMainBundle/Resources/public/module/pick-entity/index.js @@ -23,12 +23,7 @@ function loadDynamicPicker(element) { (input.value === '[]' || input.value === '') ? null : [ JSON.parse(input.value) ] ) - suggested = JSON.parse('[' + el.dataset.suggested + ']'); - // suggested = suggested[0]; - - console.log(typeof suggested) - // console.log(el.dataset.suggested) - console.log('suggested', typeof suggested[0]) + suggested = JSON.parse(el.dataset.suggested); if (!isMultiple) { if (input.value === '[]'){ @@ -58,13 +53,18 @@ function loadDynamicPicker(element) { } }, methods: { - addNewEntity(entity) { + addNewEntity({entity, isSuggested = false}) { if (this.multiple) { if (!this.picked.some(el => { return el.type === entity.type && el.id === entity.id; })) { this.picked.push(entity); input.value = JSON.stringify(this.picked); + console.log(entity) + if (isSuggested) { + const indexToRemove = this.suggested.findIndex(e => e.id === entity.id) + this.suggested.splice(indexToRemove, 1); + } } } else { if (!this.picked.some(el => { @@ -76,9 +76,12 @@ function loadDynamicPicker(element) { } } }, - removeEntity(entity) { + removeEntity({entity, isSuggested = false}) { this.picked = this.picked.filter(e => !(e.type === entity.type && e.id === entity.id)); input.value = JSON.stringify(this.picked); + if (isSuggested) { + this.suggested.push(entity); + } }, } }) diff --git a/src/Bundle/ChillMainBundle/Resources/public/vuejs/PickEntity/PickEntity.vue b/src/Bundle/ChillMainBundle/Resources/public/vuejs/PickEntity/PickEntity.vue index 23a904b14..7d6d0bd83 100644 --- a/src/Bundle/ChillMainBundle/Resources/public/vuejs/PickEntity/PickEntity.vue +++ b/src/Bundle/ChillMainBundle/Resources/public/vuejs/PickEntity/PickEntity.vue @@ -17,8 +17,7 @@
-
    -

    hello {{ Object.keys(suggested) }}

    +
    • {{ s.text }}
    @@ -105,14 +104,12 @@ export default { }, methods: { addNewSuggested(entity) { - this.$emit('addNewEntity', entity); - const indexToRemove = this.suggested.findIndex(e => e.id === entity.id) - this.suggested.splice(indexToRemove, 1); + this.$emit('addNewEntity', {entity: entity, isSuggested: true}); }, addNewEntity({ selected, modal }) { selected.forEach((item) => { - this.$emit('addNewEntity', item.result); - }, this + this.$emit('addNewEntity', { entity: item.result }); + }, this ); this.$refs.addPersons.resetSearch(); // to cast child method modal.showModal = false; @@ -121,8 +118,7 @@ export default { if (!this.$props.removableIfSet) { return; } - this.$emit('removeEntity', entity); - this.suggested.push(entity); + this.$emit('removeEntity',{ entity: entity, isSuggested: true }); } }, } diff --git a/src/Bundle/ChillMainBundle/Resources/views/Form/fields.html.twig b/src/Bundle/ChillMainBundle/Resources/views/Form/fields.html.twig index 2a9015746..96c194a76 100644 --- a/src/Bundle/ChillMainBundle/Resources/views/Form/fields.html.twig +++ b/src/Bundle/ChillMainBundle/Resources/views/Form/fields.html.twig @@ -249,7 +249,11 @@ {% block pick_entity_dynamic_widget %} -
    +
    {% endblock %} {% block pick_postal_code_widget %} diff --git a/src/Bundle/ChillPersonBundle/Form/Type/PickPersonDynamicType.php b/src/Bundle/ChillPersonBundle/Form/Type/PickPersonDynamicType.php index c0955b3ad..3a875f8aa 100644 --- a/src/Bundle/ChillPersonBundle/Form/Type/PickPersonDynamicType.php +++ b/src/Bundle/ChillPersonBundle/Form/Type/PickPersonDynamicType.php @@ -18,21 +18,25 @@ use Symfony\Component\Form\FormInterface; use Symfony\Component\Form\FormView; use Symfony\Component\OptionsResolver\OptionsResolver; use Symfony\Component\Serializer\Normalizer\DenormalizerInterface; +use Symfony\Component\Serializer\Normalizer\NormalizerInterface; use Symfony\Component\Serializer\SerializerInterface; /** - * Pick user dymically, using vuejs module "AddPerson". + * m* Pick user dymically, using vuejs module "AddPerson". */ class PickPersonDynamicType extends AbstractType { private DenormalizerInterface $denormalizer; + private DenormalizerInterface $normalizer; + private SerializerInterface $serializer; - public function __construct(DenormalizerInterface $denormalizer, SerializerInterface $serializer) + public function __construct(DenormalizerInterface $denormalizer, SerializerInterface $serializer, NormalizerInterface $normalizer) { $this->denormalizer = $denormalizer; $this->serializer = $serializer; + $this->normalizer = $normalizer; } public function buildForm(FormBuilderInterface $builder, array $options) @@ -45,7 +49,10 @@ class PickPersonDynamicType extends AbstractType $view->vars['multiple'] = $options['multiple']; $view->vars['types'] = ['person']; $view->vars['uniqid'] = uniqid('pick_user_dyn'); - $view->vars['suggested'] = $this->serializer->serialize($options['suggested'], 'json', ['groups' => 'read']); + + foreach ($options['suggested'] as $person) { + $view->vars['suggested'][spl_object_hash($person)] = $this->normalizer->normalize($person, 'json', ['groups' => 'read']); + } } public function configureOptions(OptionsResolver $resolver) diff --git a/src/Bundle/ChillThirdPartyBundle/Form/Type/PickThirdpartyDynamicType.php b/src/Bundle/ChillThirdPartyBundle/Form/Type/PickThirdpartyDynamicType.php index 2e282a31b..7d5625ec6 100644 --- a/src/Bundle/ChillThirdPartyBundle/Form/Type/PickThirdpartyDynamicType.php +++ b/src/Bundle/ChillThirdPartyBundle/Form/Type/PickThirdpartyDynamicType.php @@ -18,6 +18,7 @@ use Symfony\Component\Form\FormInterface; use Symfony\Component\Form\FormView; use Symfony\Component\OptionsResolver\OptionsResolver; use Symfony\Component\Serializer\Normalizer\DenormalizerInterface; +use Symfony\Component\Serializer\Normalizer\NormalizerInterface; use Symfony\Component\Serializer\SerializerInterface; /** @@ -27,12 +28,15 @@ class PickThirdpartyDynamicType extends AbstractType { private DenormalizerInterface $denormalizer; + private NormalizerInterface $normalizer; + private SerializerInterface $serializer; - public function __construct(DenormalizerInterface $denormalizer, SerializerInterface $serializer) + public function __construct(DenormalizerInterface $denormalizer, SerializerInterface $serializer, NormalizerInterface $normalizer) { $this->denormalizer = $denormalizer; $this->serializer = $serializer; + $this->normalizer = $normalizer; } public function buildForm(FormBuilderInterface $builder, array $options) @@ -45,7 +49,10 @@ class PickThirdpartyDynamicType extends AbstractType $view->vars['multiple'] = $options['multiple']; $view->vars['types'] = ['thirdparty']; $view->vars['uniqid'] = uniqid('pick_user_dyn'); - $view->vars['suggested'] = $this->serializer->serialize($options['suggested'], 'json', ['groups' => 'read']); + + foreach ($options['suggested'] as $tp) { + $view->vars['suggested'][spl_object_hash($tp)] = $this->normalizer->normalize($tp, 'json', ['groups' => 'read']); + } } public function configureOptions(OptionsResolver $resolver) From de4cb1585bae1a04c29105f708ac6ccf762485aa Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Wed, 15 Mar 2023 09:49:46 +0100 Subject: [PATCH 31/37] FIX [normalizer] remove keys to have simple array of objects --- src/Bundle/ChillMainBundle/Form/Type/PickUserDynamicType.php | 2 +- .../Resources/public/module/pick-entity/index.js | 2 +- .../ChillPersonBundle/Form/Type/PickPersonDynamicType.php | 2 +- .../Form/Type/PickThirdpartyDynamicType.php | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Bundle/ChillMainBundle/Form/Type/PickUserDynamicType.php b/src/Bundle/ChillMainBundle/Form/Type/PickUserDynamicType.php index de54d071a..c48650f8e 100644 --- a/src/Bundle/ChillMainBundle/Form/Type/PickUserDynamicType.php +++ b/src/Bundle/ChillMainBundle/Form/Type/PickUserDynamicType.php @@ -52,7 +52,7 @@ class PickUserDynamicType extends AbstractType $view->vars['uniqid'] = uniqid('pick_user_dyn'); foreach ($options['suggested'] as $user) { - $view->vars['suggested'][spl_object_hash($user)] = $this->normalizer->normalize($user, 'json', ['groups' => 'read']); + $view->vars['suggested'][] = $this->normalizer->normalize($user, 'json', ['groups' => 'read']); } } diff --git a/src/Bundle/ChillMainBundle/Resources/public/module/pick-entity/index.js b/src/Bundle/ChillMainBundle/Resources/public/module/pick-entity/index.js index ce9c66145..fce3d43cc 100644 --- a/src/Bundle/ChillMainBundle/Resources/public/module/pick-entity/index.js +++ b/src/Bundle/ChillMainBundle/Resources/public/module/pick-entity/index.js @@ -23,7 +23,7 @@ function loadDynamicPicker(element) { (input.value === '[]' || input.value === '') ? null : [ JSON.parse(input.value) ] ) - suggested = JSON.parse(el.dataset.suggested); + suggested = JSON.parse(el.dataset.suggested) if (!isMultiple) { if (input.value === '[]'){ diff --git a/src/Bundle/ChillPersonBundle/Form/Type/PickPersonDynamicType.php b/src/Bundle/ChillPersonBundle/Form/Type/PickPersonDynamicType.php index 3a875f8aa..e8b83a416 100644 --- a/src/Bundle/ChillPersonBundle/Form/Type/PickPersonDynamicType.php +++ b/src/Bundle/ChillPersonBundle/Form/Type/PickPersonDynamicType.php @@ -51,7 +51,7 @@ class PickPersonDynamicType extends AbstractType $view->vars['uniqid'] = uniqid('pick_user_dyn'); foreach ($options['suggested'] as $person) { - $view->vars['suggested'][spl_object_hash($person)] = $this->normalizer->normalize($person, 'json', ['groups' => 'read']); + $view->vars['suggested'][] = $this->normalizer->normalize($person, 'json', ['groups' => 'read']); } } diff --git a/src/Bundle/ChillThirdPartyBundle/Form/Type/PickThirdpartyDynamicType.php b/src/Bundle/ChillThirdPartyBundle/Form/Type/PickThirdpartyDynamicType.php index 7d5625ec6..1c3984b69 100644 --- a/src/Bundle/ChillThirdPartyBundle/Form/Type/PickThirdpartyDynamicType.php +++ b/src/Bundle/ChillThirdPartyBundle/Form/Type/PickThirdpartyDynamicType.php @@ -51,7 +51,7 @@ class PickThirdpartyDynamicType extends AbstractType $view->vars['uniqid'] = uniqid('pick_user_dyn'); foreach ($options['suggested'] as $tp) { - $view->vars['suggested'][spl_object_hash($tp)] = $this->normalizer->normalize($tp, 'json', ['groups' => 'read']); + $view->vars['suggested'][] = $this->normalizer->normalize($tp, 'json', ['groups' => 'read']); } } From eaea702454a2e528f53d18c60f1a6aafd4575d20 Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Wed, 15 Mar 2023 10:14:25 +0100 Subject: [PATCH 32/37] FIX add initial user as suggestion and fix error when there are no suggestions --- src/Bundle/ChillMainBundle/Entity/Workflow/EntityWorkflow.php | 1 + src/Bundle/ChillMainBundle/Form/Type/PickUserDynamicType.php | 1 + src/Bundle/ChillPersonBundle/Form/Type/PickPersonDynamicType.php | 1 + .../Form/Type/PickThirdpartyDynamicType.php | 1 + 4 files changed, 4 insertions(+) diff --git a/src/Bundle/ChillMainBundle/Entity/Workflow/EntityWorkflow.php b/src/Bundle/ChillMainBundle/Entity/Workflow/EntityWorkflow.php index 99aba07fd..e4683f24b 100644 --- a/src/Bundle/ChillMainBundle/Entity/Workflow/EntityWorkflow.php +++ b/src/Bundle/ChillMainBundle/Entity/Workflow/EntityWorkflow.php @@ -354,6 +354,7 @@ class EntityWorkflow implements TrackCreationInterface, TrackUpdateInterface public function getUsersInvolved(): array { $usersInvolved = []; + $usersInvolved[spl_object_hash($this->getCreatedBy())] = $this->getCreatedBy(); foreach ($this->steps as $step) { foreach ($step->getDestUser() as $u) { diff --git a/src/Bundle/ChillMainBundle/Form/Type/PickUserDynamicType.php b/src/Bundle/ChillMainBundle/Form/Type/PickUserDynamicType.php index c48650f8e..f6c2b7f4a 100644 --- a/src/Bundle/ChillMainBundle/Form/Type/PickUserDynamicType.php +++ b/src/Bundle/ChillMainBundle/Form/Type/PickUserDynamicType.php @@ -50,6 +50,7 @@ class PickUserDynamicType extends AbstractType $view->vars['multiple'] = $options['multiple']; $view->vars['types'] = ['user']; $view->vars['uniqid'] = uniqid('pick_user_dyn'); + $view->vars['suggested'] = []; foreach ($options['suggested'] as $user) { $view->vars['suggested'][] = $this->normalizer->normalize($user, 'json', ['groups' => 'read']); diff --git a/src/Bundle/ChillPersonBundle/Form/Type/PickPersonDynamicType.php b/src/Bundle/ChillPersonBundle/Form/Type/PickPersonDynamicType.php index e8b83a416..76891a74d 100644 --- a/src/Bundle/ChillPersonBundle/Form/Type/PickPersonDynamicType.php +++ b/src/Bundle/ChillPersonBundle/Form/Type/PickPersonDynamicType.php @@ -49,6 +49,7 @@ class PickPersonDynamicType extends AbstractType $view->vars['multiple'] = $options['multiple']; $view->vars['types'] = ['person']; $view->vars['uniqid'] = uniqid('pick_user_dyn'); + $view->vars['suggested'] = []; foreach ($options['suggested'] as $person) { $view->vars['suggested'][] = $this->normalizer->normalize($person, 'json', ['groups' => 'read']); diff --git a/src/Bundle/ChillThirdPartyBundle/Form/Type/PickThirdpartyDynamicType.php b/src/Bundle/ChillThirdPartyBundle/Form/Type/PickThirdpartyDynamicType.php index 1c3984b69..eb9e7e5ea 100644 --- a/src/Bundle/ChillThirdPartyBundle/Form/Type/PickThirdpartyDynamicType.php +++ b/src/Bundle/ChillThirdPartyBundle/Form/Type/PickThirdpartyDynamicType.php @@ -49,6 +49,7 @@ class PickThirdpartyDynamicType extends AbstractType $view->vars['multiple'] = $options['multiple']; $view->vars['types'] = ['thirdparty']; $view->vars['uniqid'] = uniqid('pick_user_dyn'); + $view->vars['suggested'] = []; foreach ($options['suggested'] as $tp) { $view->vars['suggested'][] = $this->normalizer->normalize($tp, 'json', ['groups' => 'read']); From 96ddc73e45c406cf49ee2762417f3c171683a402 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Thu, 23 Mar 2023 12:48:37 +0100 Subject: [PATCH 33/37] Feature: [calendar sync msgraph] Allow to show the calendar details if the user does not have msgraph mapping We first check that there are "msgraph" attributes before forcing redirection to MSGraph authorization. If not, we let's the user see the calendar edit/create page. --- .../MSGraphRemoteCalendarConnector.php | 25 ++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/src/Bundle/ChillCalendarBundle/RemoteCalendar/Connector/MSGraphRemoteCalendarConnector.php b/src/Bundle/ChillCalendarBundle/RemoteCalendar/Connector/MSGraphRemoteCalendarConnector.php index c376f9680..d409e6f03 100644 --- a/src/Bundle/ChillCalendarBundle/RemoteCalendar/Connector/MSGraphRemoteCalendarConnector.php +++ b/src/Bundle/ChillCalendarBundle/RemoteCalendar/Connector/MSGraphRemoteCalendarConnector.php @@ -34,6 +34,7 @@ use Psr\Log\LoggerInterface; use Symfony\Component\HttpFoundation\RedirectResponse; use Symfony\Component\HttpFoundation\Response; use Symfony\Component\Routing\Generator\UrlGeneratorInterface; +use Symfony\Component\Security\Core\Security; use Symfony\Contracts\HttpClient\Exception\ClientExceptionInterface; use Symfony\Contracts\HttpClient\HttpClientInterface; use Symfony\Contracts\Translation\TranslatorInterface; @@ -64,6 +65,8 @@ class MSGraphRemoteCalendarConnector implements RemoteCalendarConnectorInterface private OnBehalfOfUserHttpClient $userHttpClient; + private Security $security; + public function __construct( CalendarRepository $calendarRepository, CalendarRangeRepository $calendarRangeRepository, @@ -74,7 +77,8 @@ class MSGraphRemoteCalendarConnector implements RemoteCalendarConnectorInterface OnBehalfOfUserHttpClient $userHttpClient, RemoteEventConverter $remoteEventConverter, TranslatorInterface $translator, - UrlGeneratorInterface $urlGenerator + UrlGeneratorInterface $urlGenerator, + Security $security ) { $this->calendarRepository = $calendarRepository; $this->calendarRangeRepository = $calendarRangeRepository; @@ -86,6 +90,7 @@ class MSGraphRemoteCalendarConnector implements RemoteCalendarConnectorInterface $this->translator = $translator; $this->urlGenerator = $urlGenerator; $this->userHttpClient = $userHttpClient; + $this->security = $security; } public function countEventsForUser(User $user, DateTimeImmutable $startDate, DateTimeImmutable $endDate): int @@ -133,6 +138,24 @@ class MSGraphRemoteCalendarConnector implements RemoteCalendarConnectorInterface public function isReady(): bool { + $user = $this->security->getUser(); + + if (!$user instanceof User) { + // this is not a user from chill. This is not the role of this class to + // restrict access, so we will just say that we do not have to do anything more + // here... + return true; + } + + if (null === $this->mapCalendarToUser->getUserId($user)) { + // this user is not mapped with remote calendar. The user will have to wait for + // the next calendar subscription iteration + $this->logger->debug('mark user ready for msgraph calendar as he does not have any mapping', [ + 'userId' => $user->getId(), + ]); + return true; + } + return $this->tokenStorage->hasToken(); } From 782bda074439d45fbb7136fae4a2457d7bd48c20 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Fri, 24 Mar 2023 17:06:00 +0100 Subject: [PATCH 34/37] Fixed: [Pick entity / suggestion] handle case when user choose one suggested in the modal In the previous implementation, if the user would add an entity from the modal, and if this entity is also present in the suggestion, the entity would not be removed from the suggestion list. --- .../public/module/pick-entity/index.js | 29 ++++++++++++------- .../public/vuejs/PickEntity/PickEntity.vue | 6 ++-- 2 files changed, 22 insertions(+), 13 deletions(-) diff --git a/src/Bundle/ChillMainBundle/Resources/public/module/pick-entity/index.js b/src/Bundle/ChillMainBundle/Resources/public/module/pick-entity/index.js index fce3d43cc..6b143a11d 100644 --- a/src/Bundle/ChillMainBundle/Resources/public/module/pick-entity/index.js +++ b/src/Bundle/ChillMainBundle/Resources/public/module/pick-entity/index.js @@ -37,7 +37,7 @@ function loadDynamicPicker(element) { ':types="types" ' + ':picked="picked" ' + ':uniqid="uniqid" ' + - ':suggested="suggested" ' + + ':suggested="notPickedSuggested" ' + '@addNewEntity="addNewEntity" ' + '@removeEntity="removeEntity">', components: { @@ -52,8 +52,21 @@ function loadDynamicPicker(element) { suggested: suggested } }, + computed: { + notPickedSuggested() { + if (this.multiple) { + const pickedIds = new Set(); + for (const p of this.picked) { + pickedIds.add(`${p.type}${p.id}`); + } + return this.suggested.filter(e => !pickedIds.has(`${e.type}${e.id}`)) + } + + return this.suggested.filter(e => e.type !== this.picked.type && e.id !== e.picked.id); + } + }, methods: { - addNewEntity({entity, isSuggested = false}) { + addNewEntity({entity}) { if (this.multiple) { if (!this.picked.some(el => { return el.type === entity.type && el.id === entity.id; @@ -61,10 +74,6 @@ function loadDynamicPicker(element) { this.picked.push(entity); input.value = JSON.stringify(this.picked); console.log(entity) - if (isSuggested) { - const indexToRemove = this.suggested.findIndex(e => e.id === entity.id) - this.suggested.splice(indexToRemove, 1); - } } } else { if (!this.picked.some(el => { @@ -76,12 +85,12 @@ function loadDynamicPicker(element) { } } }, - removeEntity({entity, isSuggested = false}) { - this.picked = this.picked.filter(e => !(e.type === entity.type && e.id === entity.id)); - input.value = JSON.stringify(this.picked); - if (isSuggested) { + removeEntity({entity}) { + if (-1 === this.suggested.findIndex(e => e.type === entity.type && e.id === entity.id)) { this.suggested.push(entity); } + this.picked = this.picked.filter(e => !(e.type === entity.type && e.id === entity.id)); + input.value = JSON.stringify(this.picked); }, } }) diff --git a/src/Bundle/ChillMainBundle/Resources/public/vuejs/PickEntity/PickEntity.vue b/src/Bundle/ChillMainBundle/Resources/public/vuejs/PickEntity/PickEntity.vue index 7d6d0bd83..0a39718e2 100644 --- a/src/Bundle/ChillMainBundle/Resources/public/vuejs/PickEntity/PickEntity.vue +++ b/src/Bundle/ChillMainBundle/Resources/public/vuejs/PickEntity/PickEntity.vue @@ -104,11 +104,11 @@ export default { }, methods: { addNewSuggested(entity) { - this.$emit('addNewEntity', {entity: entity, isSuggested: true}); + this.$emit('addNewEntity', {entity: entity}); }, addNewEntity({ selected, modal }) { selected.forEach((item) => { - this.$emit('addNewEntity', { entity: item.result }); + this.$emit('addNewEntity', { entity: item.result}); }, this ); this.$refs.addPersons.resetSearch(); // to cast child method @@ -118,7 +118,7 @@ export default { if (!this.$props.removableIfSet) { return; } - this.$emit('removeEntity',{ entity: entity, isSuggested: true }); + this.$emit('removeEntity',{ entity: entity }); } }, } From 77dc0400343fbb29daf71a61628bf5ddaaf61f38 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Tue, 21 Mar 2023 12:28:37 +0100 Subject: [PATCH 35/37] DX: update fullcalendar --- package.json | 18 +++++++++--------- .../Resources/public/types.ts | 2 +- .../Resources/public/vuejs/Calendar/App.vue | 1 - .../public/vuejs/Calendar/store/utils.ts | 2 +- .../public/vuejs/MyCalendarRange/App2.vue | 6 ++---- .../Components/EditLocation.vue | 2 +- .../store/modules/calendarLocals.ts | 2 +- .../store/modules/calendarRanges.ts | 2 +- .../store/modules/calendarRemotes.ts | 2 +- 9 files changed, 17 insertions(+), 20 deletions(-) diff --git a/package.json b/package.json index 17b02c63a..0bd3a81e5 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { - "name": "chill", - "version": "2.0.0", - "devDependencies": { + "name": "chill", + "version": "2.0.0", + "devDependencies": { "@alexlafroscia/yaml-merge": "^4.0.0", "@apidevtools/swagger-cli": "^4.0.4", "@babel/core": "^7.20.5", @@ -34,12 +34,12 @@ "webpack-cli": "^5.0.1" }, "dependencies": { - "@fullcalendar/core": "^5.11.0", - "@fullcalendar/daygrid": "^5.11.0", - "@fullcalendar/interaction": "^5.11.0", - "@fullcalendar/list": "^5.11.0", - "@fullcalendar/timegrid": "^5.11.0", - "@fullcalendar/vue3": "^5.11.1", + "@fullcalendar/core": "^6.1.4", + "@fullcalendar/daygrid": "^6.1.4", + "@fullcalendar/interaction": "^6.1.4", + "@fullcalendar/list": "^6.1.4", + "@fullcalendar/timegrid": "^6.1.4", + "@fullcalendar/vue3": "^6.1.4", "@popperjs/core": "^2.9.2", "dropzone": "^5.7.6", "es6-promise": "^4.2.8", diff --git a/src/Bundle/ChillCalendarBundle/Resources/public/types.ts b/src/Bundle/ChillCalendarBundle/Resources/public/types.ts index ebc7ab7be..c18cfea13 100644 --- a/src/Bundle/ChillCalendarBundle/Resources/public/types.ts +++ b/src/Bundle/ChillCalendarBundle/Resources/public/types.ts @@ -1,4 +1,4 @@ -import {EventInput} from '@fullcalendar/vue3'; +import {EventInput} from '@fullcalendar/core'; import {DateTime, Location, User, UserAssociatedInterface} from '../../../ChillMainBundle/Resources/public/types' ; import {Person} from "../../../ChillPersonBundle/Resources/public/types"; diff --git a/src/Bundle/ChillCalendarBundle/Resources/public/vuejs/Calendar/App.vue b/src/Bundle/ChillCalendarBundle/Resources/public/vuejs/Calendar/App.vue index 472bb525b..32b6b569b 100644 --- a/src/Bundle/ChillCalendarBundle/Resources/public/vuejs/Calendar/App.vue +++ b/src/Bundle/ChillCalendarBundle/Resources/public/vuejs/Calendar/App.vue @@ -116,7 +116,6 @@