From b269ef38b3fecefbb265cd3e79215c94e0e29163 Mon Sep 17 00:00:00 2001 From: Nicolas Potier Date: Wed, 19 Jan 2022 18:37:24 +0100 Subject: [PATCH] add fixes related to pull #1045 conversation --- Grid/Export/Export.php | 2 +- Grid/GridManager.php | 10 +++++++++- Resources/views/blocks.html.twig | 32 ++++++++++++++++---------------- 3 files changed, 26 insertions(+), 18 deletions(-) diff --git a/Grid/Export/Export.php b/Grid/Export/Export.php index 7f7cfdcd..a4782760 100644 --- a/Grid/Export/Export.php +++ b/Grid/Export/Export.php @@ -19,7 +19,7 @@ abstract class Export implements ExportInterface, ContainerAwareInterface { - const DEFAULT_TEMPLATE = 'APYDataGridBundle::blocks.html.twig'; + const DEFAULT_TEMPLATE = '@APYDataGrid/blocks.html.twig'; protected $title; diff --git a/Grid/GridManager.php b/Grid/GridManager.php index 271f301d..454eccd0 100644 --- a/Grid/GridManager.php +++ b/Grid/GridManager.php @@ -193,7 +193,15 @@ public function getGridManagerResponse($param1 = null, $param2 = null, Response return $parameters; } - return $this->container->get('templating')->renderResponse($view, $parameters, $response); + $content = $this->container->get('twig')->render($view, $parameters); + + if (null === $response) { + $response = new Response(); + } + + $response->setContent($content); + + return $response; } } diff --git a/Resources/views/blocks.html.twig b/Resources/views/blocks.html.twig index 9f41c756..d1b8d50e 100644 --- a/Resources/views/blocks.html.twig +++ b/Resources/views/blocks.html.twig @@ -43,7 +43,7 @@ {% block grid_no_data %}

{{ grid.noDataMessage|default('No data')|trans|raw }}

{% endblock grid_no_data %} {# --------------------------------------------------- grid_no_result ------------------------------------------------- #} {% block grid_no_result %} -{% spaceless %} +{% apply spaceless %} {% set nbColumns = 0 %} {% for column in grid.columns %} {% if column.visible(grid.isReadyForExport) %} @@ -53,7 +53,7 @@ {{ grid.noResultMessage|default('No result')|trans|raw }} -{% endspaceless %} +{% endapply %} {% endblock grid_no_result %} {# --------------------------------------------------- grid_titles -------------------------------------------------- #} {% block grid_titles %} @@ -62,7 +62,7 @@ {% set translation_domain = column.translationDomain %} {% if column.visible(grid.isReadyForExport) %} -1) %} style="width:{{ column.size }}px;"{% endif %}> - {%- spaceless %} + {% apply spaceless %} {% if column.type == 'massaction' %} {% else %} @@ -88,7 +88,7 @@ {{ columnTitle }} {% endif %} {% endif %} - {% endspaceless -%} + {% endapply -%} {% endif %} {% endfor %} @@ -128,7 +128,7 @@ {% block grid_rows %} {% for row in grid.rows %} {% set last_row = loop.last %} - {% spaceless %} + {% apply spaceless %} {% set gridColumns %} {% for column in grid.columns %} {% if column.visible(grid.isReadyForExport) %} @@ -138,7 +138,7 @@ {% endset %} {{ gridColumns }} - {% endspaceless %} + {% endapply %} {% else %} {{ grid_no_result(grid) }} @@ -163,11 +163,11 @@ {# ---------------------------------------------------- grid_pager_selectpage -------------------------------------------------- #} {% block grid_pager_selectpage %} {{ 'Page'|trans }} -{% spaceless %} +{% apply spaceless %} = grid.pageCount-1 %}disabled="disabled"{% endif %} onclick="return {{ grid.hash }}_nextPage();"/> {{ 'of %count%'|trans({ '%count%' : grid.pageCount }) }} -{% endspaceless %} +{% endapply %} {% endblock grid_pager_selectpage %} {# ---------------------------------------------------- grid_pager_results_perpage -------------------------------------------------- #} {% block grid_pager_results_perpage %} @@ -188,7 +188,7 @@ {{ 'Deselect all'|trans }} - {% spaceless %} + {% apply spaceless %}
{{ 'Action'|trans }} @@ -200,13 +200,13 @@
- {% endspaceless %} + {% endapply %} {% endblock grid_actions %} {# --------------------------------------------------- grid_exports ------------------------------------------------- #} {% block grid_exports %}
- {% spaceless %} + {% apply spaceless %} {{ 'Export'|trans }} - {% endspaceless %} + {% endapply %}
{% endblock grid_exports %} {# --------------------------------------------------- grid_tweaks ------------------------------------------------- #} {% block grid_tweaks %}
- {% spaceless %} + {% apply spaceless %} {{ 'Tweaks'|trans }} - {% endspaceless %} + {% endapply %}
{% endblock grid_tweaks %} {# ------------------------------------------------ grid_column_actions_cell --------------------------------------------- #} @@ -299,7 +299,7 @@ {% endblock grid_column_type_simple_array_cell %} {# ------------------------------------------- grid_column_cell ---------------------------------------- #} {% block grid_column_cell %} -{%- spaceless %} +{% apply spaceless %} {% if column.filterable and column.searchOnClick %} {% set sourceValue = sourceValue is defined ? sourceValue : row.field(column.id) %} {{ value }} @@ -308,7 +308,7 @@ {% else %} {{ value|escape(column.safe)|raw }} {% endif %} -{% endspaceless -%} +{% endapply -%} {% endblock grid_column_cell %} {# -------------------------------------------- grid_column_operator --------------------------------------- #} {% block grid_column_operator %}