Add suggested thirdparties, with same parent, for thirdparties of kind 'child'

This commit is contained in:
Julie Lenaerts 2025-03-03 20:16:41 +01:00
parent 3d397c0145
commit 58291c7402
3 changed files with 17 additions and 1 deletions

View File

@ -31,7 +31,13 @@ class ThirdpartyDuplicateController extends AbstractController
#[Route(path: '/{_locale}/3party/{thirdparty_id}/find-manually', name: 'chill_thirdparty_find_duplicate')] #[Route(path: '/{_locale}/3party/{thirdparty_id}/find-manually', name: 'chill_thirdparty_find_duplicate')]
public function findManuallyDuplicateAction(ThirdParty $thirdparty, Request $request) public function findManuallyDuplicateAction(ThirdParty $thirdparty, Request $request)
{ {
$form = $this->createForm(ThirdpartyFindDuplicateType::class); $suggested = [];
if ('child' === $thirdparty->getKind()) {
$suggested = $thirdparty->getParent()->getChildren();
}
$form = $this->createForm(ThirdpartyFindDuplicateType::class, null, ['suggested' => $suggested]);
$form->handleRequest($request); $form->handleRequest($request);

View File

@ -15,6 +15,7 @@ use Chill\ThirdPartyBundle\Form\Type\PickThirdpartyDynamicType;
use Symfony\Component\Form\AbstractType; use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\HiddenType; use Symfony\Component\Form\Extension\Core\Type\HiddenType;
use Symfony\Component\Form\FormBuilderInterface; use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
class ThirdpartyFindDuplicateType extends AbstractType class ThirdpartyFindDuplicateType extends AbstractType
{ {
@ -24,9 +25,17 @@ class ThirdpartyFindDuplicateType extends AbstractType
->add('thirdparty', PickThirdpartyDynamicType::class, [ ->add('thirdparty', PickThirdpartyDynamicType::class, [
'label' => 'Find duplicate', 'label' => 'Find duplicate',
'mapped' => false, 'mapped' => false,
'suggested' => $options['suggested'],
]) ])
->add('direction', HiddenType::class, [ ->add('direction', HiddenType::class, [
'data' => 'starting', 'data' => 'starting',
]); ]);
} }
public function configureOptions(OptionsResolver $resolver)
{
$resolver->setDefaults([
'suggested' => [],
]);
}
} }

View File

@ -39,6 +39,7 @@ class ThirdPartyRender implements ChillEntityRenderInterface
'showContacts' => $options['showContacts'] ?? false, 'showContacts' => $options['showContacts'] ?? false,
'showParent' => $options['showParent'] ?? true, 'showParent' => $options['showParent'] ?? true,
'isConfidential' => $options['isConfidential'] ?? false, 'isConfidential' => $options['isConfidential'] ?? false,
'showFusion' => $options['showFusion'] ?? false,
]; ];
return return