exports: display group as a breadcrumb in template

add a private method in controller which could be moved maybe in ExportManager
This commit is contained in:
Mathieu Jaumotte 2022-08-17 13:02:54 +02:00
parent d9b668e614
commit df9a5071c7
5 changed files with 43 additions and 1 deletions

View File

@ -86,6 +86,9 @@ class ExportController extends AbstractController
{
/** @var \Chill\MainBundle\Export\ExportManager $exportManager */
$exportManager = $this->exportManager;
$export = $exportManager->getExport($alias);
$key = $request->query->get('key', null);
[$dataCenters, $dataExport, $dataFormatter] = $this->rebuildData($key);
@ -100,7 +103,8 @@ class ExportController extends AbstractController
$viewVariables = [
'alias' => $alias,
'export' => $exportManager->getExport($alias),
'export' => $export,
'export_group' => $this->getExportGroup($export),
];
if ($formater instanceof \Chill\MainBundle\Export\Formatter\CSVListFormatter) {
@ -316,6 +320,7 @@ class ExportController extends AbstractController
'form' => $form->createView(),
'export_alias' => $alias,
'export' => $export,
'export_group' => $this->getExportGroup($export),
]);
}
@ -371,6 +376,7 @@ class ExportController extends AbstractController
[
'form' => $form->createView(),
'export' => $export,
'export_group' => $this->getExportGroup($export),
]
);
}
@ -514,6 +520,7 @@ class ExportController extends AbstractController
[
'form' => $form->createView(),
'export' => $export,
'export_group' => $this->getExportGroup($export),
]
);
}
@ -565,4 +572,19 @@ class ExportController extends AbstractController
throw new LogicException("the step {$step} is not defined.");
}
}
private function getExportGroup($target): string
{
$exportManager = $this->exportManager;
$groups = $exportManager->getExportsGrouped(true);
foreach ($groups as $group => $array) {
foreach ($array as $alias => $export) {
if ($export === $target) {
return $group;
}
}
}
}
}

View File

@ -36,6 +36,11 @@ window.addEventListener("DOMContentLoaded", function(e) {
{% block content %}
<div class="col-md-10">
<h6>
<i class="fa fa-folder-open-o fa-fw"></i>
{{ export_group|trans }}
</h6>
<h1>{{ export.title|trans }}</h1>
<h2>{{ "Download export"|trans }}</h2>

View File

@ -27,6 +27,11 @@
{% block content %}
<div class="col-md-10">
<h6>
<i class="fa fa-folder-open-o fa-fw"></i>
{{ export_group|trans }}
</h6>
<h1>{{ export.title|trans }}</h1>
<p>{{ export.description|trans }}</p>

View File

@ -23,6 +23,11 @@
{% block content %}
<div class="col-md-10">
<h6>
<i class="fa fa-folder-open-o fa-fw"></i>
{{ export_group|trans }}
</h6>
<h1>{{ export.title|trans }}</h1>
<p>{{ export.description|trans }}</p>

View File

@ -22,6 +22,11 @@
{% block content %}
<div class="col-md-10">
<h6>
<i class="fa fa-folder-open-o fa-fw"></i>
{{ export_group|trans }}
</h6>
<h1>{{ export.title|trans }}</h1>