diff --git a/src/Bundle/ChillPersonBundle/Controller/AccompanyingPeriodWorkDuplicateController.php b/src/Bundle/ChillPersonBundle/Controller/AccompanyingPeriodWorkDuplicateController.php
index 0b557b173..321b1812a 100644
--- a/src/Bundle/ChillPersonBundle/Controller/AccompanyingPeriodWorkDuplicateController.php
+++ b/src/Bundle/ChillPersonBundle/Controller/AccompanyingPeriodWorkDuplicateController.php
@@ -11,45 +11,33 @@ declare(strict_types=1);
namespace Chill\PersonBundle\Controller;
-use Chill\MainBundle\Templating\TranslatableStringHelperInterface;
-use Chill\PersonBundle\Entity\AccompanyingPeriod\AccompanyingPeriodWork;
use Chill\PersonBundle\Form\FindAccompanyingPeriodWorkType;
use Chill\PersonBundle\Repository\AccompanyingPeriod\AccompanyingPeriodWorkRepository;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Contracts\Translation\TranslatorInterface;
-use Sensio\Bundle\FrameworkExtraBundle\Configuration\ParamConverter;
+
class AccompanyingPeriodWorkDuplicateController extends AbstractController
{
- public function __construct(private readonly AccompanyingPeriodWorkRepository $accompanyingPeriodWorkRepository, private readonly TranslatorInterface $translator, private readonly TranslatableStringHelperInterface $stringHelper) {}
+ public function __construct(private readonly AccompanyingPeriodWorkRepository $accompanyingPeriodWorkRepository, private readonly TranslatorInterface $translator) {}
- /**
- * @ParamConverter("accompanyingPeriodWork", options={"id": "acpw_id"})
- */
#[Route(path: '{_locale}/person/accompanying-period/work/{id}/assign-duplicate', name: 'chill_person_accompanying_period_work_assign_duplicate', methods: ['GET'])]
- public function assignDuplicate(AccompanyingPeriodWork $acpw, Request $request)
+ public function assignDuplicate(mixed $id, Request $request)
{
- $accompanyingPeriod = $acpw->getAccompanyingPeriod();
+ $acpw1= $this->accompanyingPeriodWorkRepository->find($id);
- $acpwList = $this->accompanyingPeriodWorkRepository->findByAccompanyingPeriod($accompanyingPeriod);
-
- $acpwArray = array_map(function ($acpw) {
- return [
- 'id' => $acpw->getId(),
- 'socialAction' => $this->stringHelper->localize($acpw->getSocialAction()->getTitle()),
- 'startDate' => $acpw->getStartDate(),
- 'endDate' => $acpw->getEndDate(),
- ];
- }, $acpwList);
+ if (null === $acpw1) {
+ throw $this->createNotFoundException("Accompanying period work with id {$id} not".' found on this server');
+ }
$this->denyAccessUnlessGranted(
'CHILL_MAIN_ACCOMPANYING_PERIOD_WORK_UPDATE',
- $acpw,
+ $acpw1,
'You are not allowed to merge this accompanying period work'
);
- $form = $this->createForm(FindAccompanyingPeriodWorkType::class, null, ['accompanyingPeriod' => $accompanyingPeriod]);
+ $form = $this->createForm(FindAccompanyingPeriodWorkType::class);
$form->handleRequest($request);
@@ -57,33 +45,32 @@ class AccompanyingPeriodWorkDuplicateController extends AbstractController
$acpw2 = $form->get('person')->getData();
// Validation: Ensure person1 is not the same as person2
- if ($acpw->getId() === $acpw2->getId()) {
+ if ($acpw1->getId() === $acpw2->getId()) {
$this->addFlash('error', $this->translator->trans('The entities you are trying to merge cannot be the same'));
- return $this->redirectToRoute('chill_person_accompanying_period_work_show', ['id' => $acpw->getId()]);
+ return $this->redirectToRoute('chill_person_accompanying_period_work_show', ['id' => $acpw1->getId()]);
}
$direction = $form->get('direction')->getData();
-/* if ('starting' === $direction) {
+ if ('starting' === $direction) {
$params = [
- 'acpw1_id' => $acpw->getId(),
+ 'acpw1_id' => $acpw1->getId(),
'acpw2_id' => $acpw2->getId(),
];
} else {
$params = [
'acpw1_id' => $acpw2->getId(),
- 'acpw2_id' => $acpw->getId(),
+ 'acpw2_id' => $acpw1->getId(),
];
- }*/
+ }
// return $this->redirectToRoute('chill_person_acpw_duplicate_confirm', $params);
}
return $this->render('@ChillPerson/AccompanyingPeriodWorkDuplicate/assign_acpw_duplicate.html.twig', [
- 'accompanyingCourse' => $acpw->getAccompanyingPeriod(),
- 'acpwList' => $acpwArray,
- 'acpw' => $acpw,
+ 'accompanyingCourse' => $acpw1->getAccompanyingPeriod(),
+ 'acpw' => $acpw1,
'form' => $form->createView(),
]);
}
diff --git a/src/Bundle/ChillPersonBundle/Form/FindAccompanyingPeriodWorkType.php b/src/Bundle/ChillPersonBundle/Form/FindAccompanyingPeriodWorkType.php
index 1fd856e0b..69ade244b 100644
--- a/src/Bundle/ChillPersonBundle/Form/FindAccompanyingPeriodWorkType.php
+++ b/src/Bundle/ChillPersonBundle/Form/FindAccompanyingPeriodWorkType.php
@@ -11,10 +11,7 @@ declare(strict_types=1);
namespace Chill\PersonBundle\Form;
-use Chill\PersonBundle\Entity\AccompanyingPeriod;
use Chill\PersonBundle\Form\Type\PickAccompanyingPeriodWorkDynamicType;
-use Chill\PersonBundle\Form\Type\PickLinkedAccompanyingPeriodWorkType;
-use Chill\PersonBundle\Repository\AccompanyingPeriod\AccompanyingPeriodWorkRepository;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\HiddenType;
use Symfony\Component\Form\FormBuilderInterface;
@@ -22,27 +19,11 @@ use Symfony\Component\OptionsResolver\OptionsResolver;
class FindAccompanyingPeriodWorkType extends AbstractType
{
- public function __construct(private readonly AccompanyingPeriodWorkRepository $repository)
- {
- }
public function buildForm(FormBuilderInterface $builder, array $options)
{
- $accompanyingPeriod = $options['accompanyingPeriod'];
- $suggestedAcpw = $this->repository->findByAccompanyingPeriod($accompanyingPeriod);
-
- $builder
- ->add('acpw', HiddenType::class, [
- 'label' => 'Accompanying period work',
- ])
+ $builder->add('acpw', PickAccompanyingPeriodWorkDynamicType::class)
->add('direction', HiddenType::class, [
'data' => 'starting',
]);
}
-
- public function configureOptions(OptionsResolver $resolver)
- {
- $resolver
- ->setRequired('accompanyingPeriod')
- ->setAllowedTypes('accompanyingPeriod', AccompanyingPeriod::class);
- }
}
diff --git a/src/Bundle/ChillPersonBundle/Form/Type/PickAccompanyingPeriodWorkDynamicType.php b/src/Bundle/ChillPersonBundle/Form/Type/PickAccompanyingPeriodWorkDynamicType.php
new file mode 100644
index 000000000..8936b41c6
--- /dev/null
+++ b/src/Bundle/ChillPersonBundle/Form/Type/PickAccompanyingPeriodWorkDynamicType.php
@@ -0,0 +1,49 @@
+addViewTransformer(new EntityToJsonTransformer($this->denormalizer, $this->serializer, $options['multiple'], 'accompanyingPeriodWork'));
+ }
+
+ public function buildView(FormView $view, FormInterface $form, array $options)
+ {
+ $view->vars['types'] = ['accompanyingPeriodWork'];
+ $view->vars['uniqid'] = uniqid('pick_acpw_dyn');
+ $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';
+ }
+
+ public function configureOptions(OptionsResolver $resolver)
+ {
+ $resolver
+ ->setDefault('multiple', false)
+ ->setAllowedTypes('multiple', ['bool'])
+ ->setDefault('compound', false)
+ ->setDefault('suggested', [])
+ ->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/ChillPersonBundle/Resources/public/vuejs/_components/Entity/AccompanyingPeriodWorkRenderBox.vue b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/_components/Entity/AccompanyingPeriodWorkRenderBox.vue
new file mode 100644
index 000000000..c1b13b319
--- /dev/null
+++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/_components/Entity/AccompanyingPeriodWorkRenderBox.vue
@@ -0,0 +1,22 @@
+
+
+
+ {{ accompanyingPeriodWork.socialAction.title.fr }}
+
+
+