Skip to content

Commit

Permalink
Avoid to translate an empty admin label
Browse files Browse the repository at this point in the history
  • Loading branch information
VincentLanglet authored and OskarStark committed Dec 15, 2020
1 parent 1578ead commit 61caba0
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 19 deletions.
26 changes: 14 additions & 12 deletions src/Resources/views/Block/block_admin_list.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -25,18 +25,20 @@ file that was distributed with this source code.
<tbody>
{% for admin in group.items %}
{% if admin.dashboardActions|length > 0 %}
<tr>
<td class="sonata-ba-list-label" width="40%">
{{ admin.label|trans({}, admin.translationdomain) }}
</td>
<td>
<div class="btn-group">
{% for action in admin.dashboardActions %}
{% include action.template|default('@SonataAdmin/CRUD/dashboard__action.html.twig') with {'action': action} %}
{% endfor %}
</div>
</td>
</tr>
<tr>
<td class="sonata-ba-list-label" width="40%">
{% if admin.label is not empty %}
{{ admin.label|trans({}, admin.translationdomain) }}
{% endif %}
</td>
<td>
<div class="btn-group">
{% for action in admin.dashboardActions %}
{% include action.template|default('@SonataAdmin/CRUD/dashboard__action.html.twig') with {'action': action} %}
{% endfor %}
</div>
</td>
</tr>
{% endif %}
{% endfor %}
</tbody>
Expand Down
4 changes: 3 additions & 1 deletion src/Resources/views/Block/block_search_result.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@ file that was distributed with this source code.
{% set icon = settings.icon|default('') %}
{{ icon|raw }}
<h3 class="box-title">
{{ admin.label|trans({}, admin.translationdomain) }}
{% if admin.label is not empty %}
{{ admin.label|trans({}, admin.translationdomain) }}
{% endif %}
</h3>

<div class="box-tools pull-right">
Expand Down
13 changes: 9 additions & 4 deletions src/Resources/views/CRUD/Association/edit_many_script.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -131,8 +131,9 @@ This code manages the many-to-[one|many] association field popup
// populate the popup container
field_dialog_content_{{ id }}.html(html);
field_dialog_title_{{ id }}.html("{{ associationadmin.label|trans({}, associationadmin.translationdomain) }}");
{% if admin.label is not empty %}

This comment has been minimized.

Copy link
@mpoiriert

mpoiriert Jan 2, 2021

Contributor

This need to check 'associationadmin.label'.

I have a simple script that load all the admin of my project and I did catch this error on the last update.

The error repeat in the same file.

@VincentLanglet @OskarStark

This comment has been minimized.

Copy link
@VincentLanglet

VincentLanglet Jan 2, 2021

Author Member

Thanks for the report

field_dialog_title_{{ id }}.html("{{ associationadmin.label|trans({}, associationadmin.translationdomain) }}");
{% endif %}
Admin.shared_setup(field_dialog_{{ id }});
Expand Down Expand Up @@ -169,7 +170,9 @@ This code manages the many-to-[one|many] association field popup
// populate the popup container
field_dialog_content_{{ id }}.html(html);
field_dialog_title_{{ id }}.html("{{ associationadmin.label|trans({}, associationadmin.translationdomain) }}");
{% if admin.label is not empty %}
field_dialog_title_{{ id }}.html("{{ associationadmin.label|trans({}, associationadmin.translationdomain) }}");
{% endif %}
Admin.shared_setup(field_dialog_{{ id }});
Expand Down Expand Up @@ -209,7 +212,9 @@ This code manages the many-to-[one|many] association field popup
// populate the popup container
field_dialog_content_{{ id }}.html(html);
field_dialog_title_{{ id }}.html("{{ associationadmin.label|trans({}, associationadmin.translationdomain) }}");
{% if admin.label is not empty %}
field_dialog_title_{{ id }}.html("{{ associationadmin.label|trans({}, associationadmin.translationdomain) }}");
{% endif %}
Admin.shared_setup(field_dialog_{{ id }});
Expand Down
10 changes: 8 additions & 2 deletions src/Resources/views/Core/add_block.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,18 @@
{% if admin.hasRoute('create') and admin.hasAccess('create') %}
{% if admin.subClasses is empty %}
<li role="presentation">
<a role="menuitem" tabindex="-1" href="{{ admin.generateUrl('create') }}">{{ admin.label|trans({}, admin.translationdomain) }}</a>
<a role="menuitem" tabindex="-1" href="{{ admin.generateUrl('create') }}">
{% if admin.label is not empty %}
{{ admin.label|trans({}, admin.translationdomain) }}
{% endif %}
</a>
</li>
{% else %}
{% for subclass in admin.subclasses|keys %}
<li role="presentation">
<a role="menuitem" tabindex="-1" href="{{ admin.generateUrl('create', {'subclass': subclass}) }}">{{ subclass|trans({}, admin.translationdomain) }}</a>
<a role="menuitem" tabindex="-1" href="{{ admin.generateUrl('create', {'subclass': subclass}) }}">
{{ subclass|trans({}, admin.translationdomain) }}
</a>
</li>
{% endfor %}
{% endif %}
Expand Down

0 comments on commit 61caba0

Please sign in to comment.