Skip to content

Commit

Permalink
Ask admin exporter service for available formats
Browse files Browse the repository at this point in the history
  • Loading branch information
greg0ire committed Aug 18, 2016
1 parent f83de10 commit 3f378a1
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
3 changes: 3 additions & 0 deletions Controller/CRUDController.php
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,9 @@ public function listAction()
'form' => $formView,
'datagrid' => $datagrid,
'csrf_token' => $this->getCsrfToken('sonata.batch'),
'export_formats' => $this->has('sonata.admin.admin_exporter') ?
$this->get('sonata.admin.admin_exporter')->getAvailableFormats($this->admin) :
$this->admin->getExportFormats(),
), null, $request);
}

Expand Down
7 changes: 5 additions & 2 deletions Resources/views/CRUD/base_list.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -159,16 +159,19 @@ file that was distributed with this source code.
</div>


{# NEXT_MAJOR : remove this assignment #}
{% set export_formats = export_formats|default(admin.getExportFormats) %}

<div class="pull-right">
{% if admin.hasRoute('export') and admin.isGranted('EXPORT') and admin.getExportFormats()|length %}
{% if admin.hasRoute('export') and admin.isGranted('EXPORT') and export_formats|length %}
<div class="btn-group">
<button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown">
<i class="fa fa-share-square-o"></i>
{{ "label_export_download"|trans({}, "SonataAdminBundle") }}
<span class="caret"></span>
</button>
<ul class="dropdown-menu">
{% for format in admin.getExportFormats() %}
{% for format in export_formats %}
<li>
<a href="{{ admin.generateUrl('export', admin.modelmanager.paginationparameters(admin.datagrid, 0) + {'format' : format}) }}">
<i class="fa fa-arrow-circle-o-down"></i>
Expand Down
6 changes: 5 additions & 1 deletion Resources/views/CRUD/list_outer_rows_mosaic.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,12 @@ This template can be customized to match your needs. You should only extends the
{% endblock %}
</div>
</div>

{# NEXT_MAJOR : remove this assignment #}
{% set export_formats = export_formats|default(admin.getExportFormats) %}

<div class="mosaic-inner-text">
{% if (admin.hasRoute('batch') and batchactions|length > 0) or (admin.hasRoute('export') and admin.isGranted("EXPORT") and admin.getExportFormats()|length) %}
{% if (admin.hasRoute('batch') and batchactions|length > 0) or (admin.hasRoute('export') and admin.isGranted("EXPORT") and export_formats|length) %}
<input type="checkbox" name="idx[]" value="{{ admin.id(object) }}">
{% else %}
&nbsp;
Expand Down

0 comments on commit 3f378a1

Please sign in to comment.