mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2025-07-08 01:14:34 +02:00
Added possibility to export Parts from part tables
This commit is contained in:
parent
3b36b2a4dc
commit
49944cda87
9 changed files with 161 additions and 8 deletions
|
@ -102,6 +102,34 @@ final class PartsTableActionHandler
|
|||
);
|
||||
}
|
||||
|
||||
//When action starts with "export_" we have to redirect to the export controller
|
||||
$matches = [];
|
||||
if (preg_match('/^export_(json|yaml|xml|csv)$/', $action, $matches)) {
|
||||
$ids = implode(',', array_map(static fn (Part $part) => $part->getID(), $selected_parts));
|
||||
switch ($target_id) {
|
||||
case 1:
|
||||
default:
|
||||
$level = 'simple';
|
||||
break;
|
||||
case 2:
|
||||
$level = 'extended';
|
||||
break;
|
||||
case 3:
|
||||
$level = 'full';
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
return new RedirectResponse(
|
||||
$this->urlGenerator->generate('parts_export', [
|
||||
'format' => $matches[1],
|
||||
'level' => $level,
|
||||
'ids' => $ids,
|
||||
'_redirect' => $redirect_url
|
||||
])
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
//Iterate over the parts and apply the action to it:
|
||||
foreach ($selected_parts as $part) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue