Implement show and hide logic within workflow form

This commit is contained in:
2024-07-11 15:15:41 +02:00
parent e57d52d00e
commit 72e3325626
3 changed files with 126 additions and 9 deletions

View File

@@ -17,6 +17,7 @@ use Chill\MainBundle\Form\Type\ChillTextareaType;
use Chill\MainBundle\Form\Type\PickUserDynamicType;
use Chill\MainBundle\Templating\TranslatableStringHelperInterface;
use Chill\MainBundle\Workflow\WorkflowTransitionContextDTO;
use Chill\PersonBundle\Form\Type\PickPersonDynamicType;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
use Symfony\Component\Form\Extension\Core\Type\EmailType;
@@ -102,6 +103,7 @@ class WorkflowStepType extends AbstractType
'choice_attr' => static function (Transition $transition) use ($workflow) {
$toFinal = true;
$isForward = 'neutral';
$isSignature = [];
$metadata = $workflow->getMetadataStore()->getTransitionMetadata($transition);
@@ -121,15 +123,38 @@ class WorkflowStepType extends AbstractType
) {
$toFinal = false;
}
if (\array_key_exists('isSignature', $meta)) {
$isSignature = $meta['isSignature'];
}
}
return [
'data-is-transition' => 'data-is-transition',
'data-to-final' => $toFinal ? '1' : '0',
'data-is-forward' => $isForward,
'data-is-signature' => json_encode($isSignature),
];
},
])
->add('isPersonOrUserSignature', ChoiceType::class, [
'mapped' => false,
'multiple' => false,
'expanded' => true,
'label' => 'workflow.Type of signature',
'choices' => [
'person' => 'person',
'user' => 'user',
],
])
->add('futurePersonSignatures', PickPersonDynamicType::class, [
'label' => 'workflow.person signatures',
'multiple' => true,
])
->add('futureUserSignature', PickUserDynamicType::class, [
'label' => 'workflow.user signatures',
'multiple' => false,
])
->add('futureDestUsers', PickUserDynamicType::class, [
'label' => 'workflow.dest for next steps',
'multiple' => true,
@@ -140,6 +165,7 @@ class WorkflowStepType extends AbstractType
'multiple' => true,
'required' => false,
'suggested' => $options['suggested_users'],
'attr' => ['class' => 'future-cc-users'],
])
->add('futureDestEmails', ChillCollectionType::class, [
'label' => 'workflow.dest by email',