Skip to content

Commit

Permalink
add fixes related to pull #1045 conversation
Browse files Browse the repository at this point in the history
  • Loading branch information
npotier committed Jan 19, 2022
1 parent b18e837 commit b269ef3
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 18 deletions.
2 changes: 1 addition & 1 deletion Grid/Export/Export.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
10 changes: 9 additions & 1 deletion Grid/GridManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}

Expand Down
32 changes: 16 additions & 16 deletions Resources/views/blocks.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
{% block grid_no_data %}<p class="no_data">{{ grid.noDataMessage|default('No data')|trans|raw }}</p>{% 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) %}
Expand All @@ -53,7 +53,7 @@
<tr class="grid-row-cells">
<td class="last-column last-row" colspan="{{ nbColumns }}" style="text-align: center;">{{ grid.noResultMessage|default('No result')|trans|raw }}</td>
</tr>
{% endspaceless %}
{% endapply %}
{% endblock grid_no_result %}
{# --------------------------------------------------- grid_titles -------------------------------------------------- #}
{% block grid_titles %}
Expand All @@ -62,7 +62,7 @@
{% set translation_domain = column.translationDomain %}
{% if column.visible(grid.isReadyForExport) %}
<th class="{% if column.align != 'left'%}align-{{ column.align }}{% endif %}{% if column.class %} {{ column.class }}{% endif %}{% if loop.last %} last-column{% endif %}"{% if(column.size > -1) %} style="width:{{ column.size }}px;"{% endif %}>
{%- spaceless %}
{% apply spaceless %}
{% if column.type == 'massaction' %}
<input type="checkbox" class="grid-mass-selector" onclick="{{ grid.hash }}_markVisible(this.checked);"/>
{% else %}
Expand All @@ -88,7 +88,7 @@
{{ columnTitle }}
{% endif %}
{% endif %}
{% endspaceless -%}
{% endapply -%}
</th>
{% endif %}
{% endfor %}
Expand Down Expand Up @@ -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) %}
Expand All @@ -138,7 +138,7 @@
{% endset %}
<tr{% if row.color != '' %} style="background-color:{{ row.color }};"{% endif %} class="grid-row-cells {{ cycle(['odd', 'even'], loop.index) }}{% if row.class != '' %} {{ row.class }}{% endif %}">
{{ gridColumns }}
{% endspaceless %}
{% endapply %}
</tr>
{% else %}
{{ grid_no_result(grid) }}
Expand All @@ -163,11 +163,11 @@
{# ---------------------------------------------------- grid_pager_selectpage -------------------------------------------------- #}
{% block grid_pager_selectpage %}
{{ 'Page'|trans }}
{% spaceless %}
{% apply spaceless %}
<input type="button" class="prev" {% if grid.page <= 0 %}disabled="disabled"{% endif %} value="<" onclick="return {{ grid.hash }}_previousPage();"/>
<input type="text" class="current" value="{{ grid.page + 1 }}" size="2" onkeypress="return {{ grid.hash }}_enterPage(event, parseInt(this.value)-1);"/>
<input type="button" value=">" class="next" {% if grid.page >= 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 %}
Expand All @@ -188,7 +188,7 @@
<a href="#" onclick="return {{ grid.hash }}_markAll(false);">{{ 'Deselect all'|trans }}</a>
<span class="mass-actions-selected" id="{{ grid.hash }}_mass_action_selected"></span>
</span>
{% spaceless %}
{% apply spaceless %}
<div style="float:right;" class="grid_massactions">
{{ 'Action'|trans }}
<input type="hidden" id="{{ grid.hash }}_mass_action_all" name="{{ grid.hash }}[{{ constant('APY\\DataGridBundle\\Grid\\Grid::REQUEST_QUERY_MASS_ACTION_ALL_KEYS_SELECTED') }}]" value="0"/>
Expand All @@ -200,13 +200,13 @@
</select>
<input type="submit" value="{{ 'Submit Action'|trans }}"/>
</div>
{% endspaceless %}
{% endapply %}
</div>
{% endblock grid_actions %}
{# --------------------------------------------------- grid_exports ------------------------------------------------- #}
{% block grid_exports %}
<div class="exports" style="float:right">
{% spaceless %}
{% apply spaceless %}
{{ 'Export'|trans }}
<select name="{{grid.hash}}[{{ constant('APY\\DataGridBundle\\Grid\\Grid::REQUEST_QUERY_EXPORT') }}]">
<option value="-1"></option>
Expand All @@ -215,13 +215,13 @@
{% endfor %}
</select>
<input type="submit" value="{{ 'Export'|trans }}"/>
{% endspaceless %}
{% endapply %}
</div>
{% endblock grid_exports %}
{# --------------------------------------------------- grid_tweaks ------------------------------------------------- #}
{% block grid_tweaks %}
<div class="tweaks" style="float:right">
{% spaceless %}
{% apply spaceless %}
{{ 'Tweaks'|trans }}
<select name="{{grid.hash}}[{{ constant('APY\\DataGridBundle\\Grid\\Grid::REQUEST_QUERY_TWEAK') }}]">
<option value=""></option>
Expand All @@ -230,7 +230,7 @@
{% endfor %}
</select>
<input type="submit" value="{{ 'Tweak'|trans }}"/>
{% endspaceless %}
{% endapply %}
</div>
{% endblock grid_tweaks %}
{# ------------------------------------------------ grid_column_actions_cell --------------------------------------------- #}
Expand Down Expand Up @@ -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) %}
<a href="?{{ grid.hash }}[{{ column.id }}][from]={{ sourceValue | url_encode() }}" class="searchOnClick">{{ value }}</a>
Expand All @@ -308,7 +308,7 @@
{% else %}
{{ value|escape(column.safe)|raw }}
{% endif %}
{% endspaceless -%}
{% endapply -%}
{% endblock grid_column_cell %}
{# -------------------------------------------- grid_column_operator --------------------------------------- #}
{% block grid_column_operator %}
Expand Down

0 comments on commit b269ef3

Please sign in to comment.