diff --git a/assets/controllers/search_bar_controller.js b/assets/controllers/search_bar_controller.js index 5398046..e752f4c 100644 --- a/assets/controllers/search_bar_controller.js +++ b/assets/controllers/search_bar_controller.js @@ -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]}` }; } diff --git a/src/Controller/IndexController.php b/src/Controller/IndexController.php index d5d831b..dfc214d 100644 --- a/src/Controller/IndexController.php +++ b/src/Controller/IndexController.php @@ -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", ]; } } diff --git a/templates/components/SearchBar.html.twig b/templates/components/SearchBar.html.twig index f079710..3224c6b 100644 --- a/templates/components/SearchBar.html.twig +++ b/templates/components/SearchBar.html.twig @@ -2,8 +2,7 @@