mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2025-06-21 17:39:06 +02:00
Allow to directly specify the scanned string via an input query parameter
This commit is contained in:
parent
4f82a0f026
commit
49ae906029
3 changed files with 54 additions and 3 deletions
|
@ -49,6 +49,7 @@ use InvalidArgumentException;
|
|||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\HttpKernel\Attribute\MapQueryParameter;
|
||||
use Symfony\Component\Routing\Annotation\Route;
|
||||
|
||||
#[Route(path: '/scan')]
|
||||
|
@ -59,16 +60,18 @@ class ScanController extends AbstractController
|
|||
}
|
||||
|
||||
#[Route(path: '/', name: 'scan_dialog')]
|
||||
public function dialog(Request $request): Response
|
||||
public function dialog(Request $request, #[MapQueryParameter] ?string $input = null): Response
|
||||
{
|
||||
$this->denyAccessUnlessGranted('@tools.label_scanner');
|
||||
|
||||
$form = $this->createForm(ScanDialogType::class);
|
||||
$form->handleRequest($request);
|
||||
|
||||
if ($form->isSubmitted() && $form->isValid()) {
|
||||
if ($input === null && $form->isSubmitted() && $form->isValid()) {
|
||||
$input = $form['input']->getData();
|
||||
}
|
||||
|
||||
if ($input !== null) {
|
||||
try {
|
||||
[$type, $id] = $this->barcodeNormalizer->normalizeBarcodeContent($input);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue