Add title and creation date to export data handling

Enhanced export functionality by including `title` and `createdDate` in data passed to the Vue app. Updated controllers, templates, and components to handle and display the new fields, improving export file naming and user interface. Removed a debug `dump` call for cleaner code.
This commit is contained in:
Julien Fastré 2025-03-13 17:36:47 +01:00
parent 70ca4acafb
commit fb806a9579
Signed by: julienfastre
GPG Key ID: BDE2190974723FCB
5 changed files with 18 additions and 4 deletions

View File

@ -538,7 +538,6 @@ class ExportController extends AbstractController
$formFormatter->submit($dataFormatter); $formFormatter->submit($dataFormatter);
$dataFormatter = $formFormatter->getData(); $dataFormatter = $formFormatter->getData();
} }
dump($dataExport);
return [ return [
'centers' => $dataCenters['centers'], 'centers' => $dataCenters['centers'],

View File

@ -13,6 +13,7 @@ namespace Chill\MainBundle\Controller;
use Chill\DocStoreBundle\Entity\StoredObject; use Chill\DocStoreBundle\Entity\StoredObject;
use Chill\MainBundle\Entity\ExportGeneration; use Chill\MainBundle\Entity\ExportGeneration;
use Chill\MainBundle\Export\ExportManager;
use Symfony\Component\HttpFoundation\JsonResponse; use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException; use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException;
@ -28,6 +29,7 @@ final readonly class ExportGenerationController
private Security $security, private Security $security,
private Environment $twig, private Environment $twig,
private SerializerInterface $serializer, private SerializerInterface $serializer,
private ExportManager $exportManager,
) {} ) {}
#[Route('/{_locale}/main/export-generation/{id}/wait', methods: ['GET'], name: 'chill_main_export-generation_wait')] #[Route('/{_locale}/main/export-generation/{id}/wait', methods: ['GET'], name: 'chill_main_export-generation_wait')]
@ -37,8 +39,10 @@ final readonly class ExportGenerationController
throw new AccessDeniedHttpException('Only users can download an export'); throw new AccessDeniedHttpException('Only users can download an export');
} }
$export = $this->exportManager->getExport($exportGeneration->getExportAlias());
return new Response( return new Response(
$this->twig->render('@ChillMain/ExportGeneration/wait.html.twig', ['exportGeneration' => $exportGeneration]), $this->twig->render('@ChillMain/ExportGeneration/wait.html.twig', ['exportGeneration' => $exportGeneration, 'export' => $export]),
); );
} }

View File

@ -13,6 +13,8 @@ import DocumentActionButtonsGroup from "ChillDocStoreAssets/vuejs/DocumentAction
interface AppProps { interface AppProps {
exportGenerationId: string; exportGenerationId: string;
title: string;
createdDate: string;
} }
const props = defineProps<AppProps>(); const props = defineProps<AppProps>();
@ -26,6 +28,7 @@ const isFetching = computed<boolean>(
); );
const isReady = computed<boolean>(() => status.value === "ready"); const isReady = computed<boolean>(() => status.value === "ready");
const isFailure = computed<boolean>(() => status.value === "failure"); const isFailure = computed<boolean>(() => status.value === "failure");
const filename = computed<string>(() => `${props.title}-${props.createdDate}`);
/** /**
* counter for the number of times that we check for a new status * counter for the number of times that we check for a new status
@ -113,6 +116,7 @@ onMounted(() => {
<p v-if="storedObject !== null"> <p v-if="storedObject !== null">
<document-action-buttons-group <document-action-buttons-group
:stored-object="storedObject" :stored-object="storedObject"
:filename="filename"
></document-action-buttons-group> ></document-action-buttons-group>
</p> </p>
</div> </div>

View File

@ -9,4 +9,7 @@ if (null === el) {
} }
const exportGenerationId = el?.dataset.exportGenerationId as string; const exportGenerationId = el?.dataset.exportGenerationId as string;
createApp(App, { exportGenerationId }).mount(el); const title = el?.dataset.exportTitle as string;
const createdDate = el?.dataset.exportGenerationDate as string;
createApp(App, { exportGenerationId, title, createdDate }).mount(el);

View File

@ -11,7 +11,11 @@
{% endblock %} {% endblock %}
{% block content %} {% block content %}
<div id="app" data-export-generation-id="{{ exportGeneration.id | escape('html_attr') }}"></div> <div id="app"
data-export-generation-id="{{ exportGeneration.id | escape('html_attr') }}"
data-export-generation-date="{{ exportGeneration.createdAt.format('Ymd-His') }}"
data-export-title="{{ export.title|trans }}"
></div>
<ul class="sticky-form-buttons record_actions"> <ul class="sticky-form-buttons record_actions">
<li class="cancel"> <li class="cancel">