Skip to content

Commit 2b4cb89

Browse files
committed
Add export functionality to batch select and fix errors
1 parent 3ee2d3f commit 2b4cb89

File tree

5 files changed

+10
-5
lines changed

5 files changed

+10
-5
lines changed

src/Services/ImportExportSystem/EntityExporter.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ public function exportEntities(AbstractNamedDBElement|array $entities, array $op
9292
$options = $resolver->resolve($options);
9393

9494
//Handle Excel formats by converting from CSV
95-
if (in_array($options['format'], ['xlsx', 'xls'])) {
95+
if (in_array($options['format'], ['xlsx', 'xls'], true)) {
9696
return $this->exportToExcel($entities, $options);
9797
}
9898

src/Services/ImportExportSystem/EntityImporter.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -339,7 +339,7 @@ public function importFile(File $file, array $options = [], array &$errors = [])
339339
$this->configureOptions($resolver);
340340
$options = $resolver->resolve($options);
341341

342-
if (in_array($options['format'], ['xlsx', 'xls'])) {
342+
if (in_array($options['format'], ['xlsx', 'xls'], true)) {
343343
$this->logger->info('Converting Excel file to CSV', [
344344
'filename' => $file->getFilename(),
345345
'format' => $options['format'],

src/Services/Parts/PartsTableActionHandler.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,11 @@
3030
use App\Entity\Parts\MeasurementUnit;
3131
use App\Entity\Parts\Part;
3232
use App\Entity\Parts\PartLot;
33-
use App\Repository\PartRepository;
3433
use Doctrine\ORM\EntityManagerInterface;
3534
use InvalidArgumentException;
3635
use Symfony\Component\HttpFoundation\RedirectResponse;
3736
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
3837
use Symfony\Component\Security\Core\Exception\AccessDeniedException;
39-
use Symfony\Contracts\Translation\TranslatableInterface;
4038

4139
use function Symfony\Component\Translation\t;
4240

@@ -100,7 +98,7 @@ public function handleAction(string $action, array $selected_parts, ?int $target
10098

10199
//When action starts with "export_" we have to redirect to the export controller
102100
$matches = [];
103-
if (preg_match('/^export_(json|yaml|xml|csv)$/', $action, $matches)) {
101+
if (preg_match('/^export_(json|yaml|xml|csv|xlsx)$/', $action, $matches)) {
104102
$ids = implode(',', array_map(static fn (Part $part) => $part->getID(), $selected_parts));
105103
$level = match ($target_id) {
106104
2 => 'extended',

templates/components/datatables.macro.html.twig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@
7272
<option {% if not is_granted('@parts.read') %}disabled{% endif %} value="export_csv" data-url="{{ path('select_export_level')}}" data-turbo="false">{% trans %}part_list.action.export_csv{% endtrans %}</option>
7373
<option {% if not is_granted('@parts.read') %}disabled{% endif %} value="export_yaml" data-url="{{ path('select_export_level')}}" data-turbo="false">{% trans %}part_list.action.export_yaml{% endtrans %}</option>
7474
<option {% if not is_granted('@parts.read') %}disabled{% endif %} value="export_xml" data-url="{{ path('select_export_level')}}" data-turbo="false">{% trans %}part_list.action.export_xml{% endtrans %}</option>
75+
<option {% if not is_granted('@parts.read') %}disabled{% endif %} value="export_xlsx" data-url="{{ path('select_export_level')}}" data-turbo="false">{% trans %}part_list.action.export_xlsx{% endtrans %}</option>
7576
</optgroup>
7677
</select>
7778

translations/messages.en.xlf

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10903,6 +10903,12 @@ Element 3</target>
1090310903
<target>Export to XML</target>
1090410904
</segment>
1090510905
</unit>
10906+
<unit id="xLSXExport" name="part_list.action.export_xlsx">
10907+
<segment state="translated">
10908+
<source>part_list.action.export_xlsx</source>
10909+
<target>Export to Excel</target>
10910+
</segment>
10911+
</unit>
1090610912
<unit id="w0AgPEI" name="parts.import.title">
1090710913
<segment state="translated">
1090810914
<source>parts.import.title</source>

0 commit comments

Comments
 (0)