mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2025-06-21 09:35:49 +02:00
Use an enum for target_type in log entries
This commit is contained in:
parent
2da7463edf
commit
9adfcc7aec
12 changed files with 359 additions and 210 deletions
64
src/DataTables/Column/EnumColumn.php
Normal file
64
src/DataTables/Column/EnumColumn.php
Normal file
|
@ -0,0 +1,64 @@
|
||||||
|
<?php
|
||||||
|
/*
|
||||||
|
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
|
||||||
|
*
|
||||||
|
* Copyright (C) 2019 - 2023 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/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace App\DataTables\Column;
|
||||||
|
|
||||||
|
use Omines\DataTablesBundle\Column\AbstractColumn;
|
||||||
|
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||||
|
use UnitEnum;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @template T of UnitEnum
|
||||||
|
*/
|
||||||
|
class EnumColumn extends AbstractColumn
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @phpstan-return T
|
||||||
|
*/
|
||||||
|
public function normalize($value): UnitEnum
|
||||||
|
{
|
||||||
|
if (is_a($value, $this->getEnumClass())) {
|
||||||
|
return $value;
|
||||||
|
}
|
||||||
|
|
||||||
|
//@phpstan-ignore-next-line
|
||||||
|
return ($this->getEnumClass())::from($value);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function configureOptions(OptionsResolver $resolver)
|
||||||
|
{
|
||||||
|
parent::configureOptions($resolver);
|
||||||
|
|
||||||
|
$resolver->setRequired('class');
|
||||||
|
$resolver->setAllowedTypes('class', 'string');
|
||||||
|
$resolver->addAllowedValues('class', enum_exists(...));
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return class-string<T>
|
||||||
|
*/
|
||||||
|
public function getEnumClass(): string
|
||||||
|
{
|
||||||
|
return $this->options['class'];
|
||||||
|
}
|
||||||
|
}
|
|
@ -22,6 +22,8 @@ declare(strict_types=1);
|
||||||
|
|
||||||
namespace App\DataTables;
|
namespace App\DataTables;
|
||||||
|
|
||||||
|
use App\DataTables\Column\EnumColumn;
|
||||||
|
use App\Entity\LogSystem\LogTargetType;
|
||||||
use Symfony\Bundle\SecurityBundle\Security;
|
use Symfony\Bundle\SecurityBundle\Security;
|
||||||
use App\DataTables\Column\IconLinkColumn;
|
use App\DataTables\Column\IconLinkColumn;
|
||||||
use App\DataTables\Column\LocaleDateTimeColumn;
|
use App\DataTables\Column\LocaleDateTimeColumn;
|
||||||
|
@ -186,11 +188,12 @@ class LogDataTable implements DataTableTypeInterface
|
||||||
},
|
},
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$dataTable->add('target_type', TextColumn::class, [
|
$dataTable->add('target_type', EnumColumn::class, [
|
||||||
'label' => 'log.target_type',
|
'label' => 'log.target_type',
|
||||||
'visible' => false,
|
'visible' => false,
|
||||||
'render' => function ($value, AbstractLogEntry $context) {
|
'class' => LogTargetType::class,
|
||||||
$class = $context->getTargetClass();
|
'render' => function (LogTargetType $value, AbstractLogEntry $context) {
|
||||||
|
$class = $value->toClass();
|
||||||
if (null !== $class) {
|
if (null !== $class) {
|
||||||
return $this->elementTypeNameGenerator->getLocalizedTypeLabel($class);
|
return $this->elementTypeNameGenerator->getLocalizedTypeLabel($class);
|
||||||
}
|
}
|
||||||
|
@ -277,8 +280,8 @@ class LogDataTable implements DataTableTypeInterface
|
||||||
->andWhere('log.target_type NOT IN (:disallowed)');
|
->andWhere('log.target_type NOT IN (:disallowed)');
|
||||||
|
|
||||||
$builder->setParameter('disallowed', [
|
$builder->setParameter('disallowed', [
|
||||||
AbstractLogEntry::targetTypeClassToID(User::class),
|
LogTargetType::USER,
|
||||||
AbstractLogEntry::targetTypeClassToID(Group::class),
|
LogTargetType::GROUP,
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -286,9 +289,12 @@ class LogDataTable implements DataTableTypeInterface
|
||||||
foreach ($options['filter_elements'] as $element) {
|
foreach ($options['filter_elements'] as $element) {
|
||||||
/** @var AbstractDBElement $element */
|
/** @var AbstractDBElement $element */
|
||||||
|
|
||||||
$target_type = AbstractLogEntry::targetTypeClassToID($element::class);
|
$target_type = LogTargetType::fromElementClass($element);
|
||||||
$target_id = $element->getID();
|
$target_id = $element->getID();
|
||||||
$builder->orWhere("log.target_type = ${target_type} AND log.target_id = ${target_id}");
|
|
||||||
|
$builder->orWhere('log.target_type = :filter_target_type AND log.target_id = :filter_target_id');
|
||||||
|
$builder->setParameter('filter_target_type', $target_type);
|
||||||
|
$builder->setParameter('filter_target_id', $target_id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -63,50 +63,6 @@ use App\Repository\LogEntryRepository;
|
||||||
#[ORM\Index(columns: ['datetime'], name: 'log_idx_datetime')]
|
#[ORM\Index(columns: ['datetime'], name: 'log_idx_datetime')]
|
||||||
abstract class AbstractLogEntry extends AbstractDBElement
|
abstract class AbstractLogEntry extends AbstractDBElement
|
||||||
{
|
{
|
||||||
protected const TARGET_TYPE_NONE = 0;
|
|
||||||
protected const TARGET_TYPE_USER = 1;
|
|
||||||
protected const TARGET_TYPE_ATTACHEMENT = 2;
|
|
||||||
protected const TARGET_TYPE_ATTACHEMENTTYPE = 3;
|
|
||||||
protected const TARGET_TYPE_CATEGORY = 4;
|
|
||||||
protected const TARGET_TYPE_DEVICE = 5;
|
|
||||||
protected const TARGET_TYPE_DEVICEPART = 6;
|
|
||||||
protected const TARGET_TYPE_FOOTPRINT = 7;
|
|
||||||
protected const TARGET_TYPE_GROUP = 8;
|
|
||||||
protected const TARGET_TYPE_MANUFACTURER = 9;
|
|
||||||
protected const TARGET_TYPE_PART = 10;
|
|
||||||
protected const TARGET_TYPE_STORELOCATION = 11;
|
|
||||||
protected const TARGET_TYPE_SUPPLIER = 12;
|
|
||||||
protected const TARGET_TYPE_PARTLOT = 13;
|
|
||||||
protected const TARGET_TYPE_CURRENCY = 14;
|
|
||||||
protected const TARGET_TYPE_ORDERDETAIL = 15;
|
|
||||||
protected const TARGET_TYPE_PRICEDETAIL = 16;
|
|
||||||
protected const TARGET_TYPE_MEASUREMENTUNIT = 17;
|
|
||||||
protected const TARGET_TYPE_PARAMETER = 18;
|
|
||||||
protected const TARGET_TYPE_LABEL_PROFILE = 19;
|
|
||||||
|
|
||||||
|
|
||||||
protected const TARGET_CLASS_MAPPING = [
|
|
||||||
self::TARGET_TYPE_USER => User::class,
|
|
||||||
self::TARGET_TYPE_ATTACHEMENT => Attachment::class,
|
|
||||||
self::TARGET_TYPE_ATTACHEMENTTYPE => AttachmentType::class,
|
|
||||||
self::TARGET_TYPE_CATEGORY => Category::class,
|
|
||||||
self::TARGET_TYPE_DEVICE => Project::class,
|
|
||||||
self::TARGET_TYPE_DEVICEPART => ProjectBOMEntry::class,
|
|
||||||
self::TARGET_TYPE_FOOTPRINT => Footprint::class,
|
|
||||||
self::TARGET_TYPE_GROUP => Group::class,
|
|
||||||
self::TARGET_TYPE_MANUFACTURER => Manufacturer::class,
|
|
||||||
self::TARGET_TYPE_PART => Part::class,
|
|
||||||
self::TARGET_TYPE_STORELOCATION => Storelocation::class,
|
|
||||||
self::TARGET_TYPE_SUPPLIER => Supplier::class,
|
|
||||||
self::TARGET_TYPE_PARTLOT => PartLot::class,
|
|
||||||
self::TARGET_TYPE_CURRENCY => Currency::class,
|
|
||||||
self::TARGET_TYPE_ORDERDETAIL => Orderdetail::class,
|
|
||||||
self::TARGET_TYPE_PRICEDETAIL => Pricedetail::class,
|
|
||||||
self::TARGET_TYPE_MEASUREMENTUNIT => MeasurementUnit::class,
|
|
||||||
self::TARGET_TYPE_PARAMETER => AbstractParameter::class,
|
|
||||||
self::TARGET_TYPE_LABEL_PROFILE => LabelProfile::class,
|
|
||||||
];
|
|
||||||
|
|
||||||
/** @var User|null The user which has caused this log entry
|
/** @var User|null The user which has caused this log entry
|
||||||
*/
|
*/
|
||||||
#[ORM\ManyToOne(targetEntity: User::class, fetch: 'EAGER')]
|
#[ORM\ManyToOne(targetEntity: User::class, fetch: 'EAGER')]
|
||||||
|
@ -135,10 +91,10 @@ abstract class AbstractLogEntry extends AbstractDBElement
|
||||||
#[ORM\Column(name: 'target_id', type: Types::INTEGER)]
|
#[ORM\Column(name: 'target_id', type: Types::INTEGER)]
|
||||||
protected int $target_id = 0;
|
protected int $target_id = 0;
|
||||||
|
|
||||||
/** @var int The Type of the targeted element
|
/** @var LogTargetType The Type of the targeted element
|
||||||
*/
|
*/
|
||||||
#[ORM\Column(name: 'target_type', type: Types::SMALLINT)]
|
#[ORM\Column(name: 'target_type', type: Types::SMALLINT, enumType: LogTargetType::class)]
|
||||||
protected int $target_type = 0;
|
protected LogTargetType $target_type = LogTargetType::NONE;
|
||||||
|
|
||||||
/** @var string The type of this log entry, aka the description what has happened.
|
/** @var string The type of this log entry, aka the description what has happened.
|
||||||
* The mapping between the log entry class and the discriminator column is done by doctrine.
|
* The mapping between the log entry class and the discriminator column is done by doctrine.
|
||||||
|
@ -299,11 +255,16 @@ abstract class AbstractLogEntry extends AbstractDBElement
|
||||||
*/
|
*/
|
||||||
public function getTargetClass(): ?string
|
public function getTargetClass(): ?string
|
||||||
{
|
{
|
||||||
if (self::TARGET_TYPE_NONE === $this->target_type) {
|
return $this->target_type->toClass();
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return self::targetTypeIdToClass($this->target_type);
|
/**
|
||||||
|
* Returns the type of the target element associated with this log entry.
|
||||||
|
* @return LogTargetType
|
||||||
|
*/
|
||||||
|
public function getTargetType(): LogTargetType
|
||||||
|
{
|
||||||
|
return $this->target_type;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -340,14 +301,14 @@ abstract class AbstractLogEntry extends AbstractDBElement
|
||||||
*/
|
*/
|
||||||
public function setTargetElement(?AbstractDBElement $element): self
|
public function setTargetElement(?AbstractDBElement $element): self
|
||||||
{
|
{
|
||||||
if (!$element instanceof AbstractDBElement) {
|
if ($element === null) {
|
||||||
$this->target_id = 0;
|
$this->target_id = 0;
|
||||||
$this->target_type = self::TARGET_TYPE_NONE;
|
$this->target_type = LogTargetType::NONE;
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->target_type = static::targetTypeClassToID($element::class);
|
$this->target_type = LogTargetType::fromElementClass($element);
|
||||||
$this->target_id = $element->getID();
|
$this->target_id = $element->getID();
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
|
@ -370,42 +331,4 @@ abstract class AbstractLogEntry extends AbstractDBElement
|
||||||
return $this->extra;
|
return $this->extra;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Converts a target type id to a full qualified class name.
|
|
||||||
*
|
|
||||||
* @param int $type_id The target type ID
|
|
||||||
*/
|
|
||||||
final public static function targetTypeIdToClass(int $type_id): string
|
|
||||||
{
|
|
||||||
if (!isset(self::TARGET_CLASS_MAPPING[$type_id])) {
|
|
||||||
throw new InvalidArgumentException('No target type with this ID is existing!');
|
|
||||||
}
|
|
||||||
|
|
||||||
return self::TARGET_CLASS_MAPPING[$type_id];
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Convert a class name to a target type ID.
|
|
||||||
*
|
|
||||||
* @param string $class The name of the class (FQN) that should be converted to id
|
|
||||||
*
|
|
||||||
* @return int the ID of the associated target type ID
|
|
||||||
*/
|
|
||||||
final public static function targetTypeClassToID(string $class): int
|
|
||||||
{
|
|
||||||
$tmp = array_flip(self::TARGET_CLASS_MAPPING);
|
|
||||||
//Check if we can use a key directly
|
|
||||||
if (isset($tmp[$class])) {
|
|
||||||
return $tmp[$class];
|
|
||||||
}
|
|
||||||
|
|
||||||
//Otherwise we have to iterate over everything and check for inheritance
|
|
||||||
foreach ($tmp as $compare_class => $class_id) {
|
|
||||||
if (is_a($class, $compare_class, true)) {
|
|
||||||
return $class_id;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
throw new InvalidArgumentException('No target ID for this class is existing! (Class: '.$class.')');
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -89,6 +89,8 @@ class CollectionElementDeleted extends AbstractLogEntry implements LogWithEventU
|
||||||
{
|
{
|
||||||
protected string $typeString = 'collection_element_deleted';
|
protected string $typeString = 'collection_element_deleted';
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public function __construct(AbstractDBElement $changed_element, string $collection_name, AbstractDBElement $deletedElement)
|
public function __construct(AbstractDBElement $changed_element, string $collection_name, AbstractDBElement $deletedElement)
|
||||||
{
|
{
|
||||||
parent::__construct();
|
parent::__construct();
|
||||||
|
@ -97,7 +99,7 @@ class CollectionElementDeleted extends AbstractLogEntry implements LogWithEventU
|
||||||
|
|
||||||
$this->setTargetElement($changed_element);
|
$this->setTargetElement($changed_element);
|
||||||
$this->extra['n'] = $collection_name;
|
$this->extra['n'] = $collection_name;
|
||||||
$this->extra['c'] = self::targetTypeClassToID($deletedElement::class);
|
$this->extra['c'] = LogTargetType::fromElementClass($deletedElement)->value;
|
||||||
$this->extra['i'] = $deletedElement->getID();
|
$this->extra['i'] = $deletedElement->getID();
|
||||||
if ($deletedElement instanceof NamedElementInterface) {
|
if ($deletedElement instanceof NamedElementInterface) {
|
||||||
$this->extra['o'] = $deletedElement->getName();
|
$this->extra['o'] = $deletedElement->getName();
|
||||||
|
@ -127,7 +129,7 @@ class CollectionElementDeleted extends AbstractLogEntry implements LogWithEventU
|
||||||
public function getDeletedElementClass(): string
|
public function getDeletedElementClass(): string
|
||||||
{
|
{
|
||||||
//The class name of our target element
|
//The class name of our target element
|
||||||
$tmp = self::targetTypeIdToClass($this->extra['c']);
|
$tmp = LogTargetType::from($this->extra['c'])->toClass();
|
||||||
|
|
||||||
$reflection_class = new \ReflectionClass($tmp);
|
$reflection_class = new \ReflectionClass($tmp);
|
||||||
//If the class is abstract, we have to map it to an instantiable class
|
//If the class is abstract, we have to map it to an instantiable class
|
||||||
|
|
123
src/Entity/LogSystem/LogTargetType.php
Normal file
123
src/Entity/LogSystem/LogTargetType.php
Normal file
|
@ -0,0 +1,123 @@
|
||||||
|
<?php
|
||||||
|
/*
|
||||||
|
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
|
||||||
|
*
|
||||||
|
* Copyright (C) 2019 - 2023 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/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace App\Entity\LogSystem;
|
||||||
|
|
||||||
|
use App\Entity\Attachments\Attachment;
|
||||||
|
use App\Entity\Attachments\AttachmentType;
|
||||||
|
use App\Entity\LabelSystem\LabelProfile;
|
||||||
|
use App\Entity\Parameters\AbstractParameter;
|
||||||
|
use App\Entity\Parts\Category;
|
||||||
|
use App\Entity\Parts\Footprint;
|
||||||
|
use App\Entity\Parts\Manufacturer;
|
||||||
|
use App\Entity\Parts\MeasurementUnit;
|
||||||
|
use App\Entity\Parts\Part;
|
||||||
|
use App\Entity\Parts\PartLot;
|
||||||
|
use App\Entity\Parts\Storelocation;
|
||||||
|
use App\Entity\Parts\Supplier;
|
||||||
|
use App\Entity\PriceInformations\Currency;
|
||||||
|
use App\Entity\PriceInformations\Orderdetail;
|
||||||
|
use App\Entity\PriceInformations\Pricedetail;
|
||||||
|
use App\Entity\ProjectSystem\Project;
|
||||||
|
use App\Entity\ProjectSystem\ProjectBOMEntry;
|
||||||
|
use App\Entity\UserSystem\Group;
|
||||||
|
use App\Entity\UserSystem\User;
|
||||||
|
|
||||||
|
enum LogTargetType: int
|
||||||
|
{
|
||||||
|
case NONE = 0;
|
||||||
|
case USER = 1;
|
||||||
|
case ATTACHMENT = 2;
|
||||||
|
case ATTACHMENT_TYPE = 3;
|
||||||
|
case CATEGORY = 4;
|
||||||
|
case PROJECT = 5;
|
||||||
|
case BOM_ENTRY = 6;
|
||||||
|
case FOOTPRINT = 7;
|
||||||
|
case GROUP = 8;
|
||||||
|
case MANUFACTURER = 9;
|
||||||
|
case PART = 10;
|
||||||
|
case STORELOCATION = 11;
|
||||||
|
case SUPPLIER = 12;
|
||||||
|
case PART_LOT = 13;
|
||||||
|
case CURRENCY = 14;
|
||||||
|
case ORDERDETAIL = 15;
|
||||||
|
case PRICEDETAIL = 16;
|
||||||
|
case MEASUREMENT_UNIT = 17;
|
||||||
|
case PARAMETER = 18;
|
||||||
|
case LABEL_PROFILE = 19;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the class name of the target type or null if the target type is NONE.
|
||||||
|
* @return string|null
|
||||||
|
*/
|
||||||
|
public function toClass(): ?string
|
||||||
|
{
|
||||||
|
return match ($this) {
|
||||||
|
self::NONE => null,
|
||||||
|
self::USER => User::class,
|
||||||
|
self::ATTACHMENT => Attachment::class,
|
||||||
|
self::ATTACHMENT_TYPE => AttachmentType::class,
|
||||||
|
self::CATEGORY => Category::class,
|
||||||
|
self::PROJECT => Project::class,
|
||||||
|
self::BOM_ENTRY => ProjectBOMEntry::class,
|
||||||
|
self::FOOTPRINT => Footprint::class,
|
||||||
|
self::GROUP => Group::class,
|
||||||
|
self::MANUFACTURER => Manufacturer::class,
|
||||||
|
self::PART => Part::class,
|
||||||
|
self::STORELOCATION => Storelocation::class,
|
||||||
|
self::SUPPLIER => Supplier::class,
|
||||||
|
self::PART_LOT => PartLot::class,
|
||||||
|
self::CURRENCY => Currency::class,
|
||||||
|
self::ORDERDETAIL => Orderdetail::class,
|
||||||
|
self::PRICEDETAIL => Pricedetail::class,
|
||||||
|
self::MEASUREMENT_UNIT => MeasurementUnit::class,
|
||||||
|
self::PARAMETER => AbstractParameter::class,
|
||||||
|
self::LABEL_PROFILE => LabelProfile::class,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Determines the target type from the given class name or object.
|
||||||
|
* @param object|string $element
|
||||||
|
* @phpstan-param object|class-string $element
|
||||||
|
* @return self
|
||||||
|
*/
|
||||||
|
public static function fromElementClass(object|string $element): self
|
||||||
|
{
|
||||||
|
//Iterate over all possible types
|
||||||
|
foreach (self::cases() as $case) {
|
||||||
|
$class = $case->toClass();
|
||||||
|
|
||||||
|
//Skip NONE
|
||||||
|
if ($class === null) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
//Check if the given element is a instance of the class
|
||||||
|
if (is_a($element, $class, true)) {
|
||||||
|
return $case;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$elementClass = is_object($element) ? get_class($element) : $element;
|
||||||
|
//If no matching type was found, throw an exception
|
||||||
|
throw new \InvalidArgumentException("The given class $elementClass is not a valid log target type.");
|
||||||
|
}
|
||||||
|
}
|
|
@ -26,6 +26,7 @@ use App\DataTables\Filters\LogFilter;
|
||||||
use App\Entity\Attachments\Attachment;
|
use App\Entity\Attachments\Attachment;
|
||||||
use App\Entity\Attachments\AttachmentType;
|
use App\Entity\Attachments\AttachmentType;
|
||||||
use App\Entity\LogSystem\LogLevel;
|
use App\Entity\LogSystem\LogLevel;
|
||||||
|
use App\Entity\LogSystem\LogTargetType;
|
||||||
use App\Entity\LogSystem\PartStockChangedLogEntry;
|
use App\Entity\LogSystem\PartStockChangedLogEntry;
|
||||||
use App\Entity\ProjectSystem\Project;
|
use App\Entity\ProjectSystem\Project;
|
||||||
use App\Entity\ProjectSystem\ProjectBOMEntry;
|
use App\Entity\ProjectSystem\ProjectBOMEntry;
|
||||||
|
@ -123,29 +124,31 @@ class LogFilterType extends AbstractType
|
||||||
'label' => 'log.user',
|
'label' => 'log.user',
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$builder->add('targetType', ChoiceConstraintType::class, [
|
$builder->add('targetType', EnumConstraintType::class, [
|
||||||
'label' => 'log.target_type',
|
'label' => 'log.target_type',
|
||||||
'choices' => [
|
'enum_class' => LogTargetType::class,
|
||||||
'user.label' => AbstractLogEntry::targetTypeClassToID(User::class),
|
'choice_label' => fn(LogTargetType $type): string => match ($type) {
|
||||||
'attachment.label' => AbstractLogEntry::targetTypeClassToID(Attachment::class),
|
LogTargetType::NONE => 'log.target_type.none',
|
||||||
'attachment_type.label' => AbstractLogEntry::targetTypeClassToID(AttachmentType::class),
|
LogTargetType::USER => 'user.label',
|
||||||
'category.label' => AbstractLogEntry::targetTypeClassToID(Category::class),
|
LogTargetType::ATTACHMENT => 'attachment.label',
|
||||||
'project.label' => AbstractLogEntry::targetTypeClassToID(Project::class),
|
LogTargetType::ATTACHMENT_TYPE => 'attachment_type.label',
|
||||||
'project_bom_entry.label' => AbstractLogEntry::targetTypeClassToID(ProjectBOMEntry::class),
|
LogTargetType::CATEGORY => 'category.label',
|
||||||
'footprint.label' => AbstractLogEntry::targetTypeClassToID(Footprint::class),
|
LogTargetType::PROJECT => 'project.label',
|
||||||
'group.label' => AbstractLogEntry::targetTypeClassToID(Group::class),
|
LogTargetType::BOM_ENTRY => 'project_bom_entry.label',
|
||||||
'manufacturer.label' => AbstractLogEntry::targetTypeClassToID(Manufacturer::class),
|
LogTargetType::FOOTPRINT => 'footprint.label',
|
||||||
'part.label' => AbstractLogEntry::targetTypeClassToID(Part::class),
|
LogTargetType::GROUP => 'group.label',
|
||||||
'storelocation.label' => AbstractLogEntry::targetTypeClassToID(Storelocation::class),
|
LogTargetType::MANUFACTURER => 'manufacturer.label',
|
||||||
'supplier.label' => AbstractLogEntry::targetTypeClassToID(Supplier::class),
|
LogTargetType::PART => 'part.label',
|
||||||
'part_lot.label' => AbstractLogEntry::targetTypeClassToID(PartLot::class),
|
LogTargetType::STORELOCATION => 'storelocation.label',
|
||||||
'currency.label' => AbstractLogEntry::targetTypeClassToID(Currency::class),
|
LogTargetType::SUPPLIER => 'supplier.label',
|
||||||
'orderdetail.label' => AbstractLogEntry::targetTypeClassToID(Orderdetail::class),
|
LogTargetType::PART_LOT => 'part_lot.label',
|
||||||
'pricedetail.label' => AbstractLogEntry::targetTypeClassToID(Pricedetail::class),
|
LogTargetType::CURRENCY => 'currency.label',
|
||||||
'measurement_unit.label' => AbstractLogEntry::targetTypeClassToID(MeasurementUnit::class),
|
LogTargetType::ORDERDETAIL => 'orderdetail.label',
|
||||||
'parameter.label' => AbstractLogEntry::targetTypeClassToID(AbstractParameter::class),
|
LogTargetType::PRICEDETAIL => 'pricedetail.label',
|
||||||
'label_profile.label' => AbstractLogEntry::targetTypeClassToID(LabelProfile::class),
|
LogTargetType::MEASUREMENT_UNIT => 'measurement_unit.label',
|
||||||
]
|
LogTargetType::PARAMETER => 'parameter.label',
|
||||||
|
LogTargetType::LABEL_PROFILE => 'label_profile.label',
|
||||||
|
},
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$builder->add('targetId', NumberConstraintType::class, [
|
$builder->add('targetId', NumberConstraintType::class, [
|
||||||
|
|
|
@ -28,6 +28,7 @@ use App\Entity\LogSystem\CollectionElementDeleted;
|
||||||
use App\Entity\LogSystem\ElementCreatedLogEntry;
|
use App\Entity\LogSystem\ElementCreatedLogEntry;
|
||||||
use App\Entity\LogSystem\ElementDeletedLogEntry;
|
use App\Entity\LogSystem\ElementDeletedLogEntry;
|
||||||
use App\Entity\LogSystem\ElementEditedLogEntry;
|
use App\Entity\LogSystem\ElementEditedLogEntry;
|
||||||
|
use App\Entity\LogSystem\LogTargetType;
|
||||||
use App\Entity\UserSystem\User;
|
use App\Entity\UserSystem\User;
|
||||||
use DateTime;
|
use DateTime;
|
||||||
use RuntimeException;
|
use RuntimeException;
|
||||||
|
@ -45,7 +46,7 @@ class LogEntryRepository extends DBElementRepository
|
||||||
/** @var AbstractDBElement $element */
|
/** @var AbstractDBElement $element */
|
||||||
$element = $criteria['target'];
|
$element = $criteria['target'];
|
||||||
$criteria['target_id'] = $element->getID();
|
$criteria['target_id'] = $element->getID();
|
||||||
$criteria['target_type'] = AbstractLogEntry::targetTypeClassToID($element::class);
|
$criteria['target_type'] = LogTargetType::fromElementClass($element);
|
||||||
unset($criteria['target']);
|
unset($criteria['target']);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -86,7 +87,7 @@ class LogEntryRepository extends DBElementRepository
|
||||||
->setMaxResults(1);
|
->setMaxResults(1);
|
||||||
|
|
||||||
$qb->setParameters([
|
$qb->setParameters([
|
||||||
'target_type' => AbstractLogEntry::targetTypeClassToID($class),
|
'target_type' => LogTargetType::fromElementClass($class),
|
||||||
'target_id' => $id,
|
'target_id' => $id,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
@ -122,7 +123,7 @@ class LogEntryRepository extends DBElementRepository
|
||||||
->orderBy('log.timestamp', 'DESC');
|
->orderBy('log.timestamp', 'DESC');
|
||||||
|
|
||||||
$qb->setParameters([
|
$qb->setParameters([
|
||||||
'target_type' => AbstractLogEntry::targetTypeClassToID($element::class),
|
'target_type' => LogTargetType::fromElementClass($element),
|
||||||
'target_id' => $element->getID(),
|
'target_id' => $element->getID(),
|
||||||
'until' => $until,
|
'until' => $until,
|
||||||
]);
|
]);
|
||||||
|
@ -148,7 +149,7 @@ class LogEntryRepository extends DBElementRepository
|
||||||
->orderBy('log.timestamp', 'DESC');
|
->orderBy('log.timestamp', 'DESC');
|
||||||
|
|
||||||
$qb->setParameters([
|
$qb->setParameters([
|
||||||
'target_type' => AbstractLogEntry::targetTypeClassToID($element::class),
|
'target_type' => LogTargetType::fromElementClass($element),
|
||||||
'target_id' => $element->getID(),
|
'target_id' => $element->getID(),
|
||||||
'until' => $timestamp,
|
'until' => $timestamp,
|
||||||
]);
|
]);
|
||||||
|
@ -209,18 +210,24 @@ class LogEntryRepository extends DBElementRepository
|
||||||
return $this->getLastUser($element, ElementCreatedLogEntry::class);
|
return $this->getLastUser($element, ElementCreatedLogEntry::class);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function getLastUser(AbstractDBElement $element, string $class): ?User
|
/**
|
||||||
|
* Returns the last user that has created a log entry with the given class on the given element.
|
||||||
|
* @param AbstractDBElement $element
|
||||||
|
* @param string $log_class
|
||||||
|
* @return User|null
|
||||||
|
*/
|
||||||
|
protected function getLastUser(AbstractDBElement $element, string $log_class): ?User
|
||||||
{
|
{
|
||||||
$qb = $this->createQueryBuilder('log');
|
$qb = $this->createQueryBuilder('log');
|
||||||
$qb->select('log')
|
$qb->select('log')
|
||||||
//->where('log INSTANCE OF App\Entity\LogSystem\ElementEditedLogEntry')
|
//->where('log INSTANCE OF App\Entity\LogSystem\ElementEditedLogEntry')
|
||||||
->where('log INSTANCE OF '.$class)
|
->where('log INSTANCE OF '.$log_class)
|
||||||
->andWhere('log.target_type = :target_type')
|
->andWhere('log.target_type = :target_type')
|
||||||
->andWhere('log.target_id = :target_id')
|
->andWhere('log.target_id = :target_id')
|
||||||
->orderBy('log.timestamp', 'DESC');
|
->orderBy('log.timestamp', 'DESC');
|
||||||
|
|
||||||
$qb->setParameters([
|
$qb->setParameters([
|
||||||
'target_type' => AbstractLogEntry::targetTypeClassToID($element::class),
|
'target_type' => LogTargetType::fromElementClass($element),
|
||||||
'target_id' => $element->getID(),
|
'target_id' => $element->getID(),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
|
|
@ -60,53 +60,6 @@ use PHPUnit\Framework\TestCase;
|
||||||
|
|
||||||
class AbstractLogEntryTest extends TestCase
|
class AbstractLogEntryTest extends TestCase
|
||||||
{
|
{
|
||||||
public function targetTypeDataProvider(): array
|
|
||||||
{
|
|
||||||
return [
|
|
||||||
[1, User::class],
|
|
||||||
[2, Attachment::class],
|
|
||||||
[3, AttachmentType::class],
|
|
||||||
[4, Category::class],
|
|
||||||
[5, Project::class],
|
|
||||||
[6, ProjectBOMEntry::class],
|
|
||||||
[7, Footprint::class],
|
|
||||||
[8, Group::class],
|
|
||||||
[9, Manufacturer::class],
|
|
||||||
[10, Part::class],
|
|
||||||
[11, Storelocation::class],
|
|
||||||
[12, Supplier::class],
|
|
||||||
[-1, 'blablub', true],
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @dataProvider targetTypeDataProvider
|
|
||||||
*/
|
|
||||||
public function testTargetTypeIdToClass(int $int, string $expected_class, bool $expect_exception = false): void
|
|
||||||
{
|
|
||||||
if ($expect_exception) {
|
|
||||||
$this->expectException(\InvalidArgumentException::class);
|
|
||||||
}
|
|
||||||
$this->assertSame($expected_class, AbstractLogEntry::targetTypeIdToClass($int));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @dataProvider targetTypeDataProvider
|
|
||||||
*/
|
|
||||||
public function testTypeClassToID(int $expected_id, string $class, bool $expect_exception = false): void
|
|
||||||
{
|
|
||||||
if ($expect_exception) {
|
|
||||||
$this->expectException(\InvalidArgumentException::class);
|
|
||||||
}
|
|
||||||
$this->assertSame($expected_id, AbstractLogEntry::targetTypeClassToID($class));
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testTypeClassToIDSubclasses(): void
|
|
||||||
{
|
|
||||||
//Test if class mapping works for subclasses
|
|
||||||
$this->assertSame(2, AbstractLogEntry::targetTypeClassToID(PartAttachment::class));
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testSetGetTarget(): void
|
public function testSetGetTarget(): void
|
||||||
{
|
{
|
||||||
$part = $this->createMock(Part::class);
|
$part = $this->createMock(Part::class);
|
||||||
|
|
62
tests/Entity/LogSystem/LogTargetTypeTest.php
Normal file
62
tests/Entity/LogSystem/LogTargetTypeTest.php
Normal file
|
@ -0,0 +1,62 @@
|
||||||
|
<?php
|
||||||
|
/*
|
||||||
|
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
|
||||||
|
*
|
||||||
|
* Copyright (C) 2019 - 2023 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/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace App\Tests\Entity\LogSystem;
|
||||||
|
|
||||||
|
use App\Entity\Attachments\Attachment;
|
||||||
|
use App\Entity\Attachments\PartAttachment;
|
||||||
|
use App\Entity\LogSystem\LogTargetType;
|
||||||
|
use App\Entity\Parameters\PartParameter;
|
||||||
|
use App\Entity\Parts\Category;
|
||||||
|
use App\Entity\UserSystem\User;
|
||||||
|
use PHPUnit\Framework\TestCase;
|
||||||
|
|
||||||
|
class LogTargetTypeTest extends TestCase
|
||||||
|
{
|
||||||
|
|
||||||
|
public function testToClass(): void
|
||||||
|
{
|
||||||
|
$this->assertNull(LogTargetType::NONE->toClass());
|
||||||
|
$this->assertSame(User::class, LogTargetType::USER->toClass());
|
||||||
|
$this->assertSame(Category::class, LogTargetType::CATEGORY->toClass());
|
||||||
|
$this->assertSame(Attachment::class, LogTargetType::ATTACHMENT->toClass());
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testFromElementClass(): void
|
||||||
|
{
|
||||||
|
//Test creation from string class
|
||||||
|
$this->assertSame(LogTargetType::CATEGORY, LogTargetType::fromElementClass(Category::class));
|
||||||
|
$this->assertSame(LogTargetType::USER, LogTargetType::fromElementClass(User::class));
|
||||||
|
|
||||||
|
//Test creation from object
|
||||||
|
$this->assertSame(LogTargetType::CATEGORY, LogTargetType::fromElementClass(new Category()));
|
||||||
|
$this->assertSame(LogTargetType::USER, LogTargetType::fromElementClass(new User()));
|
||||||
|
|
||||||
|
//Test creation from subclass
|
||||||
|
$this->assertSame(LogTargetType::ATTACHMENT, LogTargetType::fromElementClass(new PartAttachment()));
|
||||||
|
$this->assertSame(LogTargetType::PARAMETER, LogTargetType::fromElementClass(new PartParameter()));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testFromElementClassInvalid(): void
|
||||||
|
{
|
||||||
|
$this->expectException(\InvalidArgumentException::class);
|
||||||
|
LogTargetType::fromElementClass(new \stdClass());
|
||||||
|
}
|
||||||
|
}
|
|
@ -11439,5 +11439,11 @@ Element 3</target>
|
||||||
<target>An error occurred during the registration of the security key. Try again or use another security key!</target>
|
<target>An error occurred during the registration of the security key. Try again or use another security key!</target>
|
||||||
</segment>
|
</segment>
|
||||||
</unit>
|
</unit>
|
||||||
|
<unit id="ie0Ca0l" name="log.target_type.none">
|
||||||
|
<segment>
|
||||||
|
<source>log.target_type.none</source>
|
||||||
|
<target>None</target>
|
||||||
|
</segment>
|
||||||
|
</unit>
|
||||||
</file>
|
</file>
|
||||||
</xliff>
|
</xliff>
|
||||||
|
|
|
@ -2,13 +2,13 @@
|
||||||
<xliff xmlns="urn:oasis:names:tc:xliff:document:2.0" version="2.0" srcLang="en" trgLang="en">
|
<xliff xmlns="urn:oasis:names:tc:xliff:document:2.0" version="2.0" srcLang="en" trgLang="en">
|
||||||
<file id="security.en">
|
<file id="security.en">
|
||||||
<unit id="aazoCks" name="user.login_error.user_disabled">
|
<unit id="aazoCks" name="user.login_error.user_disabled">
|
||||||
<segment state="translated">
|
<segment>
|
||||||
<source>user.login_error.user_disabled</source>
|
<source>user.login_error.user_disabled</source>
|
||||||
<target>Your account is disabled! Contact an administrator if you think this is wrong.</target>
|
<target>Your account is disabled! Contact an administrator if you think this is wrong.</target>
|
||||||
</segment>
|
</segment>
|
||||||
</unit>
|
</unit>
|
||||||
<unit id="Dpb9AmY" name="saml.error.cannot_login_local_user_per_saml">
|
<unit id="Dpb9AmY" name="saml.error.cannot_login_local_user_per_saml">
|
||||||
<segment state="translated">
|
<segment>
|
||||||
<source>saml.error.cannot_login_local_user_per_saml</source>
|
<source>saml.error.cannot_login_local_user_per_saml</source>
|
||||||
<target>You cannot login as local user via SSO! Use your local user password instead.</target>
|
<target>You cannot login as local user via SSO! Use your local user password instead.</target>
|
||||||
</segment>
|
</segment>
|
||||||
|
|
|
@ -37,7 +37,7 @@
|
||||||
<note priority="1">Part-DB1\src\Entity\UserSystem\Group.php:0</note>
|
<note priority="1">Part-DB1\src\Entity\UserSystem\Group.php:0</note>
|
||||||
<note priority="1">Part-DB1\src\Entity\UserSystem\User.php:0</note>
|
<note priority="1">Part-DB1\src\Entity\UserSystem\User.php:0</note>
|
||||||
</notes>
|
</notes>
|
||||||
<segment state="translated">
|
<segment>
|
||||||
<source>part.master_attachment.must_be_picture</source>
|
<source>part.master_attachment.must_be_picture</source>
|
||||||
<target>The preview attachment must be a valid picture!</target>
|
<target>The preview attachment must be a valid picture!</target>
|
||||||
</segment>
|
</segment>
|
||||||
|
@ -82,7 +82,7 @@
|
||||||
<note priority="1">src\Entity\StructuralDBElement.php:0</note>
|
<note priority="1">src\Entity\StructuralDBElement.php:0</note>
|
||||||
<note priority="1">src\Entity\Supplier.php:0</note>
|
<note priority="1">src\Entity\Supplier.php:0</note>
|
||||||
</notes>
|
</notes>
|
||||||
<segment state="translated">
|
<segment>
|
||||||
<source>structural.entity.unique_name</source>
|
<source>structural.entity.unique_name</source>
|
||||||
<target>An element with this name already exists on this level!</target>
|
<target>An element with this name already exists on this level!</target>
|
||||||
</segment>
|
</segment>
|
||||||
|
@ -102,7 +102,7 @@
|
||||||
<note category="file-source" priority="1">Part-DB1\src\Entity\Parameters\StorelocationParameter.php:0</note>
|
<note category="file-source" priority="1">Part-DB1\src\Entity\Parameters\StorelocationParameter.php:0</note>
|
||||||
<note category="file-source" priority="1">Part-DB1\src\Entity\Parameters\SupplierParameter.php:0</note>
|
<note category="file-source" priority="1">Part-DB1\src\Entity\Parameters\SupplierParameter.php:0</note>
|
||||||
</notes>
|
</notes>
|
||||||
<segment state="translated">
|
<segment>
|
||||||
<source>parameters.validator.min_lesser_typical</source>
|
<source>parameters.validator.min_lesser_typical</source>
|
||||||
<target>Value must be lesser or equal the the typical value ({{ compared_value }}).</target>
|
<target>Value must be lesser or equal the the typical value ({{ compared_value }}).</target>
|
||||||
</segment>
|
</segment>
|
||||||
|
@ -122,7 +122,7 @@
|
||||||
<note category="file-source" priority="1">Part-DB1\src\Entity\Parameters\StorelocationParameter.php:0</note>
|
<note category="file-source" priority="1">Part-DB1\src\Entity\Parameters\StorelocationParameter.php:0</note>
|
||||||
<note category="file-source" priority="1">Part-DB1\src\Entity\Parameters\SupplierParameter.php:0</note>
|
<note category="file-source" priority="1">Part-DB1\src\Entity\Parameters\SupplierParameter.php:0</note>
|
||||||
</notes>
|
</notes>
|
||||||
<segment state="translated">
|
<segment>
|
||||||
<source>parameters.validator.min_lesser_max</source>
|
<source>parameters.validator.min_lesser_max</source>
|
||||||
<target>Value must be lesser than the maximum value ({{ compared_value }}).</target>
|
<target>Value must be lesser than the maximum value ({{ compared_value }}).</target>
|
||||||
</segment>
|
</segment>
|
||||||
|
@ -142,7 +142,7 @@
|
||||||
<note category="file-source" priority="1">Part-DB1\src\Entity\Parameters\StorelocationParameter.php:0</note>
|
<note category="file-source" priority="1">Part-DB1\src\Entity\Parameters\StorelocationParameter.php:0</note>
|
||||||
<note category="file-source" priority="1">Part-DB1\src\Entity\Parameters\SupplierParameter.php:0</note>
|
<note category="file-source" priority="1">Part-DB1\src\Entity\Parameters\SupplierParameter.php:0</note>
|
||||||
</notes>
|
</notes>
|
||||||
<segment state="translated">
|
<segment>
|
||||||
<source>parameters.validator.max_greater_typical</source>
|
<source>parameters.validator.max_greater_typical</source>
|
||||||
<target>Value must be greater or equal than the typical value ({{ compared_value }}).</target>
|
<target>Value must be greater or equal than the typical value ({{ compared_value }}).</target>
|
||||||
</segment>
|
</segment>
|
||||||
|
@ -152,7 +152,7 @@
|
||||||
<note category="file-source" priority="1">Part-DB1\src\Entity\UserSystem\User.php:0</note>
|
<note category="file-source" priority="1">Part-DB1\src\Entity\UserSystem\User.php:0</note>
|
||||||
<note priority="1">Part-DB1\src\Entity\UserSystem\User.php:0</note>
|
<note priority="1">Part-DB1\src\Entity\UserSystem\User.php:0</note>
|
||||||
</notes>
|
</notes>
|
||||||
<segment state="translated">
|
<segment>
|
||||||
<source>validator.user.username_already_used</source>
|
<source>validator.user.username_already_used</source>
|
||||||
<target>A user with this name is already exisiting</target>
|
<target>A user with this name is already exisiting</target>
|
||||||
</segment>
|
</segment>
|
||||||
|
@ -162,7 +162,7 @@
|
||||||
<note category="file-source" priority="1">Part-DB1\src\Entity\UserSystem\User.php:0</note>
|
<note category="file-source" priority="1">Part-DB1\src\Entity\UserSystem\User.php:0</note>
|
||||||
<note priority="1">Part-DB1\src\Entity\UserSystem\User.php:0</note>
|
<note priority="1">Part-DB1\src\Entity\UserSystem\User.php:0</note>
|
||||||
</notes>
|
</notes>
|
||||||
<segment state="translated">
|
<segment>
|
||||||
<source>user.invalid_username</source>
|
<source>user.invalid_username</source>
|
||||||
<target>The username must contain only letters, numbers, underscores, dots, pluses or minuses!</target>
|
<target>The username must contain only letters, numbers, underscores, dots, pluses or minuses!</target>
|
||||||
</segment>
|
</segment>
|
||||||
|
@ -171,7 +171,7 @@
|
||||||
<notes>
|
<notes>
|
||||||
<note category="state" priority="1">obsolete</note>
|
<note category="state" priority="1">obsolete</note>
|
||||||
</notes>
|
</notes>
|
||||||
<segment state="translated">
|
<segment>
|
||||||
<source>validator.noneofitschild.self</source>
|
<source>validator.noneofitschild.self</source>
|
||||||
<target>An element can not be its own parent!</target>
|
<target>An element can not be its own parent!</target>
|
||||||
</segment>
|
</segment>
|
||||||
|
@ -180,139 +180,139 @@
|
||||||
<notes>
|
<notes>
|
||||||
<note category="state" priority="1">obsolete</note>
|
<note category="state" priority="1">obsolete</note>
|
||||||
</notes>
|
</notes>
|
||||||
<segment state="translated">
|
<segment>
|
||||||
<source>validator.noneofitschild.children</source>
|
<source>validator.noneofitschild.children</source>
|
||||||
<target>You can not assign children element as parent (This would cause loops)!</target>
|
<target>You can not assign children element as parent (This would cause loops)!</target>
|
||||||
</segment>
|
</segment>
|
||||||
</unit>
|
</unit>
|
||||||
<unit id="ayNr6QK" name="validator.select_valid_category">
|
<unit id="ayNr6QK" name="validator.select_valid_category">
|
||||||
<segment state="translated">
|
<segment>
|
||||||
<source>validator.select_valid_category</source>
|
<source>validator.select_valid_category</source>
|
||||||
<target>Please select a valid category!</target>
|
<target>Please select a valid category!</target>
|
||||||
</segment>
|
</segment>
|
||||||
</unit>
|
</unit>
|
||||||
<unit id="6vIlN5q" name="validator.part_lot.only_existing">
|
<unit id="6vIlN5q" name="validator.part_lot.only_existing">
|
||||||
<segment state="translated">
|
<segment>
|
||||||
<source>validator.part_lot.only_existing</source>
|
<source>validator.part_lot.only_existing</source>
|
||||||
<target>Can not add new parts to this location as it is marked as "Only Existing"</target>
|
<target>Can not add new parts to this location as it is marked as "Only Existing"</target>
|
||||||
</segment>
|
</segment>
|
||||||
</unit>
|
</unit>
|
||||||
<unit id="3xoKOIS" name="validator.part_lot.location_full.no_increase">
|
<unit id="3xoKOIS" name="validator.part_lot.location_full.no_increase">
|
||||||
<segment state="translated">
|
<segment>
|
||||||
<source>validator.part_lot.location_full.no_increase</source>
|
<source>validator.part_lot.location_full.no_increase</source>
|
||||||
<target>Location is full. Amount can not be increased (new value must be smaller than {{ old_amount }}).</target>
|
<target>Location is full. Amount can not be increased (new value must be smaller than {{ old_amount }}).</target>
|
||||||
</segment>
|
</segment>
|
||||||
</unit>
|
</unit>
|
||||||
<unit id="R6Ov4Yt" name="validator.part_lot.location_full">
|
<unit id="R6Ov4Yt" name="validator.part_lot.location_full">
|
||||||
<segment state="translated">
|
<segment>
|
||||||
<source>validator.part_lot.location_full</source>
|
<source>validator.part_lot.location_full</source>
|
||||||
<target>Location is full. Can not add new parts to it.</target>
|
<target>Location is full. Can not add new parts to it.</target>
|
||||||
</segment>
|
</segment>
|
||||||
</unit>
|
</unit>
|
||||||
<unit id="BNQk2e7" name="validator.part_lot.single_part">
|
<unit id="BNQk2e7" name="validator.part_lot.single_part">
|
||||||
<segment state="translated">
|
<segment>
|
||||||
<source>validator.part_lot.single_part</source>
|
<source>validator.part_lot.single_part</source>
|
||||||
<target>This location can only contain a single part and it is already full!</target>
|
<target>This location can only contain a single part and it is already full!</target>
|
||||||
</segment>
|
</segment>
|
||||||
</unit>
|
</unit>
|
||||||
<unit id="4gPskOG" name="validator.attachment.must_not_be_null">
|
<unit id="4gPskOG" name="validator.attachment.must_not_be_null">
|
||||||
<segment state="translated">
|
<segment>
|
||||||
<source>validator.attachment.must_not_be_null</source>
|
<source>validator.attachment.must_not_be_null</source>
|
||||||
<target>You must select an attachment type!</target>
|
<target>You must select an attachment type!</target>
|
||||||
</segment>
|
</segment>
|
||||||
</unit>
|
</unit>
|
||||||
<unit id="cDDVrWT" name="validator.orderdetail.supplier_must_not_be_null">
|
<unit id="cDDVrWT" name="validator.orderdetail.supplier_must_not_be_null">
|
||||||
<segment state="translated">
|
<segment>
|
||||||
<source>validator.orderdetail.supplier_must_not_be_null</source>
|
<source>validator.orderdetail.supplier_must_not_be_null</source>
|
||||||
<target>You must select an supplier!</target>
|
<target>You must select an supplier!</target>
|
||||||
</segment>
|
</segment>
|
||||||
</unit>
|
</unit>
|
||||||
<unit id="k5DDdB4" name="validator.measurement_unit.use_si_prefix_needs_unit">
|
<unit id="k5DDdB4" name="validator.measurement_unit.use_si_prefix_needs_unit">
|
||||||
<segment state="translated">
|
<segment>
|
||||||
<source>validator.measurement_unit.use_si_prefix_needs_unit</source>
|
<source>validator.measurement_unit.use_si_prefix_needs_unit</source>
|
||||||
<target>To enable SI prefixes, you have to set a unit symbol!</target>
|
<target>To enable SI prefixes, you have to set a unit symbol!</target>
|
||||||
</segment>
|
</segment>
|
||||||
</unit>
|
</unit>
|
||||||
<unit id="DuzIOCr" name="part.ipn.must_be_unique">
|
<unit id="DuzIOCr" name="part.ipn.must_be_unique">
|
||||||
<segment state="translated">
|
<segment>
|
||||||
<source>part.ipn.must_be_unique</source>
|
<source>part.ipn.must_be_unique</source>
|
||||||
<target>The internal part number must be unique. {{ value }} is already in use!</target>
|
<target>The internal part number must be unique. {{ value }} is already in use!</target>
|
||||||
</segment>
|
</segment>
|
||||||
</unit>
|
</unit>
|
||||||
<unit id="Z4Kuuo2" name="validator.project.bom_entry.name_or_part_needed">
|
<unit id="Z4Kuuo2" name="validator.project.bom_entry.name_or_part_needed">
|
||||||
<segment state="translated">
|
<segment>
|
||||||
<source>validator.project.bom_entry.name_or_part_needed</source>
|
<source>validator.project.bom_entry.name_or_part_needed</source>
|
||||||
<target>You have to choose a part for a part BOM entry or set a name for a non-part BOM entry.</target>
|
<target>You have to choose a part for a part BOM entry or set a name for a non-part BOM entry.</target>
|
||||||
</segment>
|
</segment>
|
||||||
</unit>
|
</unit>
|
||||||
<unit id="WF_v4ih" name="project.bom_entry.name_already_in_bom">
|
<unit id="WF_v4ih" name="project.bom_entry.name_already_in_bom">
|
||||||
<segment state="translated">
|
<segment>
|
||||||
<source>project.bom_entry.name_already_in_bom</source>
|
<source>project.bom_entry.name_already_in_bom</source>
|
||||||
<target>There is already an BOM entry with this name!</target>
|
<target>There is already an BOM entry with this name!</target>
|
||||||
</segment>
|
</segment>
|
||||||
</unit>
|
</unit>
|
||||||
<unit id="5v4p85H" name="project.bom_entry.part_already_in_bom">
|
<unit id="5v4p85H" name="project.bom_entry.part_already_in_bom">
|
||||||
<segment state="translated">
|
<segment>
|
||||||
<source>project.bom_entry.part_already_in_bom</source>
|
<source>project.bom_entry.part_already_in_bom</source>
|
||||||
<target>This part already exists in the BOM!</target>
|
<target>This part already exists in the BOM!</target>
|
||||||
</segment>
|
</segment>
|
||||||
</unit>
|
</unit>
|
||||||
<unit id="3lM32Tw" name="project.bom_entry.mountnames_quantity_mismatch">
|
<unit id="3lM32Tw" name="project.bom_entry.mountnames_quantity_mismatch">
|
||||||
<segment state="translated">
|
<segment>
|
||||||
<source>project.bom_entry.mountnames_quantity_mismatch</source>
|
<source>project.bom_entry.mountnames_quantity_mismatch</source>
|
||||||
<target>The number of mountnames has to match the BOMs quantity!</target>
|
<target>The number of mountnames has to match the BOMs quantity!</target>
|
||||||
</segment>
|
</segment>
|
||||||
</unit>
|
</unit>
|
||||||
<unit id="x47D5WT" name="project.bom_entry.can_not_add_own_builds_part">
|
<unit id="x47D5WT" name="project.bom_entry.can_not_add_own_builds_part">
|
||||||
<segment state="translated">
|
<segment>
|
||||||
<source>project.bom_entry.can_not_add_own_builds_part</source>
|
<source>project.bom_entry.can_not_add_own_builds_part</source>
|
||||||
<target>You can not add a project's own builds part to the BOM.</target>
|
<target>You can not add a project's own builds part to the BOM.</target>
|
||||||
</segment>
|
</segment>
|
||||||
</unit>
|
</unit>
|
||||||
<unit id="2x2XDI_" name="project.bom_has_to_include_all_subelement_parts">
|
<unit id="2x2XDI_" name="project.bom_has_to_include_all_subelement_parts">
|
||||||
<segment state="translated">
|
<segment>
|
||||||
<source>project.bom_has_to_include_all_subelement_parts</source>
|
<source>project.bom_has_to_include_all_subelement_parts</source>
|
||||||
<target>The project BOM has to include all subprojects builds parts. Part %part_name% of project %project_name% missing!</target>
|
<target>The project BOM has to include all subprojects builds parts. Part %part_name% of project %project_name% missing!</target>
|
||||||
</segment>
|
</segment>
|
||||||
</unit>
|
</unit>
|
||||||
<unit id="U9b1EzD" name="project.bom_entry.price_not_allowed_on_parts">
|
<unit id="U9b1EzD" name="project.bom_entry.price_not_allowed_on_parts">
|
||||||
<segment state="translated">
|
<segment>
|
||||||
<source>project.bom_entry.price_not_allowed_on_parts</source>
|
<source>project.bom_entry.price_not_allowed_on_parts</source>
|
||||||
<target>Prices are not allowed on BOM entries associated with a part. Define the price on the part instead.</target>
|
<target>Prices are not allowed on BOM entries associated with a part. Define the price on the part instead.</target>
|
||||||
</segment>
|
</segment>
|
||||||
</unit>
|
</unit>
|
||||||
<unit id="ID056SR" name="validator.project_build.lot_bigger_than_needed">
|
<unit id="ID056SR" name="validator.project_build.lot_bigger_than_needed">
|
||||||
<segment state="translated">
|
<segment>
|
||||||
<source>validator.project_build.lot_bigger_than_needed</source>
|
<source>validator.project_build.lot_bigger_than_needed</source>
|
||||||
<target>You have selected more quantity to withdraw than needed! Remove unnecessary quantity.</target>
|
<target>You have selected more quantity to withdraw than needed! Remove unnecessary quantity.</target>
|
||||||
</segment>
|
</segment>
|
||||||
</unit>
|
</unit>
|
||||||
<unit id="6hV5UqD" name="validator.project_build.lot_smaller_than_needed">
|
<unit id="6hV5UqD" name="validator.project_build.lot_smaller_than_needed">
|
||||||
<segment state="translated">
|
<segment>
|
||||||
<source>validator.project_build.lot_smaller_than_needed</source>
|
<source>validator.project_build.lot_smaller_than_needed</source>
|
||||||
<target>You have selected less quantity to withdraw than needed for the build! Add additional quantity.</target>
|
<target>You have selected less quantity to withdraw than needed for the build! Add additional quantity.</target>
|
||||||
</segment>
|
</segment>
|
||||||
</unit>
|
</unit>
|
||||||
<unit id="G9ZKt.4" name="part.name.must_match_category_regex">
|
<unit id="G9ZKt.4" name="part.name.must_match_category_regex">
|
||||||
<segment state="translated">
|
<segment>
|
||||||
<source>part.name.must_match_category_regex</source>
|
<source>part.name.must_match_category_regex</source>
|
||||||
<target>The part name does not match the regular expression stated by the category: %regex%</target>
|
<target>The part name does not match the regular expression stated by the category: %regex%</target>
|
||||||
</segment>
|
</segment>
|
||||||
</unit>
|
</unit>
|
||||||
<unit id="m8kMFhf" name="validator.attachment.name_not_blank">
|
<unit id="m8kMFhf" name="validator.attachment.name_not_blank">
|
||||||
<segment state="translated">
|
<segment>
|
||||||
<source>validator.attachment.name_not_blank</source>
|
<source>validator.attachment.name_not_blank</source>
|
||||||
<target>Set a value here, or upload a file to automatically use its filename as name for the attachment.</target>
|
<target>Set a value here, or upload a file to automatically use its filename as name for the attachment.</target>
|
||||||
</segment>
|
</segment>
|
||||||
</unit>
|
</unit>
|
||||||
<unit id="nwGaNBW" name="validator.part_lot.owner_must_match_storage_location_owner">
|
<unit id="nwGaNBW" name="validator.part_lot.owner_must_match_storage_location_owner">
|
||||||
<segment state="translated">
|
<segment>
|
||||||
<source>validator.part_lot.owner_must_match_storage_location_owner</source>
|
<source>validator.part_lot.owner_must_match_storage_location_owner</source>
|
||||||
<target>The owner of this lot must match the owner of the selected storage location (%owner_name%)!</target>
|
<target>The owner of this lot must match the owner of the selected storage location (%owner_name%)!</target>
|
||||||
</segment>
|
</segment>
|
||||||
</unit>
|
</unit>
|
||||||
<unit id="HXSz3nQ" name="validator.part_lot.owner_must_not_be_anonymous">
|
<unit id="HXSz3nQ" name="validator.part_lot.owner_must_not_be_anonymous">
|
||||||
<segment state="translated">
|
<segment>
|
||||||
<source>validator.part_lot.owner_must_not_be_anonymous</source>
|
<source>validator.part_lot.owner_must_not_be_anonymous</source>
|
||||||
<target>A lot owner must not be the anonymous user!</target>
|
<target>A lot owner must not be the anonymous user!</target>
|
||||||
</segment>
|
</segment>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue