fix: redirects user on selection

This commit is contained in:
2025-07-06 09:31:47 -05:00
parent eafcf3fcb1
commit 023b1b7844
3 changed files with 8 additions and 5 deletions

View File

@@ -20,8 +20,10 @@ export default class extends Controller {
_onPreConnect(event) {
// TomSelect has not been initialized - options can be changed
console.log(event.detail.options); // Options that will be used to initialize TomSelect
event.detail.options.onChange = (value) => {
// ...
event.detail.options.onItemAdd = (value, $item) => {
console.log(value, $item)
const params = value.split('|')
window.location.href = `/result/${params[0]}/${params[1]}`
};
}

View File

@@ -7,6 +7,7 @@ use App\Monitor\Action\Command\MonitorTvShowCommand;
use App\Monitor\Action\Handler\MonitorTvShowHandler;
use App\Monitor\Framework\Scheduler\MonitorDispatcher;
use App\Tmdb\Tmdb;
use App\Tmdb\TmdbResult;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
@@ -41,9 +42,10 @@ final class IndexController extends AbstractController
$tmdbResults = $tmdb->search($term);
foreach ($tmdbResults as $tmdbResult) {
/** @var TmdbResult $tmdbResult */
$results[] = [
'text' => $tmdbResult->title,
'value' => $tmdbResult->title,
'value' => "$tmdbResult->mediaType|$tmdbResult->imdbId",
];
}
}

View File

@@ -2,8 +2,7 @@
<div class="relative">
<form id="search" action="{{ path('app_search') }}">
<select
{{ stimulus_controller('symfony/ux-autocomplete/autocomplete', {url: path('app_test'), create: false, highlight: false}) }}
{{ stimulus_controller('search_bar') }}
{{ stimulus_controller('search_bar')|stimulus_controller('symfony/ux-autocomplete/autocomplete', {url: path('app_test'), create: false, highlight: false}) }}
name="term"
class="w-full bg-orange-500 rounded-md bg-clip-padding backdrop-filter
backdrop-blur-md bg-opacity-40 placeholder:text-slate-200 text-gray-50