mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2026-08-03 23:21:44 +00:00
remove hierarchical paths from being exported in CSV to match datatable format
This commit is contained in:
parent
8306b7e747
commit
d39066bf04
2 changed files with 16 additions and 10 deletions
|
|
@ -134,9 +134,9 @@ final readonly class ProjectBomExporter
|
|||
? $part->getDescription()
|
||||
: $entry->getComment(),
|
||||
|
||||
'category' => $part?->getCategory()?->getFullPath() ?? '',
|
||||
'category' => $part?->getCategory()?->getName() ?? '',
|
||||
|
||||
'footprint' => $part?->getFootprint()?->getFullPath() ?? '',
|
||||
'footprint' => $part?->getFootprint()?->getName() ?? '',
|
||||
|
||||
'manufacturer' => $part?->getManufacturer()?->getName() ?? '',
|
||||
|
||||
|
|
@ -185,15 +185,21 @@ final readonly class ProjectBomExporter
|
|||
return trim((string) $entry->getName());
|
||||
}
|
||||
|
||||
$values = [$part->getName()];
|
||||
$partName = trim($part->getName());
|
||||
$entryName = trim((string) $entry->getName());
|
||||
|
||||
$values = [$partName];
|
||||
|
||||
/*
|
||||
* The DataTable displays the optional BOM entry name beneath the
|
||||
* linked part's name. Preserve that information with a separating
|
||||
* space in CSV.
|
||||
* The DataTable displays the optional BOM entry name beneath the linked
|
||||
* part's name. Preserve that information in the CSV, but avoid exporting
|
||||
* duplicate names.
|
||||
*/
|
||||
if ($entry->getName() !== null && $entry->getName() !== '') {
|
||||
$values[] = $entry->getName();
|
||||
if (
|
||||
$entryName !== ''
|
||||
&& $entryName !== $partName
|
||||
) {
|
||||
$values[] = $entryName;
|
||||
}
|
||||
|
||||
return implode(' ', $values);
|
||||
|
|
@ -275,7 +281,7 @@ final readonly class ProjectBomExporter
|
|||
}
|
||||
|
||||
$locations[$storageLocation->getID()] =
|
||||
$storageLocation->getFullPath();
|
||||
$storageLocation->getName();
|
||||
}
|
||||
|
||||
return implode(', ', array_values($locations));
|
||||
|
|
|
|||
|
|
@ -281,7 +281,7 @@ final class ProjectBomExporterTest extends WebTestCase
|
|||
);
|
||||
$this->assertSame('TEST-IPN-001', $row['IPN']);
|
||||
$this->assertSame('10k ohm resistor', $row['Description']);
|
||||
$this->assertSame($category->getFullPath(), $row['Category']);
|
||||
$this->assertSame($category->getName(), $row['Category']);
|
||||
$this->assertSame('', $row['Footprint']);
|
||||
$this->assertSame('', $row['Manufacturer']);
|
||||
$this->assertSame('', $row['Manufacturing status']);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue