From b328ebd91b15261bb8c25417edb73a42e02a89eb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Fromme?= Date: Wed, 31 Jan 2024 19:35:16 +0100 Subject: [PATCH] feat: status 'draft' for assignments --- src/Entity/Assignment.php | 3 ++- src/Form/AssignmentType.php | 8 ++++++++ src/Repository/AssignmentRepository.php | 2 ++ templates/admin/assignment/_form.html.twig | 1 + templates/admin/assignment/index.html.twig | 2 ++ 5 files changed, 15 insertions(+), 1 deletion(-) diff --git a/src/Entity/Assignment.php b/src/Entity/Assignment.php index b2abf4d..350b84a 100644 --- a/src/Entity/Assignment.php +++ b/src/Entity/Assignment.php @@ -21,6 +21,7 @@ class Assignment implements BlameableEntityInterface, TimestampableEntityInterfa use TimestampableEntity; use SoftDeletableEntity; + public const STATUS_DRAFT = 'draft'; public const STATUS_OPEN = 'open'; public const STATUS_CLOSED = 'closed'; @@ -90,7 +91,7 @@ class Assignment implements BlameableEntityInterface, TimestampableEntityInterfa public function __construct() { $this->uuid = Uuid::v4(); - $this->status = static::STATUS_OPEN; + $this->status = static::STATUS_DRAFT; $this->fees = new ArrayCollection(); $this->applications = new ArrayCollection(); $this->dispositions = new ArrayCollection(); diff --git a/src/Form/AssignmentType.php b/src/Form/AssignmentType.php index 91c6dc5..44396c7 100644 --- a/src/Form/AssignmentType.php +++ b/src/Form/AssignmentType.php @@ -32,6 +32,14 @@ class AssignmentType extends AbstractType public function buildForm(FormBuilderInterface $builder, array $options): void { $builder + ->add('status', ChoiceType::class, [ + 'label' => 'Status', + 'choices' => [ + 'Entwurf' => Assignment::STATUS_DRAFT, + 'offen' => Assignment::STATUS_OPEN, + 'geschlossen' => Assignment::STATUS_CLOSED, + ], + ]) ->add('availableDispositions', IntegerType::class, [ 'label' => 'zu vergeben', 'required' => false, diff --git a/src/Repository/AssignmentRepository.php b/src/Repository/AssignmentRepository.php index 661bbf2..888e23c 100644 --- a/src/Repository/AssignmentRepository.php +++ b/src/Repository/AssignmentRepository.php @@ -223,10 +223,12 @@ class AssignmentRepository extends ServiceEntityRepository ->leftJoin('assignment.applications', 'application', Join::WITH, $qb->expr()->eq('application.teamer', ':teamer')) ->leftJoin('assignment.dispositions', 'disposition', Join::WITH, $qb->expr()->eq('disposition.teamer', ':teamer')) ->where($qb->expr()->andX( + $qb->expr()->eq('assignment.status', ':status'), $qb->expr()->in('assignment.jobProfile', ':jobProfiles'), $qb->expr()->isNull('application'), $qb->expr()->isNull('disposition') )) + ->setParameter('status', Assignment::STATUS_OPEN) ->setParameter('jobProfiles', $teamer->getJobProfiles()) ->setParameter('teamer', $teamer) ; diff --git a/templates/admin/assignment/_form.html.twig b/templates/admin/assignment/_form.html.twig index d1cb121..d872eaf 100644 --- a/templates/admin/assignment/_form.html.twig +++ b/templates/admin/assignment/_form.html.twig @@ -17,6 +17,7 @@
{{ form_row(form.destination) }}
+ {{ form_row(form.status) }} {{ form_row(form.availableDispositions) }}

diff --git a/templates/admin/assignment/index.html.twig b/templates/admin/assignment/index.html.twig index cb26ffd..2832a4e 100644 --- a/templates/admin/assignment/index.html.twig +++ b/templates/admin/assignment/index.html.twig @@ -98,6 +98,8 @@ {{ assignment.validApplications|length }}/{{ assignment.availableDispositions - assignment.dispositions|length }} {% if assignment.status == 'closed' %} {{ icon('locked', 'w-4 h-4 text-red-500') }} + {% elseif assignment.status == 'draft' %} + {{ icon('hourglass', 'w-4 h-4 text-yellow-500') }} {% else %} {{ icon('unlocked', 'w-4 h-4') }} {% endif %}