Task: Misc adjustments

This commit is contained in:
Björn Fromme
2023-10-25 15:22:38 +02:00
parent 3e540e215d
commit 011f1faf0f
20 changed files with 125 additions and 57 deletions
@@ -4,9 +4,9 @@ namespace App\Controller\Admin\Application;
use App\Entity\Application;
use App\Event\ApplicationStatusEvent;
use App\Form\ApplicationCheckType;
use App\Form\ApplicationStatusType;
use App\Model\AjaxModalResponseDto;
use App\Model\ApplicationCheckDto;
use App\Model\ApplicationStatusDto;
use Doctrine\ORM\EntityManagerInterface;
use Psr\Log\LoggerInterface;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
@@ -32,20 +32,24 @@ class StatusController extends AbstractController
{
$response = new AjaxModalResponseDto();
$formAction = $this->generateUrl('app_admin_application_status', ['uuid' => $application->getUuid()]);
$formData = new ApplicationCheckDto($application);
$form = $this->createForm(ApplicationCheckType::class, $formData, ['action' => $formAction, 'ajax_submit' => true]);
$statusDto = new ApplicationStatusDto($application);
$form = $this->createForm(ApplicationStatusType::class, $statusDto, ['action' => $formAction, 'ajax_submit' => true]);
$form->handleRequest($request);
if ($form->isSubmitted() && $form->isValid()) {
$this->eventDispatcher->dispatch(new ApplicationStatusEvent($formData), ApplicationStatusEvent::NAME);
$application->setStatus($formData->getStatus());
$this->eventDispatcher->dispatch(new ApplicationStatusEvent($statusDto), ApplicationStatusEvent::NAME);
$application
->setStatus($statusDto->getStatus())
->setComment($statusDto->getComment())
->setCommentVisible($statusDto->isCommentVisible())
;
$this->entityManager->flush();
$this->addFlash('success', 'Der Status der Bewerbung wurde aktualisiert');
$this->logger->info('Update application status', [
'application_id' => $application->getId(),
'status_new' => $formData->getStatus(),
'status_new' => $statusDto->getStatus(),
'teamer' => (string) $application->getTeamer(),
]);
+19 -19
View File
@@ -38,10 +38,10 @@ class Application implements TimestampableEntityInterface
private ?string $status;
#[ORM\Column(type: Types::TEXT, nullable: true)]
private ?string $remarks = null;
private ?string $comment = null;
#[ORM\ManyToOne]
private ?User $remarksBy = null;
#[ORM\Column]
private ?bool $commentVisible = false;
public function __construct(Assignment $assignment, Teamer $teamer)
{
@@ -109,18 +109,6 @@ class Application implements TimestampableEntityInterface
return $this;
}
public function getRemarks(): ?string
{
return $this->remarks;
}
public function setRemarks(?string $remarks): static
{
$this->remarks = $remarks;
return $this;
}
public function matchesPickup(): bool
{
if (0 === $pickupId = (int) $this->getAssignment()->getPickup()) {
@@ -147,14 +135,26 @@ class Application implements TimestampableEntityInterface
return $count === $requiredTrainings->count();
}
public function getRemarksBy(): ?User
public function getComment(): ?string
{
return $this->remarksBy;
return $this->comment;
}
public function setRemarksBy(?User $remarksBy): static
public function setComment(?string $comment): static
{
$this->remarksBy = $remarksBy;
$this->comment = $comment;
return $this;
}
public function isCommentVisible(): ?bool
{
return $this->commentVisible;
}
public function setCommentVisible(bool $commentVisible): static
{
$this->commentVisible = $commentVisible;
return $this;
}
-1
View File
@@ -54,7 +54,6 @@ class Disposition implements BlameableEntityInterface, TimestampableEntityInterf
$this->status = static::STATUS_NEW;
$this->assignment = $application->getAssignment();
$this->teamer = $application->getTeamer();
$this->remarks = $application->getRemarks();
$this->documents = new ArrayCollection();
}
+2 -2
View File
@@ -3,7 +3,7 @@
namespace App\Event;
use App\Entity\Application;
use App\Model\ApplicationCheckDto;
use App\Model\ApplicationStatusDto;
use Symfony\Contracts\EventDispatcher\Event;
class ApplicationStatusEvent extends Event
@@ -13,7 +13,7 @@ class ApplicationStatusEvent extends Event
private Application $application;
private ?string $comment;
public function __construct(ApplicationCheckDto $applicationCheckDto)
public function __construct(ApplicationStatusDto $applicationCheckDto)
{
$this->application = $applicationCheckDto->getApplication();
$this->comment = $applicationCheckDto->getComment();
@@ -3,14 +3,15 @@
namespace App\Form;
use App\Entity\Application;
use App\Model\ApplicationCheckDto;
use App\Model\ApplicationStatusDto;
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\TextareaType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
class ApplicationCheckType extends AbstractType
class ApplicationStatusType extends AbstractType
{
public function buildForm(FormBuilderInterface $builder, array $options): void
{
@@ -29,13 +30,17 @@ class ApplicationCheckType extends AbstractType
'rows' => 3,
],
])
->add('commentVisible', CheckboxType::class, [
'label' => 'Kommentar/Begründung sichtbar für Teamer:in',
'required' => false,
])
;
}
public function configureOptions(OptionsResolver $resolver): void
{
$resolver->setDefaults([
'data_class' => ApplicationCheckDto::class,
'data_class' => ApplicationStatusDto::class,
]);
}
}
+1 -1
View File
@@ -86,7 +86,7 @@ class AssignmentType extends AbstractType
'expanded' => true,
])
->add('contact', EntityType::class, [
'label' => 'Ansprechpartner RM',
'label' => 'Ansprechperson für den Einsatz',
'class' => User::class,
'choice_label' => 'fullName',
'query_builder' => function (EntityRepository $repository) {
+2 -2
View File
@@ -92,8 +92,8 @@ abstract class AbstractMenuBuilder
{
if ($this->security->isGranted('ROLE_TEAMER')) {
$menu
->addChild('zum Teamerbereich', ['route' => 'app_teamer_index'])
->setChildrenAttribute('title', 'zum Teamerbereich')
->addChild('zum Teamer:innenbereich', ['route' => 'app_teamer_index'])
->setChildrenAttribute('title', 'zum Teamer:innenbereich')
->setExtra('icon', 'user')
;
}
+1 -1
View File
@@ -39,7 +39,7 @@ class AdminMenuBuilder extends AbstractMenuBuilder
],
[
'route' => 'app_admin_teamer_index',
'title' => 'Teamerübersicht',
'title' => 'Teamer:innenübersicht',
'icon' => 'users',
'hideChildren' => true,
'children' => $this->getTeamerMenuItems(),
@@ -4,16 +4,19 @@ namespace App\Model;
use App\Entity\Application;
class ApplicationCheckDto
class ApplicationStatusDto
{
private Application $application;
private string $status;
private ?string $comment = null;
private ?string $comment;
private bool $commentVisible;
public function __construct(Application $application)
{
$this->application = $application;
$this->status = $application->getStatus();
$this->comment = $application->getComment();
$this->commentVisible = $application->isCommentVisible();
}
public function getApplication(): Application
@@ -44,4 +47,16 @@ class ApplicationCheckDto
return $this;
}
public function isCommentVisible(): bool
{
return $this->commentVisible;
}
public function setCommentVisible(bool $commentVisible): static
{
$this->commentVisible = $commentVisible;
return $this;
}
}
+2 -2
View File
@@ -28,10 +28,10 @@ class AppRuntime implements RuntimeExtensionInterface
public function teamerStatusLabel(string $status): string
{
if (Teamer::STATUS_NEW === $status) {
return 'Neuteamer';
return 'Neuteamer:in';
}
return 'Bestandsteamer';
return 'Bestandsteamer:in';
}
public function licenseLabel(string $type): string