diff --git a/migrations/Version20231025131443.php b/migrations/Version20231025131443.php new file mode 100644 index 0000000..57deeb7 --- /dev/null +++ b/migrations/Version20231025131443.php @@ -0,0 +1,35 @@ +addSql('ALTER TABLE application DROP FOREIGN KEY FK_A45BDDC1DF01D017'); + $this->addSql('DROP INDEX IDX_A45BDDC1DF01D017 ON application'); + $this->addSql('ALTER TABLE application ADD comment_visible TINYINT(1) NOT NULL, DROP remarks_by_id, CHANGE remarks comment LONGTEXT DEFAULT NULL'); + } + + public function down(Schema $schema): void + { + // this down() migration is auto-generated, please modify it to your needs + $this->addSql('ALTER TABLE application ADD remarks_by_id INT DEFAULT NULL, DROP comment_visible, CHANGE comment remarks LONGTEXT DEFAULT NULL'); + $this->addSql('ALTER TABLE application ADD CONSTRAINT FK_A45BDDC1DF01D017 FOREIGN KEY (remarks_by_id) REFERENCES user (id)'); + $this->addSql('CREATE INDEX IDX_A45BDDC1DF01D017 ON application (remarks_by_id)'); + } +} diff --git a/src/Controller/Admin/Application/StatusController.php b/src/Controller/Admin/Application/StatusController.php index 29af882..1b37184 100644 --- a/src/Controller/Admin/Application/StatusController.php +++ b/src/Controller/Admin/Application/StatusController.php @@ -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(), ]); diff --git a/src/Entity/Application.php b/src/Entity/Application.php index 801d8a2..10b16ca 100644 --- a/src/Entity/Application.php +++ b/src/Entity/Application.php @@ -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; } diff --git a/src/Entity/Disposition.php b/src/Entity/Disposition.php index ef544c8..1f01974 100644 --- a/src/Entity/Disposition.php +++ b/src/Entity/Disposition.php @@ -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(); } diff --git a/src/Event/ApplicationStatusEvent.php b/src/Event/ApplicationStatusEvent.php index 0ccb0da..9ee5770 100644 --- a/src/Event/ApplicationStatusEvent.php +++ b/src/Event/ApplicationStatusEvent.php @@ -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(); diff --git a/src/Form/ApplicationCheckType.php b/src/Form/ApplicationStatusType.php similarity index 73% rename from src/Form/ApplicationCheckType.php rename to src/Form/ApplicationStatusType.php index 9f58fc9..acfd4f1 100644 --- a/src/Form/ApplicationCheckType.php +++ b/src/Form/ApplicationStatusType.php @@ -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, ]); } } \ No newline at end of file diff --git a/src/Form/AssignmentType.php b/src/Form/AssignmentType.php index 4a4a09f..058f2f7 100644 --- a/src/Form/AssignmentType.php +++ b/src/Form/AssignmentType.php @@ -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) { diff --git a/src/Menu/AbstractMenuBuilder.php b/src/Menu/AbstractMenuBuilder.php index cdcad50..7466167 100644 --- a/src/Menu/AbstractMenuBuilder.php +++ b/src/Menu/AbstractMenuBuilder.php @@ -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') ; } diff --git a/src/Menu/AdminMenuBuilder.php b/src/Menu/AdminMenuBuilder.php index 9de5f5c..a2ffb6b 100644 --- a/src/Menu/AdminMenuBuilder.php +++ b/src/Menu/AdminMenuBuilder.php @@ -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(), diff --git a/src/Model/ApplicationCheckDto.php b/src/Model/ApplicationStatusDto.php similarity index 63% rename from src/Model/ApplicationCheckDto.php rename to src/Model/ApplicationStatusDto.php index 56003bb..e1df01b 100644 --- a/src/Model/ApplicationCheckDto.php +++ b/src/Model/ApplicationStatusDto.php @@ -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; + } } \ No newline at end of file diff --git a/src/Twig/AppRuntime.php b/src/Twig/AppRuntime.php index 1946230..0b3d288 100644 --- a/src/Twig/AppRuntime.php +++ b/src/Twig/AppRuntime.php @@ -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 diff --git a/templates/admin/application/index.html.twig b/templates/admin/application/index.html.twig index 21d377e..628b531 100644 --- a/templates/admin/application/index.html.twig +++ b/templates/admin/application/index.html.twig @@ -24,7 +24,7 @@ {{ knp_pagination_sortable(pagination, 'Bus', 'destination.pickup') }} - {{ knp_pagination_sortable(pagination, 'Bewerber*in', 'teamer.lastName') }} + {{ knp_pagination_sortable(pagination, 'Bewerber:in', 'teamer.lastName') }} @@ -74,7 +74,7 @@ aria-label="Bewerber:innen-Info anzeigen" {{ stimulus_controller('modal-button', [], [], {'ajax-modal': '#ajax-modal'}) }} {{ stimulus_action('modal-button', 'ajax', 'click', { - 'title': 'Teeamer-Info ' ~ application.teamer, + 'title': 'Teamer:innen-Info ' ~ application.teamer, 'url': path('app_admin_application_info', { 'uuid': application.uuid }) }) }}> {% if assignment.pickup %} diff --git a/templates/admin/application/status.html.twig b/templates/admin/application/status.html.twig index 29f8e9e..6890d1f 100644 --- a/templates/admin/application/status.html.twig +++ b/templates/admin/application/status.html.twig @@ -2,6 +2,7 @@
{{ form_row(form.status) }} {{ form_row(form.comment) }} + {{ form_row(form.commentVisible) }}