From 7d69d6ba308c9136bbc40643be531abb395d5530 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20B=C3=B6hmer?= Date: Sun, 3 Dec 2023 15:29:17 +0100 Subject: [PATCH] Changed logic of invisible to a (forced) visibility field --- src/Entity/EDA/EDACategoryInfo.php | 14 +++++++------- src/Entity/EDA/EDAPartInfo.php | 14 +++++++------- src/Form/Part/EDA/EDACategoryInfoType.php | 5 +++-- src/Form/Part/EDA/EDAPartInfoType.php | 5 +++-- src/Services/EDA/KiCadHelper.php | 4 ++-- templates/admin/category_admin.html.twig | 2 +- templates/parts/edit/_eda.html.twig | 2 +- templates/parts/info/_extended_infos.html.twig | 2 +- translations/messages.en.xlf | 18 ++++++++++++------ 9 files changed, 37 insertions(+), 29 deletions(-) diff --git a/src/Entity/EDA/EDACategoryInfo.php b/src/Entity/EDA/EDACategoryInfo.php index db56485a..61d99988 100644 --- a/src/Entity/EDA/EDACategoryInfo.php +++ b/src/Entity/EDA/EDACategoryInfo.php @@ -38,10 +38,10 @@ class EDACategoryInfo #[Groups(['full', 'category:read', 'category:write'])] private ?string $reference_prefix = null; - /** @var bool|null If this is true, then this part is invisible for the EDA software */ - #[Column(type: Types::BOOLEAN, nullable: true)] + /** @var bool|null Visibility of this part to EDA software in trinary logic. True=Visible, False=Invisible, Null=Auto */ + #[Column(name: 'invisible', type: Types::BOOLEAN, nullable: true)] //TODO: Rename column to visibility #[Groups(['full', 'category:read', 'category:write'])] - private ?bool $invisible = null; + private ?bool $visibility = null; /** @var bool|null If this is set to true, then this part will be excluded from the BOM */ #[Column(type: Types::BOOLEAN, nullable: true)] @@ -74,14 +74,14 @@ class EDACategoryInfo return $this; } - public function getInvisible(): ?bool + public function getVisibility(): ?bool { - return $this->invisible; + return $this->visibility; } - public function setInvisible(?bool $invisible): EDACategoryInfo + public function setVisibility(?bool $visibility): EDACategoryInfo { - $this->invisible = $invisible; + $this->visibility = $visibility; return $this; } diff --git a/src/Entity/EDA/EDAPartInfo.php b/src/Entity/EDA/EDAPartInfo.php index e314d580..5742921a 100644 --- a/src/Entity/EDA/EDAPartInfo.php +++ b/src/Entity/EDA/EDAPartInfo.php @@ -43,10 +43,10 @@ class EDAPartInfo #[Groups(['full', 'eda_info:read', 'eda_info:write'])] private ?string $value = null; - /** @var bool|null If this is true, then this part is invisible for the EDA software */ - #[Column(type: Types::BOOLEAN, nullable: true)] + /** @var bool|null Visibility of this part to EDA software in trinary logic. True=Visible, False=Invisible, Null=Auto */ + #[Column(name: 'invisible', type: Types::BOOLEAN, nullable: true)] //TODO: Rename column to visibility #[Groups(['full', 'eda_info:read', 'eda_info:write'])] - private ?bool $invisible = null; + private ?bool $visibility = null; /** @var bool|null If this is set to true, then this part will be excluded from the BOM */ #[Column(type: Types::BOOLEAN, nullable: true)] @@ -100,14 +100,14 @@ class EDAPartInfo return $this; } - public function getInvisible(): ?bool + public function getVisibility(): ?bool { - return $this->invisible; + return $this->visibility; } - public function setInvisible(?bool $invisible): EDAPartInfo + public function setVisibility(?bool $visibility): EDAPartInfo { - $this->invisible = $invisible; + $this->visibility = $visibility; return $this; } diff --git a/src/Form/Part/EDA/EDACategoryInfoType.php b/src/Form/Part/EDA/EDACategoryInfoType.php index 3e60913e..24fe6717 100644 --- a/src/Form/Part/EDA/EDACategoryInfoType.php +++ b/src/Form/Part/EDA/EDACategoryInfoType.php @@ -45,8 +45,9 @@ class EDACategoryInfoType extends AbstractType ] ] ) - ->add('invisible', TriStateCheckboxType::class, [ - 'label' => 'eda_info.invisible', + ->add('visibility', TriStateCheckboxType::class, [ + 'help' => 'eda_info.visibility.help', + 'label' => 'eda_info.visibility', ]) ->add('exclude_from_bom', TriStateCheckboxType::class, [ 'label' => 'eda_info.exclude_from_bom', diff --git a/src/Form/Part/EDA/EDAPartInfoType.php b/src/Form/Part/EDA/EDAPartInfoType.php index 2e75d9e8..e8cac681 100644 --- a/src/Form/Part/EDA/EDAPartInfoType.php +++ b/src/Form/Part/EDA/EDAPartInfoType.php @@ -50,8 +50,9 @@ class EDAPartInfoType extends AbstractType 'placeholder' => t('eda_info.value.placeholder'), ] ]) - ->add('invisible', TriStateCheckboxType::class, [ - 'label' => 'eda_info.invisible', + ->add('visibility', TriStateCheckboxType::class, [ + 'help' => 'eda_info.visibility.help', + 'label' => 'eda_info.visibility', ]) ->add('exclude_from_bom', TriStateCheckboxType::class, [ 'label' => 'eda_info.exclude_from_bom', diff --git a/src/Services/EDA/KiCadHelper.php b/src/Services/EDA/KiCadHelper.php index 455ce7eb..cab52a19 100644 --- a/src/Services/EDA/KiCadHelper.php +++ b/src/Services/EDA/KiCadHelper.php @@ -80,7 +80,7 @@ class KiCadHelper $result = []; foreach ($categories as $category) { //Skip invisible categories - if ($category->getEdaInfo()->getInvisible() ?? false) { + if ($category->getEdaInfo()->getVisibility() === false) { continue; } @@ -146,7 +146,7 @@ class KiCadHelper $result = []; foreach ($parts as $part) { //If the part is invisible, then skip it - if ($part->getEdaInfo()->getInvisible() ?? $part->getCategory()?->getEdaInfo()->getInvisible() ?? false) { + if ($part->getEdaInfo()->getVisibility() === false || $part->getCategory()?->getEdaInfo()->getVisibility() === false) { continue; } diff --git a/templates/admin/category_admin.html.twig b/templates/admin/category_admin.html.twig index ddbf9b9b..5811640b 100644 --- a/templates/admin/category_admin.html.twig +++ b/templates/admin/category_admin.html.twig @@ -41,7 +41,7 @@
- {{ form_row(form.eda_info.invisible) }} + {{ form_row(form.eda_info.visibility) }}
diff --git a/templates/parts/edit/_eda.html.twig b/templates/parts/edit/_eda.html.twig index c1cd3991..4df675c4 100644 --- a/templates/parts/edit/_eda.html.twig +++ b/templates/parts/edit/_eda.html.twig @@ -3,7 +3,7 @@
- {{ form_row(form.eda_info.invisible) }} + {{ form_row(form.eda_info.visibility) }}
diff --git a/templates/parts/info/_extended_infos.html.twig b/templates/parts/info/_extended_infos.html.twig index 6eab4826..4ed60a09 100644 --- a/templates/parts/info/_extended_infos.html.twig +++ b/templates/parts/info/_extended_infos.html.twig @@ -92,7 +92,7 @@
{% trans %}eda_info.value{% endtrans %}: {{ part.edaInfo.value }}
- {% trans %}eda_info.invisible{% endtrans %}: {{ helper.boolean_badge( part.edaInfo.invisible ?? part.category.edaInfo.invisible ?? false) }} + {% trans %}eda_info.visibility{% endtrans %}: {{ helper.boolean_badge( part.edaInfo.visibility ?? part.category.edaInfo.visibility) }}
{% trans %}eda_info.exclude_from_bom{% endtrans %}: {{ helper.boolean_badge( part.edaInfo.excludeFromBom ?? part.category.edaInfo.excludeFromBom ?? false) }}
diff --git a/translations/messages.en.xlf b/translations/messages.en.xlf index c49b8448..10a96df5 100644 --- a/translations/messages.en.xlf +++ b/translations/messages.en.xlf @@ -12107,12 +12107,6 @@ Please note, that you can not impersonate a disabled user. If you try you will g e.g. 100n - - - eda_info.invisible - Invisible to EDA software - - eda_info.exclude_from_bom @@ -12179,5 +12173,17 @@ Please note, that you can not impersonate a disabled user. If you try you will g KiCad API root URL + + + eda_info.visibility + Force visibility + + + + + eda_info.visibility.help + By default, the visibility to the EDA software is automatically determined. With this checkbox, you can force the part to be visible or invisible. + +