Fix search sort filters (#338)

This commit is contained in:
Brahim Hadriche authored and GitHub committed 2024-03-24 14:37:40 -04:00
1 parent 862fea74e7
commit 3391e3d787
6 files changed
+20 -22

No files matched your search

+1
View File
@@ -20,6 +20,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- A bug where instance testing is not immediately cancelled when the testing page is closed - A bug where instance testing is not immediately cancelled when the testing page is closed
- A bug in the web app where "upcoming" videos show up as "live" - A bug in the web app where "upcoming" videos show up as "live"
- Search sort filters
## [0.21.2] - 2024-03-10 ## [0.21.2] - 2024-03-10
@@ -87,15 +87,15 @@ function Init()
title: Tr(Locale.SearchFilters.Location) title: Tr(Locale.SearchFilters.Location)
value: "location" value: "location"
}] }]
sort_by: [{ sort: [{
title: Tr(Locale.SearchFilters.Relevance) title: Tr(Locale.SearchFilters.Relevance)
value: "" value: ""
}, { }, {
title: Tr(Locale.SearchFilters.UploadDate) title: Tr(Locale.SearchFilters.UploadDate)
value: "upload_date" value: "date"
}, { }, {
title: Tr(Locale.SearchFilters.ViewCount) title: Tr(Locale.SearchFilters.ViewCount)
value: "view_count" value: "views"
}, { }, {
title: Tr(Locale.SearchFilters.Rating) title: Tr(Locale.SearchFilters.Rating)
value: "rating" value: "rating"
@@ -107,7 +107,7 @@ function Init()
type: m.top.findNode("TypeList") type: m.top.findNode("TypeList")
duration: m.top.findNode("DurationList") duration: m.top.findNode("DurationList")
features: m.top.findNode("FeaturesList") features: m.top.findNode("FeaturesList")
sort_by: m.top.findNode("SortByList") sort: m.top.findNode("SortList")
} }
for each filterKey in m.controls for each filterKey in m.controls
@@ -120,12 +120,12 @@ function Init()
type: m.controls.type.content type: m.controls.type.content
duration: m.controls.duration.content duration: m.controls.duration.content
features: m.controls.features.content features: m.controls.features.content
sort_by: m.controls.sort_by.content sort: m.controls.sort.content
} }
PopulateLists(m.contentNodes, options) PopulateLists(m.contentNodes, options)
navigationNodes = [m.controls.date, m.controls.type, m.controls.duration, m.controls.features, m.controls.sort_by] navigationNodes = [m.controls.date, m.controls.type, m.controls.duration, m.controls.features, m.controls.sort]
for i = 0 to navigationNodes.count() - 2 for i = 0 to navigationNodes.count() - 2
SetNavigation(navigationNodes[i], "right", navigationNodes[i + 1]) SetNavigation(navigationNodes[i], "right", navigationNodes[i + 1])
end for end for
@@ -154,7 +154,7 @@ function OnNodeReady()
m.controls.type.ObserveField("checkedItem", FuncName(OnListChecked)) m.controls.type.ObserveField("checkedItem", FuncName(OnListChecked))
m.controls.duration.ObserveField("checkedItem", FuncName(OnListChecked)) m.controls.duration.ObserveField("checkedItem", FuncName(OnListChecked))
m.controls.features.ObserveField("checkedState", FuncName(OnListChecked)) m.controls.features.ObserveField("checkedState", FuncName(OnListChecked))
m.controls.sort_by.ObserveField("checkedItem", FuncName(OnListChecked)) m.controls.sort.ObserveField("checkedItem", FuncName(OnListChecked))
end function end function
function RefreshUI() function RefreshUI()
@@ -108,7 +108,7 @@
width="180" width="180"
height="1" /> height="1" />
<RadioButtonList <RadioButtonList
id="SortByList" id="SortList"
vertFocusAnimationStyle="floatingFocus" vertFocusAnimationStyle="floatingFocus"
font="dictionary:ItemFont" font="dictionary:ItemFont"
focusedFont="dictionary:ItemFocusedFont" focusedFont="dictionary:ItemFocusedFont"
@@ -34,7 +34,7 @@ function Init()
type: "" type: ""
duration: "" duration: ""
features: [] features: []
sort_by: "" sort: ""
} }
m.top.ObserveField("filters", FuncName(OnFiltersChange)) m.top.ObserveField("filters", FuncName(OnFiltersChange))
@@ -23,12 +23,12 @@ search:
queryParams: queryParams:
q: q:
type: string type: string
sort_by: sort:
type: type:
- relevance - relevance
- rating - rating
- upload_date - date
- view_count - views
date: date:
type: type:
- hour - hour
@@ -10,7 +10,7 @@
type: "", type: "",
duration: "", duration: "",
features: [], features: [],
sort_by: "", sort: "",
}; };
let features_kv: any = {}; let features_kv: any = {};
@@ -28,7 +28,7 @@
count += filters.type ? 1 : 0; count += filters.type ? 1 : 0;
count += filters.duration ? 1 : 0; count += filters.duration ? 1 : 0;
count += filters.features.length; count += filters.features.length;
count += filters.sort_by ? 1 : 0; count += filters.sort ? 1 : 0;
label = $tr("Filters") + `${count > 0 ? ` (${count})` : ""}`; label = $tr("Filters") + `${count > 0 ? ` (${count})` : ""}`;
} }
@@ -146,18 +146,18 @@
value: "location", value: "location",
}, },
], ],
sort_by: [ sort: [
{ {
title: "Relevance", title: "Relevance",
value: "", value: "",
}, },
{ {
title: "Upload date", title: "Upload date",
value: "upload_date", value: "date",
}, },
{ {
title: "View count", title: "View count",
value: "view_count", value: "views",
}, },
{ {
title: "Rating", title: "Rating",
@@ -223,11 +223,8 @@
<div class="mb-4"> <div class="mb-4">
<h3 class="text-lg font-bold mb-2">{$tr("Sort by")}</h3> <h3 class="text-lg font-bold mb-2">{$tr("Sort by")}</h3>
<select <select class="input input-bordered w-full" bind:value={filters.sort}>
class="input input-bordered w-full" {#each options.sort as { title, value }}
bind:value={filters.sort_by}
>
{#each options.sort_by as { title, value }}
<option {value}>{$tr(title)}</option> <option {value}>{$tr(title)}</option>
{/each} {/each}
</select> </select>