mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2025-06-24 02:38:50 +02:00
parent
9244fe5944
commit
4aedce9668
4 changed files with 52 additions and 0 deletions
|
@ -112,6 +112,8 @@ const PLACEHOLDERS = [
|
||||||
['[[COMMENT_T]]', 'Comment (plain text)'],
|
['[[COMMENT_T]]', 'Comment (plain text)'],
|
||||||
['[[LAST_MODIFIED]]', 'Last modified datetime'],
|
['[[LAST_MODIFIED]]', 'Last modified datetime'],
|
||||||
['[[CREATION_DATE]]', 'Creation datetime'],
|
['[[CREATION_DATE]]', 'Creation datetime'],
|
||||||
|
['[[OWNER]]', 'Full name of the location owner'],
|
||||||
|
['[[OWNER_USERNAME]]', 'Username of the location owner'],
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
|
@ -71,6 +71,8 @@ Object.assign( window.CKEDITOR_TRANSLATIONS[ 'de' ].dictionary, {
|
||||||
'Full path': 'Vollständiger Pfad',
|
'Full path': 'Vollständiger Pfad',
|
||||||
'Parent name': 'Name des Übergeordneten Elements',
|
'Parent name': 'Name des Übergeordneten Elements',
|
||||||
'Parent full path': 'Ganzer Pfad des Übergeordneten Elements',
|
'Parent full path': 'Ganzer Pfad des Übergeordneten Elements',
|
||||||
|
'Full name of the location owner': 'Name des Besitzers des Lagerorts',
|
||||||
|
'Username of the location owner': 'Benutzername des Besitzers des Lagerorts',
|
||||||
|
|
||||||
'Username': 'Benutzername',
|
'Username': 'Benutzername',
|
||||||
'Username (including name)': 'Benutzername (inklusive Name)',
|
'Username (including name)': 'Benutzername (inklusive Name)',
|
||||||
|
|
|
@ -0,0 +1,39 @@
|
||||||
|
<?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\Services\LabelSystem\PlaceholderProviders;
|
||||||
|
|
||||||
|
use App\Entity\Parts\Storelocation;
|
||||||
|
|
||||||
|
class StorelocationProvider implements PlaceholderProviderInterface
|
||||||
|
{
|
||||||
|
public function replace(string $placeholder, object $label_target, array $options = []): ?string
|
||||||
|
{
|
||||||
|
if ($label_target instanceof Storelocation) {
|
||||||
|
if ('[[OWNER]]' === $placeholder) {
|
||||||
|
return $label_target->getOwner() ? $label_target->getOwner()->getFullName() : '';
|
||||||
|
}
|
||||||
|
|
||||||
|
if ('[[OWNER_USERNAME]]' === $placeholder) {
|
||||||
|
return $label_target->getOwner() ? $label_target->getOwner()->getUsername() : '';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -44,6 +44,7 @@ namespace App\Tests\Services\LabelSystem\PlaceholderProviders;
|
||||||
use App\Entity\Parts\Part;
|
use App\Entity\Parts\Part;
|
||||||
use App\Entity\Parts\PartLot;
|
use App\Entity\Parts\PartLot;
|
||||||
use App\Entity\Parts\Storelocation;
|
use App\Entity\Parts\Storelocation;
|
||||||
|
use App\Entity\UserSystem\User;
|
||||||
use App\Services\LabelSystem\PlaceholderProviders\PartLotProvider;
|
use App\Services\LabelSystem\PlaceholderProviders\PartLotProvider;
|
||||||
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
|
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
|
||||||
|
|
||||||
|
@ -76,6 +77,12 @@ class PartLotProviderTest extends WebTestCase
|
||||||
$part->setName('Part');
|
$part->setName('Part');
|
||||||
$part->setDescription('Part description');
|
$part->setDescription('Part description');
|
||||||
$this->target->setPart($part);
|
$this->target->setPart($part);
|
||||||
|
|
||||||
|
$user = new User();
|
||||||
|
$user->setName('user');
|
||||||
|
$user->setFirstName('John');
|
||||||
|
$user->setLastName('Doe');
|
||||||
|
$this->target->setOwner($user);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function dataProvider(): array
|
public function dataProvider(): array
|
||||||
|
@ -91,6 +98,8 @@ class PartLotProviderTest extends WebTestCase
|
||||||
//Test part inheritance
|
//Test part inheritance
|
||||||
['Part', '[[NAME]]'],
|
['Part', '[[NAME]]'],
|
||||||
['Part description', '[[DESCRIPTION]]'],
|
['Part description', '[[DESCRIPTION]]'],
|
||||||
|
['John Doe', '[[OWNER]]'],
|
||||||
|
['user', '[[OWNER_USERNAME]]'],
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue