mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2025-06-21 09:35:49 +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();
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue