mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2025-06-21 01:25:55 +02:00
Added internal part number field to parts
This commit is contained in:
parent
81abf36867
commit
b1d359f538
12 changed files with 123 additions and 3 deletions
44
migrations/Version20221204004815.php
Normal file
44
migrations/Version20221204004815.php
Normal file
|
@ -0,0 +1,44 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace DoctrineMigrations;
|
||||
|
||||
use App\Migration\AbstractMultiPlatformMigration;
|
||||
use Doctrine\DBAL\Schema\Schema;
|
||||
use Doctrine\Migrations\AbstractMigration;
|
||||
|
||||
/**
|
||||
* Auto-generated Migration: Please modify to your needs!
|
||||
*/
|
||||
final class Version20221204004815 extends AbstractMultiPlatformMigration
|
||||
{
|
||||
public function getDescription(): string
|
||||
{
|
||||
return 'Add IPN to part';
|
||||
}
|
||||
|
||||
public function mySQLUp(Schema $schema): void
|
||||
{
|
||||
$this->addSql('ALTER TABLE parts ADD ipn VARCHAR(100) DEFAULT NULL');
|
||||
$this->addSql('CREATE UNIQUE INDEX UNIQ_6940A7FE3D721C14 ON parts (ipn)');
|
||||
$this->addSql('CREATE INDEX parts_idx_ipn ON parts (ipn)');
|
||||
}
|
||||
|
||||
public function mySQLDown(Schema $schema): void
|
||||
{
|
||||
$this->addSql('DROP INDEX UNIQ_6940A7FE3D721C14 ON `parts`');
|
||||
$this->addSql('DROP INDEX parts_idx_ipn ON `parts`');
|
||||
$this->addSql('ALTER TABLE `parts` DROP ipn');
|
||||
}
|
||||
|
||||
public function sqLiteUp(Schema $schema): void
|
||||
{
|
||||
// TODO: Implement sqLiteUp() method.
|
||||
}
|
||||
|
||||
public function sqLiteDown(Schema $schema): void
|
||||
{
|
||||
// TODO: Implement sqLiteDown() method.
|
||||
}
|
||||
}
|
|
@ -153,6 +153,10 @@ final class PartsDataTable implements DataTableTypeInterface
|
|||
'label' => $this->translator->trans('part.table.id'),
|
||||
'visible' => false,
|
||||
])
|
||||
->add('ipn', TextColumn::class, [
|
||||
'label' => $this->translator->trans('part.table.ipn'),
|
||||
'visible' => false,
|
||||
])
|
||||
->add('description', MarkdownColumn::class, [
|
||||
'label' => $this->translator->trans('part.table.description'),
|
||||
]);
|
||||
|
|
|
@ -37,6 +37,7 @@ use DateTime;
|
|||
use Doctrine\Common\Collections\ArrayCollection;
|
||||
use Doctrine\Common\Collections\Collection;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
|
||||
use Symfony\Component\Validator\Constraints as Assert;
|
||||
|
||||
/**
|
||||
|
@ -49,7 +50,9 @@ use Symfony\Component\Validator\Constraints as Assert;
|
|||
* @ORM\Table("`parts`", indexes={
|
||||
* @ORM\Index(name="parts_idx_datet_name_last_id_needs", columns={"datetime_added", "name", "last_modified", "id", "needs_review"}),
|
||||
* @ORM\Index(name="parts_idx_name", columns={"name"}),
|
||||
* @ORM\Index(name="parts_idx_ipn", columns={"ipn"}),
|
||||
* })
|
||||
* @UniqueEntity(fields={"ipn"}, message="part.ipn.must_be_unique")
|
||||
*/
|
||||
class Part extends AttachmentContainingDBElement
|
||||
{
|
||||
|
|
|
@ -50,6 +50,14 @@ trait AdvancedPropertyTrait
|
|||
*/
|
||||
protected ?float $mass = null;
|
||||
|
||||
/**
|
||||
* @var string The internal part number of the part
|
||||
* @ORM\Column(type="string", length=100, nullable=true, unique=true)
|
||||
* @Assert\Length(max="100")
|
||||
*
|
||||
*/
|
||||
protected ?string $ipn = null;
|
||||
|
||||
/**
|
||||
* Checks if this part is marked, for that it needs further review.
|
||||
*/
|
||||
|
@ -117,4 +125,26 @@ trait AdvancedPropertyTrait
|
|||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the internal part number of the part.
|
||||
* @return string
|
||||
*/
|
||||
public function getIpn(): ?string
|
||||
{
|
||||
return $this->ipn;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the internal part number of the part
|
||||
* @param string $ipn The new IPN of the part
|
||||
* @return Part
|
||||
*/
|
||||
public function setIpn(?string $ipn): Part
|
||||
{
|
||||
$this->ipn = $ipn;
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -50,6 +50,8 @@ use Symfony\Component\OptionsResolver\OptionsResolver;
|
|||
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
|
||||
use Symfony\Component\Security\Core\Security;
|
||||
|
||||
use function Sodium\add;
|
||||
|
||||
class PartBaseType extends AbstractType
|
||||
{
|
||||
protected Security $security;
|
||||
|
@ -169,6 +171,11 @@ class PartBaseType extends AbstractType
|
|||
'required' => false,
|
||||
'disable_not_selectable' => true,
|
||||
'label' => 'part.edit.partUnit',
|
||||
])
|
||||
->add('ipn', TextType::class, [
|
||||
'required' => false,
|
||||
'empty_data' => null,
|
||||
'label' => 'part.edit.ipn',
|
||||
]);
|
||||
|
||||
//Comment section
|
||||
|
|
|
@ -130,7 +130,9 @@ abstract class AbstractMultiPlatformMigration extends AbstractMigration
|
|||
public function postUp(Schema $schema): void
|
||||
{
|
||||
parent::postUp($schema);
|
||||
$this->logger->warning('<question>[!!!] Permissions were updated! Please check if they fit your expectations!</question>');
|
||||
if($this->permissions_updated) {
|
||||
$this->logger->warning('<question>[!!!] Permissions were updated! Please check if they fit your expectations!</question>');
|
||||
}
|
||||
|
||||
if (!empty($this->admin_pw)) {
|
||||
$this->logger->warning('');
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
{{ form_row(form.needsReview) }}
|
||||
{{ form_row(form.favorite) }}
|
||||
{{ form_row(form.mass) }}
|
||||
{{ form_row(form.ipn) }}
|
||||
{{ form_row(form.partUnit) }}
|
|
@ -9,7 +9,7 @@
|
|||
{% trans with {'%name%': part.name} %}part.edit.card_title{% endtrans %}
|
||||
<b><a href="{{ entity_url(part, 'info') }}" class="text-white">{{ part.name }}</a></b>
|
||||
<div class="float-end">
|
||||
{% trans %}id.label{% endtrans %}: {{ part.id }}
|
||||
{% trans %}id.label{% endtrans %}: {{ part.id }} {% if part.ipn is not empty %}(<i>{{ part.ipn }}</i>){% endif %}
|
||||
</div>
|
||||
{% endblock %}
|
||||
|
||||
|
|
|
@ -37,6 +37,11 @@
|
|||
<td>{{ part.iD }}</td>
|
||||
</tr>
|
||||
|
||||
<tr> {# ID #}
|
||||
<td>{% trans %}part.edit.ipn{% endtrans %}</td>
|
||||
<td>{{ part.ipn ?? 'part.ipn.not_defined'|trans }}</td>
|
||||
</tr>
|
||||
|
||||
<tr> {# Favorite status #}
|
||||
<td>{% trans %}part.isFavorite{% endtrans %}</td>
|
||||
<td>{{ helper.boolean(part.favorite) }}</td>
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
<i>({{ timeTravel | format_datetime('short') }})</i>
|
||||
{% endif %}
|
||||
<div class="float-end">
|
||||
{% trans %}id.label{% endtrans %}: {{ part.id }}
|
||||
{% trans %}id.label{% endtrans %}: {{ part.id }} {% if part.ipn is not empty %}(<i>{{ part.ipn }}</i>){% endif %}
|
||||
</div>
|
||||
{% endblock %}
|
||||
|
||||
|
|
|
@ -9905,5 +9905,23 @@ Element 3</target>
|
|||
<target>Unset Needs Review Status</target>
|
||||
</segment>
|
||||
</unit>
|
||||
<unit id="DNEEkTy" name="part.edit.ipn">
|
||||
<segment>
|
||||
<source>part.edit.ipn</source>
|
||||
<target>Internal Part Number (IPN)</target>
|
||||
</segment>
|
||||
</unit>
|
||||
<unit id="bT6yxOA" name="part.ipn.not_defined">
|
||||
<segment>
|
||||
<source>part.ipn.not_defined</source>
|
||||
<target>Not defined</target>
|
||||
</segment>
|
||||
</unit>
|
||||
<unit id="SHo2Ejq" name="part.table.ipn">
|
||||
<segment>
|
||||
<source>part.table.ipn</source>
|
||||
<target>IPN</target>
|
||||
</segment>
|
||||
</unit>
|
||||
</file>
|
||||
</xliff>
|
||||
|
|
|
@ -233,5 +233,11 @@
|
|||
<target>To enable SI prefixes, you have to set a unit symbol!</target>
|
||||
</segment>
|
||||
</unit>
|
||||
<unit id="DuzIOCr" name="part.ipn.must_be_unique">
|
||||
<segment>
|
||||
<source>part.ipn.must_be_unique</source>
|
||||
<target>The internal part number must be unique. {{ value }} is already in use!</target>
|
||||
</segment>
|
||||
</unit>
|
||||
</file>
|
||||
</xliff>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue