From 8a444a12f44dc0b8503c0a0ec5a9f4195737e37b Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Tue, 18 Mar 2025 10:57:24 +0100 Subject: [PATCH 01/11] Turn off eslint error ban-ts-comment --- eslint.config.mjs | 1 + 1 file changed, 1 insertion(+) diff --git a/eslint.config.mjs b/eslint.config.mjs index 2b37a3fa5..dbcafea0a 100644 --- a/eslint.config.mjs +++ b/eslint.config.mjs @@ -34,6 +34,7 @@ export default ts.config( // override/add rules settings here, such as: "vue/multi-word-component-names": "off", "@typescript-eslint/no-require-imports": "off", + "@typescript-eslint/ban-ts-comment": "off" }, }, ); From fe6949ea266fb02c1b33111182b07cd384e002ac Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Tue, 18 Mar 2025 13:47:31 +0100 Subject: [PATCH 02/11] Update chill bundles to v3.10.3 --- .changes/v3.10.3.md | 3 +++ CHANGELOG.md | 4 ++++ 2 files changed, 7 insertions(+) create mode 100644 .changes/v3.10.3.md diff --git a/.changes/v3.10.3.md b/.changes/v3.10.3.md new file mode 100644 index 000000000..3d402ca34 --- /dev/null +++ b/.changes/v3.10.3.md @@ -0,0 +1,3 @@ +## v3.10.3 - 2025-03-18 +### DX +* Eslint fixes diff --git a/CHANGELOG.md b/CHANGELOG.md index dccae4734..b1b9aa894 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,10 @@ adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html), and is generated by [Changie](https://github.com/miniscruff/changie). +## v3.10.3 - 2025-03-18 +### DX +* Eslint fixes + ## v3.10.2 - 2025-03-17 ### Fixed * Replace a ts-expect-error with a ts-ignore From ec5c4d51b3226d6074273e0d100c4eb795add92c Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Mon, 10 Mar 2025 19:19:51 +0100 Subject: [PATCH 03/11] Frontend: display and behavior of pickUserOrMe form field --- .../Form/Type/PickUserOrMeDynamicType.php | 82 +++++++++++++++++++ .../public/module/pick-entity/index.js | 23 ++++-- .../public/vuejs/PickEntity/PickEntity.vue | 32 +++++++- .../translations/messages.fr.yml | 1 + .../ReferrerFilter.php | 6 +- 5 files changed, 135 insertions(+), 9 deletions(-) create mode 100644 src/Bundle/ChillMainBundle/Form/Type/PickUserOrMeDynamicType.php diff --git a/src/Bundle/ChillMainBundle/Form/Type/PickUserOrMeDynamicType.php b/src/Bundle/ChillMainBundle/Form/Type/PickUserOrMeDynamicType.php new file mode 100644 index 000000000..93ecd3f4e --- /dev/null +++ b/src/Bundle/ChillMainBundle/Form/Type/PickUserOrMeDynamicType.php @@ -0,0 +1,82 @@ +addViewTransformer(new EntityToJsonTransformer($this->denormalizer, $this->serializer, $options['multiple'], 'user')); + } + + public function buildView(FormView $view, FormInterface $form, array $options) + { + $view->vars['multiple'] = $options['multiple']; + $view->vars['types'] = ['user']; + $view->vars['uniqid'] = uniqid('pick_user_or_me_dyn'); + $view->vars['suggested'] = []; + $view->vars['as_id'] = true === $options['as_id'] ? '1' : '0'; + $view->vars['submit_on_adding_new_entity'] = true === $options['submit_on_adding_new_entity'] ? '1' : '0'; + + foreach ($options['suggested'] as $user) { + $view->vars['suggested'][] = $this->normalizer->normalize($user, 'json', ['groups' => 'read']); + } + // $user = /* should come from context */ $options['context']; + } + + public function configureOptions(OptionsResolver $resolver) + { + $resolver + ->setDefault('multiple', false) + ->setAllowedTypes('multiple', ['bool']) + ->setDefault('compound', false) + ->setDefault('suggested', []) + // if set to true, only the id will be set inside the content. The denormalization will not work. + ->setDefault('as_id', false) + ->setAllowedTypes('as_id', ['bool']) + ->setDefault('submit_on_adding_new_entity', false) + ->setAllowedTypes('submit_on_adding_new_entity', ['bool']); + } + + public function getBlockPrefix() + { + return 'pick_entity_dynamic'; + } +} 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 1b3ee4594..1f89002fe 100644 --- a/src/Bundle/ChillMainBundle/Resources/public/module/pick-entity/index.js +++ b/src/Bundle/ChillMainBundle/Resources/public/module/pick-entity/index.js @@ -12,6 +12,11 @@ function loadDynamicPicker(element) { let apps = element.querySelectorAll('[data-module="pick-dynamic"]'); apps.forEach(function (el) { + let suggested; + let as_id; + let submit_on_adding_new_entity; + let label; + let isCurrentUserPicker; const isMultiple = parseInt(el.dataset.multiple) === 1, uniqId = el.dataset.uniqid, input = element.querySelector( @@ -22,12 +27,13 @@ function loadDynamicPicker(element) { ? JSON.parse(input.value) : input.value === "[]" || input.value === "" ? null - : [JSON.parse(input.value)], - suggested = JSON.parse(el.dataset.suggested), - as_id = parseInt(el.dataset.asId) === 1, - submit_on_adding_new_entity = - parseInt(el.dataset.submitOnAddingNewEntity) === 1, - label = el.dataset.label; + : [JSON.parse(input.value)]; + suggested = JSON.parse(el.dataset.suggested); + as_id = parseInt(el.dataset.asId) === 1; + submit_on_adding_new_entity = + parseInt(el.dataset.submitOnAddingNewEntity) === 1; + label = el.dataset.label; + isCurrentUserPicker = uniqId.startsWith("pick_user_or_me_dyn"); if (!isMultiple) { if (input.value === "[]") { @@ -44,6 +50,7 @@ function loadDynamicPicker(element) { ':uniqid="uniqid" ' + ':suggested="notPickedSuggested" ' + ':label="label" ' + + ':isCurrentUserPicker="isCurrentUserPicker" ' + '@addNewEntity="addNewEntity" ' + '@removeEntity="removeEntity" ' + '@addNewEntityProcessEnded="addNewEntityProcessEnded"' + @@ -61,6 +68,7 @@ function loadDynamicPicker(element) { as_id, submit_on_adding_new_entity, label, + isCurrentUserPicker }; }, computed: { @@ -89,7 +97,8 @@ function loadDynamicPicker(element) { const ids = this.picked.map((el) => el.id); input.value = ids.join(","); } - console.log(entity); + console.log(this.picked) + // console.log(entity); } } else { if ( diff --git a/src/Bundle/ChillMainBundle/Resources/public/vuejs/PickEntity/PickEntity.vue b/src/Bundle/ChillMainBundle/Resources/public/vuejs/PickEntity/PickEntity.vue index 56e324133..9403ff625 100644 --- a/src/Bundle/ChillMainBundle/Resources/public/vuejs/PickEntity/PickEntity.vue +++ b/src/Bundle/ChillMainBundle/Resources/public/vuejs/PickEntity/PickEntity.vue @@ -1,10 +1,22 @@ - diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/ReferrerFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/ReferrerFilter.php index 3573a9363..3f17dfe42 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/ReferrerFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/ReferrerFilter.php @@ -68,11 +68,8 @@ class ReferrerFilter implements FilterInterface { $builder ->add('accepted_referrers', PickUserOrMeDynamicType::class, [ - 'multiple' => false, - ]) -/* ->add('accepted_referrers', PickUserDynamicType::class, [ 'multiple' => true, - ])*/ + ]) ->add('date_calc', PickRollingDateType::class, [ 'label' => 'export.filter.course.by_referrer.Computation date for referrer', 'required' => true, From 9503cb89b607334cc09325eb9f69506a13d2b513 Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Tue, 11 Mar 2025 09:27:03 +0100 Subject: [PATCH 06/11] Setup if condition in EntityToJsonTransformer.php for when 'me' is passed --- .../EntityToJsonTransformer.php | 23 ++++++++++--------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/src/Bundle/ChillMainBundle/Form/Type/DataTransformer/EntityToJsonTransformer.php b/src/Bundle/ChillMainBundle/Form/Type/DataTransformer/EntityToJsonTransformer.php index b51601caf..1863e8579 100644 --- a/src/Bundle/ChillMainBundle/Form/Type/DataTransformer/EntityToJsonTransformer.php +++ b/src/Bundle/ChillMainBundle/Form/Type/DataTransformer/EntityToJsonTransformer.php @@ -68,6 +68,17 @@ class EntityToJsonTransformer implements DataTransformerInterface private function denormalizeOne(array|string $item) { + if ('me' === $item) { + dump($item); +/* return + $this->denormalizer->denormalize( + // pass id of current user that we get from the exportGenerationContext... + ['type' => User::class, 'id' => $item['id']], + User::class, + 'json', + $context, + );*/ + } if (!\array_key_exists('type', $item)) { throw new TransformationFailedException('the key "type" is missing on element'); } @@ -76,17 +87,6 @@ class EntityToJsonTransformer implements DataTransformerInterface throw new TransformationFailedException('the key "id" is missing on element'); } - if ('me' === $item) { - // return the denormalized current user - /* return - $this->denormalizer->denormalize( - ['type' => $item['type'], 'id' => $item['id']], - User::class, - 'json', - $context, - );*/ - } - $class = match ($this->type) { 'user' => User::class, 'person' => Person::class, @@ -109,5 +109,6 @@ class EntityToJsonTransformer implements DataTransformerInterface 'json', $context, ); + } } From ac6a81cbd8a09044f2e8cbf261177322e58e57aa Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Tue, 11 Mar 2025 09:46:55 +0100 Subject: [PATCH 07/11] Adjust styling of current user selected --- .../Resources/public/vuejs/PickEntity/PickEntity.vue | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/Bundle/ChillMainBundle/Resources/public/vuejs/PickEntity/PickEntity.vue b/src/Bundle/ChillMainBundle/Resources/public/vuejs/PickEntity/PickEntity.vue index c1cee6416..a8a8dcd8a 100644 --- a/src/Bundle/ChillMainBundle/Resources/public/vuejs/PickEntity/PickEntity.vue +++ b/src/Bundle/ChillMainBundle/Resources/public/vuejs/PickEntity/PickEntity.vue @@ -2,7 +2,7 @@
  • - {{ trans(USER_CURRENT_USER) }} + {{ trans(USER_CURRENT_USER) }} {{ p.text }}
@@ -102,3 +102,11 @@ const removeEntity = (entity) => { emit("removeEntity", { entity }); }; + + From b4c6ccf309eaa55a30011e6c9c32b63a2e9df756 Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Tue, 11 Mar 2025 09:49:40 +0100 Subject: [PATCH 08/11] Add missing rendering condition --- .../Resources/public/vuejs/PickEntity/PickEntity.vue | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/Bundle/ChillMainBundle/Resources/public/vuejs/PickEntity/PickEntity.vue b/src/Bundle/ChillMainBundle/Resources/public/vuejs/PickEntity/PickEntity.vue index a8a8dcd8a..bb1f6959b 100644 --- a/src/Bundle/ChillMainBundle/Resources/public/vuejs/PickEntity/PickEntity.vue +++ b/src/Bundle/ChillMainBundle/Resources/public/vuejs/PickEntity/PickEntity.vue @@ -7,7 +7,7 @@
    -
  • +