mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2025-06-23 10:18:56 +02:00
Added option to mark all imported parts as "needs review"
This commit is contained in:
parent
b7aae7d87b
commit
193650efd4
6 changed files with 32 additions and 2 deletions
|
@ -355,6 +355,7 @@ abstract class BaseAdminController extends AbstractController
|
|||
'format' => $format,
|
||||
'class' => $this->entity_class,
|
||||
'csv_delimiter' => $data['csv_delimiter'],
|
||||
'abort_on_validation_error' => $data['abort_on_validation_error'],
|
||||
];
|
||||
|
||||
$this->commentHelper->setMessage('Import '.$file->getClientOriginalName());
|
||||
|
|
|
@ -84,6 +84,8 @@ class PartImportExportController extends AbstractController
|
|||
'part_category' => $data['part_category'],
|
||||
'class' => Part::class,
|
||||
'csv_delimiter' => $data['csv_delimiter'],
|
||||
'part_needs_review' => $data['part_needs_review'],
|
||||
'abort_on_validation_error' => $data['abort_on_validation_error'],
|
||||
];
|
||||
|
||||
$this->commentHelper->setMessage('Import '.$file->getClientOriginalName());
|
||||
|
|
|
@ -91,6 +91,13 @@ class ImportType extends AbstractType
|
|||
'disable_not_selectable' => true,
|
||||
'allow_add' => true
|
||||
]);
|
||||
$builder->add('part_needs_review', CheckboxType::class, [
|
||||
'data' => false,
|
||||
'required' => false,
|
||||
'label' => 'parts.import.part_needs_review.label',
|
||||
'help' => 'parts.import.part_needs_review.help',
|
||||
'disabled' => $disabled,
|
||||
]);
|
||||
}
|
||||
|
||||
if ($entity instanceof AbstractStructuralDBElement) {
|
||||
|
|
|
@ -179,8 +179,13 @@ class EntityImporter
|
|||
if ($entity instanceof AbstractStructuralDBElement) {
|
||||
$entity->setParent($options['parent']);
|
||||
}
|
||||
if ($entity instanceof Part && $options['part_category']) {
|
||||
$entity->setCategory($options['part_category']);
|
||||
if ($entity instanceof Part) {
|
||||
if ($options['part_category']) {
|
||||
$entity->setCategory($options['part_category']);
|
||||
}
|
||||
if ($options['part_needs_review']) {
|
||||
$entity->setNeedsReview(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -218,6 +223,7 @@ class EntityImporter
|
|||
'parent' => null, //The parent element to which the imported elements should be added
|
||||
'abort_on_validation_error' => true,
|
||||
'part_category' => null,
|
||||
'part_needs_review' => false, //If true, the imported parts will be marked as "needs review", otherwise the value from the file will be used
|
||||
'create_unknown_datastructures' => true, //If true, unknown datastructures (categories, footprints, etc.) will be created on the fly
|
||||
'path_delimiter' => '->', //The delimiter used to separate the path elements in the name of a structural element
|
||||
]);
|
||||
|
@ -227,6 +233,7 @@ class EntityImporter
|
|||
$resolver->setAllowedTypes('preserve_children', 'bool');
|
||||
$resolver->setAllowedTypes('class', 'string');
|
||||
$resolver->setAllowedTypes('part_category', [Category::class, 'null']);
|
||||
$resolver->setAllowedTypes('part_needs_review', 'bool');
|
||||
|
||||
return $resolver;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue