Added custom part status (#1053)
Some checks failed
Build assets artifact / Build assets artifact (push) Has been cancelled
Docker Image Build / docker (push) Has been cancelled
Docker Image Build (FrankenPHP) / docker (push) Has been cancelled
Static analysis / Static analysis (push) Has been cancelled
PHPUnit Tests / PHPUnit and coverage Test (PHP 8.2, mysql) (push) Has been cancelled
PHPUnit Tests / PHPUnit and coverage Test (PHP 8.3, mysql) (push) Has been cancelled
PHPUnit Tests / PHPUnit and coverage Test (PHP 8.4, mysql) (push) Has been cancelled
PHPUnit Tests / PHPUnit and coverage Test (PHP 8.5, mysql) (push) Has been cancelled
PHPUnit Tests / PHPUnit and coverage Test (PHP 8.2, postgres) (push) Has been cancelled
PHPUnit Tests / PHPUnit and coverage Test (PHP 8.3, postgres) (push) Has been cancelled
PHPUnit Tests / PHPUnit and coverage Test (PHP 8.4, postgres) (push) Has been cancelled
PHPUnit Tests / PHPUnit and coverage Test (PHP 8.5, postgres) (push) Has been cancelled
PHPUnit Tests / PHPUnit and coverage Test (PHP 8.2, sqlite) (push) Has been cancelled
PHPUnit Tests / PHPUnit and coverage Test (PHP 8.3, sqlite) (push) Has been cancelled
PHPUnit Tests / PHPUnit and coverage Test (PHP 8.4, sqlite) (push) Has been cancelled
PHPUnit Tests / PHPUnit and coverage Test (PHP 8.5, sqlite) (push) Has been cancelled

* Benutzerdefinierten Bauteilstatus einführen

* PartCustomStateController hinzufügen

* Umstellung Migrationen bzgl. Multi-Plattform-Support.
Zunächst MySQL, SQLite Statements integrieren.

* Postgre Statements integrieren

* Semikolon in Migration entfernen

* Migration für PartCustomState aktualisieren

* Benutzerdefinierten Bauteilstatus in TableSettings aufnehmen

* PartCustomStateControllerTest: Attribute für PHPUnit-Gruppen umgestellt

* PartCustomState: Mapping für Parameter korrigieren

* PartCustomState: Darstellung und Zuordnung von Anhängen ergänzt

Die Sidebar wurde um die Anzeige des benutzerdefinierten Bauteilstatus erweitert, inklusive Vorschaubild, sofern vorhanden.

* Migrationen zusammenführen

* PartCustomState: Anpassungen bzgl. Tests

* PartCustomStateEndpoint hinzufügen

* Made custom part states plural for consistency with other entity captions

* Fixed phpunit error

* Fixed phpstan issues

---------

Co-authored-by: Marcel Diegelmann <marcel.diegelmann@gmail.com>
Co-authored-by: Jan Böhmer <mail@jan-boehmer.de>
This commit is contained in:
web-devinition.de 2025-10-27 21:58:16 +01:00 committed by GitHub
parent 600686c32b
commit 14a4f1f437
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
65 changed files with 2044 additions and 18 deletions

View file

@ -0,0 +1,69 @@
<?php
/*
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
*
* Copyright (C) 2019 - 2024 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\Tests\API\Endpoints;
class PartCustomStateEndpointTest extends CrudEndpointTestCase
{
protected function getBasePath(): string
{
return '/api/part_custom_states';
}
public function testGetCollection(): void
{
$this->_testGetCollection();
self::assertJsonContains([
'hydra:totalItems' => 7,
]);
}
public function testGetItem(): void
{
$this->_testGetItem(1);
$this->_testGetItem(2);
$this->_testGetItem(3);
}
public function testCreateItem(): void
{
$this->_testPostItem([
'name' => 'Test API',
'parent' => '/api/part_custom_states/1',
]);
}
public function testUpdateItem(): void
{
$this->_testPatchItem(5, [
'name' => 'Updated',
'parent' => '/api/part_custom_states/2',
]);
}
public function testDeleteItem(): void
{
$this->_testDeleteItem(4);
}
}

View file

@ -0,0 +1,34 @@
<?php
/**
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
*
* Copyright (C) 2019 - 2020 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\Tests\Controller\AdminPages;
use App\Entity\Parts\PartCustomState;
use PHPUnit\Framework\Attributes\Group;
#[Group('slow')]
#[Group('DB')]
class PartCustomStateControllerTest extends AbstractAdminController
{
protected static string $base_path = '/en/part_custom_state';
protected static string $entity_class = PartCustomState::class;
}

View file

@ -29,6 +29,7 @@ use App\Entity\Attachments\AttachmentType;
use App\Entity\Attachments\AttachmentTypeAttachment;
use App\Entity\Attachments\CategoryAttachment;
use App\Entity\Attachments\CurrencyAttachment;
use App\Entity\Attachments\PartCustomStateAttachment;
use App\Entity\Attachments\ProjectAttachment;
use App\Entity\Attachments\FootprintAttachment;
use App\Entity\Attachments\GroupAttachment;
@ -38,6 +39,7 @@ use App\Entity\Attachments\PartAttachment;
use App\Entity\Attachments\StorageLocationAttachment;
use App\Entity\Attachments\SupplierAttachment;
use App\Entity\Attachments\UserAttachment;
use App\Entity\Parts\PartCustomState;
use App\Entity\ProjectSystem\Project;
use App\Entity\Parts\Category;
use App\Entity\Parts\Footprint;
@ -86,6 +88,7 @@ class AttachmentTest extends TestCase
yield [ManufacturerAttachment::class, Manufacturer::class];
yield [MeasurementUnitAttachment::class, MeasurementUnit::class];
yield [PartAttachment::class, Part::class];
yield [PartCustomStateAttachment::class, PartCustomState::class];
yield [StorageLocationAttachment::class, StorageLocation::class];
yield [SupplierAttachment::class, Supplier::class];
yield [UserAttachment::class, User::class];

View file

@ -29,6 +29,7 @@ use App\Entity\Parts\Manufacturer;
use App\Entity\Parts\MeasurementUnit;
use App\Entity\Parts\Part;
use App\Entity\Parts\PartAssociation;
use App\Entity\Parts\PartCustomState;
use App\Entity\Parts\PartLot;
use App\Entity\PriceInformations\Orderdetail;
use App\Services\EntityMergers\Mergers\PartMerger;
@ -54,6 +55,7 @@ class PartMergerTest extends KernelTestCase
$manufacturer1 = new Manufacturer();
$manufacturer2 = new Manufacturer();
$unit = new MeasurementUnit();
$customState = new PartCustomState();
$part1 = (new Part())
->setCategory($category)
@ -62,7 +64,8 @@ class PartMergerTest extends KernelTestCase
$part2 = (new Part())
->setFootprint($footprint)
->setManufacturer($manufacturer2)
->setPartUnit($unit);
->setPartUnit($unit)
->setPartCustomState($customState);
$merged = $this->merger->merge($part1, $part2);
$this->assertSame($merged, $part1);
@ -70,6 +73,7 @@ class PartMergerTest extends KernelTestCase
$this->assertSame($footprint, $merged->getFootprint());
$this->assertSame($manufacturer1, $merged->getManufacturer());
$this->assertSame($unit, $merged->getPartUnit());
$this->assertSame($customState, $merged->getPartCustomState());
}
public function testMergeOfTags(): void

View file

@ -23,6 +23,7 @@ declare(strict_types=1);
namespace App\Tests\Twig;
use App\Entity\Attachments\PartAttachment;
use App\Entity\Parts\PartCustomState;
use App\Entity\ProjectSystem\Project;
use App\Entity\LabelSystem\LabelProfile;
use App\Entity\Parts\Category;
@ -67,6 +68,7 @@ class EntityExtensionTest extends WebTestCase
$this->assertSame('currency', $this->service->getEntityType(new Currency()));
$this->assertSame('measurement_unit', $this->service->getEntityType(new MeasurementUnit()));
$this->assertSame('label_profile', $this->service->getEntityType(new LabelProfile()));
$this->assertSame('part_custom_state', $this->service->getEntityType(new PartCustomState()));
}
}

View file

@ -7437,11 +7437,13 @@
<field Field="lowStock" Type="tinyint(1)" Null="NO" Key="" Extra="" Comment="" />
<field Field="metaPart" Type="tinyint(1)" Null="NO" Key="" Default="0" Extra="" Comment="" />
<field Field="partUnit_id" Type="int(11)" Null="YES" Key="MUL" Default="NULL" Extra="" Comment="" />
<field Field="partCustomState_id" Type="int(11)" Null="YES" Key="MUL" Default="NULL" Extra="" Comment="" />
<field Field="storageLocation_id" Type="int(11)" Null="YES" Key="MUL" Default="NULL" Extra="" Comment="" />
<key Table="part" Non_unique="0" Key_name="PRIMARY" Seq_in_index="1" Column_name="id" Collation="A" Cardinality="3" Null="" Index_type="BTREE" Comment="" Index_comment="" Ignored="NO" />
<key Table="part" Non_unique="1" Key_name="IDX_E93DDFF812469DE2" Seq_in_index="1" Column_name="category_id" Collation="A" Cardinality="3" Null="YES" Index_type="BTREE" Comment="" Index_comment="" Ignored="NO" />
<key Table="part" Non_unique="1" Key_name="IDX_E93DDFF851364C98" Seq_in_index="1" Column_name="footprint_id" Collation="A" Cardinality="3" Null="YES" Index_type="BTREE" Comment="" Index_comment="" Ignored="NO" />
<key Table="part" Non_unique="1" Key_name="IDX_E93DDFF8F7A36E87" Seq_in_index="1" Column_name="partUnit_id" Collation="A" Cardinality="3" Null="YES" Index_type="BTREE" Comment="" Index_comment="" Ignored="NO" />
<key Table="part" Non_unique="1" Key_name="IDX_E93DDFF8F7A36E88" Seq_in_index="1" Column_name="partCustomState_id" Collation="A" Cardinality="3" Null="YES" Index_type="BTREE" Comment="" Index_comment="" Ignored="NO" />
<key Table="part" Non_unique="1" Key_name="IDX_E93DDFF873CD58AF" Seq_in_index="1" Column_name="storageLocation_id" Collation="A" Cardinality="3" Null="YES" Index_type="BTREE" Comment="" Index_comment="" Ignored="NO" />
<options Name="part" Engine="InnoDB" Version="10" Row_format="Dynamic" Rows="3" Avg_row_length="5461" Data_length="16384" Max_data_length="0" Index_length="65536" Data_free="0" Auto_increment="4" Create_time="2023-03-22 22:28:36" Update_time="2023-03-22 22:40:40" Collation="utf8mb3_unicode_ci" Create_options="" Comment="" Max_index_length="0" Temporary="N" />
</table_structure>