From e2143ee0eead6cf7e6fb09b8b06a2eea7d90d8fb Mon Sep 17 00:00:00 2001 From: Pablo Vazquez Date: Thu, 15 Aug 2024 15:54:56 +0200 Subject: [PATCH] Films: Add filter by media type Copy over the functionality of filtering by media type from the regular global search, into film_search.js Also minor adjustments: * Add `media_type` label to the details of each card. Ideally we could unify it with the way it is done inside the gallery. Like showing a Blender logo for blend files, timestamp for videos, etc. For now simply show the type in a label. * Remove "Sort By:" label from the sortby element. It's clear from context. We could add a "sort" icon using CSS in the future. * Make all inputs full size. "input-sm" looks weird and it's not needed. * Move "cancel/clear" button after search. It's not the primary function so it shouldn't be right next to the text field. --- films/static/films/scripts/film_search.js | 55 ++++++++++++++++++- films/templates/films/latest_assets.html | 8 +-- search/templates/search/components/input.html | 2 +- 3 files changed, 58 insertions(+), 7 deletions(-) diff --git a/films/static/films/scripts/film_search.js b/films/static/films/scripts/film_search.js index d2fbd9d4..799a5dc0 100644 --- a/films/static/films/scripts/film_search.js +++ b/films/static/films/scripts/film_search.js @@ -13,6 +13,7 @@ const search = instantsearch({ return { query: indexUiState.query, sortBy: indexUiState && indexUiState.sortBy, + media_type: indexUiState.menu && indexUiState.menu.media_type, }; }, routeToState(routeState) { @@ -20,6 +21,9 @@ const search = instantsearch({ [indexName]: { query: routeState.query, sortBy: routeState.sortBy, + menu: { + media_type: routeState.media_type, + }, }, }; }, @@ -126,7 +130,10 @@ const renderHits = (renderOptions, isFirstRender) => {