Skip to content

Commit

Permalink
Added forms to change EDA infos of footprints and categories
Browse files Browse the repository at this point in the history
  • Loading branch information
jbtronics committed Dec 1, 2023
1 parent b5c7a78 commit 30b2c8b
Show file tree
Hide file tree
Showing 8 changed files with 203 additions and 9 deletions.
7 changes: 7 additions & 0 deletions src/Form/AdminPages/CategoryAdminForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
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;
Expand Down Expand Up @@ -104,5 +105,11 @@ protected function additionalFormElements(FormBuilderInterface $builder, array $
],
'disabled' => !$this->security->isGranted($is_new ? 'create' : 'edit', $entity),
]);

//EDA info
$builder->add('eda_info', EDACategoryInfoType::class, [
'label' => false,
'required' => false,
]);
}
}
8 changes: 8 additions & 0 deletions src/Form/AdminPages/FootprintAdminForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
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;

Expand All @@ -37,5 +39,11 @@ public function additionalFormElements(FormBuilderInterface $builder, array $opt
'filter' => '3d_model',
'entity' => $entity,
]);

//EDA info
$builder->add('eda_info', EDAFootprintInfoType::class, [
'label' => false,
'required' => false,
]);
}
}
86 changes: 86 additions & 0 deletions src/Form/Part/EDA/EDACategoryInfoType.php
Original file line number Diff line number Diff line change
@@ -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,
]);
}
}
55 changes: 55 additions & 0 deletions src/Form/Part/EDA/EDAFootprintInfoType.php
Original file line number Diff line number Diff line change
@@ -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,
]);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
12 changes: 5 additions & 7 deletions src/Form/Part/PartBaseType.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,28 +22,28 @@

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;
Expand All @@ -53,7 +53,6 @@
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
{
Expand Down Expand Up @@ -260,7 +259,6 @@ public function buildForm(FormBuilderInterface $builder, array $options): void
$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, [
Expand Down
26 changes: 26 additions & 0 deletions templates/admin/category_admin.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -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 %}
Expand Down Expand Up @@ -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 %}
15 changes: 15 additions & 0 deletions templates/admin/footprint_admin.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -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 %}

0 comments on commit 30b2c8b

Please sign in to comment.