From 7d834ac8d7aad36b34829e7d6bc10fa0c8109c27 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20B=C3=B6hmer?= Date: Wed, 16 Oct 2024 23:57:02 +0200 Subject: [PATCH] Include the query part of the request, when generating the url for the datatables via a custom twig function. This fixes issue #735, as without this the query gets not passed to the datatable --- src/Twig/MiscExtension.php | 17 +++++++++++++++++ templates/admin/project_admin.html.twig | 2 +- templates/components/datatables.macro.html.twig | 6 +++--- .../components/history_log_macros.html.twig | 2 +- .../log_system/details/helper.macro.html.twig | 2 +- templates/parts/info/_merge_modal.html.twig | 2 +- templates/parts/info/_projects.html.twig | 2 +- templates/parts/info/_tools.html.twig | 2 +- templates/parts/info/_withdraw_modal.html.twig | 2 +- templates/projects/info/_bom.html.twig | 2 +- templates/projects/info/_builds.html.twig | 2 +- 11 files changed, 29 insertions(+), 12 deletions(-) diff --git a/src/Twig/MiscExtension.php b/src/Twig/MiscExtension.php index 1edef7a3..93762d35 100644 --- a/src/Twig/MiscExtension.php +++ b/src/Twig/MiscExtension.php @@ -22,6 +22,7 @@ declare(strict_types=1); */ namespace App\Twig; +use Symfony\Component\HttpFoundation\Request; use Twig\TwigFunction; use App\Services\LogSystem\EventCommentNeededHelper; use Twig\Extension\AbstractExtension; @@ -38,6 +39,22 @@ final class MiscExtension extends AbstractExtension new TwigFunction('event_comment_needed', fn(string $operation_type) => $this->eventCommentNeededHelper->isCommentNeeded($operation_type) ), + + new TwigFunction('uri_without_host', $this->uri_without_host(...)) ]; } + + /** + * Similar to the getUri function of the request, but does not contain protocol and host. + * @param Request $request + * @return string + */ + public function uri_without_host(Request $request): string + { + if (null !== $qs = $request->getQueryString()) { + $qs = '?'.$qs; + } + + return $request->getBaseUrl().$request->getPathInfo().$qs; + } } diff --git a/templates/admin/project_admin.html.twig b/templates/admin/project_admin.html.twig index 7c4418a7..1a995069 100644 --- a/templates/admin/project_admin.html.twig +++ b/templates/admin/project_admin.html.twig @@ -36,7 +36,7 @@ {% if entity.buildPart %} {{ entity.buildPart.name }} {% else %} - {% trans %}project.edit.associated_build_part.add{% endtrans %} {% endif %}

{% trans %}project.edit.associated_build.hint{% endtrans %}

diff --git a/templates/components/datatables.macro.html.twig b/templates/components/datatables.macro.html.twig index 2fbde82b..c32294ba 100644 --- a/templates/components/datatables.macro.html.twig +++ b/templates/components/datatables.macro.html.twig @@ -1,5 +1,5 @@ {% macro datatable(datatable, controller = 'elements/datatables/datatables', state_save_tag = null) %} -
+
@@ -20,12 +20,12 @@ {% macro partsDatatableWithForm(datatable, state_save_tag = 'parts') %}
- + diff --git a/templates/components/history_log_macros.html.twig b/templates/components/history_log_macros.html.twig index 69610e8b..68df2015 100644 --- a/templates/components/history_log_macros.html.twig +++ b/templates/components/history_log_macros.html.twig @@ -17,7 +17,7 @@ {{ stimulus_controller('elements/delete_btn') }} {{ stimulus_action('elements/delete_btn', "submit", "submit") }} data-delete-title="{% trans %}log.undo.confirm_title{% endtrans %}" data-delete-message="{% trans %}log.undo.confirm_message{% endtrans %}"> - + {{ datatables.logDataTable(datatable, tag) }}
diff --git a/templates/log_system/details/helper.macro.html.twig b/templates/log_system/details/helper.macro.html.twig index 95f2ab0a..e8957b66 100644 --- a/templates/log_system/details/helper.macro.html.twig +++ b/templates/log_system/details/helper.macro.html.twig @@ -22,7 +22,7 @@ data-delete-title="{% trans %}log.undo.confirm_title{% endtrans %}" data-delete-message="{% trans %}log.undo.confirm_message{% endtrans %}"> - +