mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2026-01-18 16:19:34 +00:00
Anpassungen aus Analyse
This commit is contained in:
parent
0d7404d3e6
commit
f7875ba385
11 changed files with 33 additions and 47 deletions
|
|
@ -91,6 +91,8 @@ class AssemblyBomEntriesDataTable implements DataTableTypeInterface
|
|||
return htmlspecialchars((string) $context->getName());
|
||||
}
|
||||
|
||||
$tmp = $context->getName();
|
||||
|
||||
if ($context->getPart() !== null) {
|
||||
$tmp = $this->partDataTableHelper->renderName($context->getPart());
|
||||
$tmp = $this->translator->trans('part.table.name.value.for_part', ['%value%' => $tmp]);
|
||||
|
|
|
|||
|
|
@ -135,17 +135,6 @@ class AssemblySearchFilter implements FilterInterface
|
|||
return $this;
|
||||
}
|
||||
|
||||
public function isCategory(): bool
|
||||
{
|
||||
return $this->category;
|
||||
}
|
||||
|
||||
public function setCategory(bool $category): AssemblySearchFilter
|
||||
{
|
||||
$this->category = $category;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function isDescription(): bool
|
||||
{
|
||||
return $this->description;
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@ class AssemblyAdminForm extends BaseEntityAdminForm
|
|||
public function __construct(
|
||||
protected Security $security,
|
||||
protected EventCommentNeededHelper $eventCommentNeededHelper,
|
||||
protected AssemblySettings $assemblySettings,
|
||||
protected ?AssemblySettings $assemblySettings = null,
|
||||
) {
|
||||
parent::__construct($security, $eventCommentNeededHelper, $assemblySettings);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -52,7 +52,7 @@ class BaseEntityAdminForm extends AbstractType
|
|||
public function __construct(
|
||||
protected Security $security,
|
||||
protected EventCommentNeededHelper $eventCommentNeededHelper,
|
||||
protected AssemblySettings $assemblySettings,
|
||||
protected ?AssemblySettings $assemblySettings = null,
|
||||
) {
|
||||
}
|
||||
|
||||
|
|
@ -74,7 +74,7 @@ class BaseEntityAdminForm extends AbstractType
|
|||
->add('name', TextType::class, [
|
||||
'empty_data' => '',
|
||||
'label' => 'name.label',
|
||||
'data' => $is_new && $entity instanceof Assembly && $this->assemblySettings->useIpnPlaceholderInName ? '%%ipn%%' : $entity->getName(),
|
||||
'data' => $is_new && $entity instanceof Assembly && $this->assemblySettings !== null && $this->assemblySettings->useIpnPlaceholderInName ? '%%ipn%%' : $entity->getName(),
|
||||
'attr' => [
|
||||
'placeholder' => 'part.name.placeholder',
|
||||
],
|
||||
|
|
|
|||
|
|
@ -114,6 +114,8 @@ class LogFilterType extends AbstractType
|
|||
LogTargetType::CATEGORY => 'category.label',
|
||||
LogTargetType::PROJECT => 'project.label',
|
||||
LogTargetType::BOM_ENTRY => 'project_bom_entry.label',
|
||||
LogTargetType::ASSEMBLY => 'assembly.label',
|
||||
LogTargetType::ASSEMBLY_BOM_ENTRY => 'assembly_bom_entry.label',
|
||||
LogTargetType::FOOTPRINT => 'footprint.label',
|
||||
LogTargetType::GROUP => 'group.label',
|
||||
LogTargetType::MANUFACTURER => 'manufacturer.label',
|
||||
|
|
|
|||
|
|
@ -45,7 +45,7 @@ use App\Entity\AssemblySystem\Assembly;
|
|||
|
||||
/**
|
||||
* @template TEntityClass of Assembly
|
||||
* @extends DBElementRepository<TEntityClass>
|
||||
* @extends StructuralDBElementRepository<TEntityClass>
|
||||
*/
|
||||
class AssemblyRepository extends StructuralDBElementRepository
|
||||
{
|
||||
|
|
@ -66,4 +66,4 @@ class AssemblyRepository extends StructuralDBElementRepository
|
|||
|
||||
return $qb->getQuery()->getResult();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -513,8 +513,10 @@ class BOMImporter
|
|||
|
||||
//Convert column name into hierarchy
|
||||
$path = explode('_', $column);
|
||||
/** @var array<string, mixed> $temp */
|
||||
$temp = &$entry;
|
||||
|
||||
/** @var lowercase-string $step */
|
||||
foreach ($path as $step) {
|
||||
if (!isset($temp[$step])) {
|
||||
$temp[$step] = [];
|
||||
|
|
@ -526,7 +528,7 @@ class BOMImporter
|
|||
//If there is no value, skip
|
||||
if (isset($values[$index]) && $values[$index] !== '') {
|
||||
//Check whether the value is numerical
|
||||
if (is_numeric($values[$index]) && !in_array($column, ['name','description','manufacturer','designator'])) {
|
||||
if (is_numeric($values[$index]) && !in_array($column, ['name','description','manufacturer','designator'], true)) {
|
||||
//Convert to integer or float
|
||||
$temp = (str_contains($values[$index], '.'))
|
||||
? floatval($values[$index])
|
||||
|
|
@ -577,7 +579,7 @@ class BOMImporter
|
|||
$bomEntry->setMountnames(trim($entry['designator']) === '' ? '' : trim($entry['designator']));
|
||||
}
|
||||
|
||||
$bomEntry->setQuantity((float) $entry['quantity'] ?? 0);
|
||||
$bomEntry->setQuantity((float) $entry['quantity']);
|
||||
|
||||
$result->addBomEntry($bomEntry);
|
||||
}
|
||||
|
|
@ -706,7 +708,7 @@ class BOMImporter
|
|||
$result->addViolation($this->buildJsonViolation(
|
||||
'validator.bom_importer.json_csv.parameter.array',
|
||||
'entry[$key].part.manufacturer',
|
||||
$entry['part']['manufacturer']) ?? null
|
||||
$entry['part']['manufacturer'])
|
||||
);
|
||||
}
|
||||
|
||||
|
|
@ -728,8 +730,8 @@ class BOMImporter
|
|||
if (($manufacturerIdValid || $manufacturerNameValid) && $manufacturer === null) {
|
||||
$value = sprintf(
|
||||
'manufacturer.id: %s, manufacturer.name: %s',
|
||||
isset($entry['part']['manufacturer']['id']) && $entry['part']['manufacturer']['id'] !== null ? '<strong>' . $entry['part']['manufacturer']['id'] . '</strong>' : '-',
|
||||
isset($entry['part']['manufacturer']['name']) && $entry['part']['manufacturer']['name'] !== null ? '<strong>' . $entry['part']['manufacturer']['name'] . '</strong>' : '-'
|
||||
isset($entry['part']['manufacturer']['id']) && $entry['part']['manufacturer']['id'] != null ? '<strong>' . $entry['part']['manufacturer']['id'] . '</strong>' : '-',
|
||||
isset($entry['part']['manufacturer']['name']) && $entry['part']['manufacturer']['name'] != null ? '<strong>' . $entry['part']['manufacturer']['name'] . '</strong>' : '-'
|
||||
);
|
||||
|
||||
$result->addViolation($this->buildJsonViolation(
|
||||
|
|
@ -760,7 +762,7 @@ class BOMImporter
|
|||
$result->addViolation($this->buildJsonViolation(
|
||||
'validator.bom_importer.json_csv.parameter.array',
|
||||
'entry[$key].part.category',
|
||||
$entry['part']['category']) ?? null
|
||||
$entry['part']['category'])
|
||||
);
|
||||
}
|
||||
|
||||
|
|
@ -782,8 +784,8 @@ class BOMImporter
|
|||
if (($categoryIdValid || $categoryNameValid)) {
|
||||
$value = sprintf(
|
||||
'category.id: %s, category.name: %s',
|
||||
isset($entry['part']['category']['id']) && $entry['part']['category']['id'] !== null ? '<strong>' . $entry['part']['category']['id'] . '</strong>' : '-',
|
||||
isset($entry['part']['category']['name']) && $entry['part']['category']['name'] !== null ? '<strong>' . $entry['part']['category']['name'] . '</strong>' : '-'
|
||||
isset($entry['part']['category']['id']) && $entry['part']['category']['id'] != null ? '<strong>' . $entry['part']['category']['id'] . '</strong>' : '-',
|
||||
isset($entry['part']['category']['name']) && $entry['part']['category']['name'] != null ? '<strong>' . $entry['part']['category']['name'] . '</strong>' : '-'
|
||||
);
|
||||
|
||||
$result->addViolation($this->buildJsonViolation(
|
||||
|
|
@ -816,11 +818,13 @@ class BOMImporter
|
|||
$part->setDescription($partDescription);
|
||||
}
|
||||
|
||||
/** @var Manufacturer|null $manufacturer */
|
||||
if ($manufacturer !== null && $manufacturer->getID() !== $part->getManufacturer()->getID()) {
|
||||
//When updating the associated parts, take over to a assembly of the manufacturer of the part.
|
||||
$part->setManufacturer($manufacturer);
|
||||
}
|
||||
|
||||
/** @var Category|null $category */
|
||||
if ($category !== null && $category->getID() !== $part->getCategory()->getID()) {
|
||||
//When updating the associated parts to a assembly, take over the category of the part.
|
||||
$part->setCategory($category);
|
||||
|
|
|
|||
|
|
@ -414,7 +414,7 @@ class EntityExporter
|
|||
'ProjectFullName' => $this->getFullName($entity),
|
||||
|
||||
//BOM relevant attributes
|
||||
'Quantity' => $bomEntry->getQuantity() ?? '',
|
||||
'Quantity' => $bomEntry->getQuantity(),
|
||||
'PartId' => $bomEntry->getPart()?->getId() ?? '',
|
||||
'PartName' => $bomEntry->getPart()?->getName() ?? '',
|
||||
'Ipn' => $bomEntry->getPart()?->getIpn() ?? '',
|
||||
|
|
@ -582,7 +582,7 @@ class EntityExporter
|
|||
'AssemblyFullName' => $this->getFullName($assembly),
|
||||
|
||||
//BOM relevant attributes
|
||||
'Quantity' => $bomEntry->getQuantity() ?? '',
|
||||
'Quantity' => $bomEntry->getQuantity(),
|
||||
'PartId' => $bomEntry->getPart()?->getId() ?? '-',
|
||||
'PartName' => $bomEntry->getPart()?->getName() ?? '-',
|
||||
'Ipn' => $bomEntry->getPart()?->getIpn() ?? '-',
|
||||
|
|
|
|||
|
|
@ -132,10 +132,10 @@ class AssemblyCycleValidator extends ConstraintValidator
|
|||
* The process involves reflection to access private or protected properties of violation objects.
|
||||
*
|
||||
* @param mixed $value The value that triggered the violation.
|
||||
* @param Constraint $constraint The constraint containing the validation details.
|
||||
* @param AssemblyCycle $constraint The constraint containing the validation details.
|
||||
*
|
||||
*/
|
||||
private function addViolation(mixed $value, Constraint $constraint): void
|
||||
private function addViolation(mixed $value, AssemblyCycle $constraint): void
|
||||
{
|
||||
/** @var ConstraintViolationBuilder $buildViolation */
|
||||
$buildViolation = $this->context->buildViolation($constraint->message)
|
||||
|
|
@ -166,4 +166,4 @@ class AssemblyCycleValidator extends ConstraintValidator
|
|||
$buildViolation->addViolation();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -97,19 +97,6 @@ class AssemblyInvalidBomEntryValidator extends ConstraintValidator
|
|||
|
||||
}
|
||||
|
||||
private function isOnSameLevel(Assembly $assembly1, Assembly $assembly2): bool
|
||||
{
|
||||
$parent1 = $assembly1->getParent();
|
||||
$parent2 = $assembly2->getParent();
|
||||
|
||||
if ($parent1 === null || $parent2 === null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Beide Assemblies teilen denselben Parent
|
||||
return $parent1 !== null && $parent2 !== null && $parent1->getId() === $parent2->getId();
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a violation to the current context if it hasn’t already been added.
|
||||
*
|
||||
|
|
@ -117,11 +104,11 @@ class AssemblyInvalidBomEntryValidator extends ConstraintValidator
|
|||
* already exists in the context. If such a violation is found, the current violation is not added again.
|
||||
* The process involves reflection to access private or protected properties of violation objects.
|
||||
*
|
||||
* @param mixed $value The value that triggered the violation.
|
||||
* @param Constraint $constraint The constraint containing the validation details.
|
||||
* @param mixed $value The value that triggered the violation.
|
||||
* @param AssemblyInvalidBomEntry $constraint The constraint containing the validation details.
|
||||
*
|
||||
*/
|
||||
private function addViolation($value, Constraint $constraint): void
|
||||
private function addViolation($value, AssemblyInvalidBomEntry $constraint): void
|
||||
{
|
||||
/** @var ConstraintViolationBuilder $buildViolation */
|
||||
$buildViolation = $this->context->buildViolation($constraint->message)
|
||||
|
|
@ -152,4 +139,4 @@ class AssemblyInvalidBomEntryValidator extends ConstraintValidator
|
|||
$buildViolation->addViolation();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -30,6 +30,7 @@ class UniqueReferencedAssemblyValidator extends ConstraintValidator
|
|||
public function validate($value, Constraint $constraint)
|
||||
{
|
||||
$assemblies = [];
|
||||
|
||||
foreach ($value as $entry) {
|
||||
$referencedAssemblyId = $entry->getReferencedAssembly()?->getId();
|
||||
if ($referencedAssemblyId === null) {
|
||||
|
|
@ -37,6 +38,7 @@ class UniqueReferencedAssemblyValidator extends ConstraintValidator
|
|||
}
|
||||
|
||||
if (isset($assemblies[$referencedAssemblyId])) {
|
||||
/** @var UniqueReferencedAssembly $constraint */
|
||||
$this->context->buildViolation($constraint->message)
|
||||
->atPath('referencedAssembly')
|
||||
->addViolation();
|
||||
|
|
@ -45,4 +47,4 @@ class UniqueReferencedAssemblyValidator extends ConstraintValidator
|
|||
$assemblies[$referencedAssemblyId] = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue