mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2026-07-29 04:31:50 +00:00
Add per-parameter "visible in symbol" flag for KiCad EDA export (#1444)
* Add per-parameter "visible in symbol" flag for KiCad EDA export
Introduce a nullable tri-state eda_symbol_visibility on part parameters
that drives the KiCad field's "visible" flag in the EDA HTTP-library API
response. This is independent of the existing eda_visibility, which only
controls whether the parameter is exported as a field at all.
When the per-parameter flag is null, the new system default
KiCadEDASettings::defaultParameterSymbolVisibility applies. Both default
such that exported parameter fields keep their previous behavior
("visible": "False"), so the change is backward compatible.
- Entity: eda_symbol_visibility column + accessors, with matching
serialization groups and a multi-platform migration
- Form: second TriStateCheckboxType, shown for part parameters only
- KiCadHelper: resolve the flag (explicit, else system default) and pass
it to createField()
- Settings: defaultParameterSymbolVisibility (default false)
- Templates: new eye-icon column in the specifications table
- Translations (en) + tests
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
* Fixed message ids
---------
Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-authored-by: Jan Böhmer <mail@jan-boehmer.de>
This commit is contained in:
parent
f3c2f4b913
commit
0169c2d1fa
9 changed files with 137 additions and 1 deletions
46
migrations/Version20260713120000.php
Normal file
46
migrations/Version20260713120000.php
Normal file
|
|
@ -0,0 +1,46 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace DoctrineMigrations;
|
||||||
|
|
||||||
|
use App\Migration\AbstractMultiPlatformMigration;
|
||||||
|
use Doctrine\DBAL\Schema\Schema;
|
||||||
|
|
||||||
|
final class Version20260713120000 extends AbstractMultiPlatformMigration
|
||||||
|
{
|
||||||
|
public function getDescription(): string
|
||||||
|
{
|
||||||
|
return 'Add eda_symbol_visibility nullable boolean column to parameters table (controls the "visible" flag of the exported KiCad field)';
|
||||||
|
}
|
||||||
|
|
||||||
|
public function mySQLUp(Schema $schema): void
|
||||||
|
{
|
||||||
|
$this->addSql('ALTER TABLE parameters ADD eda_symbol_visibility TINYINT(1) DEFAULT NULL');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function mySQLDown(Schema $schema): void
|
||||||
|
{
|
||||||
|
$this->addSql('ALTER TABLE parameters DROP COLUMN eda_symbol_visibility');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function sqLiteUp(Schema $schema): void
|
||||||
|
{
|
||||||
|
$this->addSql('ALTER TABLE parameters ADD COLUMN eda_symbol_visibility BOOLEAN DEFAULT NULL');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function sqLiteDown(Schema $schema): void
|
||||||
|
{
|
||||||
|
$this->addSql('ALTER TABLE parameters DROP COLUMN eda_symbol_visibility');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function postgreSQLUp(Schema $schema): void
|
||||||
|
{
|
||||||
|
$this->addSql('ALTER TABLE parameters ADD eda_symbol_visibility BOOLEAN DEFAULT NULL');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function postgreSQLDown(Schema $schema): void
|
||||||
|
{
|
||||||
|
$this->addSql('ALTER TABLE parameters DROP COLUMN eda_symbol_visibility');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -179,6 +179,14 @@ abstract class AbstractParameter extends AbstractNamedDBElement implements Uniqu
|
||||||
#[ORM\Column(type: Types::BOOLEAN, nullable: true, options: ['default' => null])]
|
#[ORM\Column(type: Types::BOOLEAN, nullable: true, options: ['default' => null])]
|
||||||
protected ?bool $eda_visibility = null;
|
protected ?bool $eda_visibility = null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var bool|null Whether the exported EDA field should be visible in the schematic symbol
|
||||||
|
* (sets the KiCad field's "visible" flag). Null means use system default.
|
||||||
|
*/
|
||||||
|
#[Groups(['full', 'parameter:read', 'parameter:write', 'import'])]
|
||||||
|
#[ORM\Column(type: Types::BOOLEAN, nullable: true, options: ['default' => null])]
|
||||||
|
protected ?bool $eda_symbol_visibility = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Mapping is done in subclasses.
|
* Mapping is done in subclasses.
|
||||||
*
|
*
|
||||||
|
|
@ -493,6 +501,21 @@ abstract class AbstractParameter extends AbstractNamedDBElement implements Uniqu
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function isEdaSymbolVisibility(): ?bool
|
||||||
|
{
|
||||||
|
return $this->eda_symbol_visibility;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return $this
|
||||||
|
*/
|
||||||
|
public function setEdaSymbolVisibility(?bool $eda_symbol_visibility): self
|
||||||
|
{
|
||||||
|
$this->eda_symbol_visibility = $eda_symbol_visibility;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
public function getComparableFields(): array
|
public function getComparableFields(): array
|
||||||
{
|
{
|
||||||
return ['name' => $this->name, 'group' => $this->group, 'element' => $this->element?->getId()];
|
return ['name' => $this->name, 'group' => $this->group, 'element' => $this->element?->getId()];
|
||||||
|
|
|
||||||
|
|
@ -156,6 +156,11 @@ class ParameterType extends AbstractType
|
||||||
'label' => false,
|
'label' => false,
|
||||||
'required' => false,
|
'required' => false,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
$builder->add('eda_symbol_visibility', TriStateCheckboxType::class, [
|
||||||
|
'label' => false,
|
||||||
|
'required' => false,
|
||||||
|
]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -341,7 +341,9 @@ class KiCadHelper
|
||||||
$fieldName = $parameter->getName();
|
$fieldName = $parameter->getName();
|
||||||
//Don't overwrite hardcoded fields
|
//Don't overwrite hardcoded fields
|
||||||
if (!isset($result['fields'][$fieldName])) {
|
if (!isset($result['fields'][$fieldName])) {
|
||||||
$result['fields'][$fieldName] = $this->createField($parameter->getFormattedValue());
|
//Whether the field should be visible in the schematic symbol (explicit, or system default when null)
|
||||||
|
$symbolVisibility = $parameter->isEdaSymbolVisibility() ?? $this->kiCadEDASettings->defaultParameterSymbolVisibility;
|
||||||
|
$result['fields'][$fieldName] = $this->createField($parameter->getFormattedValue(), $symbolVisibility);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -56,6 +56,13 @@ class KiCadEDASettings
|
||||||
)]
|
)]
|
||||||
public bool $defaultParameterVisibility = false;
|
public bool $defaultParameterVisibility = false;
|
||||||
|
|
||||||
|
#[SettingsParameter(
|
||||||
|
label: new TM("settings.misc.kicad_eda.default_parameter_symbol_visibility"),
|
||||||
|
description: new TM("settings.misc.kicad_eda.default_parameter_symbol_visibility.help"),
|
||||||
|
|
||||||
|
)]
|
||||||
|
public bool $defaultParameterSymbolVisibility = false;
|
||||||
|
|
||||||
#[SettingsParameter(
|
#[SettingsParameter(
|
||||||
label: new TM("settings.misc.kicad_eda.default_orderdetails_visibility"),
|
label: new TM("settings.misc.kicad_eda.default_orderdetails_visibility"),
|
||||||
description: new TM("settings.misc.kicad_eda.default_orderdetails_visibility.help"),
|
description: new TM("settings.misc.kicad_eda.default_orderdetails_visibility.help"),
|
||||||
|
|
|
||||||
|
|
@ -15,6 +15,7 @@
|
||||||
<th>{% trans %}specifications.text{% endtrans %}</th>
|
<th>{% trans %}specifications.text{% endtrans %}</th>
|
||||||
<th>{% trans %}specifications.group{% endtrans %}</th>
|
<th>{% trans %}specifications.group{% endtrans %}</th>
|
||||||
<th title="{% trans %}specifications.eda_visibility.help{% endtrans %}"><i class="fas fa-bolt fa-fw"></i></th>
|
<th title="{% trans %}specifications.eda_visibility.help{% endtrans %}"><i class="fas fa-bolt fa-fw"></i></th>
|
||||||
|
<th title="{% trans %}specifications.eda_symbol_visibility.help{% endtrans %}"><i class="fas fa-eye fa-fw"></i></th>
|
||||||
<th></th>
|
<th></th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
|
|
|
||||||
|
|
@ -83,6 +83,9 @@
|
||||||
{% if form.eda_visibility is defined %}
|
{% if form.eda_visibility is defined %}
|
||||||
<td class="text-center">{{ form_widget(form.eda_visibility) }}</td>
|
<td class="text-center">{{ form_widget(form.eda_visibility) }}</td>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
{% if form.eda_symbol_visibility is defined %}
|
||||||
|
<td class="text-center">{{ form_widget(form.eda_symbol_visibility) }}</td>
|
||||||
|
{% endif %}
|
||||||
<td>
|
<td>
|
||||||
<button type="button" class="btn btn-danger btn-sm order_btn_delete position-relative {% if form.parent.vars.allow_delete is defined and not form.parent.vars.allow_delete %}disabled{% endif %}"
|
<button type="button" class="btn btn-danger btn-sm order_btn_delete position-relative {% if form.parent.vars.allow_delete is defined and not form.parent.vars.allow_delete %}disabled{% endif %}"
|
||||||
{{ collection.delete_btn() }} title="{% trans %}orderdetail.delete{% endtrans %}">
|
{{ collection.delete_btn() }} title="{% trans %}orderdetail.delete{% endtrans %}">
|
||||||
|
|
|
||||||
|
|
@ -389,6 +389,37 @@ final class KiCadHelperTest extends KernelTestCase
|
||||||
|
|
||||||
self::assertArrayHasKey('Voltage Rating', $result['fields']);
|
self::assertArrayHasKey('Voltage Rating', $result['fields']);
|
||||||
self::assertSame('3.3 V', $result['fields']['Voltage Rating']['value']);
|
self::assertSame('3.3 V', $result['fields']['Voltage Rating']['value']);
|
||||||
|
//Without an explicit symbol visibility the field defaults to not being shown in the symbol
|
||||||
|
self::assertSame('False', $result['fields']['Voltage Rating']['visible']);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test that a parameter with eda_symbol_visibility=true is marked visible in the symbol.
|
||||||
|
*/
|
||||||
|
public function testParameterWithSymbolVisibilityIsVisibleInSymbol(): void
|
||||||
|
{
|
||||||
|
$category = $this->em->find(Category::class, 1);
|
||||||
|
|
||||||
|
$part = new Part();
|
||||||
|
$part->setName('Part with Symbol-Visible Parameter');
|
||||||
|
$part->setCategory($category);
|
||||||
|
|
||||||
|
$param = new PartParameter();
|
||||||
|
$param->setName('Voltage Rating');
|
||||||
|
$param->setValueTypical(3.3);
|
||||||
|
$param->setUnit('V');
|
||||||
|
$param->setEdaVisibility(true);
|
||||||
|
$param->setEdaSymbolVisibility(true);
|
||||||
|
$part->addParameter($param);
|
||||||
|
|
||||||
|
$this->em->persist($part);
|
||||||
|
$this->em->flush();
|
||||||
|
|
||||||
|
$result = $this->helper->getKiCADPart($part);
|
||||||
|
|
||||||
|
self::assertArrayHasKey('Voltage Rating', $result['fields']);
|
||||||
|
self::assertSame('3.3 V', $result['fields']['Voltage Rating']['value']);
|
||||||
|
self::assertSame('True', $result['fields']['Voltage Rating']['visible']);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -648,6 +648,12 @@ Sub elements will be moved upwards.</target>
|
||||||
<target>Export this parameter as an EDA field</target>
|
<target>Export this parameter as an EDA field</target>
|
||||||
</segment>
|
</segment>
|
||||||
</unit>
|
</unit>
|
||||||
|
<unit id="Nx6h9XW" name="specifications.eda_symbol_visibility.help">
|
||||||
|
<segment state="translated">
|
||||||
|
<source>specifications.eda_symbol_visibility.help</source>
|
||||||
|
<target>Make this parameter field visible in the schematic symbol</target>
|
||||||
|
</segment>
|
||||||
|
</unit>
|
||||||
<unit id="XclPxI9" name="specification.create">
|
<unit id="XclPxI9" name="specification.create">
|
||||||
<segment state="translated">
|
<segment state="translated">
|
||||||
<source>specification.create</source>
|
<source>specification.create</source>
|
||||||
|
|
@ -13043,6 +13049,18 @@ Buerklin-API Authentication server:
|
||||||
<target>EDA visibility for all [part] parameters who does not have an explicit visibility set. When enabled all parameters will be visible in the EDA software by default.</target>
|
<target>EDA visibility for all [part] parameters who does not have an explicit visibility set. When enabled all parameters will be visible in the EDA software by default.</target>
|
||||||
</segment>
|
</segment>
|
||||||
</unit>
|
</unit>
|
||||||
|
<unit id="XchzDpI" name="settings.misc.kicad_eda.default_parameter_symbol_visibility">
|
||||||
|
<segment state="translated">
|
||||||
|
<source>settings.misc.kicad_eda.default_parameter_symbol_visibility</source>
|
||||||
|
<target>Default symbol visibility of parameters</target>
|
||||||
|
</segment>
|
||||||
|
</unit>
|
||||||
|
<unit id="zLHkPCx" name="settings.misc.kicad_eda.default_parameter_symbol_visibility.help">
|
||||||
|
<segment state="translated">
|
||||||
|
<source>settings.misc.kicad_eda.default_parameter_symbol_visibility.help</source>
|
||||||
|
<target>Whether exported [part] parameter fields that do not have an explicit symbol visibility set are shown in the schematic symbol (the KiCad field's "visible" flag). Only affects parameters that are already exported as EDA fields.</target>
|
||||||
|
</segment>
|
||||||
|
</unit>
|
||||||
<unit id="J6pYnaC" name="settings.misc.kicad_eda.default_orderdetails_visibility">
|
<unit id="J6pYnaC" name="settings.misc.kicad_eda.default_orderdetails_visibility">
|
||||||
<segment state="translated">
|
<segment state="translated">
|
||||||
<source>settings.misc.kicad_eda.default_orderdetails_visibility</source>
|
<source>settings.misc.kicad_eda.default_orderdetails_visibility</source>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue