mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2025-06-27 04:08:57 +02:00
Allow to edit parameters for data structures.
This commit is contained in:
parent
4c63c88021
commit
ff05868051
16 changed files with 118 additions and 10 deletions
|
@ -44,6 +44,7 @@ namespace App\Controller\AdminPages;
|
|||
|
||||
use App\Entity\Attachments\AttachmentType;
|
||||
use App\Entity\Attachments\AttachmentTypeAttachment;
|
||||
use App\Entity\Parameters\AttachmentTypeParameter;
|
||||
use App\Form\AdminPages\AttachmentTypeAdminForm;
|
||||
use App\Services\EntityExporter;
|
||||
use App\Services\EntityImporter;
|
||||
|
@ -64,6 +65,7 @@ class AttachmentTypeController extends BaseAdminController
|
|||
protected $form_class = AttachmentTypeAdminForm::class;
|
||||
protected $route_base = 'attachment_type';
|
||||
protected $attachment_class = AttachmentTypeAttachment::class;
|
||||
protected $parameter_class = AttachmentTypeParameter::class;
|
||||
|
||||
/**
|
||||
* @Route("/{id}", name="attachment_type_delete", methods={"DELETE"})
|
||||
|
|
|
@ -77,6 +77,7 @@ abstract class BaseAdminController extends AbstractController
|
|||
protected $twig_template = '';
|
||||
protected $route_base = '';
|
||||
protected $attachment_class = '';
|
||||
protected $parameter_class = '';
|
||||
|
||||
protected $passwordEncoder;
|
||||
protected $translator;
|
||||
|
@ -101,6 +102,10 @@ abstract class BaseAdminController extends AbstractController
|
|||
throw new InvalidArgumentException('You have to override the $attachment_class value in your subclass!');
|
||||
}
|
||||
|
||||
if ('' === $this->parameter_class) {
|
||||
throw new InvalidArgumentException('You have to override the $parameter_class value in your subclass!');
|
||||
}
|
||||
|
||||
$this->translator = $translator;
|
||||
$this->passwordEncoder = $passwordEncoder;
|
||||
$this->attachmentHelper = $attachmentHelper;
|
||||
|
@ -149,6 +154,7 @@ abstract class BaseAdminController extends AbstractController
|
|||
|
||||
$form = $this->createForm($this->form_class, $entity, [
|
||||
'attachment_class' => $this->attachment_class,
|
||||
'parameter_class' => $this->parameter_class,
|
||||
'disabled' => null !== $timeTravel_timestamp ? true : null,
|
||||
]);
|
||||
|
||||
|
@ -189,7 +195,10 @@ abstract class BaseAdminController extends AbstractController
|
|||
|
||||
//Rebuild form, so it is based on the updated data. Important for the parent field!
|
||||
//We can not use dynamic form events here, because the parent entity list is build from database!
|
||||
$form = $this->createForm($this->form_class, $entity, ['attachment_class' => $this->attachment_class]);
|
||||
$form = $this->createForm($this->form_class, $entity, [
|
||||
'attachment_class' => $this->attachment_class,
|
||||
'parameter_class' => $this->parameter_class
|
||||
]);
|
||||
} elseif ($form->isSubmitted() && ! $form->isValid()) {
|
||||
$this->addFlash('error', 'entity.edit_flash.invalid');
|
||||
}
|
||||
|
@ -212,7 +221,10 @@ abstract class BaseAdminController extends AbstractController
|
|||
$this->denyAccessUnlessGranted('read', $new_entity);
|
||||
|
||||
//Basic edit form
|
||||
$form = $this->createForm($this->form_class, $new_entity, ['attachment_class' => $this->attachment_class]);
|
||||
$form = $this->createForm($this->form_class, $new_entity, [
|
||||
'attachment_class' => $this->attachment_class,
|
||||
'parameter_class' => $this->parameter_class,
|
||||
]);
|
||||
|
||||
$form->handleRequest($request);
|
||||
|
||||
|
|
|
@ -43,6 +43,7 @@ declare(strict_types=1);
|
|||
namespace App\Controller\AdminPages;
|
||||
|
||||
use App\Entity\Attachments\CategoryAttachment;
|
||||
use App\Entity\Parameters\CategoryParameter;
|
||||
use App\Entity\Parts\Category;
|
||||
use App\Form\AdminPages\CategoryAdminForm;
|
||||
use App\Services\EntityExporter;
|
||||
|
@ -64,6 +65,7 @@ class CategoryController extends BaseAdminController
|
|||
protected $form_class = CategoryAdminForm::class;
|
||||
protected $route_base = 'category';
|
||||
protected $attachment_class = CategoryAttachment::class;
|
||||
protected $parameter_class = CategoryParameter::class;
|
||||
|
||||
/**
|
||||
* @Route("/{id}", name="category_delete", methods={"DELETE"})
|
||||
|
|
|
@ -43,6 +43,7 @@ declare(strict_types=1);
|
|||
namespace App\Controller\AdminPages;
|
||||
|
||||
use App\Entity\Attachments\CurrencyAttachment;
|
||||
use App\Entity\Parameters\CurrencyParameter;
|
||||
use App\Entity\PriceInformations\Currency;
|
||||
use App\Form\AdminPages\CurrencyAdminForm;
|
||||
use App\Services\EntityExporter;
|
||||
|
@ -66,6 +67,7 @@ class CurrencyController extends BaseAdminController
|
|||
protected $form_class = CurrencyAdminForm::class;
|
||||
protected $route_base = 'currency';
|
||||
protected $attachment_class = CurrencyAttachment::class;
|
||||
protected $parameter_class = CurrencyParameter::class;
|
||||
|
||||
/**
|
||||
* @Route("/{id}", name="currency_delete", methods={"DELETE"})
|
||||
|
|
|
@ -44,6 +44,7 @@ namespace App\Controller\AdminPages;
|
|||
|
||||
use App\Entity\Attachments\DeviceAttachment;
|
||||
use App\Entity\Devices\Device;
|
||||
use App\Entity\Parameters\DeviceParameter;
|
||||
use App\Form\AdminPages\BaseEntityAdminForm;
|
||||
use App\Services\EntityExporter;
|
||||
use App\Services\EntityImporter;
|
||||
|
@ -64,6 +65,7 @@ class DeviceController extends BaseAdminController
|
|||
protected $form_class = BaseEntityAdminForm::class;
|
||||
protected $route_base = 'device';
|
||||
protected $attachment_class = DeviceAttachment::class;
|
||||
protected $parameter_class = DeviceParameter::class;
|
||||
|
||||
/**
|
||||
* @Route("/{id}", name="device_delete", methods={"DELETE"})
|
||||
|
|
|
@ -44,6 +44,7 @@ namespace App\Controller\AdminPages;
|
|||
|
||||
use App\Entity\Attachments\AttachmentType;
|
||||
use App\Entity\Attachments\FootprintAttachment;
|
||||
use App\Entity\Parameters\FootprintParameter;
|
||||
use App\Entity\Parts\Footprint;
|
||||
use App\Form\AdminPages\FootprintAdminForm;
|
||||
use App\Services\EntityExporter;
|
||||
|
@ -64,6 +65,7 @@ class FootprintController extends BaseAdminController
|
|||
protected $form_class = FootprintAdminForm::class;
|
||||
protected $route_base = 'footprint';
|
||||
protected $attachment_class = FootprintAttachment::class;
|
||||
protected $parameter_class = FootprintParameter::class;
|
||||
|
||||
/**
|
||||
* @Route("/{id}", name="footprint_delete", methods={"DELETE"})
|
||||
|
|
|
@ -43,6 +43,7 @@ declare(strict_types=1);
|
|||
namespace App\Controller\AdminPages;
|
||||
|
||||
use App\Entity\Attachments\ManufacturerAttachment;
|
||||
use App\Entity\Parameters\ManufacturerParameter;
|
||||
use App\Entity\Parts\Manufacturer;
|
||||
use App\Form\AdminPages\CompanyForm;
|
||||
use App\Services\EntityExporter;
|
||||
|
@ -63,6 +64,7 @@ class ManufacturerController extends BaseAdminController
|
|||
protected $form_class = CompanyForm::class;
|
||||
protected $route_base = 'manufacturer';
|
||||
protected $attachment_class = ManufacturerAttachment::class;
|
||||
protected $parameter_class = ManufacturerParameter::class;
|
||||
|
||||
/**
|
||||
* @Route("/{id}", name="manufacturer_delete", methods={"DELETE"})
|
||||
|
|
|
@ -44,6 +44,7 @@ namespace App\Controller\AdminPages;
|
|||
|
||||
use App\Entity\Attachments\AttachmentType;
|
||||
use App\Entity\Attachments\MeasurementUnitAttachment;
|
||||
use App\Entity\Parameters\MeasurementUnitParameter;
|
||||
use App\Entity\Parts\MeasurementUnit;
|
||||
use App\Form\AdminPages\MeasurementUnitAdminForm;
|
||||
use App\Services\EntityExporter;
|
||||
|
@ -64,6 +65,7 @@ class MeasurementUnitController extends BaseAdminController
|
|||
protected $form_class = MeasurementUnitAdminForm::class;
|
||||
protected $route_base = 'measurement_unit';
|
||||
protected $attachment_class = MeasurementUnitAttachment::class;
|
||||
protected $parameter_class = MeasurementUnitParameter::class;
|
||||
|
||||
/**
|
||||
* @Route("/{id}", name="measurement_unit_delete", methods={"DELETE"})
|
||||
|
|
|
@ -42,6 +42,7 @@ declare(strict_types=1);
|
|||
|
||||
namespace App\Controller\AdminPages;
|
||||
|
||||
use App\Entity\Parameters\StorelocationParameter;
|
||||
use App\Entity\Parts\Storelocation;
|
||||
use App\Form\AdminPages\StorelocationAdminForm;
|
||||
use App\Services\EntityExporter;
|
||||
|
@ -62,6 +63,7 @@ class StorelocationController extends BaseAdminController
|
|||
protected $form_class = StorelocationAdminForm::class;
|
||||
protected $route_base = 'store_location';
|
||||
protected $attachment_class = StorelocationAdminForm::class;
|
||||
protected $parameter_class = StorelocationParameter::class;
|
||||
|
||||
/**
|
||||
* @Route("/{id}", name="store_location_delete", methods={"DELETE"})
|
||||
|
|
|
@ -43,6 +43,7 @@ declare(strict_types=1);
|
|||
namespace App\Controller\AdminPages;
|
||||
|
||||
use App\Entity\Attachments\SupplierAttachment;
|
||||
use App\Entity\Parameters\SupplierParameter;
|
||||
use App\Entity\Parts\Supplier;
|
||||
use App\Form\AdminPages\SupplierForm;
|
||||
use App\Services\EntityExporter;
|
||||
|
@ -63,6 +64,7 @@ class SupplierController extends BaseAdminController
|
|||
protected $form_class = SupplierForm::class;
|
||||
protected $route_base = 'supplier';
|
||||
protected $attachment_class = SupplierAttachment::class;
|
||||
protected $parameter_class = SupplierParameter::class;
|
||||
|
||||
/**
|
||||
* @Route("/{id}", name="supplier_delete", methods={"DELETE"})
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue