mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-20 14:43:49 +00:00
improve workflow decision form
This commit is contained in:
@@ -48,6 +48,8 @@ class WorkflowStepType extends AbstractType
|
||||
$entityWorkflow = $options['entity_workflow'];
|
||||
$handler = $this->entityWorkflowManager->getHandler($entityWorkflow);
|
||||
$workflow = $this->registry->get($entityWorkflow, $entityWorkflow->getWorkflowName());
|
||||
$place = $workflow->getMarking($entityWorkflow);
|
||||
$placeMetadata = $workflow->getMetadataStore()->getPlaceMetadata(array_keys($place->getPlaces())[0]);
|
||||
|
||||
if (true === $options['transition']) {
|
||||
if (null === $options['entity_workflow']) {
|
||||
@@ -68,40 +70,77 @@ class WorkflowStepType extends AbstractType
|
||||
$transitions
|
||||
);
|
||||
|
||||
if (array_key_exists('validationFilterInputLabels', $placeMetadata)) {
|
||||
$inputLabels = $placeMetadata['validationFilterInputLabels'];
|
||||
|
||||
$builder->add('transitionFilter', ChoiceType::class, [
|
||||
'multiple' => false,
|
||||
'label' => 'workflow.My decision',
|
||||
'choices' => [
|
||||
'forward' => 'forward',
|
||||
'backward' => 'backward',
|
||||
'neutral' => 'neutral',
|
||||
],
|
||||
'choice_label' => function (string $key) use ($inputLabels) {
|
||||
return $this->translatableStringHelper->localize($inputLabels[$key]);
|
||||
},
|
||||
'choice_attr' => static function (string $key) {
|
||||
return [
|
||||
$key => $key,
|
||||
];
|
||||
},
|
||||
'mapped' => false,
|
||||
'expanded' => true,
|
||||
'data' => 'forward',
|
||||
]);
|
||||
}
|
||||
|
||||
$builder
|
||||
->add('transition', ChoiceType::class, [
|
||||
'label' => 'workflow.Transition to apply',
|
||||
'label' => 'workflow.Next step',
|
||||
'mapped' => false,
|
||||
'multiple' => false,
|
||||
'expanded' => true,
|
||||
'choices' => $choices,
|
||||
'choice_label' => function (Transition $transition) use ($workflow) {
|
||||
$meta = $workflow->getMetadataStore()->getTransitionMetadata($transition);
|
||||
$meta = $workflow->getMetadataStore()->getTransitionMetadata($transition);
|
||||
|
||||
if (array_key_exists('label', $meta)) {
|
||||
return $this->translatableStringHelper->localize($meta['label']);
|
||||
}
|
||||
if (array_key_exists('label', $meta)) {
|
||||
return $this->translatableStringHelper->localize($meta['label']);
|
||||
}
|
||||
|
||||
return $transition->getName();
|
||||
},
|
||||
return $transition->getName();
|
||||
},
|
||||
'choice_attr' => static function (Transition $transition) use ($workflow) {
|
||||
$toFinal = true;
|
||||
$toFinal = true;
|
||||
$isForward = 'neutral';
|
||||
|
||||
foreach ($transition->getTos() as $to) {
|
||||
$meta = $workflow->getMetadataStore()->getPlaceMetadata($to);
|
||||
$metadata = $workflow->getMetadataStore()->getTransitionMetadata($transition);
|
||||
|
||||
if (
|
||||
if (array_key_exists('isForward', $metadata)) {
|
||||
if ($metadata['isForward']) {
|
||||
$isForward = 'forward';
|
||||
} else {
|
||||
$isForward = 'backward';
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($transition->getTos() as $to) {
|
||||
$meta = $workflow->getMetadataStore()->getPlaceMetadata($to);
|
||||
|
||||
if (
|
||||
!array_key_exists('isFinal', $meta) || false === $meta['isFinal']
|
||||
) {
|
||||
$toFinal = false;
|
||||
}
|
||||
$toFinal = false;
|
||||
}
|
||||
}
|
||||
|
||||
return [
|
||||
'data-is-transition' => 'data-is-transition',
|
||||
'data-to-final' => $toFinal ? '1' : '0',
|
||||
];
|
||||
},
|
||||
return [
|
||||
'data-is-transition' => 'data-is-transition',
|
||||
'data-to-final' => $toFinal ? '1' : '0',
|
||||
'data-is-forward' => $isForward,
|
||||
];
|
||||
},
|
||||
])
|
||||
->add('future_dest_users', PickUserDynamicType::class, [
|
||||
'label' => 'workflow.dest for next steps',
|
||||
|
Reference in New Issue
Block a user