Allow to control the path delimiter and create unknown datastructures

Also the labeling of form fields was improved
This commit is contained in:
Jan Böhmer 2023-03-12 22:03:02 +01:00
parent 508641d1e8
commit 256d628543
4 changed files with 103 additions and 16 deletions

View file

@ -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,

View file

@ -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, [

View file

@ -26,6 +26,11 @@
{% endblock %}
{% block card_content %}
<p class="text-muted offset-sm-3">
{% trans %}parts.import.help{% endtrans %}<br>
{% trans with {'%link%': 'https://docs.part-db.de/'} %}parts.import.help_documentation{% endtrans %}
</p>
{{ form(import_form) }}
{% if imported_entities %}

View file

@ -11055,5 +11055,65 @@ Element 3</target>
<target>File invalid / malformatted. Please check that you have selected the right format!</target>
</segment>
</unit>
<unit id="ih.wsVn" name="parts.import.part_category.label">
<segment>
<source>parts.import.part_category.label</source>
<target>Category override</target>
</segment>
</unit>
<unit id="mLczcax" name="parts.import.part_category.help">
<segment>
<source>parts.import.part_category.help</source>
<target>If you select a value here, all imported parts will be assigned to this category. No matter what was set in the data.</target>
</segment>
</unit>
<unit id="W09n3nV" name="import.create_unknown_datastructures">
<segment>
<source>import.create_unknown_datastructures</source>
<target>Create unknown datastructures</target>
</segment>
</unit>
<unit id="QkzTk.8" name="import.create_unknown_datastructures.help">
<segment>
<source>import.create_unknown_datastructures.help</source>
<target>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</target>
</segment>
</unit>
<unit id="p6fTkCQ" name="import.path_delimiter">
<segment>
<source>import.path_delimiter</source>
<target>Path delimiter</target>
</segment>
</unit>
<unit id="gSn6XRk" name="import.path_delimiter.help">
<segment>
<source>import.path_delimiter.help</source>
<target>The delimiter used to mark different levels in data structure pathes like category, footprint, etc.</target>
</segment>
</unit>
<unit id="aNR2tK9" name="parts.import.help_documentation">
<segment>
<source>parts.import.help_documentation</source>
<target><![CDATA[See the <a href="%link%">documentation</a> for more information on the file format.]]></target>
</segment>
</unit>
<unit id="bOHORjK" name="parts.import.help">
<segment>
<source>parts.import.help</source>
<target>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.</target>
</segment>
</unit>
<unit id="sweByB7" name="parts.import.flash.success">
<segment>
<source>parts.import.flash.success</source>
<target>Part import successful!</target>
</segment>
</unit>
<unit id="j7NAkR." name="parts.import.errors.imported_entities">
<segment>
<source>parts.import.errors.imported_entities</source>
<target>Imported parts</target>
</segment>
</unit>
</file>
</xliff>