diff --git a/src/Controller/PartImportExportController.php b/src/Controller/PartImportExportController.php index 4d4aa54c..c2eae0a9 100644 --- a/src/Controller/PartImportExportController.php +++ b/src/Controller/PartImportExportController.php @@ -75,7 +75,8 @@ class PartImportExportController extends AbstractController } $options = [ - 'preserve_children' => $data['preserve_children'], + 'create_unknown_datastructures' => $data['create_unknown_datastructures'], + 'path_delimiter' => $data['path_delimiter'], 'format' => $format, 'part_category' => $data['part_category'], 'class' => Part::class, diff --git a/src/Form/AdminPages/ImportType.php b/src/Form/AdminPages/ImportType.php index ba0c7db7..6af7d6e1 100644 --- a/src/Form/AdminPages/ImportType.php +++ b/src/Form/AdminPages/ImportType.php @@ -85,13 +85,40 @@ class ImportType extends AbstractType $builder->add('part_category', StructuralEntityType::class, [ 'class' => Category::class, 'required' => false, - 'label' => 'category.label', + 'label' => 'parts.import.part_category.label', + 'help' => 'parts.import.part_category.help', 'disabled' => $disabled, 'disable_not_selectable' => true, 'allow_add' => true ]); } + if ($entity instanceof AbstractStructuralDBElement) { + $builder->add('preserve_children', CheckboxType::class, [ + 'data' => true, + 'required' => false, + 'label' => 'import.preserve_children', + 'disabled' => $disabled, + ]); + } + + if ($entity instanceof Part) { + $builder->add('create_unknown_datastructures', CheckboxType::class, [ + 'data' => true, + 'required' => false, + 'label' => 'import.create_unknown_datastructures', + 'help' => 'import.create_unknown_datastructures.help', + 'disabled' => $disabled, + ]); + + $builder->add('path_delimiter', TextType::class, [ + 'data' => '->', + 'label' => 'import.path_delimiter', + 'help' => 'import.path_delimiter.help', + 'disabled' => $disabled, + ]); + } + $builder->add('file', FileType::class, [ 'label' => 'import.file', 'attr' => [ @@ -100,21 +127,15 @@ class ImportType extends AbstractType 'data-show-upload' => 'false', ], 'disabled' => $disabled, - ]) + ]); - ->add('preserve_children', CheckboxType::class, [ - 'data' => true, - 'required' => false, - 'label' => 'import.preserve_children', - 'disabled' => $disabled, - ]) - ->add('abort_on_validation_error', CheckboxType::class, [ - 'data' => true, - 'required' => false, - 'label' => 'import.abort_on_validation', - 'help' => 'import.abort_on_validation.help', - 'disabled' => $disabled, - ]) + $builder->add('abort_on_validation_error', CheckboxType::class, [ + 'data' => true, + 'required' => false, + 'label' => 'import.abort_on_validation', + 'help' => 'import.abort_on_validation.help', + 'disabled' => $disabled, + ]) //Buttons ->add('import', SubmitType::class, [ diff --git a/templates/parts/import/parts_import.html.twig b/templates/parts/import/parts_import.html.twig index bd9d8f09..3f3d4c48 100644 --- a/templates/parts/import/parts_import.html.twig +++ b/templates/parts/import/parts_import.html.twig @@ -26,6 +26,11 @@ {% endblock %} {% block card_content %} +

+ {% trans %}parts.import.help{% endtrans %}
+ {% trans with {'%link%': 'https://docs.part-db.de/'} %}parts.import.help_documentation{% endtrans %} +

+ {{ form(import_form) }} {% if imported_entities %} diff --git a/translations/messages.en.xlf b/translations/messages.en.xlf index a7f4bf2d..324ff192 100644 --- a/translations/messages.en.xlf +++ b/translations/messages.en.xlf @@ -11055,5 +11055,65 @@ Element 3 File invalid / malformatted. Please check that you have selected the right format! + + + parts.import.part_category.label + Category override + + + + + parts.import.part_category.help + If you select a value here, all imported parts will be assigned to this category. No matter what was set in the data. + + + + + import.create_unknown_datastructures + Create unknown datastructures + + + + + import.create_unknown_datastructures.help + If this is selected, datastructures (like categories, footprints, etc.) which does not exist in the database yet, will be automatically created. If this is not selected, only existing data structures will be used, and if no matching data structure is found, the part will get assigned nothing + + + + + import.path_delimiter + Path delimiter + + + + + import.path_delimiter.help + The delimiter used to mark different levels in data structure pathes like category, footprint, etc. + + + + + parts.import.help_documentation + documentation for more information on the file format.]]> + + + + + parts.import.help + You can import parts from existing files with this tool. The parts will be directly written to database, so please check your file beforehand for correct content before uploading it here. + + + + + parts.import.flash.success + Part import successful! + + + + + parts.import.errors.imported_entities + Imported parts + +