Added forms to change EDA infos of footprints and categories

This commit is contained in:
Jan Böhmer 2023-12-01 22:47:05 +01:00
parent b5c7a789a2
commit 30b2c8b841
8 changed files with 203 additions and 9 deletions

View file

@ -23,6 +23,7 @@ declare(strict_types=1);
namespace App\Form\AdminPages;
use App\Entity\Base\AbstractNamedDBElement;
use App\Form\Part\EDA\EDACategoryInfoType;
use App\Form\Type\RichTextEditorType;
use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
use Symfony\Component\Form\Extension\Core\Type\TextType;
@ -104,5 +105,11 @@ class CategoryAdminForm extends BaseEntityAdminForm
],
'disabled' => !$this->security->isGranted($is_new ? 'create' : 'edit', $entity),
]);
//EDA info
$builder->add('eda_info', EDACategoryInfoType::class, [
'label' => false,
'required' => false,
]);
}
}

View file

@ -23,6 +23,8 @@ declare(strict_types=1);
namespace App\Form\AdminPages;
use App\Entity\Base\AbstractNamedDBElement;
use App\Entity\EDA\EDAFootprintInfo;
use App\Form\Part\EDA\EDAFootprintInfoType;
use App\Form\Type\MasterPictureAttachmentType;
use Symfony\Component\Form\FormBuilderInterface;
@ -37,5 +39,11 @@ class FootprintAdminForm extends BaseEntityAdminForm
'filter' => '3d_model',
'entity' => $entity,
]);
//EDA info
$builder->add('eda_info', EDAFootprintInfoType::class, [
'label' => false,
'required' => false,
]);
}
}

View file

@ -0,0 +1,86 @@
<?php
/*
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
*
* Copyright (C) 2019 - 2023 Jan Böhmer (https://github.com/jbtronics)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
declare(strict_types=1);
namespace App\Form\Part\EDA;
use App\Entity\EDA\EDACategoryInfo;
use App\Entity\EDA\EDAFootprintInfo;
use App\Form\Type\TriStateCheckboxType;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
use function Symfony\Component\Translation\t;
class EDACategoryInfoType extends AbstractType
{
public function buildForm(FormBuilderInterface $builder, array $options): void
{
$builder
->add('reference_prefix', TextType::class, [
'label' => 'eda_info.reference_prefix',
'attr' => [
'placeholder' => t('eda_info.reference_prefix.placeholder'),
]
]
)
->add('invisible', TriStateCheckboxType::class, [
'label' => 'eda_info.invisible',
])
->add('exclude_from_bom', TriStateCheckboxType::class, [
'label' => 'eda_info.exclude_from_bom',
'label_attr' => [
'class' => 'checkbox-inline'
]
])
->add('exclude_from_board', TriStateCheckboxType::class, [
'label' => 'eda_info.exclude_from_board',
'label_attr' => [
'class' => 'checkbox-inline'
]
])
->add('exclude_from_sim', TriStateCheckboxType::class, [
'label' => 'eda_info.exclude_from_sim',
'label_attr' => [
'class' => 'checkbox-inline'
]
])
->add('kicad_symbol', TextType::class, [
'label' => 'eda_info.kicad_symbol',
'attr' => [
'placeholder' => t('eda_info.kicad_symbol.placeholder'),
]
])
;
}
public function configureOptions(OptionsResolver $resolver): void
{
$resolver->setDefaults([
'data_class' => EDACategoryInfo::class,
]);
}
}

View file

@ -0,0 +1,55 @@
<?php
/*
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
*
* Copyright (C) 2019 - 2023 Jan Böhmer (https://github.com/jbtronics)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
declare(strict_types=1);
namespace App\Form\Part\EDA;
use App\Entity\EDA\EDAFootprintInfo;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
use function Symfony\Component\Translation\t;
class EDAFootprintInfoType extends AbstractType
{
public function buildForm(FormBuilderInterface $builder, array $options): void
{
$builder
->add('kicad_footprint', TextType::class, [
'label' => 'eda_info.kicad_footprint',
'attr' => [
'placeholder' => t('eda_info.kicad_footprint.placeholder'),
]
]);
}
public function configureOptions(OptionsResolver $resolver): void
{
$resolver->setDefaults([
'data_class' => EDAFootprintInfo::class,
]);
}
}

View file

@ -21,10 +21,9 @@
declare(strict_types=1);
namespace App\Form\Part;
namespace App\Form\Part\EDA;
use App\Entity\EDA\EDAPartInfo;
use App\Entity\Parts\PartAssociation;
use App\Form\Type\TriStateCheckboxType;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\TextType;

View file

@ -22,28 +22,28 @@ declare(strict_types=1);
namespace App\Form\Part;
use App\Entity\EDA\EDAPartInfo;
use App\Entity\Parts\ManufacturingStatus;
use App\Services\InfoProviderSystem\DTOs\PartDetailDTO;
use Symfony\Bundle\SecurityBundle\Security;
use App\Entity\Attachments\PartAttachment;
use App\Entity\EDA\EDAPartInfo;
use App\Entity\Parameters\PartParameter;
use App\Entity\Parts\Category;
use App\Entity\Parts\Footprint;
use App\Entity\Parts\Manufacturer;
use App\Entity\Parts\ManufacturingStatus;
use App\Entity\Parts\MeasurementUnit;
use App\Entity\Parts\Part;
use App\Entity\PriceInformations\Orderdetail;
use App\Form\AttachmentFormType;
use App\Form\ParameterType;
use App\Form\Part\EDA\EDAPartInfoType;
use App\Form\Type\MasterPictureAttachmentType;
use App\Form\Type\RichTextEditorType;
use App\Form\Type\SIUnitType;
use App\Form\Type\StructuralEntityType;
use App\Services\InfoProviderSystem\DTOs\PartDetailDTO;
use App\Services\LogSystem\EventCommentNeededHelper;
use Symfony\Bundle\SecurityBundle\Security;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
use Symfony\Component\Form\Extension\Core\Type\CollectionType;
use Symfony\Component\Form\Extension\Core\Type\EnumType;
use Symfony\Component\Form\Extension\Core\Type\ResetType;
@ -53,7 +53,6 @@ use Symfony\Component\Form\Extension\Core\Type\UrlType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
use Symfony\Contracts\Translation\TranslatorInterface;
class PartBaseType extends AbstractType
{
@ -260,7 +259,6 @@ class PartBaseType extends AbstractType
$builder->add('eda_info', EDAPartInfoType::class, [
'label' => false,
'required' => false,
'setter' => fn (Part $part, ?EDAPartInfo $x) => $part->setEdaInfo($x),
]);
$builder->add('log_comment', TextType::class, [

View file

@ -7,6 +7,7 @@
{% block additional_pills %}
<li class="nav-item"><a data-bs-toggle="tab" class="nav-link link-anchor" href="#home_options">{% trans %}admin.options{% endtrans %}</a></li>
<li class="nav-item"><a data-bs-toggle="tab" class="nav-link link-anchor" href="#home_advanced">{% trans %}admin.advanced{% endtrans %}</a></li>
<li class="nav-item"><a data-bs-toggle="tab" class="nav-link link-anchor" href="#eda">{% trans %}part.edit.tab.eda{% endtrans %}</a></li>
{% endblock %}
{% block edit_title %}
@ -34,4 +35,29 @@
{{ form_row(form.default_description) }}
{{ form_row(form.default_comment) }}
</div>
<div class="tab-pane" id="eda">
{{ form_row(form.eda_info.reference_prefix) }}
<div class="row">
<div class="col-sm-9 offset-sm-3">
{{ form_row(form.eda_info.invisible) }}
</div>
</div>
<div class="row mb-2">
<div class="col-sm-9 offset-sm-3">
{{ form_widget(form.eda_info.exclude_from_bom) }}
{{ form_widget(form.eda_info.exclude_from_board) }}
{{ form_widget(form.eda_info.exclude_from_sim) }}
</div>
</div>
<div class="row">
<div class="col-sm-9 offset-sm-3">
<h6>{% trans %}eda_info.kicad_section.title{% endtrans %}:</h6>
</div>
</div>
{{ form_row(form.eda_info.kicad_symbol) }}
</div>
{% endblock %}

View file

@ -19,4 +19,19 @@
{% block additional_controls %}
{{ form_row(form.alternative_names) }}
{% endblock %}
{% block additional_pills %}
<li class="nav-item"><a data-bs-toggle="tab" class="nav-link link-anchor" href="#eda">{% trans %}part.edit.tab.eda{% endtrans %}</a></li>
{% endblock %}
{% block additional_panes %}
<div class="tab-pane" id="eda">
<div class="row">
<div class="col-sm-9 offset-sm-3">
<h6>{% trans %}eda_info.kicad_section.title{% endtrans %}:</h6>
</div>
</div>
{{ form_row(form.eda_info.kicad_footprint) }}
</div>
{% endblock %}