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 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" }, }, ); diff --git a/src/Bundle/ChillMainBundle/Form/Type/DataTransformer/EntityToJsonTransformer.php b/src/Bundle/ChillMainBundle/Form/Type/DataTransformer/EntityToJsonTransformer.php index 8f0126049..cf78cd33d 100644 --- a/src/Bundle/ChillMainBundle/Form/Type/DataTransformer/EntityToJsonTransformer.php +++ b/src/Bundle/ChillMainBundle/Form/Type/DataTransformer/EntityToJsonTransformer.php @@ -66,8 +66,11 @@ class EntityToJsonTransformer implements DataTransformerInterface ]); } - private function denormalizeOne(array $item) + private function denormalizeOne(array|string $item) { + if ('me' === $item) { + return $item; + } if (!\array_key_exists('type', $item)) { throw new TransformationFailedException('the key "type" is missing on element'); } @@ -98,5 +101,6 @@ class EntityToJsonTransformer implements DataTransformerInterface 'json', $context, ); + } } 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..9f6bb753e 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..850db686c 100644 --- a/src/Bundle/ChillMainBundle/Resources/public/vuejs/PickEntity/PickEntity.vue +++ b/src/Bundle/ChillMainBundle/Resources/public/vuejs/PickEntity/PickEntity.vue @@ -1,10 +1,25 @@ - + + diff --git a/src/Bundle/ChillMainBundle/translations/messages.fr.yml b/src/Bundle/ChillMainBundle/translations/messages.fr.yml index 922a8b353..a2d718143 100644 --- a/src/Bundle/ChillMainBundle/translations/messages.fr.yml +++ b/src/Bundle/ChillMainBundle/translations/messages.fr.yml @@ -49,6 +49,7 @@ Name: Nom Label: Nom user: + current_user: Utilisateur courant profile: title: Mon profil Phonenumber successfully updated!: Numéro de téléphone mis à jour! diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/ReferrerFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/ReferrerFilter.php index 8f451f22a..4d49f632e 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/ReferrerFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/ReferrerFilter.php @@ -13,8 +13,8 @@ namespace Chill\PersonBundle\Export\Filter\AccompanyingCourseFilters; use Chill\MainBundle\Export\FilterInterface; use Chill\MainBundle\Form\Type\PickRollingDateType; -use Chill\MainBundle\Form\Type\PickUserDynamicType; use Chill\MainBundle\Repository\UserRepositoryInterface; +use Chill\MainBundle\Form\Type\PickUserOrMeDynamicType; use Chill\MainBundle\Service\RollingDate\RollingDate; use Chill\MainBundle\Service\RollingDate\RollingDateConverterInterface; use Chill\PersonBundle\Export\Declarations; @@ -24,6 +24,7 @@ use Symfony\Component\Form\FormBuilderInterface; final readonly class ReferrerFilter implements FilterInterface { use \Chill\MainBundle\Export\ExportDataNormalizerTrait; + private const A = 'acp_referrer_filter_uhistory'; private const P = 'acp_referrer_filter_date'; @@ -68,7 +69,7 @@ final readonly class ReferrerFilter implements FilterInterface public function buildForm(FormBuilderInterface $builder): void { $builder - ->add('accepted_referrers', PickUserDynamicType::class, [ + ->add('accepted_referrers', PickUserOrMeDynamicType::class, [ 'multiple' => true, ]) ->add('date_calc', PickRollingDateType::class, [