From 1e572606f802f8ab19696f173b17c511073be59b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Fromme?= Date: Tue, 6 Feb 2024 17:45:34 +0100 Subject: [PATCH] feat: integrate with htmx --- assets/app.js | 1 + assets/controllers/ajax_modal_controller.js | 86 ------------------- .../confirmation_modal_controller.js | 17 ---- assets/controllers/form_partial_controller.js | 35 -------- assets/controllers/modal_button_controller.js | 13 --- assets/controllers/modal_controller.js | 7 ++ assets/styles/_base.css | 10 +++ assets/styles/components/button.css | 3 +- package-lock.json | 6 ++ package.json | 1 + .../Admin/Application/DisposeController.php | 36 +++++--- .../Admin/Application/InfoController.php | 12 +-- .../Admin/Application/StatusController.php | 20 ++--- .../Admin/Assignment/CreateController.php | 10 ++- .../Admin/Assignment/DeleteController.php | 30 ++++--- .../Admin/Assignment/DuplicateController.php | 10 ++- .../Admin/Assignment/EditController.php | 10 ++- .../Admin/Disposition/DeleteController.php | 20 ++--- .../Admin/Document/CheckController.php | 31 ++----- .../Admin/Document/DeleteController.php | 26 ++++-- .../Admin/Feedback/ApproveController.php | 23 ++--- .../System/Availability/CreateController.php | 23 ++--- .../System/Availability/DeleteController.php | 26 ++++-- .../Availability/DuplicateController.php | 23 ++--- .../System/Availability/EditController.php | 23 ++--- .../Admin/System/Contact/CreateController.php | 28 ++---- .../Admin/System/Contact/DeleteController.php | 26 ++++-- .../Admin/System/Contact/EditController.php | 28 ++---- .../System/Document/DeleteController.php | 26 ++++-- .../Admin/System/Document/EditController.php | 22 ++--- .../System/Document/ReplaceController.php | 17 ++-- .../System/Document/UploadController.php | 24 +++--- .../Admin/System/Faq/DeleteController.php | 28 +++--- .../Admin/System/Fee/CreateController.php | 23 ++--- .../Admin/System/Fee/DeleteController.php | 28 +++--- .../Admin/System/Fee/DuplicateController.php | 24 ++---- .../Admin/System/Fee/EditController.php | 23 ++--- .../System/FeedbackSet/DeleteController.php | 28 +++--- .../System/JobProfile/DeleteController.php | 28 +++--- .../System/Training/CreateController.php | 23 ++--- .../System/Training/DeleteController.php | 28 +++--- .../Admin/System/Training/EditController.php | 23 ++--- .../Teamer/Availability/DeleteController.php | 39 +++++---- .../IndexController.php} | 6 +- .../Admin/Teamer/InfoController.php | 12 +-- .../TrainingAttendance/CreateController.php | 27 ++---- .../TrainingAttendance/DeleteController.php | 38 +++++--- .../Common/AssignmentFilterController.php | 22 ++--- .../Common/TeamerFilterController.php | 25 ++---- .../Teamer/Application/WithdrawController.php | 37 ++++---- src/Controller/Teamer/FeedbackController.php | 12 +-- .../Profile/Availability/CreateController.php | 23 ++--- .../Profile/Availability/DeleteController.php | 42 +++++---- .../Teamer/Profile/License/AddController.php | 31 ++----- .../Profile/License/DeleteController.php | 30 ++++--- src/Form/AssignmentType.php | 8 +- src/Form/Extension/AjaxSubmitExtension.php | 32 ------- src/Htmx/HxRedirectResponse.php | 13 +++ src/Model/AjaxModalResponseDto.php | 53 ------------ src/Security/Voter/ApplicationVoter.php | 9 +- src/Security/Voter/AssignmentVoter.php | 12 ++- src/Security/Voter/DispositionVoter.php | 13 +-- src/Security/Voter/UploadVoter.php | 7 +- templates/_partials/_ajax_modal.html.twig | 22 ----- .../_partials/_confirmation_modal.html.twig | 28 ------ templates/admin/application/index.html.twig | 10 +-- templates/admin/application/info.html.twig | 44 ---------- .../admin/application/modal_delete.html.twig | 7 ++ .../admin/application/modal_dispose.html.twig | 7 ++ .../admin/application/modal_info.html.twig | 50 +++++++++++ .../admin/application/modal_status.html.twig | 17 ++++ templates/admin/application/status.html.twig | 11 --- templates/admin/assignment/_form.html.twig | 84 +++++++++--------- templates/admin/assignment/detail.html.twig | 59 ++++++------- templates/admin/assignment/index.html.twig | 20 ++--- .../admin/assignment/modal_delete.html.twig | 7 ++ templates/admin/disposition/delete.html.twig | 9 -- .../admin/disposition/modal_delete.html.twig | 15 ++++ templates/admin/document/check.html.twig | 13 --- templates/admin/document/index.html.twig | 17 ++-- .../admin/document/modal_check.html.twig | 19 ++++ .../admin/document/modal_delete.html.twig | 7 ++ templates/admin/feedback/approve.html.twig | 10 --- .../admin/feedback/modal_approve.html.twig | 16 ++++ templates/admin/index.html.twig | 14 ++- .../system/availability/_form.html.twig} | 2 +- .../admin/system/availability/form.html.twig | 11 --- .../admin/system/availability/index.html.twig | 37 ++++---- .../availability/modal_create.html.twig | 7 ++ .../availability/modal_delete.html.twig | 7 ++ .../availability/modal_duplicate.html.twig | 7 ++ .../system/availability/modal_edit.html.twig | 7 ++ .../admin/system/contact/_form.html.twig | 2 +- .../admin/system/contact/create.html.twig | 1 - templates/admin/system/contact/edit.html.twig | 1 - .../admin/system/contact/index.html.twig | 28 +++--- .../system/contact/modal_create.html.twig | 7 ++ .../system/contact/modal_delete.html.twig | 7 ++ .../admin/system/contact/modal_edit.html.twig | 7 ++ .../admin/system/document/edit.html.twig | 9 -- .../admin/system/document/index.html.twig | 33 +++---- .../system/document/modal_delete.html.twig | 7 ++ .../system/document/modal_edit.html.twig | 15 ++++ .../system/document/modal_replace.html.twig | 20 +++++ .../system/document/modal_upload.html.twig | 19 ++++ .../admin/system/document/replace.html.twig | 14 --- .../admin/system/document/upload.html.twig | 13 --- templates/admin/system/faq/index.html.twig | 10 +-- .../admin/system/faq/modal_delete.html.twig | 7 ++ .../fee/{form.html.twig => _form.html.twig} | 2 +- templates/admin/system/fee/index.html.twig | 37 ++++---- .../admin/system/fee/modal_create.html.twig | 7 ++ .../admin/system/fee/modal_delete.html.twig | 7 ++ .../system/fee/modal_duplicate.html.twig | 7 ++ .../admin/system/fee/modal_edit.html.twig | 7 ++ .../admin/system/feedback_set/index.html.twig | 9 +- .../feedback_set/modal_delete.html.twig | 7 ++ .../admin/system/job_profile/index.html.twig | 10 +-- .../system/job_profile/modal_delete.html.twig | 7 ++ .../{form.html.twig => _form.html.twig} | 2 +- .../admin/system/training/index.html.twig | 28 +++--- .../system/training/modal_create.hml.twig | 7 ++ .../system/training/modal_delete.html.twig | 13 +++ .../admin/system/training/modal_edit.hml.twig | 7 ++ .../index.html.twig} | 11 +-- .../availability/modal_delete.html.twig | 7 ++ templates/admin/teamer/index.html.twig | 23 +++-- templates/admin/teamer/info.html.twig | 67 --------------- templates/admin/teamer/modal_info.html.twig | 73 ++++++++++++++++ templates/admin/teamer/skills.html.twig | 18 ++-- .../training_attendance/create.html.twig | 9 -- .../modal_create.html.twig | 15 ++++ .../modal_delete.html.twig | 8 ++ templates/common/assignment_filter.html.twig | 15 ---- .../common/modal_assignment_filter.html.twig | 21 +++++ .../common/modal_teamer_filter.html.twig | 22 +++++ templates/common/teamer_filter.html.twig | 16 ---- templates/forms.html.twig | 1 + templates/htmx_confirmation_modal.html.twig | 25 ++++++ templates/htmx_modal.html.twig | 21 +++++ templates/layout.html.twig | 2 - .../application/modal_withdraw.html.twig | 5 ++ templates/teamer/assignment/detail.html.twig | 9 +- templates/teamer/assignment/index.html.twig | 22 ++--- templates/teamer/feedback/index.html.twig | 14 --- templates/teamer/feedback/modal.html.twig | 20 +++++ templates/teamer/index.html.twig | 19 ++-- .../profile/availability/index.html.twig | 18 ++-- .../availability/modal_create.html.twig | 17 ++++ .../availability/modal_delete.html.twig | 8 ++ .../teamer/profile/license/add.html.twig | 25 ------ .../profile/license/modal_add.html.twig | 31 +++++++ .../profile/license/modal_delete.html.twig | 7 ++ templates/teamer/profile/skills.html.twig | 18 ++-- 154 files changed, 1447 insertions(+), 1461 deletions(-) delete mode 100644 assets/controllers/ajax_modal_controller.js delete mode 100644 assets/controllers/confirmation_modal_controller.js delete mode 100644 assets/controllers/form_partial_controller.js delete mode 100644 assets/controllers/modal_button_controller.js create mode 100644 assets/controllers/modal_controller.js rename src/Controller/Admin/Teamer/{AvailabilityController.php => Availability/IndexController.php} (81%) delete mode 100644 src/Form/Extension/AjaxSubmitExtension.php create mode 100644 src/Htmx/HxRedirectResponse.php delete mode 100644 src/Model/AjaxModalResponseDto.php delete mode 100644 templates/_partials/_ajax_modal.html.twig delete mode 100644 templates/_partials/_confirmation_modal.html.twig delete mode 100644 templates/admin/application/info.html.twig create mode 100644 templates/admin/application/modal_delete.html.twig create mode 100644 templates/admin/application/modal_dispose.html.twig create mode 100644 templates/admin/application/modal_info.html.twig create mode 100644 templates/admin/application/modal_status.html.twig delete mode 100644 templates/admin/application/status.html.twig create mode 100644 templates/admin/assignment/modal_delete.html.twig delete mode 100644 templates/admin/disposition/delete.html.twig create mode 100644 templates/admin/disposition/modal_delete.html.twig delete mode 100644 templates/admin/document/check.html.twig create mode 100644 templates/admin/document/modal_check.html.twig create mode 100644 templates/admin/document/modal_delete.html.twig delete mode 100644 templates/admin/feedback/approve.html.twig create mode 100644 templates/admin/feedback/modal_approve.html.twig rename templates/{teamer/profile/availability/create.html.twig => admin/system/availability/_form.html.twig} (68%) delete mode 100644 templates/admin/system/availability/form.html.twig create mode 100644 templates/admin/system/availability/modal_create.html.twig create mode 100644 templates/admin/system/availability/modal_delete.html.twig create mode 100644 templates/admin/system/availability/modal_duplicate.html.twig create mode 100644 templates/admin/system/availability/modal_edit.html.twig delete mode 100644 templates/admin/system/contact/create.html.twig delete mode 100644 templates/admin/system/contact/edit.html.twig create mode 100644 templates/admin/system/contact/modal_create.html.twig create mode 100644 templates/admin/system/contact/modal_delete.html.twig create mode 100644 templates/admin/system/contact/modal_edit.html.twig delete mode 100644 templates/admin/system/document/edit.html.twig create mode 100644 templates/admin/system/document/modal_delete.html.twig create mode 100644 templates/admin/system/document/modal_edit.html.twig create mode 100644 templates/admin/system/document/modal_replace.html.twig create mode 100644 templates/admin/system/document/modal_upload.html.twig delete mode 100644 templates/admin/system/document/replace.html.twig delete mode 100644 templates/admin/system/document/upload.html.twig create mode 100644 templates/admin/system/faq/modal_delete.html.twig rename templates/admin/system/fee/{form.html.twig => _form.html.twig} (67%) create mode 100644 templates/admin/system/fee/modal_create.html.twig create mode 100644 templates/admin/system/fee/modal_delete.html.twig create mode 100644 templates/admin/system/fee/modal_duplicate.html.twig create mode 100644 templates/admin/system/fee/modal_edit.html.twig create mode 100644 templates/admin/system/feedback_set/modal_delete.html.twig create mode 100644 templates/admin/system/job_profile/modal_delete.html.twig rename templates/admin/system/training/{form.html.twig => _form.html.twig} (60%) create mode 100644 templates/admin/system/training/modal_create.hml.twig create mode 100644 templates/admin/system/training/modal_delete.html.twig create mode 100644 templates/admin/system/training/modal_edit.hml.twig rename templates/admin/teamer/{availability.html.twig => availability/index.html.twig} (73%) create mode 100644 templates/admin/teamer/availability/modal_delete.html.twig delete mode 100644 templates/admin/teamer/info.html.twig create mode 100644 templates/admin/teamer/modal_info.html.twig delete mode 100644 templates/admin/teamer/training_attendance/create.html.twig create mode 100644 templates/admin/teamer/training_attendance/modal_create.html.twig create mode 100644 templates/admin/teamer/training_attendance/modal_delete.html.twig delete mode 100644 templates/common/assignment_filter.html.twig create mode 100644 templates/common/modal_assignment_filter.html.twig create mode 100644 templates/common/modal_teamer_filter.html.twig delete mode 100644 templates/common/teamer_filter.html.twig create mode 100644 templates/htmx_confirmation_modal.html.twig create mode 100644 templates/htmx_modal.html.twig create mode 100644 templates/teamer/application/modal_withdraw.html.twig delete mode 100644 templates/teamer/feedback/index.html.twig create mode 100644 templates/teamer/feedback/modal.html.twig create mode 100644 templates/teamer/profile/availability/modal_create.html.twig create mode 100644 templates/teamer/profile/availability/modal_delete.html.twig delete mode 100644 templates/teamer/profile/license/add.html.twig create mode 100644 templates/teamer/profile/license/modal_add.html.twig create mode 100644 templates/teamer/profile/license/modal_delete.html.twig diff --git a/assets/app.js b/assets/app.js index 0224bf8..9c189e3 100644 --- a/assets/app.js +++ b/assets/app.js @@ -1,3 +1,4 @@ +import 'htmx.org'; import './bootstrap.js'; /* * Welcome to your app's main JavaScript file! diff --git a/assets/controllers/ajax_modal_controller.js b/assets/controllers/ajax_modal_controller.js deleted file mode 100644 index f418a63..0000000 --- a/assets/controllers/ajax_modal_controller.js +++ /dev/null @@ -1,86 +0,0 @@ -import { Controller } from '@hotwired/stimulus' -import { useFetch } from '../mixins/use_fetch' - -export default class extends Controller { - - static targets = [ 'title', 'content', 'spinner' ] - static values = { loading: Boolean } - - connect() { - useFetch(this) - } - - show({ title, url }) { - this.titleTarget.innerHTML = title - this.element.classList.remove('hidden') - this.loadContent(url) - } - - hide() { - this.element.classList.add('hidden') - } - - loadContent(url) { - this.loadingValue = true - fetch(url, this.getInitObject()) - .then(this.checkStatus) - .then(this.parseJSON) - .then(response => { - this.handleResponse(response) - }) - .catch(error => { - this.handleResponse(this.createErrorResponse(error)) - }) - .finally(() => { - this.loadingValue = false - }) - } - - submitForm(event) { - event.preventDefault() - this.loadingValue = true - const form = event.target - const formData = new FormData(form) - formData.append(event.submitter.name, event.submitter.value) - fetch(form.action, this.getInitObject('post', formData)) - .then(this.checkStatus) - .then(this.parseJSON) - .then(response => { - this.handleResponse(response) - }) - .catch(error => { - this.handleResponse(this.createErrorResponse(error)) - }) - .finally(() => { - this.loadingValue = false - }) - } - - handleResponse(modalResponse) { - if (modalResponse.redirect) { - window.location = modalResponse.redirect - return - } - - if (true === modalResponse.close) { - this.element.classList.add('hidden') - return - } - - this.contentTarget.innerHTML = modalResponse.content - } - - createErrorResponse(error) { - return { - close: false, - redirect: null, - content: error.message, - } - } - - loadingValueChanged() { - this.spinnerTarget.classList.toggle('hidden', false === this.loadingValue) - this.contentTarget.classList.toggle('hidden', true === this.loadingValue) - } - -} diff --git a/assets/controllers/confirmation_modal_controller.js b/assets/controllers/confirmation_modal_controller.js deleted file mode 100644 index cc8991c..0000000 --- a/assets/controllers/confirmation_modal_controller.js +++ /dev/null @@ -1,17 +0,0 @@ -import { Controller } from '@hotwired/stimulus' - -export default class extends Controller { - static targets = [ 'form', 'title', 'content' ] - - show({ targetUrl, title, content }) { - this.formTarget.action = targetUrl - this.titleTarget.innerText = title - this.contentTarget.innerHTML = content - this.element.classList.remove('hidden') - } - - hide() { - this.element.classList.add('hidden') - } - -} diff --git a/assets/controllers/form_partial_controller.js b/assets/controllers/form_partial_controller.js deleted file mode 100644 index 77170ce..0000000 --- a/assets/controllers/form_partial_controller.js +++ /dev/null @@ -1,35 +0,0 @@ -import { Controller } from '@hotwired/stimulus' -import { useFetch } from '../mixins/use_fetch' - -export default class extends Controller { - - static targets = [ 'form', 'container', 'spinner' ] - static values = { url: String, loading: Boolean } - - connect() { - useFetch(this) - } - - update() { - this.loadingValue = true - const formData = new FormData(this.formTarget) - fetch(this.urlValue, { method: 'POST', body: formData }) - .then(this.checkStatus) - .then(this.parseHTML) - .then(response => { - this.containerTarget.innerHTML = response - }) - .catch(error => { - }) - .finally(() => { - this.loadingValue = false - }) - - } - - loadingValueChanged(loading) { - if (this.hasSpinnerTarget) { - this.spinnerTarget.classList.toggle('hidden', false === loading) - } - } -} \ No newline at end of file diff --git a/assets/controllers/modal_button_controller.js b/assets/controllers/modal_button_controller.js deleted file mode 100644 index 55ac624..0000000 --- a/assets/controllers/modal_button_controller.js +++ /dev/null @@ -1,13 +0,0 @@ -import { Controller } from '@hotwired/stimulus' - -export default class extends Controller { - static outlets = [ 'confirmation-modal', 'ajax-modal' ] - - confirmation({ params: { title, targetUrl, content } }) { - this.confirmationModalOutlet.show({ title, targetUrl, content }) - } - - ajax({ params: { title, url } }) { - this.ajaxModalOutlet.show({ title, url }) - } -} diff --git a/assets/controllers/modal_controller.js b/assets/controllers/modal_controller.js new file mode 100644 index 0000000..cf64a54 --- /dev/null +++ b/assets/controllers/modal_controller.js @@ -0,0 +1,7 @@ +import { Controller } from '@hotwired/stimulus' + +export default class extends Controller { + close() { + this.element.remove() + } +} diff --git a/assets/styles/_base.css b/assets/styles/_base.css index ec185f7..878768c 100644 --- a/assets/styles/_base.css +++ b/assets/styles/_base.css @@ -30,3 +30,13 @@ font-weight: 900; src: url('../fonts/lato-v24-latin-900.woff2') format('woff2'); /* Chrome 36+, Opera 23+, Firefox 39+, Safari 12+, iOS 10+ */ } + +.htmx-indicator{ + @apply invisible; +} +.htmx-request .htmx-indicator{ + @apply visible; +} +.htmx-request.htmx-indicator{ + @apply visible; +} diff --git a/assets/styles/components/button.css b/assets/styles/components/button.css index 8da0b48..426332a 100644 --- a/assets/styles/components/button.css +++ b/assets/styles/components/button.css @@ -1,5 +1,6 @@ .btn { - @apply inline-flex justify-center rounded-lg text-sm uppercase font-semibold py-2.5 px-4 bg-primary text-white hover:bg-primary/80 shadow-md; + @apply inline-flex space-x-1 justify-center rounded-lg text-sm uppercase font-semibold py-2.5 px-4; + @apply bg-primary text-white hover:bg-primary/80 shadow-md; } .btn--small { diff --git a/package-lock.json b/package-lock.json index a7bc7d3..d445333 100644 --- a/package-lock.json +++ b/package-lock.json @@ -7,6 +7,7 @@ "name": "myep-team", "license": "UNLICENSED", "dependencies": { + "htmx.org": "^1.9.10", "sortablejs": "^1.15.0" }, "devDependencies": { @@ -5360,6 +5361,11 @@ "entities": "^2.0.0" } }, + "node_modules/htmx.org": { + "version": "1.9.10", + "resolved": "https://registry.npmjs.org/htmx.org/-/htmx.org-1.9.10.tgz", + "integrity": "sha512-UgchasltTCrTuU2DQLom3ohHrBvwr7OqpwyAVJ9VxtNBng4XKkVsqrv0Qr3srqvM9ZNI3f1MmvVQQqK7KW/bTA==" + }, "node_modules/http-deceiver": { "version": "1.2.7", "resolved": "https://registry.npmjs.org/http-deceiver/-/http-deceiver-1.2.7.tgz", diff --git a/package.json b/package.json index e6de70b..94c44f2 100644 --- a/package.json +++ b/package.json @@ -36,6 +36,7 @@ "mjml": "mjml assets/mjml/layout.mjml -o templates/email/layout.html.twig" }, "dependencies": { + "htmx.org": "^1.9.10", "sortablejs": "^1.15.0" } } diff --git a/src/Controller/Admin/Application/DisposeController.php b/src/Controller/Admin/Application/DisposeController.php index 664d034..ad1558f 100644 --- a/src/Controller/Admin/Application/DisposeController.php +++ b/src/Controller/Admin/Application/DisposeController.php @@ -5,9 +5,11 @@ namespace App\Controller\Admin\Application; use App\Entity\Application; use App\Entity\Disposition; use App\Event\DispositionCreatedEvent; +use App\Htmx\HxRedirectResponse; use Doctrine\ORM\EntityManagerInterface; use Psr\Log\LoggerInterface; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; +use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; use Symfony\Component\Routing\Attribute\Route; use Symfony\Component\Security\Http\Attribute\IsGranted; @@ -25,24 +27,32 @@ class DisposeController extends AbstractController #[Route('/admin/application/dispose/{uuid}', name: 'app_admin_application_dispose')] #[IsGranted('ROLE_ADMINISTRATIVE')] #[IsGranted('DISPOSE', subject: 'application')] - public function index(Application $application): Response + public function index(Application $application, Request $request): Response { - $disposition = new Disposition($application); + if (true === $request->isMethod('POST')) { + $disposition = new Disposition($application); - $this->entityManager->persist($disposition); - $this->entityManager->remove($application); - $this->entityManager->flush(); + $this->entityManager->persist($disposition); + $this->entityManager->remove($application); + $this->entityManager->flush(); - $this->eventDispatcher->dispatch(new DispositionCreatedEvent($disposition), DispositionCreatedEvent::NAME); + $this->eventDispatcher->dispatch(new DispositionCreatedEvent($disposition), DispositionCreatedEvent::NAME); - $this->addFlash('success', 'Teamer:in wurde eingeteilt'); - $this->logger->info('Create disposition', [ - 'disposition_id' => $disposition->getId(), - 'teamer' => (string) $application->getTeamer(), - ]); + $this->addFlash('success', 'Teamer:in wurde eingeteilt'); + $this->logger->info('Create disposition', [ + 'disposition_id' => $disposition->getId(), + 'teamer' => (string) $application->getTeamer(), + ]); - return $this->redirectToRoute('app_admin_assignment_detail', [ - 'uuid' => $application->getAssignment()->getUuid(), + $redirectUrl = $this->generateUrl('app_admin_assignment_detail', [ + 'uuid' => $application->getAssignment()->getUuid(), + ]); + + return new HxRedirectResponse($redirectUrl); + } + + return $this->render('admin/application/modal_dispose.html.twig', [ + 'application' => $application, ]); } } \ No newline at end of file diff --git a/src/Controller/Admin/Application/InfoController.php b/src/Controller/Admin/Application/InfoController.php index 0aea43e..9f81bac 100644 --- a/src/Controller/Admin/Application/InfoController.php +++ b/src/Controller/Admin/Application/InfoController.php @@ -3,21 +3,17 @@ namespace App\Controller\Admin\Application; use App\Entity\Application; -use App\Model\AjaxModalResponseDto; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; -use Symfony\Component\HttpFoundation\JsonResponse; +use Symfony\Component\HttpFoundation\Response; use Symfony\Component\Routing\Attribute\Route; class InfoController extends AbstractController { #[Route('/admin/application/info/{uuid}', name: 'app_admin_application_info')] - public function index(Application $application): JsonResponse + public function index(Application $application): Response { - $response = new AjaxModalResponseDto(); - $response->setContent($this->renderView('admin/application/info.html.twig', [ + return $this->render('admin/application/modal_info.html.twig', [ 'application' => $application, - ])); - - return $this->json($response); + ]); } } \ No newline at end of file diff --git a/src/Controller/Admin/Application/StatusController.php b/src/Controller/Admin/Application/StatusController.php index b6f70b8..6abec3c 100644 --- a/src/Controller/Admin/Application/StatusController.php +++ b/src/Controller/Admin/Application/StatusController.php @@ -5,13 +5,13 @@ namespace App\Controller\Admin\Application; use App\Entity\Application; use App\Event\ApplicationStatusEvent; use App\Form\ApplicationStatusType; -use App\Model\AjaxModalResponseDto; +use App\Htmx\HxRedirectResponse; use App\Model\ApplicationStatusDto; use Doctrine\ORM\EntityManagerInterface; use Psr\Log\LoggerInterface; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; -use Symfony\Component\HttpFoundation\JsonResponse; use Symfony\Component\HttpFoundation\Request; +use Symfony\Component\HttpFoundation\Response; use Symfony\Component\Routing\Attribute\Route; use Symfony\Component\Security\Http\Attribute\IsGranted; use Symfony\Contracts\EventDispatcher\EventDispatcherInterface; @@ -28,12 +28,10 @@ class StatusController extends AbstractController #[Route('/admin/application/status/{uuid}', name: 'app_admin_application_status')] #[IsGranted('ROLE_ADMINISTRATIVE')] #[IsGranted('STATUS', subject: 'application')] - public function index(Application $application, Request $request): JsonResponse + public function index(Application $application, Request $request): Response { - $response = new AjaxModalResponseDto(); - $formAction = $this->generateUrl('app_admin_application_status', ['uuid' => $application->getUuid()]); $statusDto = new ApplicationStatusDto($application); - $form = $this->createForm(ApplicationStatusType::class, $statusDto, ['action' => $formAction, 'ajax_submit' => true]); + $form = $this->createForm(ApplicationStatusType::class, $statusDto); $form->handleRequest($request); @@ -53,15 +51,13 @@ class StatusController extends AbstractController 'teamer' => (string) $application->getTeamer(), ]); - $response->setCloseAndRedirect($this->generateUrl('app_admin_assignment_detail', [ + return new HxRedirectResponse($this->generateUrl('app_admin_assignment_detail', [ 'uuid' => $application->getAssignment()->getUuid(), ])); - } else { - $response->setContent($this->renderView('admin/application/status.html.twig', [ - 'form' => $form, - ])); } - return $this->json($response); + return $this->render('admin/application/modal_status.html.twig', [ + 'form' => $form->createView(), + ]); } } \ No newline at end of file diff --git a/src/Controller/Admin/Assignment/CreateController.php b/src/Controller/Admin/Assignment/CreateController.php index bd481c9..a839ccf 100644 --- a/src/Controller/Admin/Assignment/CreateController.php +++ b/src/Controller/Admin/Assignment/CreateController.php @@ -30,7 +30,13 @@ class CreateController extends AbstractController $assignment = new Assignment(); $assignment->setOwner($user); - $form = $this->createForm(AssignmentType::class, $assignment); + $form = $this->createForm( + AssignmentType::class, + $assignment, + [ + 'pickup_form_url' => $this->generateUrl('app_admin_assignment_pickup_form'), + ] + ); $form->handleRequest($request); if ($form->isSubmitted() && $form->isValid()) { @@ -49,7 +55,7 @@ class CreateController extends AbstractController } return $this->render('admin/assignment/create.html.twig', [ - 'form' => $form, + 'form' => $form->createView(), ]); } } \ No newline at end of file diff --git a/src/Controller/Admin/Assignment/DeleteController.php b/src/Controller/Admin/Assignment/DeleteController.php index 9b85296..6cfac6e 100644 --- a/src/Controller/Admin/Assignment/DeleteController.php +++ b/src/Controller/Admin/Assignment/DeleteController.php @@ -3,9 +3,11 @@ namespace App\Controller\Admin\Assignment; use App\Entity\Assignment; +use App\Htmx\HxRedirectResponse; use Doctrine\ORM\EntityManagerInterface; use Psr\Log\LoggerInterface; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; +use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; use Symfony\Component\Routing\Attribute\Route; use Symfony\Component\Security\Http\Attribute\IsGranted; @@ -20,19 +22,25 @@ class DeleteController extends AbstractController #[Route('/admin/assignment/delete/{uuid}', name: 'app_admin_assignment_delete')] #[IsGranted('ROLE_ADMINISTRATIVE')] - public function index(Assignment $assignment): Response + public function index(Assignment $assignment, Request $request): Response { - $assignment->setDeleted(); - $this->entityManager->flush(); + if (true === $request->isMethod('POST')) { + $assignment->setDeleted(); + $this->entityManager->flush(); - $this->logger->info('Delete assignment', [ - 'assignment_id' => $assignment->getId(), - 'destination' => (string) $assignment->getDestination(), - 'job_profile' => $assignment->getJobProfile()->getName(), + $this->logger->info('Delete assignment', [ + 'assignment_id' => $assignment->getId(), + 'destination' => (string) $assignment->getDestination(), + 'job_profile' => $assignment->getJobProfile()->getName(), + ]); + + $this->addFlash('success', 'Der Einsatz wurde gelöscht'); + + return new HxRedirectResponse($this->generateUrl('app_admin_assignment_index')); + } + + return $this->render('admin/assignment/modal_delete.html.twig', [ + 'assignment' => $assignment, ]); - - $this->addFlash('success', 'Der Einsatz wurde gelöscht'); - - return $this->redirectToRoute('app_admin_assignment_index'); } } \ No newline at end of file diff --git a/src/Controller/Admin/Assignment/DuplicateController.php b/src/Controller/Admin/Assignment/DuplicateController.php index 8e51e69..5d9cbbf 100644 --- a/src/Controller/Admin/Assignment/DuplicateController.php +++ b/src/Controller/Admin/Assignment/DuplicateController.php @@ -26,7 +26,13 @@ class DuplicateController extends AbstractController { $copy = Assignment::duplicate($assignment); - $form = $this->createForm(AssignmentType::class, $copy); + $form = $this->createForm( + AssignmentType::class, + $copy, + [ + 'pickup_form_url' => $this->generateUrl('app_admin_assignment_pickup_form'), + ] + ); $form->handleRequest($request); if ($form->isSubmitted() && $form->isValid()) { @@ -48,7 +54,7 @@ class DuplicateController extends AbstractController } return $this->render('admin/assignment/duplicate.html.twig', [ - 'form' => $form, + 'form' => $form->createView(), ]); } } \ No newline at end of file diff --git a/src/Controller/Admin/Assignment/EditController.php b/src/Controller/Admin/Assignment/EditController.php index 47ef5db..a6ba9dd 100644 --- a/src/Controller/Admin/Assignment/EditController.php +++ b/src/Controller/Admin/Assignment/EditController.php @@ -24,7 +24,13 @@ class EditController extends AbstractController #[IsGranted('EDIT', subject: 'assignment')] public function index(Assignment $assignment, Request $request): Response { - $form = $this->createForm(AssignmentType::class, $assignment); + $form = $this->createForm( + AssignmentType::class, + $assignment, + [ + 'pickup_form_url' => $this->generateUrl('app_admin_assignment_pickup_form'), + ] + ); $form->handleRequest($request); if ($form->isSubmitted() && $form->isValid()) { @@ -42,7 +48,7 @@ class EditController extends AbstractController } return $this->render('admin/assignment/edit.html.twig', [ - 'form' => $form, + 'form' => $form->createView(), ]); } } \ No newline at end of file diff --git a/src/Controller/Admin/Disposition/DeleteController.php b/src/Controller/Admin/Disposition/DeleteController.php index 33ef742..ef656fa 100644 --- a/src/Controller/Admin/Disposition/DeleteController.php +++ b/src/Controller/Admin/Disposition/DeleteController.php @@ -4,13 +4,13 @@ namespace App\Controller\Admin\Disposition; use App\Entity\Disposition; use App\Event\DispositionDeletedEvent; -use App\Model\AjaxModalResponseDto; +use App\Htmx\HxRedirectResponse; use Doctrine\ORM\EntityManagerInterface; use Psr\Log\LoggerInterface; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Component\Form\Extension\Core\Type\TextareaType; -use Symfony\Component\HttpFoundation\JsonResponse; use Symfony\Component\HttpFoundation\Request; +use Symfony\Component\HttpFoundation\Response; use Symfony\Component\Routing\Attribute\Route; use Symfony\Component\Security\Http\Attribute\IsGranted; use Symfony\Contracts\EventDispatcher\EventDispatcherInterface; @@ -27,12 +27,10 @@ class DeleteController extends AbstractController #[Route('/admin/disposition/delete/{uuid}', name: 'app_admin_disposition_delete')] #[IsGranted('ROLE_ADMINISTRATIVE')] #[IsGranted('DELETE', subject: 'disposition')] - public function index(Disposition $disposition, Request $request): JsonResponse + public function index(Disposition $disposition, Request $request): Response { - $response = new AjaxModalResponseDto(); - $formAction = $this->generateUrl('app_admin_disposition_delete', ['uuid' => $disposition->getUuid()]); $form = $this - ->createFormBuilder($disposition, ['action' => $formAction, 'ajax_submit' => true]) + ->createFormBuilder($disposition) ->add('remarks', TextareaType::class, [ 'label' => 'Kommentar/Begründung', 'required' => false, @@ -56,15 +54,13 @@ class DeleteController extends AbstractController $this->entityManager->remove($disposition); $this->entityManager->flush(); - $response->setCloseAndRedirect($this->generateUrl('app_admin_assignment_detail', [ + return new HxRedirectResponse($this->generateUrl('app_admin_assignment_detail', [ 'uuid' => $disposition->getAssignment()->getUuid(), ])); - } else { - $response->setContent($this->renderView('admin/disposition/delete.html.twig', [ - 'form' => $form, - ])); } - return $this->json($response); + return $this->render('admin/disposition/modal_delete.html.twig', [ + 'form' => $form->createView(), + ]); } } \ No newline at end of file diff --git a/src/Controller/Admin/Document/CheckController.php b/src/Controller/Admin/Document/CheckController.php index c546107..4825c8c 100644 --- a/src/Controller/Admin/Document/CheckController.php +++ b/src/Controller/Admin/Document/CheckController.php @@ -5,14 +5,14 @@ namespace App\Controller\Admin\Document; use App\Entity\Upload; use App\Event\DocumentRejectedEvent; use App\Form\DocumentCheckType; -use App\Model\AjaxModalResponseDto; +use App\Htmx\HxRedirectResponse; use App\Model\DocumentCheckDto; use Doctrine\ORM\EntityManagerInterface; use Psr\Log\LoggerInterface; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Component\DependencyInjection\Attribute\Target; -use Symfony\Component\HttpFoundation\JsonResponse; use Symfony\Component\HttpFoundation\Request; +use Symfony\Component\HttpFoundation\Response; use Symfony\Component\Routing\Attribute\Route; use Symfony\Component\Security\Http\Attribute\IsGranted; use Symfony\Component\Workflow\WorkflowInterface; @@ -32,20 +32,10 @@ class CheckController extends AbstractController #[Route('/admin/document/check/{uuid}', name: 'app_admin_document_check')] #[IsGranted('ROLE_ADMINISTRATIVE')] #[IsGranted('CHECK', subject: 'document')] - public function index(Upload $document, Request $request): JsonResponse + public function index(Upload $document, Request $request): Response { - $response = new AjaxModalResponseDto(); $formData = new DocumentCheckDto($document); - $formAction = $this->generateUrl('app_admin_document_check', ['uuid' => $document->getUuid()]); - $form = $this->createForm( - DocumentCheckType::class, - $formData, - [ - 'action' => $formAction, - 'ajax_submit' => true, - 'document_type' => $document->getType(), - ] - ); + $form = $this->createForm(DocumentCheckType::class, $formData, ['document_type' => $document->getType()]); $form->handleRequest($request); @@ -75,16 +65,13 @@ class CheckController extends AbstractController ]); } - $returnUrl = $this->generateUrl('app_admin_document_index'); - $response->setCloseAndRedirect($returnUrl); - } else { - $response->setContent($this->renderView('admin/document/check.html.twig', [ - 'document' => $document, - 'form' => $form, - ])); + return new HxRedirectResponse($this->generateUrl('app_admin_document_index')); } - return $this->json($response); + return $this->render('admin/document/modal_check.html.twig', [ + 'document' => $document, + 'form' => $form->createView(), + ]); } private function rejectDocument(Upload $document, string $comment = null): void diff --git a/src/Controller/Admin/Document/DeleteController.php b/src/Controller/Admin/Document/DeleteController.php index 4a61562..1178680 100644 --- a/src/Controller/Admin/Document/DeleteController.php +++ b/src/Controller/Admin/Document/DeleteController.php @@ -3,9 +3,11 @@ namespace App\Controller\Admin\Document; use App\Entity\Upload; +use App\Htmx\HxRedirectResponse; use Doctrine\ORM\EntityManagerInterface; use Psr\Log\LoggerInterface; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; +use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; use Symfony\Component\Routing\Attribute\Route; use Symfony\Component\Security\Http\Attribute\IsGranted; @@ -21,17 +23,23 @@ class DeleteController extends AbstractController #[Route('/admin/document/delete/{uuid}', name: 'app_admin_document_delete')] #[IsGranted('ROLE_ADMINISTRATIVE')] #[IsGranted('DELETE', subject: 'document')] - public function index(Upload $document): Response + public function index(Upload $document, Request $request): Response { - $this->entityManager->remove($document); - $this->entityManager->flush(); + if (true === $request->isMethod('POST')) { + $this->entityManager->remove($document); + $this->entityManager->flush(); - $this->addFlash('success', 'Das Dokument wurde gelöscht'); - $this->logger->info('Delete document', [ - 'document_filename' => $document->getOriginalFilename(), - 'owner' => $document->getOwner()->getFullName(), + $this->addFlash('success', 'Das Dokument wurde gelöscht'); + $this->logger->info('Delete document', [ + 'document_filename' => $document->getOriginalFilename(), + 'owner' => $document->getOwner()->getFullName(), + ]); + + return new HxRedirectResponse($this->generateUrl('app_admin_document_index')); + } + + return $this->render('admin/document/modal_delete.html.twig', [ + 'document' => $document, ]); - - return $this->redirectToRoute('app_admin_document_index'); } } \ No newline at end of file diff --git a/src/Controller/Admin/Feedback/ApproveController.php b/src/Controller/Admin/Feedback/ApproveController.php index caf607c..fe42f21 100644 --- a/src/Controller/Admin/Feedback/ApproveController.php +++ b/src/Controller/Admin/Feedback/ApproveController.php @@ -4,12 +4,12 @@ namespace App\Controller\Admin\Feedback; use App\Entity\Feedback; use App\Form\FeedbackApproveType; -use App\Model\AjaxModalResponseDto; +use App\Htmx\HxRedirectResponse; use Doctrine\ORM\EntityManagerInterface; use Psr\Log\LoggerInterface; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; -use Symfony\Component\HttpFoundation\JsonResponse; use Symfony\Component\HttpFoundation\Request; +use Symfony\Component\HttpFoundation\Response; use Symfony\Component\Routing\Attribute\Route; use Symfony\Component\Security\Http\Attribute\IsGranted; @@ -23,11 +23,9 @@ class ApproveController extends AbstractController #[Route('/admin/feedback/approve/{uuid}', name: 'app_admin_feedback_approve')] #[IsGranted('ROLE_ADMIN')] - public function index(Feedback $feedback, Request $request): JsonResponse + public function index(Feedback $feedback, Request $request): Response { - $response = new AjaxModalResponseDto(); - $action = $this->generateUrl('app_admin_feedback_approve', ['uuid' => $feedback->getUuid()]); - $form = $this->createForm(FeedbackApproveType::class, $feedback, ['action' => $action, 'ajax_submit' => true]); + $form = $this->createForm(FeedbackApproveType::class, $feedback); $form->handleRequest($request); if ($form->isSubmitted() && $form->isValid()) { @@ -39,15 +37,12 @@ class ApproveController extends AbstractController 'feedback_uuid' => $feedback->getUuid(), ]); - $returnUrl = $this->generateUrl('app_admin_index'); - $response->setCloseAndRedirect($returnUrl); - } else { - $response->setContent($this->renderView('admin/feedback/approve.html.twig', [ - 'feedback' => $feedback, - 'form' => $form->createView(), - ])); + return new HxRedirectResponse($this->generateUrl('app_admin_index')); } - return $this->json($response); + return $this->render('admin/feedback/modal_approve.html.twig', [ + 'feedback' => $feedback, + 'form' => $form->createView(), + ]); } } \ No newline at end of file diff --git a/src/Controller/Admin/System/Availability/CreateController.php b/src/Controller/Admin/System/Availability/CreateController.php index 0e41f15..1d4b287 100644 --- a/src/Controller/Admin/System/Availability/CreateController.php +++ b/src/Controller/Admin/System/Availability/CreateController.php @@ -4,12 +4,12 @@ namespace App\Controller\Admin\System\Availability; use App\Entity\Availability; use App\Form\AvailabilityType; -use App\Model\AjaxModalResponseDto; +use App\Htmx\HxRedirectResponse; use Doctrine\ORM\EntityManagerInterface; use Psr\Log\LoggerInterface; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; -use Symfony\Component\HttpFoundation\JsonResponse; use Symfony\Component\HttpFoundation\Request; +use Symfony\Component\HttpFoundation\Response; use Symfony\Component\Routing\Attribute\Route; use Symfony\Component\Security\Http\Attribute\IsGranted; @@ -23,13 +23,10 @@ class CreateController extends AbstractController #[Route('/admin/system/availability/create', name: 'app_admin_system_availability_create')] #[IsGranted('ROLE_ADMIN')] - public function index(Request $request): JsonResponse + public function index(Request $request): Response { - $response = new AjaxModalResponseDto(); - $action = $this->generateUrl('app_admin_system_availability_create'); - $availability = new Availability(); - $form = $this->createForm(AvailabilityType::class, $availability, ['action' => $action, 'ajax_submit' => true]); + $form = $this->createForm(AvailabilityType::class, $availability); $form->handleRequest($request); if ($form->isSubmitted() && $form->isValid()) { @@ -42,15 +39,11 @@ class CreateController extends AbstractController 'availability_range' => (string) $availability, ]); - $redirectUrl = $this->generateUrl('app_admin_system_availability_index'); - $response->setCloseAndRedirect($redirectUrl); - } else { - $content = $this->renderView('admin/system/availability/form.html.twig', [ - 'form' => $form, - ]); - $response->setContent($content); + return new HxRedirectResponse($this->generateUrl('app_admin_system_availability_index')); } - return $this->json($response); + return $this->render('admin/system/availability/modal_create.html.twig', [ + 'form' => $form->createView(), + ]); } } \ No newline at end of file diff --git a/src/Controller/Admin/System/Availability/DeleteController.php b/src/Controller/Admin/System/Availability/DeleteController.php index c5187f8..36e3be7 100644 --- a/src/Controller/Admin/System/Availability/DeleteController.php +++ b/src/Controller/Admin/System/Availability/DeleteController.php @@ -3,9 +3,11 @@ namespace App\Controller\Admin\System\Availability; use App\Entity\Availability; +use App\Htmx\HxRedirectResponse; use Doctrine\ORM\EntityManagerInterface; use Psr\Log\LoggerInterface; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; +use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; use Symfony\Component\Routing\Attribute\Route; use Symfony\Component\Security\Http\Attribute\IsGranted; @@ -20,17 +22,23 @@ class DeleteController extends AbstractController #[Route('/admin/system/availability/delete/{id}', name: 'app_admin_system_availability_delete', methods: ['POST'])] #[IsGranted('ROLE_ADMIN')] - public function index(Availability $availability): Response + public function index(Availability $availability, Request $request): Response { - $availability->setDeleted(); - $this->entityManager->flush(); + if (true === $request->isMethod('POST')) { + $availability->setDeleted(); + $this->entityManager->flush(); - $this->addFlash('success', 'Die Verfügbarkeit wurde gelöscht'); - $this->logger->info('Delete availability', [ - 'availability_id' => $availability->getId(), - 'availability_range' => (string) $availability, + $this->addFlash('success', 'Die Verfügbarkeit wurde gelöscht'); + $this->logger->info('Delete availability', [ + 'availability_id' => $availability->getId(), + 'availability_range' => (string) $availability, + ]); + + return new HxRedirectResponse($this->generateUrl('app_admin_system_availability_index')); + } + + return $this->render('admin/system/availability/modal_delete.html.twig', [ + 'availability' => $availability, ]); - - return $this->redirectToRoute('app_admin_system_availability_index'); } } \ No newline at end of file diff --git a/src/Controller/Admin/System/Availability/DuplicateController.php b/src/Controller/Admin/System/Availability/DuplicateController.php index d7cd9f1..a3a6baa 100644 --- a/src/Controller/Admin/System/Availability/DuplicateController.php +++ b/src/Controller/Admin/System/Availability/DuplicateController.php @@ -4,12 +4,12 @@ namespace App\Controller\Admin\System\Availability; use App\Entity\Availability; use App\Form\AvailabilityType; -use App\Model\AjaxModalResponseDto; +use App\Htmx\HxRedirectResponse; use Doctrine\ORM\EntityManagerInterface; use Psr\Log\LoggerInterface; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; -use Symfony\Component\HttpFoundation\JsonResponse; use Symfony\Component\HttpFoundation\Request; +use Symfony\Component\HttpFoundation\Response; use Symfony\Component\Routing\Attribute\Route; use Symfony\Component\Security\Http\Attribute\IsGranted; @@ -23,14 +23,11 @@ class DuplicateController extends AbstractController #[Route('/admin/system/availability/duplicate/{id}', name: 'app_admin_system_availability_duplicate')] #[IsGranted('ROLE_ADMIN')] - public function index(Availability $availability, Request $request): JsonResponse + public function index(Availability $availability, Request $request): Response { $copy = Availability::duplicate($availability); - $response = new AjaxModalResponseDto(); - $action = $this->generateUrl('app_admin_system_availability_duplicate', ['id' => $availability->getId()]); - - $form = $this->createForm(AvailabilityType::class, $copy, ['action' => $action, 'ajax_submit' => true]); + $form = $this->createForm(AvailabilityType::class, $copy); $form->handleRequest($request); if ($form->isSubmitted() && $form->isValid()) { @@ -45,15 +42,11 @@ class DuplicateController extends AbstractController 'duplicate_range' => (string) $copy, ]); - $redirectUrl = $this->generateUrl('app_admin_system_availability_index'); - $response->setCloseAndRedirect($redirectUrl); - } else { - $content = $this->renderView('admin/system/availability/form.html.twig', [ - 'form' => $form, - ]); - $response->setContent($content); + return new HxRedirectResponse($this->generateUrl('app_admin_system_availability_index')); } - return $this->json($response); + return $this->render('admin/system/availability/modal_duplicate.html.twig', [ + 'form' => $form->createView(), + ]); } } \ No newline at end of file diff --git a/src/Controller/Admin/System/Availability/EditController.php b/src/Controller/Admin/System/Availability/EditController.php index ffd96f7..6eecbeb 100644 --- a/src/Controller/Admin/System/Availability/EditController.php +++ b/src/Controller/Admin/System/Availability/EditController.php @@ -4,12 +4,12 @@ namespace App\Controller\Admin\System\Availability; use App\Entity\Availability; use App\Form\AvailabilityType; -use App\Model\AjaxModalResponseDto; +use App\Htmx\HxRedirectResponse; use Doctrine\ORM\EntityManagerInterface; use Psr\Log\LoggerInterface; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; -use Symfony\Component\HttpFoundation\JsonResponse; use Symfony\Component\HttpFoundation\Request; +use Symfony\Component\HttpFoundation\Response; use Symfony\Component\Routing\Attribute\Route; use Symfony\Component\Security\Http\Attribute\IsGranted; @@ -23,12 +23,9 @@ class EditController extends AbstractController #[Route('/admin/system/availability/edit/{id}', name: 'app_admin_system_availability_edit')] #[IsGranted('ROLE_ADMIN')] - public function index(Availability $availability, Request $request): JsonResponse + public function index(Availability $availability, Request $request): Response { - $response = new AjaxModalResponseDto(); - $action = $this->generateUrl('app_admin_system_availability_edit', ['id' => $availability->getId()]); - - $form = $this->createForm(AvailabilityType::class, $availability, ['action' => $action, 'ajax_submit' => true]); + $form = $this->createForm(AvailabilityType::class, $availability); $form->handleRequest($request); if ($form->isSubmitted() && $form->isValid()) { @@ -40,15 +37,11 @@ class EditController extends AbstractController 'availability_range' => (string) $availability, ]); - $redirectUrl = $this->generateUrl('app_admin_system_availability_index'); - $response->setCloseAndRedirect($redirectUrl); - } else { - $content = $this->renderView('admin/system/availability/form.html.twig', [ - 'form' => $form - ]); - $response->setContent($content); + return new HxRedirectResponse($this->generateUrl('app_admin_system_availability_index')); } - return $this->json($response); + return $this->render('admin/system/availability/modal_edit.html.twig', [ + 'form' => $form->createView(), + ]); } } \ No newline at end of file diff --git a/src/Controller/Admin/System/Contact/CreateController.php b/src/Controller/Admin/System/Contact/CreateController.php index f84e004..bd792ad 100644 --- a/src/Controller/Admin/System/Contact/CreateController.php +++ b/src/Controller/Admin/System/Contact/CreateController.php @@ -6,13 +6,13 @@ use App\Entity\Contact; use App\Entity\Upload; use App\Entity\User; use App\Form\ContactType; -use App\Model\AjaxModalResponseDto; +use App\Htmx\HxRedirectResponse; use App\Service\Upload\UploadHandler; use Doctrine\ORM\EntityManagerInterface; use Psr\Log\LoggerInterface; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; -use Symfony\Component\HttpFoundation\JsonResponse; use Symfony\Component\HttpFoundation\Request; +use Symfony\Component\HttpFoundation\Response; use Symfony\Component\Routing\Attribute\Route; use Symfony\Component\Security\Http\Attribute\IsGranted; @@ -27,11 +27,9 @@ class CreateController extends AbstractController #[Route('/admin/system/contact/create', name: 'app_admin_system_contact_create')] #[IsGranted('ROLE_ADMINISTRATIVE')] - public function index(Request $request): JsonResponse + public function index(Request $request): Response { - $response = new AjaxModalResponseDto(); $contact = new Contact(); - $formAction = $this->generateUrl('app_admin_system_contact_create'); // Handle upload independently from form submission to avoid issues with failing validation $uploadSession = $this->uploadHandler->getUploadSession(); @@ -48,15 +46,7 @@ class CreateController extends AbstractController $this->uploadHandler->destroyUploadSession(); } - $form = $this->createForm( - ContactType::class, - $contact, - [ - 'action' => $formAction, - 'ajax_submit' => true, - 'upload_session' => $uploadSession, - ] - ); + $form = $this->createForm(ContactType::class, $contact, ['upload_session' => $uploadSession]); $form->handleRequest($request); if ($form->isSubmitted() && $form->isValid()) { @@ -68,13 +58,11 @@ class CreateController extends AbstractController 'contact_name' => $contact->getName(), ]); - $response->setCloseAndRedirect($this->generateUrl('app_admin_system_contact_index')); - } else { - $response->setContent($this->renderView('admin/system/contact/create.html.twig', [ - 'form' => $form, - ])); + return new HxRedirectResponse($this->generateUrl('app_admin_system_contact_index')); } - return $this->json($response); + return $this->render('admin/system/contact/modal_create.html.twig', [ + 'form' => $form->createView(), + ]); } } \ No newline at end of file diff --git a/src/Controller/Admin/System/Contact/DeleteController.php b/src/Controller/Admin/System/Contact/DeleteController.php index 95bf1d3..163edbb 100644 --- a/src/Controller/Admin/System/Contact/DeleteController.php +++ b/src/Controller/Admin/System/Contact/DeleteController.php @@ -3,9 +3,11 @@ namespace App\Controller\Admin\System\Contact; use App\Entity\Contact; +use App\Htmx\HxRedirectResponse; use Doctrine\ORM\EntityManagerInterface; use Psr\Log\LoggerInterface; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; +use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; use Symfony\Component\Routing\Attribute\Route; use Symfony\Component\Security\Http\Attribute\IsGranted; @@ -20,17 +22,23 @@ class DeleteController extends AbstractController #[Route('/admin/system/contact/delete/{id}', name: 'app_admin_system_contact_delete')] #[IsGranted('ROLE_ADMINISTRATIVE')] - public function index(Contact $contact): Response + public function index(Contact $contact, Request $request): Response { - $this->entityManager->remove($contact); - $this->entityManager->flush(); + if (true === $request->isMethod('POST')) { + $this->entityManager->remove($contact); + $this->entityManager->flush(); - $this->addFlash('success', 'Die Ansprechperson wurde gelöscht'); - $this->logger->info('Delete contact', [ - 'contact_id' => $contact->getId(), - 'contact_name' => $contact->getName(), + $this->addFlash('success', 'Die Ansprechperson wurde gelöscht'); + $this->logger->info('Delete contact', [ + 'contact_id' => $contact->getId(), + 'contact_name' => $contact->getName(), + ]); + + return new HxRedirectResponse($this->generateUrl('app_admin_system_contact_index')); + } + + return $this->render('admin/system/contact/modal_delete.html.twig', [ + 'contact' => $contact, ]); - - return $this->redirectToRoute('app_admin_system_contact_index'); } } \ No newline at end of file diff --git a/src/Controller/Admin/System/Contact/EditController.php b/src/Controller/Admin/System/Contact/EditController.php index 8bd5740..e4658c4 100644 --- a/src/Controller/Admin/System/Contact/EditController.php +++ b/src/Controller/Admin/System/Contact/EditController.php @@ -6,13 +6,13 @@ use App\Entity\Contact; use App\Entity\Upload; use App\Entity\User; use App\Form\ContactType; -use App\Model\AjaxModalResponseDto; +use App\Htmx\HxRedirectResponse; use App\Service\Upload\UploadHandler; use Doctrine\ORM\EntityManagerInterface; use Psr\Log\LoggerInterface; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; -use Symfony\Component\HttpFoundation\JsonResponse; use Symfony\Component\HttpFoundation\Request; +use Symfony\Component\HttpFoundation\Response; use Symfony\Component\Routing\Attribute\Route; use Symfony\Component\Security\Http\Attribute\IsGranted; @@ -27,10 +27,8 @@ class EditController extends AbstractController #[Route('/admin/system/contact/edit/{id}', name: 'app_admin_system_contact_edit')] #[IsGranted('ROLE_ADMINISTRATIVE')] - public function index(Contact $contact, Request $request): JsonResponse + public function index(Contact $contact, Request $request): Response { - $response = new AjaxModalResponseDto(); - $formAction = $this->generateUrl('app_admin_system_contact_edit', ['id' => $contact->getId()]); // Handle upload independently from form submission to avoid issues with failing validation $uploadSession = $this->uploadHandler->getUploadSession(); if (true === $request->isMethod('POST') && 0 < $uploadSession->getCount()) { @@ -46,15 +44,7 @@ class EditController extends AbstractController $this->uploadHandler->destroyUploadSession(); } - $form = $this->createForm( - ContactType::class, - $contact, - [ - 'action' => $formAction, - 'ajax_submit' => true, - 'upload_session' => $uploadSession, - ] - ); + $form = $this->createForm(ContactType::class, $contact, ['upload_session' => $uploadSession]); $form->handleRequest($request); if ($form->isSubmitted() && $form->isValid()) { @@ -65,13 +55,11 @@ class EditController extends AbstractController 'contact_name' => $contact->getName(), ]); - $response->setCloseAndRedirect($this->generateUrl('app_admin_system_contact_index')); - } else { - $response->setContent($this->renderView('admin/system/contact/edit.html.twig', [ - 'form' => $form, - ])); + return new HxRedirectResponse($this->generateUrl('app_admin_system_contact_index')); } - return $this->json($response); + return $this->render('admin/system/contact/modal_edit.html.twig', [ + 'form' => $form->createView(), + ]); } } \ No newline at end of file diff --git a/src/Controller/Admin/System/Document/DeleteController.php b/src/Controller/Admin/System/Document/DeleteController.php index 496f1a7..42eeda9 100644 --- a/src/Controller/Admin/System/Document/DeleteController.php +++ b/src/Controller/Admin/System/Document/DeleteController.php @@ -3,9 +3,11 @@ namespace App\Controller\Admin\System\Document; use App\Entity\Upload; +use App\Htmx\HxRedirectResponse; use Doctrine\ORM\EntityManagerInterface; use Psr\Log\LoggerInterface; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; +use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; use Symfony\Component\Routing\Attribute\Route; use Symfony\Component\Security\Http\Attribute\IsGranted; @@ -21,17 +23,23 @@ class DeleteController extends AbstractController #[Route('/admin/system/document/delete/{uuid}', name: 'app_admin_system_document_delete')] #[IsGranted('ROLE_ADMINISTRATIVE')] #[IsGranted('DELETE', subject: 'document')] - public function index(Upload $document): Response + public function index(Upload $document, Request $request): Response { - $this->entityManager->remove($document); - $this->entityManager->flush(); + if (true === $request->isMethod('POST')) { + $this->entityManager->remove($document); + $this->entityManager->flush(); - $this->addFlash('success', 'Das Dokument wurde gelöscht'); - $this->logger->info('Delete document', [ - 'document_id' => $document->getId(), - 'document_filename' => $document->getOriginalFilename(), + $this->addFlash('success', 'Das Dokument wurde gelöscht'); + $this->logger->info('Delete document', [ + 'document_id' => $document->getId(), + 'document_filename' => $document->getOriginalFilename(), + ]); + + return new HxRedirectResponse($this->generateUrl('app_admin_system_document_index')); + } + + return $this->render('admin/system/document/modal_delete.html.twig', [ + 'document' => $document, ]); - - return $this->redirectToRoute('app_admin_system_document_index'); } } \ No newline at end of file diff --git a/src/Controller/Admin/System/Document/EditController.php b/src/Controller/Admin/System/Document/EditController.php index e9cc56c..32ba7bb 100644 --- a/src/Controller/Admin/System/Document/EditController.php +++ b/src/Controller/Admin/System/Document/EditController.php @@ -3,14 +3,13 @@ namespace App\Controller\Admin\System\Document; use App\Entity\Upload; -use App\Model\AjaxModalResponseDto; +use App\Htmx\HxRedirectResponse; use Doctrine\ORM\EntityManagerInterface; use Psr\Log\LoggerInterface; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; -use Symfony\Component\Form\Extension\Core\Type\CheckboxType; use Symfony\Component\Form\Extension\Core\Type\TextType; -use Symfony\Component\HttpFoundation\JsonResponse; use Symfony\Component\HttpFoundation\Request; +use Symfony\Component\HttpFoundation\Response; use Symfony\Component\Routing\Attribute\Route; use Symfony\Component\Security\Http\Attribute\IsGranted; @@ -24,15 +23,12 @@ class EditController extends AbstractController #[Route('/admin/system/document/edit/{uuid}', name: 'app_admin_system_document_edit')] #[IsGranted('ROLE_ADMINISTRATIVE')] - public function index(Upload $upload, Request $request): JsonResponse + public function index(Upload $upload, Request $request): Response { - $response = new AjaxModalResponseDto(); - $formAction = $this->generateUrl('app_admin_system_document_edit', ['uuid' => $upload->getUuid()]); - $nameBefore = $upload->getDisplayName(); $form = $this - ->createFormBuilder($upload, ['action' => $formAction, 'ajax_submit' => true]) + ->createFormBuilder($upload) ->add('displayName', TextType::class, [ 'label' => 'angezeigter Name', 'attr' => [ @@ -54,13 +50,11 @@ class EditController extends AbstractController 'document_name_after' => $upload->getDisplayName(), ]); - $response->setCloseAndRedirect($this->generateUrl('app_admin_system_document_index')); - } else { - $response->setContent($this->renderView('admin/system/document/edit.html.twig', [ - 'form' => $form->createView(), - ])); + return new HxRedirectResponse($this->generateUrl('app_admin_system_document_index')); } - return $this->json($response); + return $this->render('admin/system/document/modal_edit.html.twig', [ + 'form' => $form->createView(), + ]); } } \ No newline at end of file diff --git a/src/Controller/Admin/System/Document/ReplaceController.php b/src/Controller/Admin/System/Document/ReplaceController.php index 29f7b10..29d4535 100644 --- a/src/Controller/Admin/System/Document/ReplaceController.php +++ b/src/Controller/Admin/System/Document/ReplaceController.php @@ -4,13 +4,13 @@ namespace App\Controller\Admin\System\Document; use App\Entity\Upload; use App\Entity\User; -use App\Model\AjaxModalResponseDto; +use App\Htmx\HxRedirectResponse; use App\Service\Upload\UploadHandler; use Doctrine\ORM\EntityManagerInterface; use Psr\Log\LoggerInterface; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; -use Symfony\Component\HttpFoundation\JsonResponse; use Symfony\Component\HttpFoundation\Request; +use Symfony\Component\HttpFoundation\Response; use Symfony\Component\Routing\Attribute\Route; use Symfony\Component\Security\Http\Attribute\IsGranted; @@ -25,7 +25,7 @@ class ReplaceController extends AbstractController #[Route('/admin/system/document/replace/{uuid}', name: 'app_admin_system_document_replace')] #[IsGranted('ROLE_ADMINISTRATIVE')] - public function index(Upload $upload, Request $request): JsonResponse + public function index(Upload $upload, Request $request): Response { // Handle upload independently from form submission to avoid issues with failing validation $uploadSession = $this->uploadHandler->getUploadSession(); @@ -38,7 +38,6 @@ class ReplaceController extends AbstractController $this->uploadHandler->destroyUploadSession(); } - $response = new AjaxModalResponseDto(); $formAction = $this->generateUrl('app_admin_system_document_replace', ['uuid' => $upload->getUuid()]); $filenameBefore = $upload->getOriginalFilename(); @@ -57,13 +56,11 @@ class ReplaceController extends AbstractController 'document_filename_after' => $upload->getOriginalFilename(), ]); - $response->setCloseAndRedirect($this->generateUrl('app_admin_system_document_index')); - } else { - $response->setContent($this->renderView('admin/system/document/replace.html.twig', [ - 'form' => $form->createView(), - ])); + return new HxRedirectResponse($this->generateUrl('app_admin_system_document_index')); } - return $this->json($response); + return $this->render('admin/system/document/modal_replace.html.twig', [ + 'form' => $form->createView(), + ]); } } \ No newline at end of file diff --git a/src/Controller/Admin/System/Document/UploadController.php b/src/Controller/Admin/System/Document/UploadController.php index e19db52..3f040b5 100644 --- a/src/Controller/Admin/System/Document/UploadController.php +++ b/src/Controller/Admin/System/Document/UploadController.php @@ -4,13 +4,13 @@ namespace App\Controller\Admin\System\Document; use App\Entity\Upload; use App\Entity\User; -use App\Model\AjaxModalResponseDto; +use App\Htmx\HxRedirectResponse; use App\Service\Upload\UploadHandler; use Doctrine\ORM\EntityManagerInterface; use Psr\Log\LoggerInterface; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; -use Symfony\Component\HttpFoundation\JsonResponse; use Symfony\Component\HttpFoundation\Request; +use Symfony\Component\HttpFoundation\Response; use Symfony\Component\Routing\Attribute\Route; use Symfony\Component\Security\Http\Attribute\IsGranted; @@ -25,13 +25,10 @@ class UploadController extends AbstractController #[Route('/admin/system/document/upload', name: 'app_admin_system_document_upload')] #[IsGranted('ROLE_ADMINISTRATIVE')] - public function index(Request $request): JsonResponse + public function index(Request $request): Response { - $response = new AjaxModalResponseDto(); - $formAction = $this->generateUrl('app_admin_system_document_upload'); - $form = $this - ->createFormBuilder(null, ['action' => $formAction, 'ajax_submit' => true]) + ->createFormBuilder() ->getForm() ; $form->handleRequest($request); @@ -53,7 +50,8 @@ class UploadController extends AbstractController } if ($form->isSubmitted() && $form->isValid()) { - $this->addFlash('success', 'Das/die Dokument/e wurden hochgeladen'); + $count = count($uploadedDocuments); + $this->addFlash('success', $count === 1 ? 'Das Dokument wurde hochgeladen' : 'Die Dokumente wurden hochgeladen'); $loggerContext = []; foreach ($uploadedDocuments as $document) { $loggerContext[] = [ @@ -63,13 +61,11 @@ class UploadController extends AbstractController } $this->logger->info('Upload document(s)', $loggerContext); - $response->setCloseAndRedirect($this->generateUrl('app_admin_system_document_index')); - } else { - $response->setContent($this->renderView('admin/system/document/upload.html.twig', [ - 'form' => $form->createView(), - ])); + return new HxRedirectResponse($this->generateUrl('app_admin_system_document_index')); } - return $this->json($response); + return $this->render('admin/system/document/modal_upload.html.twig', [ + 'form' => $form->createView(), + ]); } } \ No newline at end of file diff --git a/src/Controller/Admin/System/Faq/DeleteController.php b/src/Controller/Admin/System/Faq/DeleteController.php index 50ba99f..9cf8327 100644 --- a/src/Controller/Admin/System/Faq/DeleteController.php +++ b/src/Controller/Admin/System/Faq/DeleteController.php @@ -3,9 +3,11 @@ namespace App\Controller\Admin\System\Faq; use App\Entity\Faq; +use App\Htmx\HxRedirectResponse; use Doctrine\ORM\EntityManagerInterface; use Psr\Log\LoggerInterface; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; +use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; use Symfony\Component\Routing\Attribute\Route; use Symfony\Component\Security\Http\Attribute\IsGranted; @@ -18,19 +20,25 @@ class DeleteController extends AbstractController ) { } - #[Route('/admin/system/faq/delete/{id}', name: 'app_admin_system_faq_delete', methods: ['POST'])] + #[Route('/admin/system/faq/delete/{id}', name: 'app_admin_system_faq_delete')] #[IsGranted('ROLE_ADMIN')] - public function index(Faq $faq): Response + public function index(Faq $faq, Request $request): Response { - $this->entityManager->remove($faq); - $this->entityManager->flush(); + if (true === $request->isMethod('POST')) { + $this->entityManager->remove($faq); + $this->entityManager->flush(); - $this->addFlash('success', 'Der FAQ-Eintrag wurde gelöscht'); - $this->logger->info('Delete faq', [ - 'faq_id' => $faq->getId(), - 'faq_question' => $faq->getQuestion(), + $this->addFlash('success', 'Der FAQ-Eintrag wurde gelöscht'); + $this->logger->info('Delete faq', [ + 'faq_id' => $faq->getId(), + 'faq_question' => $faq->getQuestion(), + ]); + + return new HxRedirectResponse($this->generateUrl('app_admin_system_faq_index')); + } + + return $this->render('admin/system/faq/modal_delete.html.twig', [ + 'faq' => $faq, ]); - - return $this->redirectToRoute('app_admin_system_faq_index'); } } \ No newline at end of file diff --git a/src/Controller/Admin/System/Fee/CreateController.php b/src/Controller/Admin/System/Fee/CreateController.php index 1fa26bb..38277f4 100644 --- a/src/Controller/Admin/System/Fee/CreateController.php +++ b/src/Controller/Admin/System/Fee/CreateController.php @@ -4,12 +4,12 @@ namespace App\Controller\Admin\System\Fee; use App\Entity\Fee; use App\Form\FeeType; -use App\Model\AjaxModalResponseDto; +use App\Htmx\HxRedirectResponse; use Doctrine\ORM\EntityManagerInterface; use Psr\Log\LoggerInterface; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; -use Symfony\Component\HttpFoundation\JsonResponse; use Symfony\Component\HttpFoundation\Request; +use Symfony\Component\HttpFoundation\Response; use Symfony\Component\Routing\Attribute\Route; use Symfony\Component\Security\Http\Attribute\IsGranted; @@ -23,13 +23,10 @@ class CreateController extends AbstractController #[Route('/admin/system/fee/create', name: 'app_admin_system_fee_create')] #[IsGranted('ROLE_ADMIN')] - public function index(Request $request): JsonResponse + public function index(Request $request): Response { - $response = new AjaxModalResponseDto(); - $action = $this->generateUrl('app_admin_system_fee_create'); - $fee = new Fee(); - $form = $this->createForm(FeeType::class, $fee, ['action' => $action, 'ajax_submit' => true]); + $form = $this->createForm(FeeType::class, $fee); $form->handleRequest($request); if ($form->isSubmitted() && $form->isValid()) { @@ -42,15 +39,11 @@ class CreateController extends AbstractController 'fee_name' => $fee->getNameInternal() ?? $fee->getName(), ]); - $redirectUrl = $this->generateUrl('app_admin_system_fee_index'); - $response->setCloseAndRedirect($redirectUrl); - } else { - $content = $this->renderView('admin/system/fee/form.html.twig', [ - 'form' => $form - ]); - $response->setContent($content); + return new HxRedirectResponse($this->generateUrl('app_admin_system_fee_index')); } - return $this->json($response); + return $this->render('admin/system/fee/modal_create.html.twig', [ + 'form' => $form->createView(), + ]); } } \ No newline at end of file diff --git a/src/Controller/Admin/System/Fee/DeleteController.php b/src/Controller/Admin/System/Fee/DeleteController.php index d69e157..f6f7591 100644 --- a/src/Controller/Admin/System/Fee/DeleteController.php +++ b/src/Controller/Admin/System/Fee/DeleteController.php @@ -3,9 +3,11 @@ namespace App\Controller\Admin\System\Fee; use App\Entity\Fee; +use App\Htmx\HxRedirectResponse; use Doctrine\ORM\EntityManagerInterface; use Psr\Log\LoggerInterface; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; +use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; use Symfony\Component\Routing\Attribute\Route; use Symfony\Component\Security\Http\Attribute\IsGranted; @@ -18,19 +20,25 @@ class DeleteController extends AbstractController ) { } - #[Route('/admin/system/fee/delete/{id}', name: 'app_admin_system_fee_delete', methods: ['POST'])] + #[Route('/admin/system/fee/delete/{id}', name: 'app_admin_system_fee_delete')] #[IsGranted('ROLE_ADMIN')] - public function index(Fee $fee): Response + public function index(Fee $fee, Request $request): Response { - $fee->setDeleted(); - $this->entityManager->flush(); + if (true === $request->isMethod('POST')) { + $fee->setDeleted(); + $this->entityManager->flush(); - $this->addFlash('success', 'Das Honorar wurde gelöscht'); - $this->logger->info('Delete fee', [ - 'fee_id' => $fee->getId(), - 'fee_name' => $fee->getNameInternal() ?? $fee->getName(), + $this->addFlash('success', 'Das Honorar wurde gelöscht'); + $this->logger->info('Delete fee', [ + 'fee_id' => $fee->getId(), + 'fee_name' => $fee->getNameInternal() ?? $fee->getName(), + ]); + + return new HxRedirectResponse($this->generateUrl('app_admin_system_fee_index')); + } + + return $this->render('admin/system/fee/modal_delete.html.twig', [ + 'fee' => $fee, ]); - - return $this->redirectToRoute('app_admin_system_fee_index'); } } \ No newline at end of file diff --git a/src/Controller/Admin/System/Fee/DuplicateController.php b/src/Controller/Admin/System/Fee/DuplicateController.php index 86444ff..6300f97 100644 --- a/src/Controller/Admin/System/Fee/DuplicateController.php +++ b/src/Controller/Admin/System/Fee/DuplicateController.php @@ -4,12 +4,12 @@ namespace App\Controller\Admin\System\Fee; use App\Entity\Fee; use App\Form\FeeType; -use App\Model\AjaxModalResponseDto; +use App\Htmx\HxRedirectResponse; use Doctrine\ORM\EntityManagerInterface; use Psr\Log\LoggerInterface; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; -use Symfony\Component\HttpFoundation\JsonResponse; use Symfony\Component\HttpFoundation\Request; +use Symfony\Component\HttpFoundation\Response; use Symfony\Component\Routing\Attribute\Route; use Symfony\Component\Security\Http\Attribute\IsGranted; @@ -23,14 +23,10 @@ class DuplicateController extends AbstractController #[Route('/admin/system/fee/duplicate/{id}', name: 'app_admin_system_fee_duplicate')] #[IsGranted('ROLE_ADMIN')] - public function index(Fee $fee, Request $request): JsonResponse + public function index(Fee $fee, Request $request): Response { $copy = Fee::duplicate($fee); - - $response = new AjaxModalResponseDto(); - $action = $this->generateUrl('app_admin_system_fee_duplicate', ['id' => $fee->getId()]); - - $form = $this->createForm(FeeType::class, $copy, ['action' => $action, 'ajax_submit' => true]); + $form = $this->createForm(FeeType::class, $copy); $form->handleRequest($request); if ($form->isSubmitted() && $form->isValid()) { @@ -45,15 +41,11 @@ class DuplicateController extends AbstractController 'duplicate_name' => $copy->getNameInternal() ?? $copy->getName(), ]); - $redirectUrl = $this->generateUrl('app_admin_system_fee_index'); - $response->setCloseAndRedirect($redirectUrl); - } else { - $content = $this->renderView('admin/system/fee/form.html.twig', [ - 'form' => $form - ]); - $response->setContent($content); + return new HxRedirectResponse($this->generateUrl('app_admin_system_fee_index')); } - return $this->json($response); + return $this->render('admin/system/fee/modal_duplicate.html.twig', [ + 'form' => $form->createView(), + ]); } } \ No newline at end of file diff --git a/src/Controller/Admin/System/Fee/EditController.php b/src/Controller/Admin/System/Fee/EditController.php index a92dcc7..eb19e8c 100644 --- a/src/Controller/Admin/System/Fee/EditController.php +++ b/src/Controller/Admin/System/Fee/EditController.php @@ -4,12 +4,12 @@ namespace App\Controller\Admin\System\Fee; use App\Entity\Fee; use App\Form\FeeType; -use App\Model\AjaxModalResponseDto; +use App\Htmx\HxRedirectResponse; use Doctrine\ORM\EntityManagerInterface; use Psr\Log\LoggerInterface; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; -use Symfony\Component\HttpFoundation\JsonResponse; use Symfony\Component\HttpFoundation\Request; +use Symfony\Component\HttpFoundation\Response; use Symfony\Component\Routing\Attribute\Route; use Symfony\Component\Security\Http\Attribute\IsGranted; @@ -23,12 +23,9 @@ class EditController extends AbstractController #[Route('/admin/system/fee/edit/{id}', name: 'app_admin_system_fee_edit')] #[IsGranted('ROLE_ADMIN')] - public function index(Fee $fee, Request $request): JsonResponse + public function index(Fee $fee, Request $request): Response { - $response = new AjaxModalResponseDto(); - $action = $this->generateUrl('app_admin_system_fee_edit', ['id' => $fee->getId()]); - - $form = $this->createForm(FeeType::class, $fee, ['action' => $action, 'ajax_submit' => true]); + $form = $this->createForm(FeeType::class, $fee); $form->handleRequest($request); if ($form->isSubmitted() && $form->isValid()) { @@ -40,15 +37,11 @@ class EditController extends AbstractController 'fee_name' => $fee->getNameInternal() ?? $fee->getName(), ]); - $redirectUrl = $this->generateUrl('app_admin_system_fee_index'); - $response->setCloseAndRedirect($redirectUrl); - } else { - $content = $this->renderView('admin/system/fee/form.html.twig', [ - 'form' => $form - ]); - $response->setContent($content); + return new HxRedirectResponse($this->generateUrl('app_admin_system_fee_index')); } - return $this->json($response); + return $this->render('admin/system/fee/modal_edit.html.twig', [ + 'form' => $form->createView(), + ]); } } \ No newline at end of file diff --git a/src/Controller/Admin/System/FeedbackSet/DeleteController.php b/src/Controller/Admin/System/FeedbackSet/DeleteController.php index 2a81f65..bdd052b 100644 --- a/src/Controller/Admin/System/FeedbackSet/DeleteController.php +++ b/src/Controller/Admin/System/FeedbackSet/DeleteController.php @@ -3,9 +3,11 @@ namespace App\Controller\Admin\System\FeedbackSet; use App\Entity\FeedbackSet; +use App\Htmx\HxRedirectResponse; use Doctrine\ORM\EntityManagerInterface; use Psr\Log\LoggerInterface; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; +use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; use Symfony\Component\Routing\Attribute\Route; use Symfony\Component\Security\Http\Attribute\IsGranted; @@ -18,20 +20,26 @@ class DeleteController extends AbstractController ) { } - #[Route('/admin/system/feedback-set/delete/{id}', name: 'app_admin_system_feedback_set_delete', methods: ['POST'])] + #[Route('/admin/system/feedback-set/delete/{id}', name: 'app_admin_system_feedback_set_delete')] #[IsGranted('ROLE_ADMIN')] #[IsGranted('DELETE', subject: 'feedbackSet')] - public function index(FeedbackSet $feedbackSet): Response + public function index(FeedbackSet $feedbackSet, Request $request): Response { - $this->entityManager->remove($feedbackSet); - $this->entityManager->flush(); + if (true === $request->isMethod('POST')) { + $this->entityManager->remove($feedbackSet); + $this->entityManager->flush(); - $this->addFlash('success', 'Die Feedback-Vorlage wurde gelöscht'); - $this->logger->info('Delete feedback set', [ - 'feedback_set_id' => $feedbackSet->getId(), - 'feedback_set_name' => $feedbackSet->getName(), + $this->addFlash('success', 'Die Feedback-Vorlage wurde gelöscht'); + $this->logger->info('Delete feedback set', [ + 'feedback_set_id' => $feedbackSet->getId(), + 'feedback_set_name' => $feedbackSet->getName(), + ]); + + return new HxRedirectResponse($this->generateUrl('app_admin_system_feedback_set_index')); + } + + return $this->render('admin/system/feedback_set/modal_delete.html.twig', [ + 'feedbackSet' => $feedbackSet, ]); - - return $this->redirectToRoute('app_admin_system_feedback_set_index'); } } \ No newline at end of file diff --git a/src/Controller/Admin/System/JobProfile/DeleteController.php b/src/Controller/Admin/System/JobProfile/DeleteController.php index 4ef5def..aa8ba98 100644 --- a/src/Controller/Admin/System/JobProfile/DeleteController.php +++ b/src/Controller/Admin/System/JobProfile/DeleteController.php @@ -3,9 +3,11 @@ namespace App\Controller\Admin\System\JobProfile; use App\Entity\JobProfile; +use App\Htmx\HxRedirectResponse; use Doctrine\ORM\EntityManagerInterface; use Psr\Log\LoggerInterface; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; +use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; use Symfony\Component\Routing\Attribute\Route; use Symfony\Component\Security\Http\Attribute\IsGranted; @@ -18,19 +20,25 @@ class DeleteController extends AbstractController ) { } - #[Route('/admin/system/job-profile/delete/{id}', name: 'app_admin_system_job_profile_delete', methods: ['POST'])] + #[Route('/admin/system/job-profile/delete/{id}', name: 'app_admin_system_job_profile_delete')] #[IsGranted('ROLE_ADMIN')] - public function index(JobProfile $jobProfile): Response + public function index(JobProfile $jobProfile, Request $request): Response { - $jobProfile->setDeleted(); - $this->entityManager->flush(); + if (true === $request->isMethod('POST')) { + $jobProfile->setDeleted(); + $this->entityManager->flush(); - $this->addFlash('success', 'Das Job-Profil wurde gelöscht'); - $this->logger->info('Delete job-profile', [ - 'job_profile_id' => $jobProfile->getId(), - 'job_profile_name' => $jobProfile->getName(), + $this->addFlash('success', 'Das Job-Profil wurde gelöscht'); + $this->logger->info('Delete job-profile', [ + 'job_profile_id' => $jobProfile->getId(), + 'job_profile_name' => $jobProfile->getName(), + ]); + + return new HxRedirectResponse($this->generateUrl('app_admin_system_job_profile_index')); + } + + return $this->render('admin/system/job_profile/modal_delete.html.twig', [ + 'jobProfile' => $jobProfile, ]); - - return $this->redirectToRoute('app_admin_system_job_profile_index'); } } \ No newline at end of file diff --git a/src/Controller/Admin/System/Training/CreateController.php b/src/Controller/Admin/System/Training/CreateController.php index 6ed5b30..50eb568 100644 --- a/src/Controller/Admin/System/Training/CreateController.php +++ b/src/Controller/Admin/System/Training/CreateController.php @@ -4,12 +4,12 @@ namespace App\Controller\Admin\System\Training; use App\Entity\Training; use App\Form\TrainingType; -use App\Model\AjaxModalResponseDto; +use App\Htmx\HxRedirectResponse; use Doctrine\ORM\EntityManagerInterface; use Psr\Log\LoggerInterface; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; -use Symfony\Component\HttpFoundation\JsonResponse; use Symfony\Component\HttpFoundation\Request; +use Symfony\Component\HttpFoundation\Response; use Symfony\Component\Routing\Attribute\Route; use Symfony\Component\Security\Http\Attribute\IsGranted; @@ -23,13 +23,10 @@ class CreateController extends AbstractController #[Route('/admin/system/training/create', name: 'app_admin_system_training_create')] #[IsGranted('ROLE_ADMIN')] - public function index(Request $request): JsonResponse + public function index(Request $request): Response { - $response = new AjaxModalResponseDto(); - $action = $this->generateUrl('app_admin_system_training_create'); - $training = new Training(); - $form = $this->createForm(TrainingType::class, $training, ['action' => $action, 'ajax_submit' => true]); + $form = $this->createForm(TrainingType::class, $training); $form->handleRequest($request); if ($form->isSubmitted() && $form->isValid()) { @@ -42,15 +39,11 @@ class CreateController extends AbstractController 'training_name' => $training->getName(), ]); - $redirectUrl = $this->generateUrl('app_admin_system_training_index'); - $response->setCloseAndRedirect($redirectUrl); - } else { - $content = $this->renderView('admin/system/training/form.html.twig', [ - 'form' => $form - ]); - $response->setContent($content); + return new HxRedirectResponse($this->generateUrl('app_admin_system_training_index')); } - return $this->json($response); + return $this->render('admin/system/training/modal_create.hml.twig', [ + 'form' => $form->createView(), + ]); } } \ No newline at end of file diff --git a/src/Controller/Admin/System/Training/DeleteController.php b/src/Controller/Admin/System/Training/DeleteController.php index dc3dd90..2c27ec7 100644 --- a/src/Controller/Admin/System/Training/DeleteController.php +++ b/src/Controller/Admin/System/Training/DeleteController.php @@ -3,9 +3,11 @@ namespace App\Controller\Admin\System\Training; use App\Entity\Training; +use App\Htmx\HxRedirectResponse; use Doctrine\ORM\EntityManagerInterface; use Psr\Log\LoggerInterface; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; +use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; use Symfony\Component\Routing\Attribute\Route; use Symfony\Component\Security\Http\Attribute\IsGranted; @@ -18,19 +20,25 @@ class DeleteController extends AbstractController ) { } - #[Route('/admin/system/training/delete/{id}', name: 'app_admin_system_training_delete', methods: ['POST'])] + #[Route('/admin/system/training/delete/{id}', name: 'app_admin_system_training_delete')] #[IsGranted('ROLE_ADMIN')] - public function index(Training $training): Response + public function index(Training $training, Request $request): Response { - $training->setDeleted(); - $this->entityManager->flush(); + if (true === $request->isMethod('POST')) { + $training->setDeleted(); + $this->entityManager->flush(); - $this->addFlash('success', 'Die Fortbildung wurde gelöscht'); - $this->logger->info('Delete training', [ - 'training_id' => $training->getId(), - 'training_name' => $training->getName(), + $this->addFlash('success', 'Die Fortbildung wurde gelöscht'); + $this->logger->info('Delete training', [ + 'training_id' => $training->getId(), + 'training_name' => $training->getName(), + ]); + + return new HxRedirectResponse($this->generateUrl('app_admin_system_training_index')); + } + + return $this->render('admin/system/training/modal_delete.html.twig', [ + 'training' => $training, ]); - - return $this->redirectToRoute('app_admin_system_training_index'); } } \ No newline at end of file diff --git a/src/Controller/Admin/System/Training/EditController.php b/src/Controller/Admin/System/Training/EditController.php index 86338a9..8ecd063 100644 --- a/src/Controller/Admin/System/Training/EditController.php +++ b/src/Controller/Admin/System/Training/EditController.php @@ -4,12 +4,12 @@ namespace App\Controller\Admin\System\Training; use App\Entity\Training; use App\Form\TrainingType; -use App\Model\AjaxModalResponseDto; +use App\Htmx\HxRedirectResponse; use Doctrine\ORM\EntityManagerInterface; use Psr\Log\LoggerInterface; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; -use Symfony\Component\HttpFoundation\JsonResponse; use Symfony\Component\HttpFoundation\Request; +use Symfony\Component\HttpFoundation\Response; use Symfony\Component\Routing\Attribute\Route; use Symfony\Component\Security\Http\Attribute\IsGranted; @@ -23,12 +23,9 @@ class EditController extends AbstractController #[Route('/admin/system/training/edit/{id}', name: 'app_admin_system_training_edit')] #[IsGranted('ROLE_ADMIN')] - public function index(Training $training, Request $request): JsonResponse + public function index(Training $training, Request $request): Response { - $response = new AjaxModalResponseDto(); - $action = $this->generateUrl('app_admin_system_training_edit', ['id' => $training->getId()]); - - $form = $this->createForm(TrainingType::class, $training, ['action' => $action, 'ajax_submit' => true]); + $form = $this->createForm(TrainingType::class, $training); $form->handleRequest($request); if ($form->isSubmitted() && $form->isValid()) { @@ -40,15 +37,11 @@ class EditController extends AbstractController 'training_name' => $training->getName(), ]); - $redirectUrl = $this->generateUrl('app_admin_system_training_index'); - $response->setCloseAndRedirect($redirectUrl); - } else { - $content = $this->renderView('admin/system/training/form.html.twig', [ - 'form' => $form - ]); - $response->setContent($content); + return new HxRedirectResponse($this->generateUrl('app_admin_system_training_index')); } - return $this->json($response); + return $this->render('admin/system/training/modal_edit.hml.twig', [ + 'form' => $form->createView(), + ]); } } \ No newline at end of file diff --git a/src/Controller/Admin/Teamer/Availability/DeleteController.php b/src/Controller/Admin/Teamer/Availability/DeleteController.php index 28ba598..57e6603 100644 --- a/src/Controller/Admin/Teamer/Availability/DeleteController.php +++ b/src/Controller/Admin/Teamer/Availability/DeleteController.php @@ -5,6 +5,7 @@ namespace App\Controller\Admin\Teamer\Availability; use App\Controller\Traits\ReturnUrlTrait; use App\Entity\Availability; use App\Entity\Teamer; +use App\Htmx\HxRedirectResponse; use Doctrine\ORM\EntityManagerInterface; use Psr\Log\LoggerInterface; use Symfony\Bridge\Doctrine\Attribute\MapEntity; @@ -33,24 +34,30 @@ class DeleteController extends AbstractController Availability $availability, Request $request ): Response { - if (null === $availability->getOwner()) { - $teamer->removeAvailability($availability); - } elseif ($teamer === $availability->getOwner()) { - $this->entityManager->remove($availability); + if (true === $request->isMethod('POST')) { + if (null === $availability->getOwner()) { + $teamer->removeAvailability($availability); + } elseif ($teamer === $availability->getOwner()) { + $this->entityManager->remove($availability); + } + + $this->entityManager->flush(); + + $this->addFlash('success', 'Der Zeitraum wurde entfernt/gelöscht.'); + $this->logger->info('Delete teamer availability', [ + 'availability_id' => $availability->getId(), + 'availability_range' => (string) $availability, + 'teamer_id' => $teamer->getId(), + 'teamer_name' => (string) $teamer, + ]); + + $redirectUrl = $this->getReturnUrl($request, 'app_admin_teamer_profile', ['uuid' => $teamer->getUuid()]); + + return new HxRedirectResponse($redirectUrl); } - $this->entityManager->flush(); - - $this->addFlash('success', 'Der Zeitraum wurde entfernt/gelöscht.'); - $this->logger->info('Delete teamer availability', [ - 'availability_id' => $availability->getId(), - 'availability_range' => (string) $availability, - 'teamer_id' => $teamer->getId(), - 'teamer_name' => (string) $teamer, + return $this->render('admin/teamer/availability/modal_delete.html.twig', [ + 'availability' => $availability, ]); - - $redirectUrl = $this->getReturnUrl($request, 'app_admin_teamer_profile', ['uuid' => $teamer->getUuid()]); - - return $this->redirect($redirectUrl); } } \ No newline at end of file diff --git a/src/Controller/Admin/Teamer/AvailabilityController.php b/src/Controller/Admin/Teamer/Availability/IndexController.php similarity index 81% rename from src/Controller/Admin/Teamer/AvailabilityController.php rename to src/Controller/Admin/Teamer/Availability/IndexController.php index 1f92eed..1a0f1b4 100644 --- a/src/Controller/Admin/Teamer/AvailabilityController.php +++ b/src/Controller/Admin/Teamer/Availability/IndexController.php @@ -1,6 +1,6 @@ getAvailabilities()->toArray(); $groupedAvailabilities = $processor->groupRecords($availabilities); - return $this->render('admin/teamer/availability.html.twig', [ + return $this->render('admin/teamer/availability/index.html.twig', [ 'teamer' => $teamer, 'groupedAvailabilities' => $groupedAvailabilities, ]); diff --git a/src/Controller/Admin/Teamer/InfoController.php b/src/Controller/Admin/Teamer/InfoController.php index 433303f..b1c88ad 100644 --- a/src/Controller/Admin/Teamer/InfoController.php +++ b/src/Controller/Admin/Teamer/InfoController.php @@ -3,10 +3,9 @@ namespace App\Controller\Admin\Teamer; use App\Entity\Teamer; -use App\Model\AjaxModalResponseDto; use App\Repository\DispositionRepository; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; -use Symfony\Component\HttpFoundation\JsonResponse; +use Symfony\Component\HttpFoundation\Response; use Symfony\Component\Routing\Attribute\Route; class InfoController extends AbstractController @@ -15,16 +14,13 @@ class InfoController extends AbstractController {} #[Route('/admin/teamer/info/{uuid}', name: 'app_admin_teamer_info')] - public function index(Teamer $teamer): JsonResponse + public function index(Teamer $teamer): Response { $recentDispositions = $this->dispositionRepository->findRecentDispositionsByTeamer($teamer); - $response = new AjaxModalResponseDto(); - $response->setContent($this->renderView('admin/teamer/info.html.twig', [ + return $this->render('admin/teamer/modal_info.html.twig', [ 'teamer' => $teamer, 'recentDispositions' => $recentDispositions, - ])); - - return $this->json($response); + ]); } } \ No newline at end of file diff --git a/src/Controller/Admin/Teamer/TrainingAttendance/CreateController.php b/src/Controller/Admin/Teamer/TrainingAttendance/CreateController.php index 9bfe5fc..c73a5b4 100644 --- a/src/Controller/Admin/Teamer/TrainingAttendance/CreateController.php +++ b/src/Controller/Admin/Teamer/TrainingAttendance/CreateController.php @@ -6,14 +6,13 @@ use App\Entity\Teamer; use App\Entity\Training; use App\Entity\TrainingAttendance; use App\Form\AbbreviatedDateType; -use App\Form\FeeType; -use App\Model\AjaxModalResponseDto; +use App\Htmx\HxRedirectResponse; use Doctrine\ORM\EntityManagerInterface; use Psr\Log\LoggerInterface; use Symfony\Bridge\Doctrine\Attribute\MapEntity; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; -use Symfony\Component\HttpFoundation\JsonResponse; use Symfony\Component\HttpFoundation\Request; +use Symfony\Component\HttpFoundation\Response; use Symfony\Component\Routing\Attribute\Route; use Symfony\Component\Security\Http\Attribute\IsGranted; @@ -33,13 +32,7 @@ class CreateController extends AbstractController #[MapEntity(mapping: ['teamer_id' => 'id'])] Teamer $teamer, Request $request - ): JsonResponse { - $response = new AjaxModalResponseDto(); - $action = $this->generateUrl('app_admin_teamer_skills_training_attendance_create', [ - 'training_id' => $training->getId(), - 'teamer_id' => $teamer->getId(), - ]); - + ): Response { $attendance = new TrainingAttendance(); $attendance ->setTeamer($teamer) @@ -47,7 +40,7 @@ class CreateController extends AbstractController ; $form = $this - ->createFormBuilder($attendance, ['action' => $action, 'ajax_submit' => true]) + ->createFormBuilder($attendance) ->add('date', AbbreviatedDateType::class, [ 'label' => 'Datum', ]) @@ -69,14 +62,12 @@ class CreateController extends AbstractController ]); $redirectUrl = $this->generateUrl('app_admin_teamer_skills', ['uuid' => $teamer->getUuid()]); - $response->setCloseAndRedirect($redirectUrl); - } else { - $content = $this->renderView('admin/teamer/training_attendance/create.html.twig', [ - 'form' => $form - ]); - $response->setContent($content); + + return new HxRedirectResponse($redirectUrl); } - return $this->json($response); + return $this->render('admin/teamer/training_attendance/modal_create.html.twig', [ + 'form' => $form->createView(), + ]); } } \ No newline at end of file diff --git a/src/Controller/Admin/Teamer/TrainingAttendance/DeleteController.php b/src/Controller/Admin/Teamer/TrainingAttendance/DeleteController.php index 0c3ffa6..97dd479 100644 --- a/src/Controller/Admin/Teamer/TrainingAttendance/DeleteController.php +++ b/src/Controller/Admin/Teamer/TrainingAttendance/DeleteController.php @@ -3,9 +3,11 @@ namespace App\Controller\Admin\Teamer\TrainingAttendance; use App\Entity\TrainingAttendance; +use App\Htmx\HxRedirectResponse; use Doctrine\ORM\EntityManagerInterface; use Psr\Log\LoggerInterface; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; +use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; use Symfony\Component\Routing\Attribute\Route; use Symfony\Component\Security\Http\Attribute\IsGranted; @@ -18,24 +20,32 @@ class DeleteController extends AbstractController ) { } - #[Route('/admin/teamer/skills/training-attendance/delete/{uuid}', name: 'app_admin_teamer_skills_training_attendance_delete', methods: ['POST'])] + #[Route('/admin/teamer/skills/training-attendance/delete/{uuid}', name: 'app_admin_teamer_skills_training_attendance_delete')] #[IsGranted('ROLE_ADMIN')] - public function index(TrainingAttendance $attendance): Response + public function index(TrainingAttendance $attendance, Request $request): Response { - $teamer = $attendance->getTeamer(); + if (true === $request->isMethod('POST')) { + $teamer = $attendance->getTeamer(); - $this->entityManager->remove($attendance); - $this->entityManager->flush(); + $this->entityManager->remove($attendance); + $this->entityManager->flush(); - $this->addFlash('success', 'Die Teilnahme an der Fortbilundg wurde gelöscht'); - $this->logger->info('Delete training attendance', [ - 'attendance_id' => $attendance->getId(), - 'teamer_id' => $teamer->getId(), - 'teamer_name' => (string) $teamer, - 'training_id' => $attendance->getTraining()->getId(), - 'training_name' => $attendance->getTraining()->getName(), + $this->addFlash('success', 'Die Teilnahme an der Fortbilundg wurde gelöscht'); + $this->logger->info('Delete training attendance', [ + 'attendance_id' => $attendance->getId(), + 'teamer_id' => $teamer->getId(), + 'teamer_name' => (string) $teamer, + 'training_id' => $attendance->getTraining()->getId(), + 'training_name' => $attendance->getTraining()->getName(), + ]); + + return new HxRedirectResponse($this->generateUrl('app_admin_teamer_skills', [ + 'uuid' => $teamer->getUuid(), + ])); + } + + return $this->render('admin/teamer/training_attendance/modal_delete.html.twig', [ + 'attendance' => $attendance, ]); - - return $this->redirectToRoute('app_admin_teamer_skills', ['uuid' => $teamer->getUuid()]); } } \ No newline at end of file diff --git a/src/Controller/Common/AssignmentFilterController.php b/src/Controller/Common/AssignmentFilterController.php index b4743c1..45d3e99 100644 --- a/src/Controller/Common/AssignmentFilterController.php +++ b/src/Controller/Common/AssignmentFilterController.php @@ -4,11 +4,10 @@ namespace App\Controller\Common; use App\Controller\Traits\ReturnUrlTrait; use App\Form\AssignmentFilterType; -use App\Model\AjaxModalResponseDto; +use App\Htmx\HxRedirectResponse; use App\Repository\AssignmentRepository; use App\Service\Common\AssignmentFilterHandler; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; -use Symfony\Component\HttpFoundation\JsonResponse; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; use Symfony\Component\Routing\Attribute\Route; @@ -26,15 +25,11 @@ class AssignmentFilterController extends AbstractController #[Route('/common/assignment/filter', name: 'app_common_assignment_filter')] #[IsGranted('ROLE_USER')] - public function index(Request $request): JsonResponse + public function index(Request $request): Response { - $response = new AjaxModalResponseDto(); - $formAction = $this->generateUrl('app_common_assignment_filter', ['r' => $request->query->get('r')]); $formData = $this->filterHandler->getFilterSettings(); $filterOptions = $this->assignmentRepository->getFilterOptions(); $formOptions = [ - 'action' => $formAction, - 'ajax_submit' => true, 'min_date' => $filterOptions['minDate'], 'max_date' => $filterOptions['maxDate'], 'job_profiles' => $filterOptions['jobProfiles'], @@ -47,15 +42,14 @@ class AssignmentFilterController extends AbstractController if ($form->isSubmitted() && $form->isValid()) { $this->filterHandler->handleRequest($form); $returnUrl = $this->getReturnUrl($request, 'app_admin_assignment_index'); - $response->setCloseAndRedirect($returnUrl); - } else { - $response->setContent($this->renderView('common/assignment_filter.html.twig', [ - 'filterForm' => $form, - 'filterDto' => $form->getData(), - ])); + + return new HxRedirectResponse($returnUrl); } - return $this->json($response); + return $this->render('common/modal_assignment_filter.html.twig', [ + 'filterForm' => $form->createView(), + 'filterDto' => $form->getData(), + ]); } #[Route('/common/assignment/filter/reset', name: 'app_common_assignment_filter_reset')] diff --git a/src/Controller/Common/TeamerFilterController.php b/src/Controller/Common/TeamerFilterController.php index f0d6f2d..03179c1 100644 --- a/src/Controller/Common/TeamerFilterController.php +++ b/src/Controller/Common/TeamerFilterController.php @@ -4,11 +4,10 @@ namespace App\Controller\Common; use App\Controller\Traits\ReturnUrlTrait; use App\Form\TeamerFilterType; -use App\Model\AjaxModalResponseDto; +use App\Htmx\HxRedirectResponse; use App\Repository\TeamerRepository; use App\Service\Common\TeamerFilterHandler; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; -use Symfony\Component\HttpFoundation\JsonResponse; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; use Symfony\Component\Routing\Attribute\Route; @@ -26,29 +25,23 @@ class TeamerFilterController extends AbstractController #[Route('/common/teamer/filter', name: 'app_common_teamer_filter')] #[IsGranted('ROLE_USER')] - public function index(Request $request): JsonResponse + public function index(Request $request): Response { - $response = new AjaxModalResponseDto(); - $formAction = $this->generateUrl('app_common_teamer_filter', ['r' => $request->query->get('r')]); $formData = $this->filterHandler->getFilterSettings(); - $form = $this->createForm(TeamerFilterType::class, $formData, [ - 'action' => $formAction, - 'ajax_submit' => true, - ]); + $form = $this->createForm(TeamerFilterType::class, $formData); $form->handleRequest($request); if ($form->isSubmitted() && $form->isValid()) { $this->filterHandler->handleRequest($form); $returnUrl = $this->getReturnUrl($request, 'app_admin_teamer_index'); - $response->setCloseAndRedirect($returnUrl); - } else { - $response->setContent($this->renderView('common/teamer_filter.html.twig', [ - 'filterForm' => $form, - 'filterDto' => $form->getData(), - ])); + + return new HxRedirectResponse($returnUrl); } - return $this->json($response); + return $this->render('common/modal_teamer_filter.html.twig', [ + 'filterForm' => $form->createView(), + 'filterDto' => $form->getData(), + ]); } #[Route('/common/teamer/filter/reset', name: 'app_common_teamer_filter_reset')] diff --git a/src/Controller/Teamer/Application/WithdrawController.php b/src/Controller/Teamer/Application/WithdrawController.php index 18b8dd9..89e3a62 100644 --- a/src/Controller/Teamer/Application/WithdrawController.php +++ b/src/Controller/Teamer/Application/WithdrawController.php @@ -5,6 +5,7 @@ namespace App\Controller\Teamer\Application; use App\Controller\Traits\ReturnUrlTrait; use App\Entity\Application; use App\Entity\User; +use App\Htmx\HxRedirectResponse; use Doctrine\ORM\EntityManagerInterface; use Psr\Log\LoggerInterface; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; @@ -27,24 +28,28 @@ class WithdrawController extends AbstractController #[IsGranted('WITHDRAW', subject: 'application')] public function index(Application $application, Request $request): Response { - /** @var User $user */ - $user = $this->getUser(); - $teamer = $user->getTeamer(); - $assignment = $application->getAssignment(); + if (true === $request->isMethod('POST')) { + /** @var User $user */ + $user = $this->getUser(); + $teamer = $user->getTeamer(); + $assignment = $application->getAssignment(); - $this->entityManager->remove($application); - $this->entityManager->flush(); + $this->entityManager->remove($application); + $this->entityManager->flush(); - $this->logger->info('Withdraw application', [ - 'teamer_id' => $teamer->getId(), - 'teamer_name' => (string) $teamer, - 'application_id' => $application->getId(), - 'assignment_id' => $assignment->getId(), - 'destination' => (string) $assignment->getDestination(), + $this->logger->info('Withdraw application', [ + 'teamer_id' => $teamer->getId(), + 'teamer_name' => (string) $teamer, + 'application_id' => $application->getId(), + 'assignment_id' => $assignment->getId(), + 'destination' => (string) $assignment->getDestination(), + ]); + + return new HxRedirectResponse($this->getReturnUrl($request, 'app_teamer_index')); + } + + return $this->render('teamer/application/modal_withdraw.html.twig', [ + 'application' => $application, ]); - - $returnUrl = $this->getReturnUrl($request, 'app_teamer_index'); - - return $this->redirect($returnUrl); } } \ No newline at end of file diff --git a/src/Controller/Teamer/FeedbackController.php b/src/Controller/Teamer/FeedbackController.php index 94dc041..d97ced9 100644 --- a/src/Controller/Teamer/FeedbackController.php +++ b/src/Controller/Teamer/FeedbackController.php @@ -3,9 +3,8 @@ namespace App\Controller\Teamer; use App\Entity\Feedback; -use App\Model\AjaxModalResponseDto; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; -use Symfony\Component\HttpFoundation\JsonResponse; +use Symfony\Component\HttpFoundation\Response; use Symfony\Component\Routing\Attribute\Route; use Symfony\Component\Security\Http\Attribute\IsGranted; @@ -13,13 +12,10 @@ class FeedbackController extends AbstractController { #[Route('/teamer/feedback/{uuid}', name: 'app_teamer_feedback')] #[IsGranted('VIEW', subject: 'feedback')] - public function index(Feedback $feedback): JsonResponse + public function index(Feedback $feedback): Response { - $response = new AjaxModalResponseDto(); - $response->setContent($this->renderView('teamer/feedback/index.html.twig', [ + return $this->render('teamer/feedback/modal.html.twig', [ 'feedback' => $feedback, - ])); - - return $this->json($response); + ]); } } \ No newline at end of file diff --git a/src/Controller/Teamer/Profile/Availability/CreateController.php b/src/Controller/Teamer/Profile/Availability/CreateController.php index 2d85b61..c77fef0 100644 --- a/src/Controller/Teamer/Profile/Availability/CreateController.php +++ b/src/Controller/Teamer/Profile/Availability/CreateController.php @@ -5,12 +5,12 @@ namespace App\Controller\Teamer\Profile\Availability; use App\Entity\Availability; use App\Entity\User; use App\Form\AvailabilityType; -use App\Model\AjaxModalResponseDto; +use App\Htmx\HxRedirectResponse; use Doctrine\ORM\EntityManagerInterface; use Psr\Log\LoggerInterface; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; -use Symfony\Component\HttpFoundation\JsonResponse; use Symfony\Component\HttpFoundation\Request; +use Symfony\Component\HttpFoundation\Response; use Symfony\Component\Routing\Attribute\Route; use Symfony\Component\Security\Http\Attribute\IsGranted; @@ -24,14 +24,11 @@ class CreateController extends AbstractController #[Route('/teamer/profile/availability/create', name: 'app_teamer_profile_availability_create')] #[IsGranted('ROLE_TEAMER')] - public function index(Request $request): JsonResponse + public function index(Request $request): Response { - $response = new AjaxModalResponseDto(); - $action = $this->generateUrl('app_teamer_profile_availability_create'); - $availability = new Availability(); - $form = $this->createForm(AvailabilityType::class, $availability, ['action' => $action, 'ajax_submit' => true]); + $form = $this->createForm(AvailabilityType::class, $availability); $form->handleRequest($request); if ($form->isSubmitted() && $form->isValid()) { @@ -53,15 +50,11 @@ class CreateController extends AbstractController 'availability' => (string) $availability, ]); - $redirectUrl = $this->generateUrl('app_teamer_profile_availability_index'); - $response->setCloseAndRedirect($redirectUrl); - } else { - $content = $this->renderView('teamer/profile/availability/create.html.twig', [ - 'form' => $form, - ]); - $response->setContent($content); + return new HxRedirectResponse($this->generateUrl('app_teamer_profile_availability_index')); } - return $this->json($response); + return $this->render('teamer/profile/availability/modal_create.html.twig', [ + 'form' => $form->createView(), + ]); } } \ No newline at end of file diff --git a/src/Controller/Teamer/Profile/Availability/DeleteController.php b/src/Controller/Teamer/Profile/Availability/DeleteController.php index 18ee8ef..9188995 100644 --- a/src/Controller/Teamer/Profile/Availability/DeleteController.php +++ b/src/Controller/Teamer/Profile/Availability/DeleteController.php @@ -4,9 +4,11 @@ namespace App\Controller\Teamer\Profile\Availability; use App\Entity\Availability; use App\Entity\User; +use App\Htmx\HxRedirectResponse; use Doctrine\ORM\EntityManagerInterface; use Psr\Log\LoggerInterface; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; +use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; use Symfony\Component\Routing\Attribute\Route; use Symfony\Component\Security\Http\Attribute\IsGranted; @@ -21,27 +23,33 @@ class DeleteController extends AbstractController #[Route('/teamer/profile/availability/delete/{id}', name: 'app_teamer_profile_availability_delete')] #[IsGranted('DELETE', subject: 'availability')] - public function index(Availability $availability): Response + public function index(Availability $availability, Request $request): Response { - /** @var User $user */ - $user = $this->getUser(); - $teamer = $user->getTeamer(); + if (true === $request->isMethod('POST')) { + /** @var User $user */ + $user = $this->getUser(); + $teamer = $user->getTeamer(); - if (null === $availability->getOwner()) { - $teamer->removeAvailability($availability); - } elseif ($teamer === $availability->getOwner()) { - $this->entityManager->remove($availability); + if (null === $availability->getOwner()) { + $teamer->removeAvailability($availability); + } elseif ($teamer === $availability->getOwner()) { + $this->entityManager->remove($availability); + } + + $this->entityManager->flush(); + + $this->addFlash('success', 'Der Zeitraum wurde entfernt/gelöscht.'); + $this->logger->info('Delete availability', [ + 'teamer_id' => $teamer->getId(), + 'teamer_name' => (string) $teamer, + 'availability' => (string) $availability, + ]); + + return new HxRedirectResponse($this->generateUrl('app_teamer_profile_availability_index')); } - $this->entityManager->flush(); - - $this->addFlash('success', 'Der Zeitraum wurde entfernt/gelöscht.'); - $this->logger->info('Delete availability', [ - 'teamer_id' => $teamer->getId(), - 'teamer_name' => (string) $teamer, - 'availability' => (string) $availability, + return $this->render('teamer/profile/availability/modal_delete.html.twig', [ + 'availability' => $availability, ]); - - return $this->redirectToRoute('app_teamer_profile_availability_index'); } } \ No newline at end of file diff --git a/src/Controller/Teamer/Profile/License/AddController.php b/src/Controller/Teamer/Profile/License/AddController.php index 5a34cb9..354a049 100644 --- a/src/Controller/Teamer/Profile/License/AddController.php +++ b/src/Controller/Teamer/Profile/License/AddController.php @@ -6,14 +6,14 @@ use App\Entity\License; use App\Entity\Upload; use App\Entity\User; use App\Form\LicenseType; -use App\Model\AjaxModalResponseDto; +use App\Htmx\HxRedirectResponse; use App\Model\UploadSessionDto; use App\Service\Upload\UploadHandler; use Doctrine\ORM\EntityManagerInterface; use Psr\Log\LoggerInterface; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; -use Symfony\Component\HttpFoundation\JsonResponse; use Symfony\Component\HttpFoundation\Request; +use Symfony\Component\HttpFoundation\Response; use Symfony\Component\Routing\Attribute\Route; use Symfony\Component\Security\Http\Attribute\IsGranted; @@ -28,11 +28,8 @@ class AddController extends AbstractController #[Route('/teamer/profile/license/add', name: 'app_teamer_profile_license_add')] #[IsGranted('ROLE_TEAMER')] - public function index(Request $request): JsonResponse + public function index(Request $request): Response { - $response = new AjaxModalResponseDto(); - $action = $this->generateUrl('app_teamer_profile_license_add'); - /** @var User $user */ $user = $this->getUser(); $license = new License(); @@ -43,15 +40,7 @@ class AddController extends AbstractController $this->updateCertificate($user, $license, $uploadSession); } - $form = $this->createForm( - LicenseType::class, - $license, - [ - 'action' => $action, - 'ajax_submit' => true, - 'upload_session' => $uploadSession, - ] - ); + $form = $this->createForm(LicenseType::class, $license, ['upload_session' => $uploadSession]); $form->handleRequest($request); if ($form->isSubmitted() && $form->isValid()) { @@ -69,16 +58,12 @@ class AddController extends AbstractController 'license_type' => $license->getType(), ]); - $redirectUrl = $this->generateUrl('app_teamer_profile_skills'); - $response->setCloseAndRedirect($redirectUrl); - } else { - $content = $this->renderView('teamer/profile/license/add.html.twig', [ - 'form' => $form, - ]); - $response->setContent($content); + return new HxRedirectResponse($this->generateUrl('app_teamer_profile_skills')); } - return $this->json($response); + return $this->render('teamer/profile/license/modal_add.html.twig', [ + 'form' => $form->createView(), + ]); } private function updateCertificate(User $user, License $license, UploadSessionDto $uploadSession): void diff --git a/src/Controller/Teamer/Profile/License/DeleteController.php b/src/Controller/Teamer/Profile/License/DeleteController.php index 356fce0..3a82d29 100644 --- a/src/Controller/Teamer/Profile/License/DeleteController.php +++ b/src/Controller/Teamer/Profile/License/DeleteController.php @@ -3,9 +3,11 @@ namespace App\Controller\Teamer\Profile\License; use App\Entity\License; +use App\Htmx\HxRedirectResponse; use Doctrine\ORM\EntityManagerInterface; use Psr\Log\LoggerInterface; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; +use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; use Symfony\Component\Routing\Attribute\Route; use Symfony\Component\Security\Http\Attribute\IsGranted; @@ -20,20 +22,26 @@ class DeleteController extends AbstractController #[Route('//teamer/profile/license/delete/{uuid}', name: 'app_teamer_profile_license_delete')] #[IsGranted('DELETE', subject: 'license')] - public function index(License $license): Response + public function index(License $license, Request $request): Response { - $teamer = $license->getTeamer(); + if (true === $request->isMethod('POST')) { + $teamer = $license->getTeamer(); - $this->entityManager->remove($license); - $this->entityManager->flush(); + $this->entityManager->remove($license); + $this->entityManager->flush(); - $this->addFlash('success', 'Die Lizenz wurde gelöscht.'); - $this->logger->info('Delete license', [ - 'teamer_id' => $teamer->getId(), - 'teamer_name' => (string) $teamer, - 'license_type' => $license->getType(), + $this->addFlash('success', 'Die Lizenz wurde gelöscht.'); + $this->logger->info('Delete license', [ + 'teamer_id' => $teamer->getId(), + 'teamer_name' => (string) $teamer, + 'license_type' => $license->getType(), + ]); + + return new HxRedirectResponse($this->generateUrl('app_teamer_profile_skills')); + } + + return $this->render('teamer/profile/license/modal_delete.html.twig', [ + 'license' => $license, ]); - - return $this->redirectToRoute('app_teamer_profile_skills'); } } \ No newline at end of file diff --git a/src/Form/AssignmentType.php b/src/Form/AssignmentType.php index 66039ff..7b42e26 100644 --- a/src/Form/AssignmentType.php +++ b/src/Form/AssignmentType.php @@ -54,7 +54,12 @@ class AssignmentType extends AbstractType 'label_property' => 'product', 'label_function' => fn(Destination $destination) => (string) $destination, 'endpoint_route' => 'app_admin_autocomplete_destination', - 'controller_action' => 'select->form-partial#update', + 'attr' => [ + 'hx-post' => $options['pickup_form_url'], + 'hx-trigger' => 'select', + 'hx-target' => '#pickup-form', + 'hx-swap' => 'innerHTML', + ], ]) ->add('jobProfile', EntityType::class, [ 'label' => 'Jobprofil', @@ -189,6 +194,7 @@ class AssignmentType extends AbstractType public function configureOptions(OptionsResolver $resolver): void { $resolver->setDefaults([ + 'pickup_form_url' => null, 'data_class' => Assignment::class, 'anti_xss' => true, ]); diff --git a/src/Form/Extension/AjaxSubmitExtension.php b/src/Form/Extension/AjaxSubmitExtension.php deleted file mode 100644 index 5e3c6ce..0000000 --- a/src/Form/Extension/AjaxSubmitExtension.php +++ /dev/null @@ -1,32 +0,0 @@ -setDefaults([ - 'ajax_submit' => false, - 'ajax_action' => 'ajax-modal#submitForm', - ]); - } - - public function buildView(FormView $view, FormInterface $form, array $options): void - { - if (true === $options['ajax_submit']) { - $view->vars['attr'] = array_merge($view->vars['attr'], ['data-action' => $options['ajax_action']]); - } - } - - public static function getExtendedTypes(): iterable - { - return [FormType::class]; - } -} diff --git a/src/Htmx/HxRedirectResponse.php b/src/Htmx/HxRedirectResponse.php new file mode 100644 index 0000000..92d6361 --- /dev/null +++ b/src/Htmx/HxRedirectResponse.php @@ -0,0 +1,13 @@ + $url]); + } +} \ No newline at end of file diff --git a/src/Model/AjaxModalResponseDto.php b/src/Model/AjaxModalResponseDto.php deleted file mode 100644 index 005896e..0000000 --- a/src/Model/AjaxModalResponseDto.php +++ /dev/null @@ -1,53 +0,0 @@ -content; - } - - public function setContent(string $content): self - { - $this->content = $content; - - return $this; - } - - public function getRedirect(): ?string - { - return $this->redirect; - } - - public function setRedirect(string $redirect): self - { - $this->redirect = $redirect; - $this->close = false; - - return $this; - } - - public function setCloseAndRedirect(string $redirect): self - { - $this->redirect = $redirect; - $this->close = true; - - return $this; - } - - public function isClose(): bool - { - return $this->close; - } - - public function setClose(bool $close): void - { - $this->close = $close; - } -} diff --git a/src/Security/Voter/ApplicationVoter.php b/src/Security/Voter/ApplicationVoter.php index 753bfef..a0f5e86 100644 --- a/src/Security/Voter/ApplicationVoter.php +++ b/src/Security/Voter/ApplicationVoter.php @@ -4,6 +4,7 @@ namespace App\Security\Voter; use App\Entity\Application; use App\Entity\User; +use Symfony\Bundle\SecurityBundle\Security; use Symfony\Component\Security\Core\Authentication\Token\TokenInterface; use Symfony\Component\Security\Core\Authorization\Voter\Voter; @@ -15,6 +16,10 @@ class ApplicationVoter extends Voter public const DISPOSE = 'DISPOSE'; public const STATUS = 'STATUS'; + public function __construct(private readonly Security $security) + { + } + protected function supports(string $attribute, mixed $subject): bool { if (!$subject instanceof Application) { @@ -36,7 +41,7 @@ class ApplicationVoter extends Voter $adminAttributes = [static::VIEW, static::DELETE, static::DISPOSE, static::STATUS]; $teamerAttributes = [static::VIEW, static::WITHDRAW, static::DELETE, static::STATUS]; - if ($user->hasRole('ROLE_ADMINISTRATIVE') && in_array($attribute, $adminAttributes)) { + if ($this->security->isGranted('ROLE_ADMINISTRATIVE') && in_array($attribute, $adminAttributes)) { $assignment = $application->getAssignment(); return match ($attribute) { static::VIEW, static::STATUS => Application::STATUS_REJECTED !== $status, @@ -47,7 +52,7 @@ class ApplicationVoter extends Voter }; } - if ($user->hasRole('ROLE_TEAMER') && in_array($attribute, $teamerAttributes)) { + if ($this->security->isGranted('ROLE_TEAMER') && in_array($attribute, $teamerAttributes)) { $teamer = $user->getTeamer(); return match ($attribute) { static::WITHDRAW => $teamer === $application->getTeamer(), diff --git a/src/Security/Voter/AssignmentVoter.php b/src/Security/Voter/AssignmentVoter.php index 2d4959b..ca6ac1d 100644 --- a/src/Security/Voter/AssignmentVoter.php +++ b/src/Security/Voter/AssignmentVoter.php @@ -7,6 +7,7 @@ use App\Entity\Assignment; use App\Entity\Disposition; use App\Entity\User; use Doctrine\ORM\EntityManagerInterface; +use Symfony\Bundle\SecurityBundle\Security; use Symfony\Component\Security\Core\Authentication\Token\TokenInterface; use Symfony\Component\Security\Core\Authorization\Voter\Voter; @@ -16,8 +17,11 @@ class AssignmentVoter extends Voter public const EDIT = 'EDIT'; public const APPLY = 'APPLY'; - public function __construct(private readonly EntityManagerInterface $entityManager) - {} + public function __construct( + private readonly Security $security, + private readonly EntityManagerInterface $entityManager + ) { + } protected function supports(string $attribute, mixed $subject): bool { @@ -40,7 +44,7 @@ class AssignmentVoter extends Voter // Only users with administrative role may edit assignments if (static::EDIT === $attribute) { - return in_array('ROLE_ADMINISTRATIVE', $token->getRoleNames()); + return $this->security->isGranted('ROLE_ADMINISTRATIVE'); } // Only allow applications to open assignments @@ -61,7 +65,7 @@ class AssignmentVoter extends Voter } // Only teamers without existing applications may apply to the assignment - if (in_array('ROLE_TEAMER', $token->getRoleNames())) { + if ($this->security->isGranted('ROLE_TEAMER')) { /** @var User $user */ $user = $token->getUser(); $teamer = $user->getTeamer(); diff --git a/src/Security/Voter/DispositionVoter.php b/src/Security/Voter/DispositionVoter.php index fda3f8c..e22c113 100644 --- a/src/Security/Voter/DispositionVoter.php +++ b/src/Security/Voter/DispositionVoter.php @@ -5,6 +5,7 @@ namespace App\Security\Voter; use App\BusProNet\DataProvider\HotelDataProvider; use App\BusProNet\Model\Hotel; use App\Entity\Disposition; +use Symfony\Bundle\SecurityBundle\Security; use Symfony\Component\Security\Core\Authentication\Token\TokenInterface; use Symfony\Component\Security\Core\Authorization\Voter\Voter; @@ -17,8 +18,10 @@ class DispositionVoter extends Voter public const INVOICE = 'INVOICE'; public const FEEDBACK = 'FEEDBACK'; - public function __construct(private readonly HotelDataProvider $hotelDataProvider) - { + public function __construct( + private readonly Security $security, + private readonly HotelDataProvider $hotelDataProvider + ) { } protected function supports(string $attribute, mixed $subject): bool @@ -52,12 +55,12 @@ class DispositionVoter extends Voter private function assertAdministrativeAccess(TokenInterface $token): bool { - return in_array('ROLE_ADMINISTRATIVE', $token->getRoleNames()); + return $this->security->isGranted('ROLE_ADMINISTRATIVE'); } private function assertHouseManagerAccess(TokenInterface $token, Disposition $disposition): bool { - if (false === in_array('ROLE_HOUSE_MANAGER', $token->getRoleNames())) { + if (false === $this->security->isGranted('ROLE_HOUSE_MANAGER')) { return false; } @@ -79,7 +82,7 @@ class DispositionVoter extends Voter private function assertTeamerAccess(TokenInterface $token, Disposition $disposition): bool { - if (false === in_array('ROLE_TEAMER', $token->getRoleNames())) { + if (false === $this->security->isGranted('ROLE_TEAMER')) { return false; } diff --git a/src/Security/Voter/UploadVoter.php b/src/Security/Voter/UploadVoter.php index f983d6f..d00f8a2 100644 --- a/src/Security/Voter/UploadVoter.php +++ b/src/Security/Voter/UploadVoter.php @@ -4,6 +4,7 @@ namespace App\Security\Voter; use App\Entity\Upload; use App\Entity\User; +use Symfony\Bundle\SecurityBundle\Security; use Symfony\Component\Security\Core\Authentication\Token\TokenInterface; use Symfony\Component\Security\Core\Authorization\Voter\Voter; @@ -14,6 +15,10 @@ class UploadVoter extends Voter public const DOWNLOAD = 'DOWNLOAD'; public const CHECK = 'CHECK'; + public function __construct(private readonly Security $security) + { + } + protected function supports(string $attribute, mixed $subject): bool { if (! $subject instanceof Upload) { @@ -29,7 +34,7 @@ class UploadVoter extends Voter $upload = $subject; // Administrative users have full access - if (true === in_array('ROLE_ADMINISTRATIVE', $token->getRoleNames())) { + if (true === $this->security->isGranted('ROLE_ADMINISTRATIVE')) { // Only new documents may be checked if (static::CHECK === $attribute) { return in_array($upload->getStatus(), [Upload::STATUS_NEW, Upload::STATUS_PENDING]); diff --git a/templates/_partials/_ajax_modal.html.twig b/templates/_partials/_ajax_modal.html.twig deleted file mode 100644 index 7b771ea..0000000 --- a/templates/_partials/_ajax_modal.html.twig +++ /dev/null @@ -1,22 +0,0 @@ - diff --git a/templates/_partials/_confirmation_modal.html.twig b/templates/_partials/_confirmation_modal.html.twig deleted file mode 100644 index bb5311e..0000000 --- a/templates/_partials/_confirmation_modal.html.twig +++ /dev/null @@ -1,28 +0,0 @@ - diff --git a/templates/admin/application/index.html.twig b/templates/admin/application/index.html.twig index e9b60fc..874cf46 100644 --- a/templates/admin/application/index.html.twig +++ b/templates/admin/application/index.html.twig @@ -56,7 +56,7 @@ - {% if assignment.pickup %} + {% if assignment.pickup and assignment.destination.pickup(assignment.pickup) %} {% set pickup = assignment.destination.pickup(assignment.pickup) %} ab {{ pickup.city }} @@ -77,11 +77,9 @@ role="button" title="Bewerber:innen-Info anzeigen" aria-label="Bewerber:innen-Info anzeigen" - {{ stimulus_controller('modal-button', [], [], {'ajax-modal': '#ajax-modal'}) }} - {{ stimulus_action('modal-button', 'ajax', 'click', { - 'title': 'Teamer:innen-Info ' ~ application.teamer, - 'url': path('app_admin_teamer_info', { 'uuid': application.teamer.uuid }) - }) }}> + hx-get="{{ path('app_admin_teamer_info', { 'uuid': application.teamer.uuid }) }}" + hx-target="body" + hx-swap="beforeend"> {% set requirementsMet = true %} {% if assignment.pickup and not application.matchesPickup %} {{ icon('bus', 'w-5 h-5 text-red-500 shrink-0') }} diff --git a/templates/admin/application/info.html.twig b/templates/admin/application/info.html.twig deleted file mode 100644 index 6487c15..0000000 --- a/templates/admin/application/info.html.twig +++ /dev/null @@ -1,44 +0,0 @@ -
- -
- {% set teamer = application.teamer %} - {% if teamer.photo %} - {{ teamer.firstName }} - {% else %} -
- {{ icon('user', 'w-32 h-32 text-gray-200') }} -
- {% endif %} -
-
diff --git a/templates/admin/application/modal_delete.html.twig b/templates/admin/application/modal_delete.html.twig new file mode 100644 index 0000000..7d8da40 --- /dev/null +++ b/templates/admin/application/modal_delete.html.twig @@ -0,0 +1,7 @@ +{% extends 'htmx_confirmation_modal.html.twig' %} + +{% block content %} +
+ Möchtest du die Bewerbung von {{ application.teamer }} wirklich löschen? +
+{% endblock %} \ No newline at end of file diff --git a/templates/admin/application/modal_dispose.html.twig b/templates/admin/application/modal_dispose.html.twig new file mode 100644 index 0000000..e058299 --- /dev/null +++ b/templates/admin/application/modal_dispose.html.twig @@ -0,0 +1,7 @@ +{% extends 'htmx_confirmation_modal.html.twig' %} + +{% block content %} +
+ Möchtest du {{ application.teamer }} wirklich einteilen? +
+{% endblock %} \ No newline at end of file diff --git a/templates/admin/application/modal_info.html.twig b/templates/admin/application/modal_info.html.twig new file mode 100644 index 0000000..4e5398e --- /dev/null +++ b/templates/admin/application/modal_info.html.twig @@ -0,0 +1,50 @@ +{% extends 'htmx_modal.html.twig' %} + +{% block title %}Teamer:inneninfo {{ application.teamer }}{% endblock %} + +{% block content %} +
+
+ {% include '_partials/_assignment_requirements_info.html.twig' with { + 'assignment': application.assignment, + 'teamer': application.teamer + } %} +
    + {% for type in ['ski', 'snowboard'] %} +
  • +
    + {{ type|license_label }} + {% set license = application.teamer.licenseOfType(type) %} + {% if license %} +
    + {{ license.date|date('m/Y') }} + {% if is_granted('DOWNLOAD', license.certificate) %} + + {{ icon('download', 'w-4 h-4') }} + + {% endif %} +
    + {% else %} + {{ icon('minus', 'w-4 h-4') }} + {% endif %} +
    +
  • + {% endfor %} +
+
+
+ {% set teamer = application.teamer %} + {% if teamer.photo %} + {{ teamer.firstName }} + {% else %} +
+ {{ icon('user', 'w-32 h-32 text-gray-200') }} +
+ {% endif %} +
+
+{% endblock %} \ No newline at end of file diff --git a/templates/admin/application/modal_status.html.twig b/templates/admin/application/modal_status.html.twig new file mode 100644 index 0000000..5726c69 --- /dev/null +++ b/templates/admin/application/modal_status.html.twig @@ -0,0 +1,17 @@ +{% extends 'htmx_modal.html.twig' %} + +{% block title %}Bewerbungsstatus bearbeiten{% endblock %} + +{% block content %} + {{ form_start(form, { 'attr': { 'hx-post': app.request.uri, 'hx-target': '#htmx-modal', 'hx-swap': 'outerHTML' } }) }} +
+ {{ form_row(form.status) }} + {{ form_row(form.comment) }} + {{ form_row(form.commentVisible) }} +
+ + {{ form_rest(form) }} + {{ form_end(form) }} +{% endblock %} \ No newline at end of file diff --git a/templates/admin/application/status.html.twig b/templates/admin/application/status.html.twig deleted file mode 100644 index 6890d1f..0000000 --- a/templates/admin/application/status.html.twig +++ /dev/null @@ -1,11 +0,0 @@ -{{ form_start(form) }} -
- {{ form_row(form.status) }} - {{ form_row(form.comment) }} - {{ form_row(form.commentVisible) }} -
- -{{ form_rest(form) }} -{{ form_end(form) }} diff --git a/templates/admin/assignment/_form.html.twig b/templates/admin/assignment/_form.html.twig index 53f8367..ffeb59f 100644 --- a/templates/admin/assignment/_form.html.twig +++ b/templates/admin/assignment/_form.html.twig @@ -10,52 +10,46 @@ {% endmacro %} -
- {{ form_start(form, { 'attr': { 'data-form-partial-target': 'form' } }) }} -
-
-
- {{ form_row(form.destination) }} -
- {{ form_row(form.status) }} - {{ form_row(form.availableDispositions) }} -
-

- {{ form_label(form.showAvailableDispositions) }} -

- {{ form_widget(form.showAvailableDispositions) }} -
+{{ form_start(form) }} +
+
+
+ {{ form_row(form.destination) }}
-
- {{ form_row(form.jobProfile) }} - {{ form_row(form.jobProfileInfo) }} - {{ form_row(form.benefits) }} - {{ form_row(form.contact) }} -
-
-
- {% block partial_form %} - {{ form_row(form.pickup) }} - {#{{ form_row(form.pickupDate) }}#} - {% endblock %} -
-
- {% include '_partials/_spinner.html.twig' with { 'class': 'w-8 h-8'} %} -
-
-
- {{ form_row(form.fees) }} - {{ form_row(form.remarks) }} + {{ form_row(form.status) }} + {{ form_row(form.availableDispositions) }} +
+

+ {{ form_label(form.showAvailableDispositions) }} +

+ {{ form_widget(form.showAvailableDispositions) }}
-
- - - Abbrechen - +
+ {{ form_row(form.jobProfile) }} + {{ form_row(form.jobProfileInfo) }} + {{ form_row(form.benefits) }} + {{ form_row(form.contact) }}
- {{ form_rest(form) }} - {{ form_end(form) }} -
\ No newline at end of file +
+
+ {% block partial_form %} + {{ form_row(form.pickup) }} + {% endblock %} +
+
+
+ {{ form_row(form.fees) }} + {{ form_row(form.remarks) }} +
+
+
+ + + Abbrechen + +
+{{ form_rest(form) }} +{{ form_end(form) }} \ No newline at end of file diff --git a/templates/admin/assignment/detail.html.twig b/templates/admin/assignment/detail.html.twig index e7322b5..46bb52d 100644 --- a/templates/admin/assignment/detail.html.twig +++ b/templates/admin/assignment/detail.html.twig @@ -39,11 +39,10 @@ @@ -63,34 +62,30 @@ {% if is_granted('DISPOSE', application) %} {% endif %} {% if is_granted('STATUS', application) %} {% endif %} {% if is_granted('DELETE', application) %} - {% endif %} @@ -134,11 +129,10 @@ @@ -155,11 +149,10 @@ {% if is_granted('DELETE', disposition) %} {% endif %} diff --git a/templates/admin/assignment/index.html.twig b/templates/admin/assignment/index.html.twig index 2832a4e..73c03ab 100644 --- a/templates/admin/assignment/index.html.twig +++ b/templates/admin/assignment/index.html.twig @@ -10,19 +10,16 @@
{% if filterDto.active %} @@ -109,12 +106,9 @@
diff --git a/templates/admin/assignment/modal_delete.html.twig b/templates/admin/assignment/modal_delete.html.twig new file mode 100644 index 0000000..2f1414a --- /dev/null +++ b/templates/admin/assignment/modal_delete.html.twig @@ -0,0 +1,7 @@ +{% extends 'htmx_confirmation_modal.html.twig' %} + +{% block content %} +
+ Möchtest du den Einsatz {{ assignment.destination.product }} wirklich löschen? +
+{% endblock %} \ No newline at end of file diff --git a/templates/admin/disposition/delete.html.twig b/templates/admin/disposition/delete.html.twig deleted file mode 100644 index e41282b..0000000 --- a/templates/admin/disposition/delete.html.twig +++ /dev/null @@ -1,9 +0,0 @@ -{{ form_start(form) }} -
- {{ form_row(form.remarks) }} -
- -{{ form_rest(form) }} -{{ form_end(form) }} diff --git a/templates/admin/disposition/modal_delete.html.twig b/templates/admin/disposition/modal_delete.html.twig new file mode 100644 index 0000000..35718bf --- /dev/null +++ b/templates/admin/disposition/modal_delete.html.twig @@ -0,0 +1,15 @@ +{% extends 'htmx_modal.html.twig' %} + +{% block title %}Einteilung löschen{% endblock %} + +{% block content %} + {{ form_start(form, { 'attr': { 'hx-post': app.request.uri, 'hx-target': '#htmx-modal', 'hx-swap': 'outerHTML' } }) }} +
+ {{ form_row(form.remarks) }} +
+ + {{ form_rest(form) }} + {{ form_end(form) }} +{% endblock %} \ No newline at end of file diff --git a/templates/admin/document/check.html.twig b/templates/admin/document/check.html.twig deleted file mode 100644 index e7bd9e0..0000000 --- a/templates/admin/document/check.html.twig +++ /dev/null @@ -1,13 +0,0 @@ -{{ form_start(form) }} -

- {{ ('label.document.type.' ~ document.type)|trans }} {{ document.disposition.teamer }} vom {{ document.createdAt|date('d.m.Y') }} -

-
- {{ form_row(form.status) }} - {{ form_row(form.comment) }} -
- -{{ form_rest(form) }} -{{ form_end(form) }} diff --git a/templates/admin/document/index.html.twig b/templates/admin/document/index.html.twig index da25f3e..c38ca3b 100644 --- a/templates/admin/document/index.html.twig +++ b/templates/admin/document/index.html.twig @@ -69,22 +69,17 @@ {% if is_granted('DELETE', upload) %} {% endif %} {% if is_granted('CHECK', upload) %} {% endif %} diff --git a/templates/admin/document/modal_check.html.twig b/templates/admin/document/modal_check.html.twig new file mode 100644 index 0000000..b31af19 --- /dev/null +++ b/templates/admin/document/modal_check.html.twig @@ -0,0 +1,19 @@ +{% extends 'htmx_modal.html.twig' %} + +{% block title %}Dokumentenstatus bearbeiten{% endblock %} + +{% block content %} + {{ form_start(form, { 'attr': { 'hx-post': app.request.uri, 'hx-target': '#htmx-modal', 'hx-swap': 'outerHTML' } }) }} +

+ {{ ('label.document.type.' ~ document.type)|trans }} {{ document.disposition.teamer }} vom {{ document.createdAt|date('d.m.Y') }} +

+
+ {{ form_row(form.status) }} + {{ form_row(form.comment) }} +
+ + {{ form_rest(form) }} + {{ form_end(form) }} +{% endblock %} \ No newline at end of file diff --git a/templates/admin/document/modal_delete.html.twig b/templates/admin/document/modal_delete.html.twig new file mode 100644 index 0000000..40839a1 --- /dev/null +++ b/templates/admin/document/modal_delete.html.twig @@ -0,0 +1,7 @@ +{% extends 'htmx_confirmation_modal.html.twig' %} + +{% block content %} +
+ Möchtest du das Dokument {{ ('label.document.type.' ~ document.type)|trans }} wirklich löschen? +
+{% endblock %} \ No newline at end of file diff --git a/templates/admin/feedback/approve.html.twig b/templates/admin/feedback/approve.html.twig deleted file mode 100644 index 79ac795..0000000 --- a/templates/admin/feedback/approve.html.twig +++ /dev/null @@ -1,10 +0,0 @@ -{{ form_start(form) }} -
- {{ form_row(form.comment) }} - {{ form_row(form.commentInternal) }} -
- -{{ form_rest(form) }} -{{ form_end(form) }} \ No newline at end of file diff --git a/templates/admin/feedback/modal_approve.html.twig b/templates/admin/feedback/modal_approve.html.twig new file mode 100644 index 0000000..d6f22ce --- /dev/null +++ b/templates/admin/feedback/modal_approve.html.twig @@ -0,0 +1,16 @@ +{% extends 'htmx_modal.html.twig' %} + +{% block title %}Feedback freigeben{% endblock %} + +{% block content %} + {{ form_start(form, { 'attr': { 'hx-post': app.request.uri, 'hx-target': '#htmx-modal', 'hx-swap': 'outerHTML' } }) }} +
+ {{ form_row(form.comment) }} + {{ form_row(form.commentInternal) }} +
+ + {{ form_rest(form) }} + {{ form_end(form) }} +{% endblock %} \ No newline at end of file diff --git a/templates/admin/index.html.twig b/templates/admin/index.html.twig index abfef7a..0cf208c 100644 --- a/templates/admin/index.html.twig +++ b/templates/admin/index.html.twig @@ -127,20 +127,18 @@ {% for feedback in feedbacks %}
  • {% else %} diff --git a/templates/teamer/profile/availability/create.html.twig b/templates/admin/system/availability/_form.html.twig similarity index 68% rename from templates/teamer/profile/availability/create.html.twig rename to templates/admin/system/availability/_form.html.twig index 6385948..f30c56d 100644 --- a/templates/teamer/profile/availability/create.html.twig +++ b/templates/admin/system/availability/_form.html.twig @@ -1,4 +1,4 @@ -{{ form_start(form) }} +{{ form_start(form, { 'attr': { 'hx-post': app.request.uri, 'hx-target': '#htmx-modal', 'hx-swap': 'outerHTML' } }) }}
    {{ form_row(form.dateFrom) }} {{ form_row(form.dateTo) }} diff --git a/templates/admin/system/availability/form.html.twig b/templates/admin/system/availability/form.html.twig deleted file mode 100644 index 6385948..0000000 --- a/templates/admin/system/availability/form.html.twig +++ /dev/null @@ -1,11 +0,0 @@ -{{ form_start(form) }} -
    - {{ form_row(form.dateFrom) }} - {{ form_row(form.dateTo) }} - {{ form_row(form.description) }} -
    - -{{ form_rest(form) }} -{{ form_end(form) }} \ No newline at end of file diff --git a/templates/admin/system/availability/index.html.twig b/templates/admin/system/availability/index.html.twig index d213873..9f98b91 100644 --- a/templates/admin/system/availability/index.html.twig +++ b/templates/admin/system/availability/index.html.twig @@ -39,28 +39,24 @@
    @@ -80,11 +76,10 @@
    {% endblock %} \ No newline at end of file diff --git a/templates/admin/system/availability/modal_create.html.twig b/templates/admin/system/availability/modal_create.html.twig new file mode 100644 index 0000000..7c4c2e2 --- /dev/null +++ b/templates/admin/system/availability/modal_create.html.twig @@ -0,0 +1,7 @@ +{% extends 'htmx_modal.html.twig' %} + +{% block title %}Zeitraum hinzufügen{% endblock %} + +{% block content %} + {% include 'admin/system/availability/_form.html.twig' %} +{% endblock %} \ No newline at end of file diff --git a/templates/admin/system/availability/modal_delete.html.twig b/templates/admin/system/availability/modal_delete.html.twig new file mode 100644 index 0000000..2b12dad --- /dev/null +++ b/templates/admin/system/availability/modal_delete.html.twig @@ -0,0 +1,7 @@ +{% extends 'htmx_confirmation_modal.html.twig' %} + +{% block content %} +
    + Möchtest du den Zeitraum wirklich löschen? +
    +{% endblock %} \ No newline at end of file diff --git a/templates/admin/system/availability/modal_duplicate.html.twig b/templates/admin/system/availability/modal_duplicate.html.twig new file mode 100644 index 0000000..7a6254a --- /dev/null +++ b/templates/admin/system/availability/modal_duplicate.html.twig @@ -0,0 +1,7 @@ +{% extends 'htmx_modal.html.twig' %} + +{% block title %}Zeitraum duplizieren{% endblock %} + +{% block content %} + {% include 'admin/system/availability/_form.html.twig' %} +{% endblock %} \ No newline at end of file diff --git a/templates/admin/system/availability/modal_edit.html.twig b/templates/admin/system/availability/modal_edit.html.twig new file mode 100644 index 0000000..ad32ee3 --- /dev/null +++ b/templates/admin/system/availability/modal_edit.html.twig @@ -0,0 +1,7 @@ +{% extends 'htmx_modal.html.twig' %} + +{% block title %}Zeitraum bearbeiten{% endblock %} + +{% block content %} + {% include 'admin/system/availability/_form.html.twig' %} +{% endblock %} \ No newline at end of file diff --git a/templates/admin/system/contact/_form.html.twig b/templates/admin/system/contact/_form.html.twig index 641600d..37623d4 100644 --- a/templates/admin/system/contact/_form.html.twig +++ b/templates/admin/system/contact/_form.html.twig @@ -1,4 +1,4 @@ -{{ form_start(form) }} +{{ form_start(form, { 'attr': { 'hx-post': app.request.uri, 'hx-target': '#htmx-modal', 'hx-swap': 'outerHTML' } }) }}
    {{ form_row(form.name) }} {{ form_row(form.email) }} diff --git a/templates/admin/system/contact/create.html.twig b/templates/admin/system/contact/create.html.twig deleted file mode 100644 index 6923fd8..0000000 --- a/templates/admin/system/contact/create.html.twig +++ /dev/null @@ -1 +0,0 @@ -{% include 'admin/system/contact/_form.html.twig' %} \ No newline at end of file diff --git a/templates/admin/system/contact/edit.html.twig b/templates/admin/system/contact/edit.html.twig deleted file mode 100644 index 6923fd8..0000000 --- a/templates/admin/system/contact/edit.html.twig +++ /dev/null @@ -1 +0,0 @@ -{% include 'admin/system/contact/_form.html.twig' %} \ No newline at end of file diff --git a/templates/admin/system/contact/index.html.twig b/templates/admin/system/contact/index.html.twig index 54bc848..9d6431f 100644 --- a/templates/admin/system/contact/index.html.twig +++ b/templates/admin/system/contact/index.html.twig @@ -39,20 +39,17 @@
    @@ -71,11 +68,10 @@
    {% endblock %} \ No newline at end of file diff --git a/templates/admin/system/contact/modal_create.html.twig b/templates/admin/system/contact/modal_create.html.twig new file mode 100644 index 0000000..ccfb422 --- /dev/null +++ b/templates/admin/system/contact/modal_create.html.twig @@ -0,0 +1,7 @@ +{% extends 'htmx_modal.html.twig' %} + +{% block title %}Ansprechperson hinzufügen{% endblock %} + +{% block content %} + {% include 'admin/system/contact/_form.html.twig' %} +{% endblock %} \ No newline at end of file diff --git a/templates/admin/system/contact/modal_delete.html.twig b/templates/admin/system/contact/modal_delete.html.twig new file mode 100644 index 0000000..5072707 --- /dev/null +++ b/templates/admin/system/contact/modal_delete.html.twig @@ -0,0 +1,7 @@ +{% extends 'htmx_confirmation_modal.html.twig' %} + +{% block content %} +
    + Möchtest du {{ contact }} als Ansprechperson wirklich löschen? +
    +{% endblock %} \ No newline at end of file diff --git a/templates/admin/system/contact/modal_edit.html.twig b/templates/admin/system/contact/modal_edit.html.twig new file mode 100644 index 0000000..e5f07b7 --- /dev/null +++ b/templates/admin/system/contact/modal_edit.html.twig @@ -0,0 +1,7 @@ +{% extends 'htmx_modal.html.twig' %} + +{% block title %}Ansprechperson bearbeiten{% endblock %} + +{% block content %} + {% include 'admin/system/contact/_form.html.twig' %} +{% endblock %} \ No newline at end of file diff --git a/templates/admin/system/document/edit.html.twig b/templates/admin/system/document/edit.html.twig deleted file mode 100644 index f12e21b..0000000 --- a/templates/admin/system/document/edit.html.twig +++ /dev/null @@ -1,9 +0,0 @@ -{{ form_start(form) }} -
    - {{ form_row(form.displayName) }} -
    - -{{ form_rest(form) }} -{{ form_end(form) }} diff --git a/templates/admin/system/document/index.html.twig b/templates/admin/system/document/index.html.twig index 02a8ff3..30e55ae 100644 --- a/templates/admin/system/document/index.html.twig +++ b/templates/admin/system/document/index.html.twig @@ -45,28 +45,21 @@
    {% endblock %} \ No newline at end of file diff --git a/templates/admin/system/document/modal_delete.html.twig b/templates/admin/system/document/modal_delete.html.twig new file mode 100644 index 0000000..1842e77 --- /dev/null +++ b/templates/admin/system/document/modal_delete.html.twig @@ -0,0 +1,7 @@ +{% extends 'htmx_confirmation_modal.html.twig' %} + +{% block content %} +
    + Möchtest du das Dokument {{ document }} wirklich löschen? +
    +{% endblock %} \ No newline at end of file diff --git a/templates/admin/system/document/modal_edit.html.twig b/templates/admin/system/document/modal_edit.html.twig new file mode 100644 index 0000000..afca21e --- /dev/null +++ b/templates/admin/system/document/modal_edit.html.twig @@ -0,0 +1,15 @@ +{% extends 'htmx_modal.html.twig' %} + +{% block title %}Dokument umbenennen{% endblock %} + +{% block content %} + {{ form_start(form, { 'attr': { 'hx-post': app.request.uri, 'hx-target': '#htmx-modal', 'hx-swap': 'outerHTML' } }) }} +
    + {{ form_row(form.displayName) }} +
    + + {{ form_rest(form) }} + {{ form_end(form) }} +{% endblock %} \ No newline at end of file diff --git a/templates/admin/system/document/modal_replace.html.twig b/templates/admin/system/document/modal_replace.html.twig new file mode 100644 index 0000000..2b8572b --- /dev/null +++ b/templates/admin/system/document/modal_replace.html.twig @@ -0,0 +1,20 @@ +{% extends 'htmx_modal.html.twig' %} + +{% block title %}Dokument ersetzen{% endblock %} + +{% block content %} + {{ form_start(form, { 'attr': { 'hx-post': app.request.uri, 'hx-target': '#htmx-modal', 'hx-swap': 'outerHTML' } }) }} +
    + {% include '_partials/_upload_collection_form.html.twig' with { + 'endpoint_upload': path('_uploader_upload_document'), + 'max_filesize': 5, + 'max_files': 1, + 'accepted_files': 'application/pdf', + } %} +
    + + {{ form_rest(form) }} + {{ form_end(form) }} +{% endblock %} \ No newline at end of file diff --git a/templates/admin/system/document/modal_upload.html.twig b/templates/admin/system/document/modal_upload.html.twig new file mode 100644 index 0000000..f2aab43 --- /dev/null +++ b/templates/admin/system/document/modal_upload.html.twig @@ -0,0 +1,19 @@ +{% extends 'htmx_modal.html.twig' %} + +{% block title %}Dokumente hinzufügen{% endblock %} + +{% block content %} + {{ form_start(form, { 'attr': { 'hx-post': app.request.uri, 'hx-target': '#htmx-modal', 'hx-swap': 'outerHTML' }}) }} +
    + {% include '_partials/_upload_collection_form.html.twig' with { + 'endpoint_upload': path('_uploader_upload_document'), + 'max_filesize': 5, + 'accepted_files': 'application/pdf', + } %} +
    + + {{ form_rest(form) }} + {{ form_end(form) }} +{% endblock %} \ No newline at end of file diff --git a/templates/admin/system/document/replace.html.twig b/templates/admin/system/document/replace.html.twig deleted file mode 100644 index 194a196..0000000 --- a/templates/admin/system/document/replace.html.twig +++ /dev/null @@ -1,14 +0,0 @@ -{{ form_start(form) }} -
    - {% include '_partials/_upload_collection_form.html.twig' with { - 'endpoint_upload': path('_uploader_upload_document'), - 'max_filesize': 5, - 'max_files': 1, - 'accepted_files': 'application/pdf', - } %} -
    - -{{ form_rest(form) }} -{{ form_end(form) }} diff --git a/templates/admin/system/document/upload.html.twig b/templates/admin/system/document/upload.html.twig deleted file mode 100644 index 76a0b9f..0000000 --- a/templates/admin/system/document/upload.html.twig +++ /dev/null @@ -1,13 +0,0 @@ -{{ form_start(form) }} -
    - {% include '_partials/_upload_collection_form.html.twig' with { - 'endpoint_upload': path('_uploader_upload_document'), - 'max_filesize': 5, - 'accepted_files': 'application/pdf', - } %} -
    - -{{ form_rest(form) }} -{{ form_end(form) }} diff --git a/templates/admin/system/faq/index.html.twig b/templates/admin/system/faq/index.html.twig index 5963edf..53385c9 100644 --- a/templates/admin/system/faq/index.html.twig +++ b/templates/admin/system/faq/index.html.twig @@ -33,12 +33,10 @@
    diff --git a/templates/admin/system/faq/modal_delete.html.twig b/templates/admin/system/faq/modal_delete.html.twig new file mode 100644 index 0000000..3932464 --- /dev/null +++ b/templates/admin/system/faq/modal_delete.html.twig @@ -0,0 +1,7 @@ +{% extends 'htmx_confirmation_modal.html.twig' %} + +{% block content %} +
    + Möchtest du die FAQ {{ faq.question }} wirklich löschen? +
    +{% endblock %} \ No newline at end of file diff --git a/templates/admin/system/fee/form.html.twig b/templates/admin/system/fee/_form.html.twig similarity index 67% rename from templates/admin/system/fee/form.html.twig rename to templates/admin/system/fee/_form.html.twig index f16a388..39dd820 100644 --- a/templates/admin/system/fee/form.html.twig +++ b/templates/admin/system/fee/_form.html.twig @@ -1,4 +1,4 @@ -{{ form_start(form) }} +{{ form_start(form, { 'attr': { 'hx-post': app.request.uri, 'hx-target': '#htmx-modal', 'hx-swap': 'outerHTML' } }) }}
    {{ form_row(form.name) }} {{ form_row(form.nameInternal) }} diff --git a/templates/admin/system/fee/index.html.twig b/templates/admin/system/fee/index.html.twig index d923eee..5a59157 100644 --- a/templates/admin/system/fee/index.html.twig +++ b/templates/admin/system/fee/index.html.twig @@ -39,28 +39,24 @@
    @@ -79,11 +75,10 @@
    {% endblock %} \ No newline at end of file diff --git a/templates/admin/system/fee/modal_create.html.twig b/templates/admin/system/fee/modal_create.html.twig new file mode 100644 index 0000000..e648c3d --- /dev/null +++ b/templates/admin/system/fee/modal_create.html.twig @@ -0,0 +1,7 @@ +{% extends 'htmx_modal.html.twig' %} + +{% block title %}Honorar hinzufügen{% endblock %} + +{% block content %} + {% include 'admin/system/fee/_form.html.twig' %} +{% endblock %} \ No newline at end of file diff --git a/templates/admin/system/fee/modal_delete.html.twig b/templates/admin/system/fee/modal_delete.html.twig new file mode 100644 index 0000000..415916d --- /dev/null +++ b/templates/admin/system/fee/modal_delete.html.twig @@ -0,0 +1,7 @@ +{% extends 'htmx_confirmation_modal.html.twig' %} + +{% block content %} +
    + Möchtest du das Honorar {{ fee.name }} wirklich löschen? +
    +{% endblock %} \ No newline at end of file diff --git a/templates/admin/system/fee/modal_duplicate.html.twig b/templates/admin/system/fee/modal_duplicate.html.twig new file mode 100644 index 0000000..2c81183 --- /dev/null +++ b/templates/admin/system/fee/modal_duplicate.html.twig @@ -0,0 +1,7 @@ +{% extends 'htmx_modal.html.twig' %} + +{% block title %}Honorar duplizieren{% endblock %} + +{% block content %} + {% include 'admin/system/fee/_form.html.twig' %} +{% endblock %} \ No newline at end of file diff --git a/templates/admin/system/fee/modal_edit.html.twig b/templates/admin/system/fee/modal_edit.html.twig new file mode 100644 index 0000000..034f944 --- /dev/null +++ b/templates/admin/system/fee/modal_edit.html.twig @@ -0,0 +1,7 @@ +{% extends 'htmx_modal.html.twig' %} + +{% block title %}Honorar bearbeiten{% endblock %} + +{% block content %} + {% include 'admin/system/fee/_form.html.twig' %} +{% endblock %} \ No newline at end of file diff --git a/templates/admin/system/feedback_set/index.html.twig b/templates/admin/system/feedback_set/index.html.twig index d038ef3..7e1aa01 100644 --- a/templates/admin/system/feedback_set/index.html.twig +++ b/templates/admin/system/feedback_set/index.html.twig @@ -34,12 +34,9 @@ {% if is_granted('DELETE', feedbackSet) %} {% endif %} diff --git a/templates/admin/system/feedback_set/modal_delete.html.twig b/templates/admin/system/feedback_set/modal_delete.html.twig new file mode 100644 index 0000000..ea5adb9 --- /dev/null +++ b/templates/admin/system/feedback_set/modal_delete.html.twig @@ -0,0 +1,7 @@ +{% extends 'htmx_confirmation_modal.html.twig' %} + +{% block content %} +
    + Möchtest du die Feedback-Vorlage {{ feedbackSet.name }} wirklich löschen? +
    +{% endblock %} \ No newline at end of file diff --git a/templates/admin/system/job_profile/index.html.twig b/templates/admin/system/job_profile/index.html.twig index 79586cf..e356ea5 100644 --- a/templates/admin/system/job_profile/index.html.twig +++ b/templates/admin/system/job_profile/index.html.twig @@ -55,12 +55,10 @@
    diff --git a/templates/admin/system/job_profile/modal_delete.html.twig b/templates/admin/system/job_profile/modal_delete.html.twig new file mode 100644 index 0000000..ebd584e --- /dev/null +++ b/templates/admin/system/job_profile/modal_delete.html.twig @@ -0,0 +1,7 @@ +{% extends 'htmx_confirmation_modal.html.twig' %} + +{% block content %} +
    + Möchtest du das Jobprofil {{ jobProfile.name }} wirklich löschen? +
    +{% endblock %} \ No newline at end of file diff --git a/templates/admin/system/training/form.html.twig b/templates/admin/system/training/_form.html.twig similarity index 60% rename from templates/admin/system/training/form.html.twig rename to templates/admin/system/training/_form.html.twig index a7fa94b..cddac5f 100644 --- a/templates/admin/system/training/form.html.twig +++ b/templates/admin/system/training/_form.html.twig @@ -1,4 +1,4 @@ -{{ form_start(form) }} +{{ form_start(form, { 'attr': { 'hx-post': app.request.uri, 'hx-target': '#htmx-modal', 'hx-swap': 'outerHTML' } }) }}
    {{ form_row(form.name) }}
    diff --git a/templates/admin/system/training/index.html.twig b/templates/admin/system/training/index.html.twig index 760d061..44c7efa 100644 --- a/templates/admin/system/training/index.html.twig +++ b/templates/admin/system/training/index.html.twig @@ -33,20 +33,17 @@
    @@ -65,11 +62,10 @@
    {% endblock %} \ No newline at end of file diff --git a/templates/admin/system/training/modal_create.hml.twig b/templates/admin/system/training/modal_create.hml.twig new file mode 100644 index 0000000..ec1b292 --- /dev/null +++ b/templates/admin/system/training/modal_create.hml.twig @@ -0,0 +1,7 @@ +{% extends 'htmx_modal.html.twig' %} + +{% block title %}Fortbildung hinzufügen{% endblock %} + +{% block content %} + {% include 'admin/system/training/_form.html.twig' %} +{% endblock %} \ No newline at end of file diff --git a/templates/admin/system/training/modal_delete.html.twig b/templates/admin/system/training/modal_delete.html.twig new file mode 100644 index 0000000..f213db5 --- /dev/null +++ b/templates/admin/system/training/modal_delete.html.twig @@ -0,0 +1,13 @@ +{% extends 'htmx_confirmation_modal.html.twig' %} + +{% block content %} +
    + Möchtest du die Fortbildung {{ training.name }} wirklich löschen? +
    + {% set attendanceCount = training.trainingAttendances|length %} + {% if attendanceCount > 0 %} +
    + An dieser Fortbildung haben {{ attendanceCount }} Teamer:innern teilgenommen. +
    + {% endif %} +{% endblock %} \ No newline at end of file diff --git a/templates/admin/system/training/modal_edit.hml.twig b/templates/admin/system/training/modal_edit.hml.twig new file mode 100644 index 0000000..32bb1cb --- /dev/null +++ b/templates/admin/system/training/modal_edit.hml.twig @@ -0,0 +1,7 @@ +{% extends 'htmx_modal.html.twig' %} + +{% block title %}Fortbildung bearbeiten{% endblock %} + +{% block content %} + {% include 'admin/system/training/_form.html.twig' %} +{% endblock %} \ No newline at end of file diff --git a/templates/admin/teamer/availability.html.twig b/templates/admin/teamer/availability/index.html.twig similarity index 73% rename from templates/admin/teamer/availability.html.twig rename to templates/admin/teamer/availability/index.html.twig index 3fb4eff..dd5f279 100644 --- a/templates/admin/teamer/availability.html.twig +++ b/templates/admin/teamer/availability/index.html.twig @@ -1,4 +1,4 @@ -{% extends 'admin/layout.html.twig' %} +{% extends 'layout.html.twig' %} {% block title %}Verfügbarkeit {{ teamer }}{% endblock %} @@ -29,12 +29,9 @@ {% if is_granted('DELETE', availability) %} {% endif %} diff --git a/templates/admin/teamer/availability/modal_delete.html.twig b/templates/admin/teamer/availability/modal_delete.html.twig new file mode 100644 index 0000000..87bf028 --- /dev/null +++ b/templates/admin/teamer/availability/modal_delete.html.twig @@ -0,0 +1,7 @@ +{% extends 'htmx_confirmation_modal.html.twig' %} + +{% block content %} +
    + Möchtest du die Verfügbarkeit {{ availability }} wirklich löschen? +
    +{% endblock %} \ No newline at end of file diff --git a/templates/admin/teamer/index.html.twig b/templates/admin/teamer/index.html.twig index 05a28b5..157cb79 100644 --- a/templates/admin/teamer/index.html.twig +++ b/templates/admin/teamer/index.html.twig @@ -10,19 +10,16 @@
    {% if filterDto.active %} diff --git a/templates/admin/teamer/info.html.twig b/templates/admin/teamer/info.html.twig deleted file mode 100644 index 0301297..0000000 --- a/templates/admin/teamer/info.html.twig +++ /dev/null @@ -1,67 +0,0 @@ - diff --git a/templates/admin/teamer/modal_info.html.twig b/templates/admin/teamer/modal_info.html.twig new file mode 100644 index 0000000..1157589 --- /dev/null +++ b/templates/admin/teamer/modal_info.html.twig @@ -0,0 +1,73 @@ +{% extends 'htmx_modal.html.twig' %} + +{% block title %}Teamer:inneninfo {{ teamer }}{% endblock %} + +{% block content %} +
    +
    + {% include '_partials/_teamer_training_info.html.twig' %} + {% include '_partials/_teamer_license_info.html.twig' %} +

    + Zustiege +

    +
      + {% for pickup in teamer.pickups %} +
    • + {{ pickup|bpn_pickup_label }} +
    • + {% endfor %} +
    +

    + Letzte Einsätze +

    +
      + {% for disposition in recentDispositions %} + {% set destination = disposition.assignment.destination %} +
    • + {{ destination.product }} +
      + {{ destination.dateFrom|date('d.m.y') }} - {{ destination.dateTo|date('d.m.y') }} +
    • + {% else %} +
    • + - +
    • + {% endfor %} +
    +
    +
    + {% if teamer.photo %} + {{ teamer.firstName }} + {% else %} +
    + {{ icon('user', 'w-32 h-32 text-gray-200') }} +
    + {% endif %} + {% include '_partials/_rating_stars.html.twig' with { 'teamer': teamer } %} + +
    +
    +{% endblock %} \ No newline at end of file diff --git a/templates/admin/teamer/skills.html.twig b/templates/admin/teamer/skills.html.twig index 7c4a12c..a0636d7 100644 --- a/templates/admin/teamer/skills.html.twig +++ b/templates/admin/teamer/skills.html.twig @@ -27,22 +27,18 @@
    {% else %} {% endif %} diff --git a/templates/admin/teamer/training_attendance/create.html.twig b/templates/admin/teamer/training_attendance/create.html.twig deleted file mode 100644 index 5944146..0000000 --- a/templates/admin/teamer/training_attendance/create.html.twig +++ /dev/null @@ -1,9 +0,0 @@ -{{ form_start(form) }} -
    - {{ form_row(form.date) }} -
    - -{{ form_rest(form) }} -{{ form_end(form) }} \ No newline at end of file diff --git a/templates/admin/teamer/training_attendance/modal_create.html.twig b/templates/admin/teamer/training_attendance/modal_create.html.twig new file mode 100644 index 0000000..fff202d --- /dev/null +++ b/templates/admin/teamer/training_attendance/modal_create.html.twig @@ -0,0 +1,15 @@ +{% extends 'htmx_modal.html.twig' %} + +{% block title %}Teilnahme hinzufügen/bestätigen{% endblock %} + +{% block content %} + {{ form_start(form, { 'attr': { 'hx-post': app.request.uri, 'hx-target': '#htmx-modal', 'hx-swap': 'outerHTML' } }) }} +
    + {{ form_row(form.date) }} +
    + + {{ form_rest(form) }} + {{ form_end(form) }} +{% endblock %} \ No newline at end of file diff --git a/templates/admin/teamer/training_attendance/modal_delete.html.twig b/templates/admin/teamer/training_attendance/modal_delete.html.twig new file mode 100644 index 0000000..3246df1 --- /dev/null +++ b/templates/admin/teamer/training_attendance/modal_delete.html.twig @@ -0,0 +1,8 @@ +{% extends 'htmx_confirmation_modal.html.twig' %} + +{% block content %} +
    + Möchtest du die Teilnahme von {{ attendance.teamer}} an der Schulung + {{ attendance.training.name }} wirklich löschen? +
    +{% endblock %} \ No newline at end of file diff --git a/templates/common/assignment_filter.html.twig b/templates/common/assignment_filter.html.twig deleted file mode 100644 index 2e2557e..0000000 --- a/templates/common/assignment_filter.html.twig +++ /dev/null @@ -1,15 +0,0 @@ -{{ form_start(filterForm) }} -
    - {{ form_row(filterForm.status) }} - {{ form_row(filterForm.dateFrom) }} - {{ form_row(filterForm.dateTo) }} - {{ form_row(filterForm.jobProfile) }} - {{ form_row(filterForm.destination) }} - {{ form_row(filterForm.duration) }} -
    -
    - {{ form_widget(filterForm.apply, { 'attr': { 'class': 'btn' } }) }} - {{ form_widget(filterForm.reset, { 'attr': { 'class': 'btn btn--secondary' } }) }} -
    -{{ form_rest(filterForm) }} -{{ form_end(filterForm) }} diff --git a/templates/common/modal_assignment_filter.html.twig b/templates/common/modal_assignment_filter.html.twig new file mode 100644 index 0000000..437d39d --- /dev/null +++ b/templates/common/modal_assignment_filter.html.twig @@ -0,0 +1,21 @@ +{% extends 'htmx_modal.html.twig' %} + +{% block title %}Einsätze filtern{% endblock %} + +{% block content %} + {{ form_start(filterForm, { 'attr': { 'hx-post': app.request.uri, 'hx-target': '#htmx-modal', 'hx-swap': 'outerHTML' } }) }} +
    + {{ form_row(filterForm.status) }} + {{ form_row(filterForm.dateFrom) }} + {{ form_row(filterForm.dateTo) }} + {{ form_row(filterForm.jobProfile) }} + {{ form_row(filterForm.destination) }} + {{ form_row(filterForm.duration) }} +
    +
    + {{ form_widget(filterForm.apply, { 'attr': { 'class': 'btn' } }) }} + {{ form_widget(filterForm.reset, { 'attr': { 'class': 'btn btn--secondary' } }) }} +
    + {{ form_rest(filterForm) }} + {{ form_end(filterForm) }} +{% endblock %} \ No newline at end of file diff --git a/templates/common/modal_teamer_filter.html.twig b/templates/common/modal_teamer_filter.html.twig new file mode 100644 index 0000000..bbf939c --- /dev/null +++ b/templates/common/modal_teamer_filter.html.twig @@ -0,0 +1,22 @@ +{% extends 'htmx_modal.html.twig' %} + +{% block title %}Team filtern{% endblock %} + +{% block content %} + {{ form_start(filterForm, { 'attr': { 'hx-post': app.request.uri, 'hx-target': '#htmx-modal', 'hx-swap': 'outerHTML'} }) }} +
    + {{ form_row(filterForm.name) }} + {{ form_row(filterForm.dateFrom) }} + {{ form_row(filterForm.dateTo) }} + {{ form_row(filterForm.jobProfile) }} + {{ form_row(filterForm.pickupId) }} + {{ form_row(filterForm.skiLicense) }} + {{ form_row(filterForm.snowboardLicense) }} +
    +
    + {{ form_widget(filterForm.apply, { 'attr': { 'class': 'btn' } }) }} + {{ form_widget(filterForm.reset, { 'attr': { 'class': 'btn btn--secondary' } }) }} +
    + {{ form_rest(filterForm) }} + {{ form_end(filterForm) }} +{% endblock %} \ No newline at end of file diff --git a/templates/common/teamer_filter.html.twig b/templates/common/teamer_filter.html.twig deleted file mode 100644 index 5cc4274..0000000 --- a/templates/common/teamer_filter.html.twig +++ /dev/null @@ -1,16 +0,0 @@ -{{ form_start(filterForm) }} -
    - {{ form_row(filterForm.name) }} - {{ form_row(filterForm.dateFrom) }} - {{ form_row(filterForm.dateTo) }} - {{ form_row(filterForm.jobProfile) }} - {{ form_row(filterForm.pickupId) }} - {{ form_row(filterForm.skiLicense) }} - {{ form_row(filterForm.snowboardLicense) }} -
    -
    - {{ form_widget(filterForm.apply, { 'attr': { 'class': 'btn' } }) }} - {{ form_widget(filterForm.reset, { 'attr': { 'class': 'btn btn--secondary' } }) }} -
    -{{ form_rest(filterForm) }} -{{ form_end(filterForm) }} diff --git a/templates/forms.html.twig b/templates/forms.html.twig index 47035ce..5718cf5 100644 --- a/templates/forms.html.twig +++ b/templates/forms.html.twig @@ -192,6 +192,7 @@ {%- endif -%}
    +
    +
    +
    +
    + {{ icon('alert', 'w-8 h-8') }} +
    + {% block title %}Bist du sicher?{% endblock %} +
    +
    + +
    + {% block content %}{% endblock %} +
    + + +
    +
    +
    diff --git a/templates/htmx_modal.html.twig b/templates/htmx_modal.html.twig new file mode 100644 index 0000000..ab4b50b --- /dev/null +++ b/templates/htmx_modal.html.twig @@ -0,0 +1,21 @@ +
    +
    +
    +
    +
    +
    + {% block title %}{% endblock %} +
    + +
    + {% block content %}{% endblock %} +
    + {% include '_partials/_spinner.html.twig' with { 'class': 'w-8 h-8'} %} +
    +
    +
    +
    diff --git a/templates/layout.html.twig b/templates/layout.html.twig index 61659ae..728f421 100644 --- a/templates/layout.html.twig +++ b/templates/layout.html.twig @@ -31,8 +31,6 @@ {% block content %}{% endblock %}
    - {% include '_partials/_ajax_modal.html.twig' %} - {% include '_partials/_confirmation_modal.html.twig' %}
    Möchtest du die Bewerbung wirklich zurückziehen?
    +{% endblock %} \ No newline at end of file diff --git a/templates/teamer/assignment/detail.html.twig b/templates/teamer/assignment/detail.html.twig index f605aa6..a6a13e8 100644 --- a/templates/teamer/assignment/detail.html.twig +++ b/templates/teamer/assignment/detail.html.twig @@ -40,12 +40,9 @@ {% endif %} diff --git a/templates/teamer/assignment/index.html.twig b/templates/teamer/assignment/index.html.twig index d745ae6..db1d62c 100644 --- a/templates/teamer/assignment/index.html.twig +++ b/templates/teamer/assignment/index.html.twig @@ -10,19 +10,15 @@
    {% if filterDto.active %} diff --git a/templates/teamer/feedback/index.html.twig b/templates/teamer/feedback/index.html.twig deleted file mode 100644 index 229ba05..0000000 --- a/templates/teamer/feedback/index.html.twig +++ /dev/null @@ -1,14 +0,0 @@ -

    - Durchschnittsnote: {{ feedback.averageRating|format_rating }} -

    -
      - {% for item in feedback.ratings %} -
    • - {{ item.rating }} - Note {{ item.mark }} -
    • - {% endfor %} -
    -

    - abgegeben von {{ feedback.author }} ({{ feedback.createdBy }}) -

    diff --git a/templates/teamer/feedback/modal.html.twig b/templates/teamer/feedback/modal.html.twig new file mode 100644 index 0000000..a7c84ca --- /dev/null +++ b/templates/teamer/feedback/modal.html.twig @@ -0,0 +1,20 @@ +{% extends 'htmx_modal.html.twig' %} + +{% block title %}{{ feedback.destinationName ~ ' ' ~ feedback.assignmentDate|date('m.Y') }}{% endblock %} + +{% block content %} +

    + Durchschnittsnote: {{ feedback.averageRating|format_rating }} +

    +
      + {% for item in feedback.ratings %} +
    • + {{ item.rating }} + Note {{ item.mark }} +
    • + {% endfor %} +
    +

    + abgegeben von {{ feedback.author }} ({{ feedback.createdBy }}) +

    +{% endblock %} \ No newline at end of file diff --git a/templates/teamer/index.html.twig b/templates/teamer/index.html.twig index ed886db..4316320 100644 --- a/templates/teamer/index.html.twig +++ b/templates/teamer/index.html.twig @@ -81,22 +81,21 @@ {% for feedback in recentFeedback %}
  • {% else %} diff --git a/templates/teamer/profile/availability/index.html.twig b/templates/teamer/profile/availability/index.html.twig index c50943a..2c0c931 100644 --- a/templates/teamer/profile/availability/index.html.twig +++ b/templates/teamer/profile/availability/index.html.twig @@ -32,12 +32,9 @@ {% if is_granted('DELETE', availability) %} {% endif %} @@ -89,11 +86,10 @@
    {% endblock %} \ No newline at end of file diff --git a/templates/teamer/profile/availability/modal_create.html.twig b/templates/teamer/profile/availability/modal_create.html.twig new file mode 100644 index 0000000..ce20af7 --- /dev/null +++ b/templates/teamer/profile/availability/modal_create.html.twig @@ -0,0 +1,17 @@ +{% extends 'htmx_modal.html.twig' %} + +{% block title %}Eigenen Zeitraum hinzufügen{% endblock %} + +{% block content %} + {{ form_start(form, { 'attr': { 'hx-post': app.request.uri, 'hx-target': '#htmx-modal', 'hx-swap': 'outerHTML' } }) }} +
    + {{ form_row(form.dateFrom) }} + {{ form_row(form.dateTo) }} + {{ form_row(form.description) }} +
    + + {{ form_rest(form) }} + {{ form_end(form) }} +{% endblock %} \ No newline at end of file diff --git a/templates/teamer/profile/availability/modal_delete.html.twig b/templates/teamer/profile/availability/modal_delete.html.twig new file mode 100644 index 0000000..3022be0 --- /dev/null +++ b/templates/teamer/profile/availability/modal_delete.html.twig @@ -0,0 +1,8 @@ +{% extends 'htmx_confirmation_modal.html.twig' %} + +{% block content %} +
    + Möchtest du die Verfügbarkeit {{ availability }}{% if availability.description %} ({{ availability.description }}){% endif %} + wirklich löschen? +
    +{% endblock %} \ No newline at end of file diff --git a/templates/teamer/profile/license/add.html.twig b/templates/teamer/profile/license/add.html.twig deleted file mode 100644 index d9ac1d6..0000000 --- a/templates/teamer/profile/license/add.html.twig +++ /dev/null @@ -1,25 +0,0 @@ -{{ form_start(form) }} -{% if not form.vars.valid %} -
    - {% include '_partials/_form_errors.html.twig' with { 'form': form } %} -
    -{% endif %} -
    - {{ form_row(form.type) }} - {{ form_row(form.date) }} -
    - - {% include '_partials/_upload_collection_form.html.twig' with { - 'endpoint_upload': path('_uploader_upload_certificate'), - 'upload_session_params': form.vars.upload_session_params, - 'accepted_files': 'application/pdf', - } %} -
    -
    - -{{ form_rest(form) }} -{{ form_end(form) }} \ No newline at end of file diff --git a/templates/teamer/profile/license/modal_add.html.twig b/templates/teamer/profile/license/modal_add.html.twig new file mode 100644 index 0000000..7647ba7 --- /dev/null +++ b/templates/teamer/profile/license/modal_add.html.twig @@ -0,0 +1,31 @@ +{% extends 'htmx_modal.html.twig' %} + +{% block title %}Lizenz hinzufügen{% endblock %} + +{% block content %} + {{ form_start(form, { 'attr': { 'hx-post': app.request.uri, 'hx-target': '#htmx-modal', 'hx-swap': 'outerHTML' } }) }} + {% if not form.vars.valid %} +
    + {% include '_partials/_form_errors.html.twig' with { 'form': form } %} +
    + {% endif %} +
    + {{ form_row(form.type) }} + {{ form_row(form.date) }} +
    + + {% include '_partials/_upload_collection_form.html.twig' with { + 'endpoint_upload': path('_uploader_upload_certificate'), + 'upload_session_params': form.vars.upload_session_params, + 'accepted_files': 'application/pdf', + } %} +
    +
    + + {{ form_rest(form) }} + {{ form_end(form) }} +{% endblock %} \ No newline at end of file diff --git a/templates/teamer/profile/license/modal_delete.html.twig b/templates/teamer/profile/license/modal_delete.html.twig new file mode 100644 index 0000000..eedc1a4 --- /dev/null +++ b/templates/teamer/profile/license/modal_delete.html.twig @@ -0,0 +1,7 @@ +{% extends 'htmx_confirmation_modal.html.twig' %} + +{% block content %} +
    + Möchtest du die Lizenz {{ license.type|license_label }} wirklich löschen? +
    +{% endblock %} \ No newline at end of file diff --git a/templates/teamer/profile/skills.html.twig b/templates/teamer/profile/skills.html.twig index 27f1713..9049986 100644 --- a/templates/teamer/profile/skills.html.twig +++ b/templates/teamer/profile/skills.html.twig @@ -42,12 +42,9 @@ {% endif %} @@ -61,11 +58,10 @@