mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2025-06-21 01:25:55 +02:00
Added possibility to set project status
This commit is contained in:
parent
5521995f79
commit
adc070d10c
7 changed files with 191 additions and 33 deletions
|
@ -1,33 +0,0 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace DoctrineMigrations;
|
||||
|
||||
use Doctrine\DBAL\Schema\Schema;
|
||||
use Doctrine\Migrations\AbstractMigration;
|
||||
|
||||
/**
|
||||
* Auto-generated Migration: Please modify to your needs!
|
||||
*/
|
||||
final class Version20221218192108 extends AbstractMigration
|
||||
{
|
||||
public function getDescription(): string
|
||||
{
|
||||
return '';
|
||||
}
|
||||
|
||||
public function up(Schema $schema): void
|
||||
{
|
||||
// this up() migration is auto-generated, please modify it to your needs
|
||||
$this->addSql('ALTER TABLE device_parts ADD name VARCHAR(255) NULL, ADD comment LONGTEXT NOT NULL, ADD last_modified DATETIME DEFAULT CURRENT_TIMESTAMP NOT NULL, ADD datetime_added DATETIME DEFAULT CURRENT_TIMESTAMP NOT NULL, CHANGE quantity quantity DOUBLE PRECISION NOT NULL');
|
||||
$this->addSql('ALTER TABLE devices ADD description LONGTEXT NOT NULL');
|
||||
}
|
||||
|
||||
public function down(Schema $schema): void
|
||||
{
|
||||
// this down() migration is auto-generated, please modify it to your needs
|
||||
$this->addSql('ALTER TABLE devices DROP description');
|
||||
$this->addSql('ALTER TABLE device_parts DROP name, DROP comment, DROP last_modified, DROP datetime_added, CHANGE quantity quantity INT NOT NULL');
|
||||
}
|
||||
}
|
39
migrations/Version20221229125204.php
Normal file
39
migrations/Version20221229125204.php
Normal file
|
@ -0,0 +1,39 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace DoctrineMigrations;
|
||||
|
||||
use Doctrine\DBAL\Schema\Schema;
|
||||
use Doctrine\Migrations\AbstractMigration;
|
||||
|
||||
/**
|
||||
* Auto-generated Migration: Please modify to your needs!
|
||||
*/
|
||||
final class Version20221229125204 extends AbstractMigration
|
||||
{
|
||||
public function getDescription(): string
|
||||
{
|
||||
return '';
|
||||
}
|
||||
|
||||
public function up(Schema $schema): void
|
||||
{
|
||||
// this up() migration is auto-generated, please modify it to your needs
|
||||
$this->addSql('ALTER TABLE device_parts ADD name VARCHAR(255) DEFAULT NULL, ADD comment LONGTEXT NOT NULL, ADD last_modified DATETIME DEFAULT CURRENT_TIMESTAMP NOT NULL, ADD datetime_added DATETIME DEFAULT CURRENT_TIMESTAMP NOT NULL, CHANGE quantity quantity DOUBLE PRECISION NOT NULL');
|
||||
$this->addSql('ALTER TABLE devices ADD status VARCHAR(64) NOT NULL, ADD description LONGTEXT NOT NULL');
|
||||
$this->addSql('ALTER TABLE parts ADD built_project_id INT DEFAULT NULL');
|
||||
$this->addSql('ALTER TABLE parts ADD CONSTRAINT FK_6940A7FEE8AE70D9 FOREIGN KEY (built_project_id) REFERENCES devices (id)');
|
||||
$this->addSql('CREATE UNIQUE INDEX UNIQ_6940A7FEE8AE70D9 ON parts (built_project_id)');
|
||||
}
|
||||
|
||||
public function down(Schema $schema): void
|
||||
{
|
||||
// this down() migration is auto-generated, please modify it to your needs
|
||||
$this->addSql('ALTER TABLE devices DROP status, DROP description');
|
||||
$this->addSql('ALTER TABLE device_parts DROP name, DROP comment, DROP last_modified, DROP datetime_added, CHANGE quantity quantity INT NOT NULL');
|
||||
$this->addSql('ALTER TABLE `parts` DROP FOREIGN KEY FK_6940A7FEE8AE70D9');
|
||||
$this->addSql('DROP INDEX UNIQ_6940A7FEE8AE70D9 ON `parts`');
|
||||
$this->addSql('ALTER TABLE `parts` DROP built_project_id');
|
||||
}
|
||||
}
|
|
@ -15,6 +15,13 @@ trait ProjectTrait
|
|||
*/
|
||||
protected $project_bom_entries = [];
|
||||
|
||||
/**
|
||||
* @var Project|null If a project is set here, then this part is special and represents the builds of a project.
|
||||
* @ORM\OneToOne(targetEntity="App\Entity\ProjectSystem\Project", inversedBy="build_part")
|
||||
* @ORM\JoinColumn(nullable=true)
|
||||
*/
|
||||
protected ?Project $built_project = null;
|
||||
|
||||
/**
|
||||
* Returns all ProjectBOMEntries that use this part.
|
||||
* @return Collection<int, ProjectBOMEntry>|ProjectBOMEntry[]
|
||||
|
@ -24,6 +31,36 @@ trait ProjectTrait
|
|||
return $this->project_bom_entries;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks whether this part represents the builds of a project
|
||||
* @return bool True if it represents the builds, false if not
|
||||
*/
|
||||
public function isProjectBuildPart(): bool
|
||||
{
|
||||
return $this->built_project !== null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the project that this part represents the builds of, or null if it doesnt
|
||||
* @return Project|null
|
||||
*/
|
||||
public function getBuiltProject(): ?Project
|
||||
{
|
||||
return $this->built_project;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Sets the project that this part represents the builds of
|
||||
* @param Project|null $built_project The project that this part represents the builds of, or null if it is not a build part
|
||||
*/
|
||||
public function setBuiltProject(?Project $built_project): self
|
||||
{
|
||||
$this->built_project = $built_project;
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get all devices which uses this part.
|
||||
*
|
||||
|
|
|
@ -25,6 +25,7 @@ namespace App\Entity\ProjectSystem;
|
|||
use App\Entity\Attachments\ProjectAttachment;
|
||||
use App\Entity\Base\AbstractStructuralDBElement;
|
||||
use App\Entity\Parameters\ProjectParameter;
|
||||
use App\Entity\Parts\Part;
|
||||
use Doctrine\Common\Collections\ArrayCollection;
|
||||
use Doctrine\Common\Collections\Collection;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
|
@ -63,6 +64,20 @@ class Project extends AbstractStructuralDBElement
|
|||
*/
|
||||
protected int $order_quantity = 0;
|
||||
|
||||
/**
|
||||
* @var string The current status of the project
|
||||
* @ORM\Column(type="string", length=64)
|
||||
* @Assert\Choice({"draft","planning","in_production","finished","archived", ""})
|
||||
*/
|
||||
protected string $status;
|
||||
|
||||
|
||||
/**
|
||||
* @var Part|null The (optional) part that represents the builds of this project in the stock
|
||||
* @ORM\OneToOne(targetEntity="App\Entity\Parts\Part", mappedBy="built_project", cascade={"persist"}, orphanRemoval=true)
|
||||
*/
|
||||
protected ?Part $build_part = null;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="boolean")
|
||||
*/
|
||||
|
@ -219,5 +234,52 @@ class Project extends AbstractStructuralDBElement
|
|||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getStatus(): string
|
||||
{
|
||||
return $this->status;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $status
|
||||
*/
|
||||
public function setStatus(string $status): void
|
||||
{
|
||||
$this->status = $status;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if this project has a associated part representing the builds of this project in the stock.
|
||||
* @return bool
|
||||
*/
|
||||
public function hasBuildPart(): bool
|
||||
{
|
||||
return $this->build_part !== null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the part representing the builds of this project in the stock, if it is existing
|
||||
* @return Part|null
|
||||
*/
|
||||
public function getBuildPart(): ?Part
|
||||
{
|
||||
return $this->build_part;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the part representing the builds of this project in the stock.
|
||||
* @param Part|null $build_part
|
||||
*/
|
||||
public function setBuildPart(?Part $build_part): void
|
||||
{
|
||||
$this->build_part = $build_part;
|
||||
if ($build_part) {
|
||||
$build_part->setBuiltProject($this);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -24,6 +24,7 @@ use App\Entity\Base\AbstractNamedDBElement;
|
|||
use App\Form\ProjectSystem\ProjectBOMEntryCollectionType;
|
||||
use App\Form\ProjectSystem\ProjectBOMEntryType;
|
||||
use App\Form\Type\RichTextEditorType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\CollectionType;
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
|
||||
|
@ -43,5 +44,20 @@ class ProjectAdminForm extends BaseEntityAdminForm
|
|||
]);
|
||||
|
||||
$builder->add('bom_entries', ProjectBOMEntryCollectionType::class);
|
||||
|
||||
$builder->add('status', ChoiceType::class, [
|
||||
'attr' => [
|
||||
'class' => 'form-select',
|
||||
],
|
||||
'label' => 'project.edit.status',
|
||||
'required' => false,
|
||||
'choices' => [
|
||||
'project.status.draft' => 'draft',
|
||||
'project.status.planning' => 'planning',
|
||||
'project.status.in_production' => 'in_production',
|
||||
'project.status.finished' => 'finished',
|
||||
'project.status.archived' => 'archived',
|
||||
],
|
||||
]);
|
||||
}
|
||||
}
|
|
@ -18,6 +18,7 @@
|
|||
|
||||
{% block additional_controls %}
|
||||
{{ form_row(form.description) }}
|
||||
{{ form_row(form.status) }}
|
||||
{% endblock %}
|
||||
|
||||
{% block additional_panes %}
|
||||
|
|
|
@ -10019,5 +10019,41 @@ Element 3</target>
|
|||
<target>BOM entry</target>
|
||||
</segment>
|
||||
</unit>
|
||||
<unit id="HYlztPH" name="project.edit.status">
|
||||
<segment>
|
||||
<source>project.edit.status</source>
|
||||
<target>Project status</target>
|
||||
</segment>
|
||||
</unit>
|
||||
<unit id="g63LZsn" name="project.status.draft">
|
||||
<segment>
|
||||
<source>project.status.draft</source>
|
||||
<target>Draft</target>
|
||||
</segment>
|
||||
</unit>
|
||||
<unit id="agiQw0z" name="project.status.planning">
|
||||
<segment>
|
||||
<source>project.status.planning</source>
|
||||
<target>Planning</target>
|
||||
</segment>
|
||||
</unit>
|
||||
<unit id="8eTvW1x" name="project.status.in_production">
|
||||
<segment>
|
||||
<source>project.status.in_production</source>
|
||||
<target>In production</target>
|
||||
</segment>
|
||||
</unit>
|
||||
<unit id="xtDIXe_" name="project.status.finished">
|
||||
<segment>
|
||||
<source>project.status.finished</source>
|
||||
<target>Finished</target>
|
||||
</segment>
|
||||
</unit>
|
||||
<unit id="wpp2047" name="project.status.archived">
|
||||
<segment>
|
||||
<source>project.status.archived</source>
|
||||
<target>Archived</target>
|
||||
</segment>
|
||||
</unit>
|
||||
</file>
|
||||
</xliff>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue