mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2025-06-22 18:03:37 +02:00
Added a part info tab to show in which projects the part is used.
This commit is contained in:
parent
d5b1c6be0a
commit
7f38095e82
4 changed files with 64 additions and 5 deletions
|
@ -33,6 +33,7 @@ use App\Entity\Parts\PartTraits\BasicPropertyTrait;
|
||||||
use App\Entity\Parts\PartTraits\InstockTrait;
|
use App\Entity\Parts\PartTraits\InstockTrait;
|
||||||
use App\Entity\Parts\PartTraits\ManufacturerTrait;
|
use App\Entity\Parts\PartTraits\ManufacturerTrait;
|
||||||
use App\Entity\Parts\PartTraits\OrderTrait;
|
use App\Entity\Parts\PartTraits\OrderTrait;
|
||||||
|
use App\Entity\ProjectSystem\ProjectBOMEntry;
|
||||||
use DateTime;
|
use DateTime;
|
||||||
use Doctrine\Common\Collections\ArrayCollection;
|
use Doctrine\Common\Collections\ArrayCollection;
|
||||||
use Doctrine\Common\Collections\Collection;
|
use Doctrine\Common\Collections\Collection;
|
||||||
|
@ -65,9 +66,10 @@ class Part extends AttachmentContainingDBElement
|
||||||
use ParametersTrait;
|
use ParametersTrait;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* TODO.
|
* @var Collection<int, ProjectBOMEntry> $project_bom_entries
|
||||||
|
* @ORM\OneToMany(targetEntity="App\Entity\ProjectSystem\ProjectBOMEntry", mappedBy="part")
|
||||||
*/
|
*/
|
||||||
protected $devices = [];
|
protected $project_bom_entries = [];
|
||||||
|
|
||||||
/** @var Collection<int, PartParameter>
|
/** @var Collection<int, PartParameter>
|
||||||
* @Assert\Valid()
|
* @Assert\Valid()
|
||||||
|
@ -120,6 +122,7 @@ class Part extends AttachmentContainingDBElement
|
||||||
$this->partLots = new ArrayCollection();
|
$this->partLots = new ArrayCollection();
|
||||||
$this->orderdetails = new ArrayCollection();
|
$this->orderdetails = new ArrayCollection();
|
||||||
$this->parameters = new ArrayCollection();
|
$this->parameters = new ArrayCollection();
|
||||||
|
$this->project_bom_entries = new ArrayCollection();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function __clone()
|
public function __clone()
|
||||||
|
@ -149,6 +152,17 @@ class Part extends AttachmentContainingDBElement
|
||||||
parent::__clone();
|
parent::__clone();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns all ProjectBOMEntries that use this part.
|
||||||
|
* @return Collection<int, ProjectBOMEntry>|ProjectBOMEntry[]
|
||||||
|
*/
|
||||||
|
public function getProjectBomEntries(): Collection
|
||||||
|
{
|
||||||
|
return $this->project_bom_entries;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get all devices which uses this part.
|
* Get all devices which uses this part.
|
||||||
*
|
*
|
||||||
|
@ -156,8 +170,14 @@ class Part extends AttachmentContainingDBElement
|
||||||
* (empty array if there are no ones)
|
* (empty array if there are no ones)
|
||||||
* * the array is sorted by the devices names
|
* * the array is sorted by the devices names
|
||||||
*/
|
*/
|
||||||
public function getDevices(): array
|
public function getProjects(): array
|
||||||
{
|
{
|
||||||
return $this->devices;
|
$projects = [];
|
||||||
|
|
||||||
|
foreach($this->project_bom_entries as $entry) {
|
||||||
|
$projects[] = $entry->getProject();
|
||||||
|
}
|
||||||
|
|
||||||
|
return $projects;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -72,7 +72,7 @@ class ProjectBOMEntry extends AbstractDBElement
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var Part|null The part associated with this
|
* @var Part|null The part associated with this
|
||||||
* @ORM\ManyToOne(targetEntity="App\Entity\Parts\Part")
|
* @ORM\ManyToOne(targetEntity="App\Entity\Parts\Part", inversedBy="project_bom_entries")
|
||||||
* @ORM\JoinColumn(name="id_part", referencedColumnName="id", nullable=true)
|
* @ORM\JoinColumn(name="id_part", referencedColumnName="id", nullable=true)
|
||||||
*/
|
*/
|
||||||
protected ?Part $part = null;
|
protected ?Part $part = null;
|
||||||
|
|
26
templates/Parts/info/_projects.html.twig
Normal file
26
templates/Parts/info/_projects.html.twig
Normal file
|
@ -0,0 +1,26 @@
|
||||||
|
{% import "components/attachments.macro.html.twig" as attachments %}
|
||||||
|
|
||||||
|
<table class="table table-striped table-sm table-hover table-responsive-sm">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th></th>
|
||||||
|
<th>{% trans %}entity.info.name{% endtrans %}</th>
|
||||||
|
<th>{% trans %}description.label{% endtrans %}</th>
|
||||||
|
<th>{% trans %}project.bom.quantity{% endtrans %}</th>
|
||||||
|
<th>{% trans %}project.bom.mountnames{% endtrans %}</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
|
||||||
|
<tbody>
|
||||||
|
{% for bom_entry in part.projectBomEntries %}
|
||||||
|
<tr>
|
||||||
|
<td>{% if bom_entry.project.masterPictureAttachment is not null %}{{ attachments.attachment_icon(bom_entry.project.masterPictureAttachment, attachment_manager) }}{% endif %}</td>
|
||||||
|
<td><a href="{{ url('project_info', {'id': bom_entry.project.iD}) }}">{{ bom_entry.project.name }}</a></td> {# Name #}
|
||||||
|
<td>{{ bom_entry.project.description|format_markdown }}</td> {# Description #}
|
||||||
|
<td>{{ bom_entry.quantity | format_amount(part.partUnit) }}</td>
|
||||||
|
<td>{{ bom_entry.mountnames }}</td>
|
||||||
|
</tr>
|
||||||
|
{% endfor %}
|
||||||
|
|
||||||
|
</tbody>
|
||||||
|
</table>
|
|
@ -91,6 +91,15 @@
|
||||||
{% trans %}vendor.partinfo.history{% endtrans %}
|
{% trans %}vendor.partinfo.history{% endtrans %}
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
|
{% if part.projectBomEntries is not empty %}
|
||||||
|
<li class="nav-item">
|
||||||
|
<a class="nav-link" id="projects-tab" data-bs-toggle="tab" href="#projects" role="tab">
|
||||||
|
<i class="fas fa-archive fa-fw"></i>
|
||||||
|
{% trans %}device.labelp{% endtrans %}
|
||||||
|
<span class="badge bg-secondary">{{ part.projectBomEntries | length }}</span>
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
|
{% endif %}
|
||||||
<li class="nav-item">
|
<li class="nav-item">
|
||||||
<a class="nav-link" id="tools-tab" data-bs-toggle="tab" href="#tools" role="tab">
|
<a class="nav-link" id="tools-tab" data-bs-toggle="tab" href="#tools" role="tab">
|
||||||
<i class="fas fa-tools"></i>
|
<i class="fas fa-tools"></i>
|
||||||
|
@ -130,6 +139,10 @@
|
||||||
</div>
|
</div>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
|
<div class="tab-pane fade" id="projects" role="tabpanel" aria-labelledby="projects-tab">
|
||||||
|
{% include "Parts/info/_projects.html.twig" %}
|
||||||
|
</div>
|
||||||
|
|
||||||
<div class="tab-pane fade" id="history" role="tabpanel" aria-labelledby="history-tab">
|
<div class="tab-pane fade" id="history" role="tabpanel" aria-labelledby="history-tab">
|
||||||
{% include "Parts/info/_history.html.twig" %}
|
{% include "Parts/info/_history.html.twig" %}
|
||||||
</div>
|
</div>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue