mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-07 18:44:08 +00:00
Allow to group exports
This commit is contained in:
parent
b7e71088ac
commit
9c6a3de0ff
@ -107,10 +107,10 @@ class ExportController extends Controller
|
|||||||
{
|
{
|
||||||
$exportManager = $this->exportManager;
|
$exportManager = $this->exportManager;
|
||||||
|
|
||||||
$exports = $exportManager->getExports(true);
|
$exports = $exportManager->getExportsGrouped(true);
|
||||||
|
|
||||||
return $this->render('ChillMainBundle:Export:layout.html.twig', array(
|
return $this->render('ChillMainBundle:Export:layout.html.twig', array(
|
||||||
'exports' => $exports
|
'grouped_exports' => $exports
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -231,6 +231,26 @@ class ExportManager
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get all exports grouped in an array.
|
||||||
|
*
|
||||||
|
* @param bool $whereUserIsGranted
|
||||||
|
* @return array where keys are the groups's name and value is an array of exports
|
||||||
|
*/
|
||||||
|
public function getExportsGrouped($whereUserIsGranted = true): array
|
||||||
|
{
|
||||||
|
$groups = [ '_' => [] ];
|
||||||
|
foreach ($this->getExports($whereUserIsGranted) as $alias => $export) {
|
||||||
|
if ($export instanceof GroupedExportInterface) {
|
||||||
|
$groups[$export->getGroup()][$alias] = $export;
|
||||||
|
} else {
|
||||||
|
$groups['_'][$alias] = $export;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $groups;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return an export by his alias
|
* Return an export by his alias
|
||||||
*
|
*
|
||||||
|
16
Export/GroupedExportInterface.php
Normal file
16
Export/GroupedExportInterface.php
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
<?php
|
||||||
|
/*
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
namespace Chill\MainBundle\Export;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add a grouping option to exports.
|
||||||
|
*
|
||||||
|
* **usage**: the exports will be grouped under the key given by the `getGroup`
|
||||||
|
* method.
|
||||||
|
*/
|
||||||
|
interface GroupedExportInterface
|
||||||
|
{
|
||||||
|
public function getGroup(): string;
|
||||||
|
}
|
@ -173,6 +173,7 @@ Choose a format: Choisir un format
|
|||||||
#export creation step 'formatter' : choose formatter option
|
#export creation step 'formatter' : choose formatter option
|
||||||
Generate the report: Générer le rapport
|
Generate the report: Générer le rapport
|
||||||
No options availables. Your report is fully configured.: Pas d'options disponibles. Votre rapport est déjà configuré.
|
No options availables. Your report is fully configured.: Pas d'options disponibles. Votre rapport est déjà configuré.
|
||||||
|
Ungrouped exports: Autres exports
|
||||||
|
|
||||||
#export download
|
#export download
|
||||||
Download export: Téléchargement du rapport
|
Download export: Téléchargement du rapport
|
||||||
|
@ -25,19 +25,44 @@
|
|||||||
<div class="container-export">
|
<div class="container-export">
|
||||||
<h1>{{ 'Exports list'|trans }}</h1>
|
<h1>{{ 'Exports list'|trans }}</h1>
|
||||||
|
|
||||||
<div class="export-list">
|
<div>
|
||||||
{% for export_alias,export in exports %}
|
{% for group, exports in grouped_exports if group != '_' %}
|
||||||
<div class="export-list__element">
|
<h2>{{ group }}</h2>
|
||||||
<h2>{{ export.title|trans }}</h2>
|
|
||||||
<p>{{ export.description|trans }}</p>
|
<div class="export-list">
|
||||||
|
{% for export_alias, export in exports %}
|
||||||
|
<div class="export-list__element">
|
||||||
|
<h2>{{ export.title|trans }}</h2>
|
||||||
|
<p>{{ export.description|trans }}</p>
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
<a class="sc-button bt-action" href="{{ path('chill_main_export_new', { 'alias': export_alias } ) }}">
|
<a class="sc-button bt-action" href="{{ path('chill_main_export_new', { 'alias': export_alias } ) }}">
|
||||||
{{ 'Create an export'|trans }}
|
{{ 'Create an export'|trans }}
|
||||||
</a>
|
</a>
|
||||||
</p>
|
</p>
|
||||||
|
</div>
|
||||||
|
{% endfor %}
|
||||||
|
</div>
|
||||||
|
{% endfor %}
|
||||||
|
|
||||||
|
{% if grouped_exports|keys|length > 1 %}
|
||||||
|
<h2>{{ 'Ungrouped exports'|trans }}</h2>
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
<div class="export-list">
|
||||||
|
{% for export_alias,export in grouped_exports['_'] %}
|
||||||
|
<div class="export-list__element">
|
||||||
|
<h2>{{ export.title|trans }}</h2>
|
||||||
|
<p>{{ export.description|trans }}</p>
|
||||||
|
|
||||||
|
<p>
|
||||||
|
<a class="sc-button bt-action" href="{{ path('chill_main_export_new', { 'alias': export_alias } ) }}">
|
||||||
|
{{ 'Create an export'|trans }}
|
||||||
|
</a>
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
{% endfor %}
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{% endfor %}
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user