From d2a61ce69b0866de5ae280cacf13463bde5c35ce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Fri, 31 May 2024 22:23:13 +0200 Subject: [PATCH] Add return path support for ticket creation and editing This commit introduces support for a return path query parameter during ticket creation and editing operations. This enables a more user-friendly redirection after a form submission operation where the return path provides more context on the next page. The return path is now also considered in the Vue.js components, with necessary checks and validations. A 'Cancel' button has been added to the ActionToolbarComponent.vue where the return path exists. --- .../src/Controller/CreateTicketController.php | 7 ++++- .../ChillTicketBundle/src/Entity/Ticket.php | 1 - .../components/ActionToolbarComponent.vue | 27 +++++++++++++++++++ .../components/AddCommentComponent.vue | 2 +- 4 files changed, 34 insertions(+), 3 deletions(-) diff --git a/src/Bundle/ChillTicketBundle/src/Controller/CreateTicketController.php b/src/Bundle/ChillTicketBundle/src/Controller/CreateTicketController.php index a3bdf31c8..8e47d3afa 100644 --- a/src/Bundle/ChillTicketBundle/src/Controller/CreateTicketController.php +++ b/src/Bundle/ChillTicketBundle/src/Controller/CreateTicketController.php @@ -63,8 +63,13 @@ final readonly class CreateTicketController $this->entityManager->flush(); + $query = []; + if ($request->query->has('returnPath')) { + $query['returnPath'] = $request->query->get('returnPath'); + } + return new RedirectResponse( - $this->urlGenerator->generate('chill_ticket_ticket_edit', ['id' => $ticket->getId()]) + $this->urlGenerator->generate('chill_ticket_ticket_edit', ['id' => $ticket->getId(), ...$query]) ); } } diff --git a/src/Bundle/ChillTicketBundle/src/Entity/Ticket.php b/src/Bundle/ChillTicketBundle/src/Entity/Ticket.php index e70447503..04cfe828b 100644 --- a/src/Bundle/ChillTicketBundle/src/Entity/Ticket.php +++ b/src/Bundle/ChillTicketBundle/src/Entity/Ticket.php @@ -69,7 +69,6 @@ class Ticket implements TrackCreationInterface, TrackUpdateInterface #[ORM\OneToMany(targetEntity: PersonHistory::class, mappedBy: 'ticket')] private Collection $personHistories; - public function __construct() { $this->addresseeHistory = new ArrayCollection(); diff --git a/src/Bundle/ChillTicketBundle/src/Resources/public/vuejs/TicketApp/components/ActionToolbarComponent.vue b/src/Bundle/ChillTicketBundle/src/Resources/public/vuejs/TicketApp/components/ActionToolbarComponent.vue index 9604caeec..10ec72a8f 100644 --- a/src/Bundle/ChillTicketBundle/src/Resources/public/vuejs/TicketApp/components/ActionToolbarComponent.vue +++ b/src/Bundle/ChillTicketBundle/src/Resources/public/vuejs/TicketApp/components/ActionToolbarComponent.vue @@ -47,6 +47,9 @@