Skip to content

Commit

Permalink
Merge pull request sonata-project#941 from pulzarraider/item_group_check
Browse files Browse the repository at this point in the history
dashboard+menu: check if at least one group item is available to show the title of a group
  • Loading branch information
rande committed Aug 20, 2012
2 parents 0c18ea1 + 5d4105c commit 6578bf7
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
11 changes: 11 additions & 0 deletions Resources/views/Block/block_admin_list.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,16 @@ file that was distributed with this source code.

{% block block %}
{% for group in groups %}
{% set group_visible = false %}

{# check if at least one group item is available #}
{% for admin in group.items if not group_visible %}
{% if (admin.hasroute('create') and admin.isGranted('CREATE')) or (admin.hasroute('list') and admin.isGranted('LIST')) %}
{% set group_visible = true %}
{% endif %}
{% endfor %}

{% if group_visible %}
<table class="zebra-striped sonata-ba-list bordered-table">
<thead>
<tr>
Expand Down Expand Up @@ -46,5 +56,6 @@ file that was distributed with this source code.
{% endfor %}
</tbody>
</table>
{% endif %}
{% endfor %}
{% endblock %}
11 changes: 11 additions & 0 deletions Resources/views/standard_layout.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,16 @@ file that was distributed with this source code.
{# There is no hasRole in a TokenInterface ... #}
{% if app.security.token and is_granted('ROLE_SONATA_ADMIN') %}
{% for group in admin_pool.dashboardgroups %}
{% set group_visible = false %}

{# check if at least one group item is available #}
{% for admin in group.items if not group_visible %}
{% if (admin.hasroute('create') and admin.isGranted('CREATE')) or (admin.hasroute('list') and admin.isGranted('LIST')) %}
{% set group_visible = true %}
{% endif %}
{% endfor %}

{% if group_visible %}
<li class="dropdown">
<a href="#" class="dropdown-toggle">{{ group.label|trans({}, group.label_catalogue) }}</a>
<ul class="dropdown-menu">
Expand All @@ -99,6 +109,7 @@ file that was distributed with this source code.
{% endfor %}
</ul>
</li>
{% endif %}
{% endfor %}
{% endif %}
{% endblock %}
Expand Down

0 comments on commit 6578bf7

Please sign in to comment.