diff --git a/src/Bundle/ChillMainBundle/Entity/ExportGeneration.php b/src/Bundle/ChillMainBundle/Entity/ExportGeneration.php index ede2943bd..a8d4e274b 100644 --- a/src/Bundle/ChillMainBundle/Entity/ExportGeneration.php +++ b/src/Bundle/ChillMainBundle/Entity/ExportGeneration.php @@ -54,6 +54,13 @@ class ExportGeneration implements TrackCreationInterface private array $options = [], #[ORM\Column(type: \Doctrine\DBAL\Types\Types::DATETIME_IMMUTABLE, nullable: true)] private ?\DateTimeImmutable $deleteAt = null, + + /** + * The related saved export. + * + * Note that, in some case, the options of this ExportGenration are not equals to the options of the saved export. + * This happens when the options of the saved export are updated. + */ #[ORM\ManyToOne(targetEntity: SavedExport::class)] #[ORM\JoinColumn(nullable: true)] private ?SavedExport $savedExport = null, @@ -118,9 +125,24 @@ class ExportGeneration implements TrackCreationInterface return null !== $this->savedExport; } - public static function fromSavedExport(SavedExport $savedExport, ?\DateTimeImmutable $deletedAt = null): self + /** + * Compares the options of the saved export and the current export generation. + * + * Return false if the current export generation's options are not equal to the one in the saved export. This may + * happens when we update the configuration of a saved export. + */ + public function isConfigurationDifferentFromSavedExport(): bool { - $generation = new self($savedExport->getExportAlias(), $savedExport->getOptions(), $deletedAt, $savedExport); + if (!$this->isLinkedToSavedExport()) { + return false; + } + + return $this->savedExport->getOptions() !== $this->getOptions(); + } + + public static function fromSavedExport(SavedExport $savedExport, ?\DateTimeImmutable $deletedAt = null, ?array $overrideOptions = null): self + { + $generation = new self($savedExport->getExportAlias(), $overrideOptions ?? $savedExport->getOptions(), $deletedAt, $savedExport); $generation->getStoredObject()->setTitle($savedExport->getTitle()); return $generation; diff --git a/src/Bundle/ChillMainBundle/Resources/views/ExportGeneration/wait.html.twig b/src/Bundle/ChillMainBundle/Resources/views/ExportGeneration/wait.html.twig index 89af3a70e..a93edf965 100644 --- a/src/Bundle/ChillMainBundle/Resources/views/ExportGeneration/wait.html.twig +++ b/src/Bundle/ChillMainBundle/Resources/views/ExportGeneration/wait.html.twig @@ -10,7 +10,10 @@ {{ encore_entry_link_tags('page_download_exports') }} {% endblock %} + {% block title exportGeneration.linkedToSavedExport ? exportGeneration.savedExport.title : 'Download export' %} + {% block content %} +

{{ block('title') }}

- {% if not exportGeneration.isLinkedToSavedExport %} + {% if not exportGeneration.linkedToSavedExport %}
  • {{ 'Save'|trans }}
  • {% else %} -
  • - +
  • + {% endif %} {% endif %} {% endblock content %}