feat: assignments with disabled formalities
addresses #869dnvm8c
This commit is contained in:
1 parent
5979988dcc
commit
c33c1b6bf0
20 files changed
+720
-67
No files matched your search
@@ -11,6 +11,7 @@ use Doctrine\ORM\EntityManagerInterface;
|
||||
use Doctrine\ORM\EntityRepository;
|
||||
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
|
||||
use Symfony\Component\Form\AbstractType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\IntegerType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\TextareaType;
|
||||
@@ -147,6 +148,7 @@ class AssignmentType extends AbstractType
|
||||
$data = $event->getData();
|
||||
|
||||
$this->addStatusField($data, $form);
|
||||
$this->addSkipFormalitiesField($data, $form);
|
||||
|
||||
$destination = $data->getDestination();
|
||||
|
||||
@@ -212,6 +214,36 @@ class AssignmentType extends AbstractType
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether the skip-formalities flag is frozen for a given assignment.
|
||||
*
|
||||
* It decides which status a Disposition is created in, so flipping it once placements
|
||||
* exist would leave them stranded halfway through a process that no longer applies -
|
||||
* a teamer confirmed without a contract, or one still being chased for a contract on an
|
||||
* assignment that no longer wants one.
|
||||
*
|
||||
* Enforced through the form's `disabled` option, which makes Symfony ignore whatever is
|
||||
* submitted for the field, so this holds against a hand-crafted POST too.
|
||||
*/
|
||||
public static function isSkipFormalitiesLocked(?Assignment $assignment): bool
|
||||
{
|
||||
return 0 < ($assignment?->getDispositions()->count() ?? 0);
|
||||
}
|
||||
|
||||
private function addSkipFormalitiesField(?Assignment $assignment, FormInterface $form): void
|
||||
{
|
||||
$isLocked = self::isSkipFormalitiesLocked($assignment);
|
||||
|
||||
$form->add('skipFormalities', CheckboxType::class, [
|
||||
'label' => '"Partymodus": Ohne Vertrags-, Honorarnoten- und Feedbackprozess',
|
||||
'required' => false,
|
||||
'disabled' => $isLocked,
|
||||
'help' => $isLocked
|
||||
? 'Nicht mehr änderbar, sobald Teamer:innen eingeteilt sind.'
|
||||
: 'Teamer:innen bewerben sich und werden eingeteilt; danach ist der Einsatz abgeschlossen.',
|
||||
]);
|
||||
}
|
||||
|
||||
private function addPickupField(Destination $destination, FormInterface $form): void
|
||||
{
|
||||
$choices = [];
|
||||
|
||||
Reference in new issue
Block a user