mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2025-06-27 04:08:57 +02:00
Allow to add a comment when editing/creating/deleting an element.
This commit is contained in:
parent
c14d6d91ff
commit
b6f95ebe48
19 changed files with 421 additions and 47 deletions
|
@ -52,6 +52,7 @@ use App\Services\Attachments\AttachmentManager;
|
|||
use App\Services\Attachments\AttachmentSubmitHandler;
|
||||
use App\Services\EntityExporter;
|
||||
use App\Services\EntityImporter;
|
||||
use App\Services\LogSystem\EventCommentHelper;
|
||||
use App\Services\StructuralElementRecursionHelper;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use InvalidArgumentException;
|
||||
|
@ -77,9 +78,11 @@ abstract class BaseAdminController extends AbstractController
|
|||
protected $translator;
|
||||
protected $attachmentHelper;
|
||||
protected $attachmentSubmitHandler;
|
||||
protected $commentHelper;
|
||||
|
||||
public function __construct(TranslatorInterface $translator, UserPasswordEncoderInterface $passwordEncoder,
|
||||
AttachmentManager $attachmentHelper, AttachmentSubmitHandler $attachmentSubmitHandler)
|
||||
AttachmentManager $attachmentHelper, AttachmentSubmitHandler $attachmentSubmitHandler,
|
||||
EventCommentHelper $commentHelper)
|
||||
{
|
||||
if ('' === $this->entity_class || '' === $this->form_class || '' === $this->twig_template || '' === $this->route_base) {
|
||||
throw new InvalidArgumentException('You have to override the $entity_class, $form_class, $route_base and $twig_template value in your subclasss!');
|
||||
|
@ -93,6 +96,7 @@ abstract class BaseAdminController extends AbstractController
|
|||
$this->passwordEncoder = $passwordEncoder;
|
||||
$this->attachmentHelper = $attachmentHelper;
|
||||
$this->attachmentSubmitHandler = $attachmentSubmitHandler;
|
||||
$this->commentHelper = $commentHelper;
|
||||
}
|
||||
|
||||
|
||||
|
@ -131,6 +135,8 @@ abstract class BaseAdminController extends AbstractController
|
|||
}
|
||||
}
|
||||
|
||||
$this->commentHelper->setMessage($form['log_comment']->getData());
|
||||
|
||||
$em->persist($entity);
|
||||
$em->flush();
|
||||
$this->addFlash('success', 'entity.edit_flash');
|
||||
|
@ -188,6 +194,8 @@ abstract class BaseAdminController extends AbstractController
|
|||
}
|
||||
}
|
||||
|
||||
$this->commentHelper->setMessage($form['log_comment']->getData());
|
||||
|
||||
$em->persist($new_entity);
|
||||
$em->flush();
|
||||
$this->addFlash('success', 'entity.created_flash');
|
||||
|
@ -215,6 +223,10 @@ abstract class BaseAdminController extends AbstractController
|
|||
'csv_separator' => $data['csv_separator'],
|
||||
];
|
||||
|
||||
$this->commentHelper->setMessage('Import ' . $file->getClientOriginalName());
|
||||
|
||||
|
||||
|
||||
$errors = $importer->fileToDBEntities($file, $this->entity_class, $options);
|
||||
|
||||
foreach ($errors as $name => $error) {
|
||||
|
@ -280,6 +292,8 @@ abstract class BaseAdminController extends AbstractController
|
|||
$entityManager->remove($entity);
|
||||
}
|
||||
|
||||
$this->commentHelper->setMessage($request->request->get('log_comment', null));
|
||||
|
||||
//Flush changes
|
||||
$entityManager->flush();
|
||||
|
||||
|
|
|
@ -50,6 +50,7 @@ use App\Form\Part\PartBaseType;
|
|||
use App\Services\Attachments\AttachmentManager;
|
||||
use App\Services\Attachments\AttachmentSubmitHandler;
|
||||
use App\Services\Attachments\PartPreviewGenerator;
|
||||
use App\Services\LogSystem\EventCommentHelper;
|
||||
use App\Services\LogSystem\HistoryHelper;
|
||||
use App\Services\LogSystem\TimeTravel;
|
||||
use App\Services\PricedetailHelper;
|
||||
|
@ -71,12 +72,15 @@ class PartController extends AbstractController
|
|||
protected $attachmentManager;
|
||||
protected $pricedetailHelper;
|
||||
protected $partPreviewGenerator;
|
||||
protected $commentHelper;
|
||||
|
||||
public function __construct(AttachmentManager $attachmentManager, PricedetailHelper $pricedetailHelper, PartPreviewGenerator $partPreviewGenerator)
|
||||
public function __construct(AttachmentManager $attachmentManager, PricedetailHelper $pricedetailHelper,
|
||||
PartPreviewGenerator $partPreviewGenerator, EventCommentHelper $commentHelper)
|
||||
{
|
||||
$this->attachmentManager = $attachmentManager;
|
||||
$this->pricedetailHelper = $pricedetailHelper;
|
||||
$this->partPreviewGenerator = $partPreviewGenerator;
|
||||
$this->commentHelper = $commentHelper;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -166,6 +170,8 @@ class PartController extends AbstractController
|
|||
}
|
||||
}
|
||||
|
||||
$this->commentHelper->setMessage($form['log_comment']->getData());
|
||||
|
||||
$em->persist($part);
|
||||
$em->flush();
|
||||
$this->addFlash('info', 'part.edited_flash');
|
||||
|
@ -197,6 +203,8 @@ class PartController extends AbstractController
|
|||
if ($this->isCsrfTokenValid('delete'.$part->getId(), $request->request->get('_token'))) {
|
||||
$entityManager = $this->getDoctrine()->getManager();
|
||||
|
||||
$this->commentHelper->setMessage($request->request->get('log_comment', null));
|
||||
|
||||
//Remove part
|
||||
$entityManager->remove($part);
|
||||
|
||||
|
@ -257,6 +265,8 @@ class PartController extends AbstractController
|
|||
}
|
||||
}
|
||||
|
||||
$this->commentHelper->setMessage($form['log_comment']->getData());
|
||||
|
||||
$em->persist($new_part);
|
||||
$em->flush();
|
||||
$this->addFlash('success', 'part.created_flash');
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue