mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2025-06-22 01:49:05 +02:00
Added simple possibility to favorite/unfavorite and delete multiple parts at once.
This commit is contained in:
parent
123b229638
commit
6f6ac0f128
4 changed files with 185 additions and 7 deletions
|
@ -48,6 +48,7 @@ use App\Entity\Parts\Footprint;
|
|||
use App\Entity\Parts\Manufacturer;
|
||||
use App\Entity\Parts\Storelocation;
|
||||
use App\Entity\Parts\Supplier;
|
||||
use App\Services\Parts\PartsTableActionHandler;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use Omines\DataTablesBundle\DataTableFactory;
|
||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||
|
@ -65,6 +66,36 @@ class PartListsController extends AbstractController
|
|||
$this->entityManager = $entityManager;
|
||||
}
|
||||
|
||||
/**
|
||||
* @Route("/table/action", name="table_action", methods={"POST"})
|
||||
*/
|
||||
public function tableAction(Request $request, PartsTableActionHandler $actionHandler): Response
|
||||
{
|
||||
$redirect = $request->request->get('redirect_back');
|
||||
$ids = $request->request->get('ids');
|
||||
$action = $request->request->get('action');
|
||||
|
||||
if (!$this->isCsrfTokenValid('table_action', $request->request->get('_token'))) {
|
||||
$this->addFlash('error', 'csfr_invalid');
|
||||
return $this->redirect($redirect);
|
||||
}
|
||||
|
||||
if ($action === null || $ids === null) {
|
||||
$this->addFlash('error', 'part.table.actions.no_params_given');
|
||||
} else {
|
||||
$parts = $actionHandler->idStringToArray($ids);
|
||||
$actionHandler->handleAction($action, $parts, null);
|
||||
|
||||
//Save changes
|
||||
$this->entityManager->flush();
|
||||
|
||||
$this->addFlash('success', 'Done');
|
||||
}
|
||||
|
||||
|
||||
return $this->redirect($redirect);
|
||||
}
|
||||
|
||||
/**
|
||||
* @Route("/category/{id}/parts", name="part_list_category")
|
||||
*
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue