WIP: Implement application handling
This commit is contained in:
@@ -0,0 +1,38 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Controller\Admin\Application;
|
||||||
|
|
||||||
|
use App\Entity\Application;
|
||||||
|
use Doctrine\ORM\EntityManagerInterface;
|
||||||
|
use Psr\Log\LoggerInterface;
|
||||||
|
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||||
|
use Symfony\Component\HttpFoundation\Response;
|
||||||
|
use Symfony\Component\Routing\Annotation\Route;
|
||||||
|
use Symfony\Component\Security\Http\Attribute\IsGranted;
|
||||||
|
|
||||||
|
class DeleteController extends AbstractController
|
||||||
|
{
|
||||||
|
public function __construct(
|
||||||
|
private readonly EntityManagerInterface $entityManager,
|
||||||
|
private readonly LoggerInterface $logger
|
||||||
|
) {
|
||||||
|
}
|
||||||
|
|
||||||
|
#[Route('/admin/application/delete/{uuid}', name: 'app_admin_application_delete')]
|
||||||
|
#[IsGranted('ROLE_ADMINISTRATIVE')]
|
||||||
|
#[IsGranted('DELETE', subject: 'application')]
|
||||||
|
public function index(Application $application): Response
|
||||||
|
{
|
||||||
|
$this->entityManager->remove($application);
|
||||||
|
$this->entityManager->flush();
|
||||||
|
|
||||||
|
$this->addFlash('success', 'Die Bewerbung wurde gelöscht');
|
||||||
|
$this->logger->info('Delete application', [
|
||||||
|
'application' => $application->getUuid(),
|
||||||
|
]);
|
||||||
|
|
||||||
|
return $this->redirectToRoute('app_admin_assignment_detail', [
|
||||||
|
'uuid' => $application->getAssignment()->getUuid(),
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
+4
-3
@@ -1,6 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace App\Controller\Admin\DIsposition;
|
namespace App\Controller\Admin\Application;
|
||||||
|
|
||||||
use App\Entity\Application;
|
use App\Entity\Application;
|
||||||
use App\Entity\Disposition;
|
use App\Entity\Disposition;
|
||||||
@@ -11,7 +11,7 @@ use Symfony\Component\HttpFoundation\Response;
|
|||||||
use Symfony\Component\Routing\Annotation\Route;
|
use Symfony\Component\Routing\Annotation\Route;
|
||||||
use Symfony\Component\Security\Http\Attribute\IsGranted;
|
use Symfony\Component\Security\Http\Attribute\IsGranted;
|
||||||
|
|
||||||
class CreateController extends AbstractController
|
class DisposeController extends AbstractController
|
||||||
{
|
{
|
||||||
public function __construct(
|
public function __construct(
|
||||||
private readonly EntityManagerInterface $entityManager,
|
private readonly EntityManagerInterface $entityManager,
|
||||||
@@ -19,8 +19,9 @@ class CreateController extends AbstractController
|
|||||||
) {
|
) {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[Route('/admin/disposition/create/{uuid}', name: 'app_admin_disposition_create')]
|
#[Route('/admin/application/dispose/{uuid}', name: 'app_admin_application_dispose')]
|
||||||
#[IsGranted('ROLE_ADMINISTRATIVE')]
|
#[IsGranted('ROLE_ADMINISTRATIVE')]
|
||||||
|
#[IsGranted('DISPOSE', subject: 'application')]
|
||||||
public function index(Application $application): Response
|
public function index(Application $application): Response
|
||||||
{
|
{
|
||||||
$disposition = new Disposition($application);
|
$disposition = new Disposition($application);
|
||||||
@@ -0,0 +1,39 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Controller\Admin\Application;
|
||||||
|
|
||||||
|
use App\Entity\Application;
|
||||||
|
use Doctrine\ORM\EntityManagerInterface;
|
||||||
|
use Psr\Log\LoggerInterface;
|
||||||
|
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||||
|
use Symfony\Component\HttpFoundation\Response;
|
||||||
|
use Symfony\Component\Routing\Annotation\Route;
|
||||||
|
use Symfony\Component\Security\Http\Attribute\IsGranted;
|
||||||
|
|
||||||
|
class RejectController extends AbstractController
|
||||||
|
{
|
||||||
|
public function __construct(
|
||||||
|
private readonly EntityManagerInterface $entityManager,
|
||||||
|
private readonly LoggerInterface $logger
|
||||||
|
) {
|
||||||
|
}
|
||||||
|
|
||||||
|
#[Route('/admin/application/reject/{uuid}', name: 'app_admin_application_reject')]
|
||||||
|
#[IsGranted('ROLE_ADMINISTRATIVE')]
|
||||||
|
#[IsGranted('REJECT', subject: 'application')]
|
||||||
|
public function index(Application $application): Response
|
||||||
|
{
|
||||||
|
$application->setStatus(Application::STATUS_REJECTED);
|
||||||
|
|
||||||
|
$this->entityManager->flush();
|
||||||
|
|
||||||
|
$this->addFlash('success', 'Die Bewerbung wurde abgelehnt');
|
||||||
|
$this->logger->info('Reject application', [
|
||||||
|
'application' => $application->getUuid(),
|
||||||
|
]);
|
||||||
|
|
||||||
|
return $this->redirectToRoute('app_admin_assignment_detail', [
|
||||||
|
'uuid' => $application->getAssignment()->getUuid(),
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -2,27 +2,34 @@
|
|||||||
|
|
||||||
namespace App\Controller\Admin\Assignment;
|
namespace App\Controller\Admin\Assignment;
|
||||||
|
|
||||||
|
use App\Controller\Traits\ReturnUrlTrait;
|
||||||
use App\Entity\Assignment;
|
use App\Entity\Assignment;
|
||||||
use App\Repository\ApplicationRepository;
|
use App\Repository\ApplicationRepository;
|
||||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||||
|
use Symfony\Component\HttpFoundation\Request;
|
||||||
use Symfony\Component\HttpFoundation\Response;
|
use Symfony\Component\HttpFoundation\Response;
|
||||||
use Symfony\Component\Routing\Annotation\Route;
|
use Symfony\Component\Routing\Annotation\Route;
|
||||||
use Symfony\Component\Security\Http\Attribute\IsGranted;
|
use Symfony\Component\Security\Http\Attribute\IsGranted;
|
||||||
|
|
||||||
class DetailController extends AbstractController
|
class DetailController extends AbstractController
|
||||||
{
|
{
|
||||||
|
use ReturnUrlTrait;
|
||||||
|
|
||||||
public function __construct(private readonly ApplicationRepository $applicationRepository)
|
public function __construct(private readonly ApplicationRepository $applicationRepository)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
#[Route('/admin/assignment/detail/{uuid}', name: 'app_admin_assignment_detail')]
|
#[Route('/admin/assignment/detail/{uuid}', name: 'app_admin_assignment_detail')]
|
||||||
#[IsGranted('ROLE_ADMINISTRATIVE')]
|
#[IsGranted('ROLE_ADMINISTRATIVE')]
|
||||||
public function index(Assignment $assignment): Response
|
public function index(Assignment $assignment, Request $request): Response
|
||||||
{
|
{
|
||||||
$applications = $this->applicationRepository->findBy(['assignment' => $assignment]);
|
$applications = $this->applicationRepository->findBy([
|
||||||
|
'assignment' => $assignment,
|
||||||
|
]);
|
||||||
|
|
||||||
return $this->render('admin/assignment/detail.html.twig', [
|
return $this->render('admin/assignment/detail.html.twig', [
|
||||||
'assignment' => $assignment,
|
'assignment' => $assignment,
|
||||||
'applications' => $applications,
|
'applications' => $applications,
|
||||||
|
'returnUrl' => $this->getReturnUrl($request, 'app_admin_assignment_index'),
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -11,6 +11,8 @@ class ApplicationVoter extends Voter
|
|||||||
{
|
{
|
||||||
public const VIEW = 'VIEW';
|
public const VIEW = 'VIEW';
|
||||||
public const DELETE = 'DELETE';
|
public const DELETE = 'DELETE';
|
||||||
|
public const DISPOSE = 'DISPOSE';
|
||||||
|
public const REJECT = 'REJECT';
|
||||||
|
|
||||||
protected function supports(string $attribute, mixed $subject): bool
|
protected function supports(string $attribute, mixed $subject): bool
|
||||||
{
|
{
|
||||||
@@ -18,7 +20,7 @@ class ApplicationVoter extends Voter
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return in_array($attribute, [static::VIEW, static::DELETE]);
|
return in_array($attribute, [static::VIEW, static::DELETE, static::DISPOSE, static::REJECT]);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function voteOnAttribute(string $attribute, mixed $subject, TokenInterface $token): bool
|
protected function voteOnAttribute(string $attribute, mixed $subject, TokenInterface $token): bool
|
||||||
@@ -30,10 +32,14 @@ class ApplicationVoter extends Voter
|
|||||||
$application = $subject;
|
$application = $subject;
|
||||||
|
|
||||||
if ($user->hasRole('ROLE_ADMINISTRATIVE')) {
|
if ($user->hasRole('ROLE_ADMINISTRATIVE')) {
|
||||||
return true;
|
return match ($attribute) {
|
||||||
|
static::VIEW, static::DELETE => true,
|
||||||
|
static::DISPOSE, static::REJECT => Application::STATUS_REJECTED !== $application->getStatus(),
|
||||||
|
default => false,
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($user->hasRole('ROLE_TEAMER')) {
|
if (static::VIEW === $attribute && $user->hasRole('ROLE_TEAMER')) {
|
||||||
return $user->getTeamer() === $application->getTeamer();
|
return $user->getTeamer() === $application->getTeamer();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -6,27 +6,100 @@
|
|||||||
<h1 class="text-2xl font-bold pb-8">
|
<h1 class="text-2xl font-bold pb-8">
|
||||||
Einsatzübersicht
|
Einsatzübersicht
|
||||||
</h1>
|
</h1>
|
||||||
<div class="grid grid-cols-2 gap-8 items-start">
|
<div class="grid grid-cols-3 gap-8 items-start">
|
||||||
<div class="bg-gray-100 rounded-md p-4">
|
<div class="bg-gray-100 rounded-md p-4">
|
||||||
{% include '_partials/_assignment_info.html.twig' %}
|
{% include '_partials/_assignment_info.html.twig' %}
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div class="col-span-2">
|
||||||
{% for application in applications %}
|
<h2 class="font-bold text-lg">
|
||||||
<a href="{{ path('app_admin_teamer_profile', { 'uuid': application.teamer.uuid, 'r': return_url() }) }}">
|
Bewerbungen
|
||||||
{{ application.teamer }}
|
</h2>
|
||||||
</a>
|
<div class="data-table-wrapper w-full">
|
||||||
{{ application.requests }}
|
<div class="data-table-wrapper__inner">
|
||||||
<button type="button"
|
<table class="data-table">
|
||||||
class="btn"
|
<thead>
|
||||||
{{ stimulus_controller('modal-button', [], [], {'confirmation-modal': '#confirmation-modal'}) }}
|
<tr>
|
||||||
{{ stimulus_action('modal-button', 'confirmation', null, {
|
<th>
|
||||||
'title': 'Bist du sicher?',
|
Name
|
||||||
'content': 'Möchtest du den Teamer ' ~ application.teamer ~ ' wirklich einteilen?',
|
</th>
|
||||||
'target-url': path('app_admin_disposition_create', { 'uuid': application.uuid })
|
<th>
|
||||||
}) }}>
|
Anmerkungen
|
||||||
einteilen
|
</th>
|
||||||
</button>
|
<th>
|
||||||
{% endfor %}
|
Status
|
||||||
|
</th>
|
||||||
|
<th></th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
{% for application in applications %}
|
||||||
|
<tr>
|
||||||
|
<td>
|
||||||
|
<a href="{{ path('app_admin_teamer_profile', { 'uuid': application.teamer.uuid, 'r': return_url() }) }}">
|
||||||
|
{{ application.teamer }}
|
||||||
|
</a>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
{{ application.requests|nl2br }}
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
{{ ('label.application.status.' ~ application.status)|trans }}
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<div class="flex items-center justify-end space-x-2">
|
||||||
|
{% if is_granted('DISPOSE', application) %}
|
||||||
|
<button type="button"
|
||||||
|
class="btn"
|
||||||
|
{{ stimulus_controller('modal-button', [], [], {'confirmation-modal': '#confirmation-modal'}) }}
|
||||||
|
{{ stimulus_action('modal-button', 'confirmation', null, {
|
||||||
|
'title': 'Bist du sicher?',
|
||||||
|
'content': 'Möchtest du den Teamer ' ~ application.teamer ~ ' wirklich einteilen?',
|
||||||
|
'target-url': path('app_admin_application_dispose', { 'uuid': application.uuid })
|
||||||
|
}) }}>
|
||||||
|
einteilen
|
||||||
|
</button>
|
||||||
|
{% endif %}
|
||||||
|
{% if is_granted('REJECT', application) %}
|
||||||
|
<button type="button" class="btn btn--secondary"
|
||||||
|
{{ stimulus_controller('modal-button', [], [], {'confirmation-modal': '#confirmation-modal'}) }}
|
||||||
|
{{ stimulus_action('modal-button', 'confirmation', null, {
|
||||||
|
'title': 'Bist du sicher?',
|
||||||
|
'content': 'Möchtest du die Bewerbung von ' ~ application.teamer ~ ' wirklich ablehnen?',
|
||||||
|
'target-url': path('app_admin_application_reject', { 'uuid': application.uuid })
|
||||||
|
}) }}>
|
||||||
|
ablehnen
|
||||||
|
</button>
|
||||||
|
{% endif %}
|
||||||
|
{% if is_granted('DELETE', application) %}
|
||||||
|
<button type="button" class="btn btn--secondary"
|
||||||
|
{{ stimulus_controller('modal-button', [], [], {'confirmation-modal': '#confirmation-modal'}) }}
|
||||||
|
{{ stimulus_action('modal-button', 'confirmation', null, {
|
||||||
|
'title': 'Bist du sicher?',
|
||||||
|
'content': 'Möchtest du die Bewerbung von ' ~ application.teamer ~ ' wirklich löschen?',
|
||||||
|
'target-url': path('app_admin_application_delete', { 'uuid': application.uuid })
|
||||||
|
}) }}>
|
||||||
|
löschen
|
||||||
|
</button>
|
||||||
|
{% endif %}
|
||||||
|
</div>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
{% else %}
|
||||||
|
<tr>
|
||||||
|
<td colspan="3">
|
||||||
|
<div class="text-center">
|
||||||
|
Bisher liegen keine Bewerbungen vor
|
||||||
|
</div>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
{% endfor %}
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<a href="{{ returnUrl }}" class="underline">
|
||||||
|
zurück
|
||||||
|
</a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
@@ -57,14 +57,14 @@
|
|||||||
{{ assignment.pickupDate ? assignment.pickupDate|date('d.m.Y') : '' }}
|
{{ assignment.pickupDate ? assignment.pickupDate|date('d.m.Y') : '' }}
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
{{ assignment.applications|length }}
|
{{ assignment.applications|length }}/{{ assignment.availableDispositions }}
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<div class="flex items-center space-x-1 justify-end">
|
<div class="flex items-center space-x-1 justify-end">
|
||||||
<a href="{{ path('app_admin_assignment_detail', { 'uuid': assignment.uuid }) }}">
|
<a href="{{ path('app_admin_assignment_detail', { 'uuid': assignment.uuid, 'r': return_url() }) }}">
|
||||||
{{ icon('info', 'w-5 h-5') }}
|
{{ icon('info', 'w-5 h-5') }}
|
||||||
</a>
|
</a>
|
||||||
<a href="{{ path('app_admin_assignment_edit', { 'uuid': assignment.uuid}) }}">
|
<a href="{{ path('app_admin_assignment_edit', { 'uuid': assignment.uuid, 'r': return_url() }) }}">
|
||||||
{{ icon('edit', 'w-5 h-5') }}
|
{{ icon('edit', 'w-5 h-5') }}
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Reference in New Issue
Block a user