mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2025-06-24 02:38:50 +02:00
Allow timetraveling on data structures admin pages.
This commit is contained in:
parent
f9bb2d57e9
commit
31290c070a
15 changed files with 125 additions and 67 deletions
|
@ -132,35 +132,56 @@ class EntityURLGenerator
|
|||
*/
|
||||
public function timeTravelURL(AbstractDBElement $entity, \DateTime $dateTime): string
|
||||
{
|
||||
if ($entity instanceof Part) {
|
||||
return $this->urlGenerator->generate('part_info', [
|
||||
'id' => $entity->getID(),
|
||||
'timestamp' => $dateTime->getTimestamp()
|
||||
]);
|
||||
}
|
||||
if ($entity instanceof PartLot) {
|
||||
return $this->urlGenerator->generate('part_info', [
|
||||
'id' => $entity->getPart()->getID(),
|
||||
'timestamp' => $dateTime->getTimestamp()
|
||||
]);
|
||||
}
|
||||
if ($entity instanceof PartAttachment) {
|
||||
return $this->urlGenerator->generate('part_info', [
|
||||
'id' => $entity->getElement()->getID(),
|
||||
'timestamp' => $dateTime->getTimestamp()
|
||||
]);
|
||||
}
|
||||
if ($entity instanceof Orderdetail) {
|
||||
return $this->urlGenerator->generate('part_info', [
|
||||
'id' => $entity->getPart()->getID(),
|
||||
'timestamp' => $dateTime->getTimestamp()
|
||||
]);
|
||||
}
|
||||
if ($entity instanceof Pricedetail) {
|
||||
return $this->urlGenerator->generate('part_info', [
|
||||
'id' => $entity->getOrderdetail()->getPart()->getID(),
|
||||
'timestamp' => $dateTime->getTimestamp()
|
||||
]);
|
||||
$map = [
|
||||
Part::class => 'part_info',
|
||||
|
||||
//As long we does not have own things for it use edit page
|
||||
AttachmentType::class => 'attachment_type_edit',
|
||||
Category::class => 'category_edit',
|
||||
Device::class => 'device_edit',
|
||||
Supplier::class => 'supplier_edit',
|
||||
Manufacturer::class => 'manufacturer_edit',
|
||||
Storelocation::class => 'store_location_edit',
|
||||
Footprint::class => 'footprint_edit',
|
||||
User::class => 'user_edit',
|
||||
Currency::class => 'currency_edit',
|
||||
MeasurementUnit::class => 'measurement_unit_edit',
|
||||
Group::class => 'group_edit',
|
||||
];
|
||||
|
||||
try {
|
||||
return $this->urlGenerator->generate(
|
||||
$this->mapToController($map, $entity),
|
||||
[
|
||||
'id' => $entity->getID(),
|
||||
'timestamp' => $dateTime->getTimestamp()
|
||||
]
|
||||
);
|
||||
} catch (EntityNotSupportedException $exception) {
|
||||
if ($entity instanceof PartLot) {
|
||||
return $this->urlGenerator->generate('part_info', [
|
||||
'id' => $entity->getPart()->getID(),
|
||||
'timestamp' => $dateTime->getTimestamp()
|
||||
]);
|
||||
}
|
||||
if ($entity instanceof PartAttachment) {
|
||||
return $this->urlGenerator->generate('part_info', [
|
||||
'id' => $entity->getElement()->getID(),
|
||||
'timestamp' => $dateTime->getTimestamp()
|
||||
]);
|
||||
}
|
||||
if ($entity instanceof Orderdetail) {
|
||||
return $this->urlGenerator->generate('part_info', [
|
||||
'id' => $entity->getPart()->getID(),
|
||||
'timestamp' => $dateTime->getTimestamp()
|
||||
]);
|
||||
}
|
||||
if ($entity instanceof Pricedetail) {
|
||||
return $this->urlGenerator->generate('part_info', [
|
||||
'id' => $entity->getOrderdetail()->getPart()->getID(),
|
||||
'timestamp' => $dateTime->getTimestamp()
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
//Otherwise throw an error
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue