mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-07 18:44:08 +00:00
allow to edit existing saved export with new export options
This commit is contained in:
parent
c3ac382711
commit
b4614974c0
@ -127,6 +127,7 @@ class ExportController extends AbstractController
|
||||
'alias' => $alias,
|
||||
'export' => $export,
|
||||
'export_group' => $this->getExportGroup($export),
|
||||
'saved_export' => $savedExport,
|
||||
];
|
||||
|
||||
if ($formater instanceof \Chill\MainBundle\Export\Formatter\CSVListFormatter) {
|
||||
@ -245,6 +246,28 @@ class ExportController extends AbstractController
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @Route("/{_locale}/export/saved/update-from-key/{id}/{key}", name="chill_main_export_saved_edit_options_from_key")
|
||||
*/
|
||||
public function editSavedExportOptionsFromKey(SavedExport $savedExport, string $key): Response
|
||||
{
|
||||
$this->denyAccessUnlessGranted('ROLE_USER');
|
||||
$user = $this->getUser();
|
||||
|
||||
if (!$user instanceof User) {
|
||||
throw new AccessDeniedHttpException();
|
||||
}
|
||||
|
||||
$data = $this->rebuildRawData($key);
|
||||
|
||||
$savedExport
|
||||
->setOptions($data);
|
||||
|
||||
$this->entityManager->flush();
|
||||
|
||||
return $this->redirectToRoute('chill_main_export_saved_edit', ['id' => $savedExport->getId()]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @Route("/{_locale}/export/save-from-key/{alias}/{key}", name="chill_main_export_save_from_key")
|
||||
*/
|
||||
@ -478,7 +501,9 @@ class ExportController extends AbstractController
|
||||
|
||||
if (null === $dataFormatter && $export instanceof \Chill\MainBundle\Export\ExportInterface) {
|
||||
return $this->redirectToRoute('chill_main_export_new', [
|
||||
'alias' => $alias, 'step' => $this->getNextStep('generate', $export, true),
|
||||
'alias' => $alias,
|
||||
'step' => $this->getNextStep('generate', $export, true),
|
||||
'from_saved' => $savedExport?->getId() ?? '',
|
||||
]);
|
||||
}
|
||||
|
||||
@ -499,7 +524,11 @@ class ExportController extends AbstractController
|
||||
$this->session->remove('formatter_step_raw');
|
||||
$this->session->remove('formatter_step');
|
||||
|
||||
return $this->redirectToRoute('chill_main_export_download', ['key' => $key, 'alias' => $alias]);
|
||||
return $this->redirectToRoute('chill_main_export_download', [
|
||||
'key' => $key,
|
||||
'alias' => $alias,
|
||||
'from_saved' => $savedExport?->getId(),
|
||||
]);
|
||||
}
|
||||
|
||||
private function rebuildData($key, ?SavedExport $savedExport)
|
||||
|
@ -147,7 +147,6 @@ final readonly class ExportFormHelper
|
||||
SavedExport $savedExport,
|
||||
array $formOptions
|
||||
): array {
|
||||
dump(__METHOD__);
|
||||
$builder = $this->formFactory
|
||||
->createBuilder(
|
||||
FormType::class,
|
||||
|
@ -53,9 +53,23 @@ window.addEventListener("DOMContentLoaded", function(e) {
|
||||
<li class="cancel"><a href="{{ chill_return_path_or('chill_main_export_index') }}" class="btn btn-cancel">{{ 'Back to the list'|trans }}</a></li>
|
||||
|
||||
{% if not app.request.query.has('prevent_save') %}
|
||||
{% if saved_export is null %}
|
||||
<li>
|
||||
<a href="{{ chill_path_add_return_path('chill_main_export_save_from_key', { alias: alias, key: app.request.query.get('key')}) }}" class="btn btn-save">{{ 'Save'|trans }}</a>
|
||||
</li>
|
||||
{% else %}
|
||||
<li>
|
||||
<div class="dropdown">
|
||||
<button class="btn btn-save dropdown-toggle" type="button" data-bs-toggle="dropdown" aria-expanded="false">
|
||||
{{ 'Save'|trans }}
|
||||
</button>
|
||||
<ul class="dropdown-menu">
|
||||
<li><a href="{{ chill_path_add_return_path('chill_main_export_save_from_key', { alias: alias, key: app.request.query.get('key')}) }}" class="dropdown-item">{{ 'Save'|trans }}</a></li>
|
||||
<li><a href="{{ chill_path_add_return_path('chill_main_export_saved_edit_options_from_key', { id: saved_export.id(), key: app.request.query.get('key') }) }}" class="dropdown-item">{{ 'saved_export.Update existing'|trans }}</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
</li>
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
</ul>
|
||||
</div>
|
||||
|
@ -601,6 +601,7 @@ saved_export:
|
||||
update_title_and_description: Modifier le titre et la description
|
||||
update_filters_aggregators_and_execute: Modifier les filtres et regroupements et télécharger
|
||||
execute: Télécharger
|
||||
Update existing: Mettre à jour le rapport enregistré existant
|
||||
|
||||
absence:
|
||||
# single letter for absence
|
||||
|
Loading…
x
Reference in New Issue
Block a user