Feat: Implement duplicating assignments for admins
This commit is contained in:
@@ -87,6 +87,9 @@
|
|||||||
<symbol id="icon-hand" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" xmlns="http://www.w3.org/2000/svg">
|
<symbol id="icon-hand" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" xmlns="http://www.w3.org/2000/svg">
|
||||||
<path stroke-linecap="round" stroke-linejoin="round" d="M10.05 4.575a1.575 1.575 0 10-3.15 0v3m3.15-3v-1.5a1.575 1.575 0 013.15 0v1.5m-3.15 0l.075 5.925m3.075.75V4.575m0 0a1.575 1.575 0 013.15 0V15M6.9 7.575a1.575 1.575 0 10-3.15 0v8.175a6.75 6.75 0 006.75 6.75h2.018a5.25 5.25 0 003.712-1.538l1.732-1.732a5.25 5.25 0 001.538-3.712l.003-2.024a.668.668 0 01.198-.471 1.575 1.575 0 10-2.228-2.228 3.818 3.818 0 00-1.12 2.687M6.9 7.575V12m6.27 4.318A4.49 4.49 0 0116.35 15m.002 0h-.002" />
|
<path stroke-linecap="round" stroke-linejoin="round" d="M10.05 4.575a1.575 1.575 0 10-3.15 0v3m3.15-3v-1.5a1.575 1.575 0 013.15 0v1.5m-3.15 0l.075 5.925m3.075.75V4.575m0 0a1.575 1.575 0 013.15 0V15M6.9 7.575a1.575 1.575 0 10-3.15 0v8.175a6.75 6.75 0 006.75 6.75h2.018a5.25 5.25 0 003.712-1.538l1.732-1.732a5.25 5.25 0 001.538-3.712l.003-2.024a.668.668 0 01.198-.471 1.575 1.575 0 10-2.228-2.228 3.818 3.818 0 00-1.12 2.687M6.9 7.575V12m6.27 4.318A4.49 4.49 0 0116.35 15m.002 0h-.002" />
|
||||||
</symbol>
|
</symbol>
|
||||||
|
<symbol id="icon-copy" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" xmlns="http://www.w3.org/2000/svg">
|
||||||
|
<path stroke-linecap="round" stroke-linejoin="round" d="M16.5 8.25V6a2.25 2.25 0 00-2.25-2.25H6A2.25 2.25 0 003.75 6v8.25A2.25 2.25 0 006 16.5h2.25m8.25-8.25H18a2.25 2.25 0 012.25 2.25V18A2.25 2.25 0 0118 20.25h-7.5A2.25 2.25 0 018.25 18v-1.5m8.25-8.25h-6a2.25 2.25 0 00-2.25 2.25v6" />
|
||||||
|
</symbol>
|
||||||
<symbol id="icon-photo" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor">
|
<symbol id="icon-photo" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor">
|
||||||
<path stroke-linecap="round" stroke-linejoin="round" d="M2.25 15.75l5.159-5.159a2.25 2.25 0 013.182 0l5.159 5.159m-1.5-1.5l1.409-1.409a2.25 2.25 0 013.182 0l2.909 2.909m-18 3.75h16.5a1.5 1.5 0 001.5-1.5V6a1.5 1.5 0 00-1.5-1.5H3.75A1.5 1.5 0 002.25 6v12a1.5 1.5 0 001.5 1.5zm10.5-11.25h.008v.008h-.008V8.25zm.375 0a.375.375 0 11-.75 0 .375.375 0 01.75 0z" />
|
<path stroke-linecap="round" stroke-linejoin="round" d="M2.25 15.75l5.159-5.159a2.25 2.25 0 013.182 0l5.159 5.159m-1.5-1.5l1.409-1.409a2.25 2.25 0 013.182 0l2.909 2.909m-18 3.75h16.5a1.5 1.5 0 001.5-1.5V6a1.5 1.5 0 00-1.5-1.5H3.75A1.5 1.5 0 002.25 6v12a1.5 1.5 0 001.5 1.5zm10.5-11.25h.008v.008h-.008V8.25zm.375 0a.375.375 0 11-.75 0 .375.375 0 01.75 0z" />
|
||||||
</symbol>
|
</symbol>
|
||||||
|
|||||||
|
Before Width: | Height: | Size: 28 KiB After Width: | Height: | Size: 28 KiB |
@@ -12,7 +12,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 EditController extends AbstractController
|
class DuplicateController extends AbstractController
|
||||||
{
|
{
|
||||||
public function __construct(
|
public function __construct(
|
||||||
private readonly EntityManagerInterface $entityManager,
|
private readonly EntityManagerInterface $entityManager,
|
||||||
@@ -20,26 +20,31 @@ class EditController extends AbstractController
|
|||||||
) {
|
) {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[Route('/admin/assignment/edit/{uuid}', name: 'app_admin_assignment_edit')]
|
#[Route('/admin/assignment/duplicate/{uuid}', name: 'app_admin_assignment_duplicate')]
|
||||||
#[IsGranted('ROLE_ADMINISTRATIVE')]
|
#[IsGranted('ROLE_ADMINISTRATIVE')]
|
||||||
public function index(Assignment $assignment, Request $request): Response
|
public function index(Assignment $assignment, Request $request): Response
|
||||||
{
|
{
|
||||||
$form = $this->createForm(AssignmentType::class, $assignment);
|
$copy = Assignment::duplicate($assignment);
|
||||||
|
|
||||||
|
$form = $this->createForm(AssignmentType::class, $copy);
|
||||||
$form->handleRequest($request);
|
$form->handleRequest($request);
|
||||||
|
|
||||||
if ($form->isSubmitted() && $form->isValid()) {
|
if ($form->isSubmitted() && $form->isValid()) {
|
||||||
|
$this->entityManager->persist($copy);
|
||||||
$this->entityManager->flush();
|
$this->entityManager->flush();
|
||||||
|
|
||||||
$this->addFlash('success', 'Der Einsatz wurde aktualisiert');
|
$this->addFlash('success', 'Der Einsatz wurde dupliziert');
|
||||||
|
|
||||||
$this->logger->info('Edit assignment', [
|
$this->logger->info('Duplicate assignment', [
|
||||||
'assignment' => $assignment->getUuid(),
|
'assignment' => $assignment->getUuid(),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
return $this->redirectToRoute('app_admin_assignment_index');
|
return $this->redirectToRoute('app_admin_assignment_edit', [
|
||||||
|
'uuid' => $copy->getUuid(),
|
||||||
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->render('admin/assignment/edit.html.twig', [
|
return $this->render('admin/assignment/duplicate.html.twig', [
|
||||||
'form' => $form,
|
'form' => $form,
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -90,6 +90,34 @@ class Assignment implements BlameableEntityInterface, TimestampableEntityInterfa
|
|||||||
$this->documents = new ArrayCollection();
|
$this->documents = new ArrayCollection();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static function duplicate(Assignment $assignment): static
|
||||||
|
{
|
||||||
|
$instance = new static();
|
||||||
|
|
||||||
|
$instance
|
||||||
|
->setDestination($assignment->getDestination())
|
||||||
|
->setJobProfile($assignment->getJobProfile())
|
||||||
|
->setAvailableDispositions($assignment->getAvailableDispositions())
|
||||||
|
->setShowAvailableDispositions($assignment->isShowAvailableDispositions())
|
||||||
|
->setDateFrom($assignment->getDateFrom())
|
||||||
|
->setDateTo($assignment->getDateTo())
|
||||||
|
->setPickupDate($assignment->getPickupDate())
|
||||||
|
->setPickup($assignment->getPickup())
|
||||||
|
->setBenefits($assignment->getBenefits())
|
||||||
|
->setContact($assignment->getContact())
|
||||||
|
;
|
||||||
|
|
||||||
|
$assignment->getFees()->map(function (Fee $fee) use ($instance) {
|
||||||
|
$instance->addFee($fee);
|
||||||
|
});
|
||||||
|
|
||||||
|
$assignment->getDocuments()->map(function (Upload $document) use ($instance) {
|
||||||
|
$instance->addDocument($document);
|
||||||
|
});
|
||||||
|
|
||||||
|
return $instance;
|
||||||
|
}
|
||||||
|
|
||||||
public function getId(): ?int
|
public function getId(): ?int
|
||||||
{
|
{
|
||||||
return $this->id;
|
return $this->id;
|
||||||
|
|||||||
@@ -0,0 +1,10 @@
|
|||||||
|
{% extends 'admin/layout.html.twig' %}
|
||||||
|
|
||||||
|
{% block title %}Einsatz duplizieren{% endblock %}
|
||||||
|
|
||||||
|
{% block content %}
|
||||||
|
<h1 class="text-2xl font-bold pb-8">
|
||||||
|
Einsatz duplizieren
|
||||||
|
</h1>
|
||||||
|
{% include 'admin/assignment/_form.html.twig' %}
|
||||||
|
{% endblock %}
|
||||||
@@ -65,6 +65,9 @@
|
|||||||
</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_duplicate', { 'uuid': assignment.uuid, 'r': return_url() }) }}">
|
||||||
|
{{ icon('copy', 'w-5 h-5') }}
|
||||||
|
</a>
|
||||||
<a href="{{ path('app_admin_assignment_edit', { 'uuid': assignment.uuid, 'r': return_url() }) }}">
|
<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>
|
||||||
|
|||||||
Reference in New Issue
Block a user