mirror of
https://github.com/ae-utbm/sith.git
synced 2026-09-01 10:09:17 +00:00
add a switch to filter closed UEs
This commit is contained in:
@@ -153,6 +153,7 @@ class UeFilterSchema(FilterSchema):
|
||||
set[Literal["CS", "TM", "EC", "OM", "QC"]] | None,
|
||||
FilterLookup("credit_type__in"),
|
||||
] = None
|
||||
is_open: bool | None = None
|
||||
language: str = "FR"
|
||||
department: Annotated[set[str] | None, FilterLookup("department__in")] = None
|
||||
|
||||
@@ -187,3 +188,10 @@ class UeFilterSchema(FilterSchema):
|
||||
return Q()
|
||||
value.add("AUTUMN_AND_SPRING")
|
||||
return Q(semester__in=value)
|
||||
|
||||
def filter_is_open(self, value: bool | None) -> Q: # noqa: FBT001
|
||||
if value is None:
|
||||
return Q()
|
||||
if not value:
|
||||
return Q(semester="CLOSED")
|
||||
return ~Q(semester="CLOSED")
|
||||
|
||||
@@ -17,6 +17,7 @@ document.addEventListener("alpine:init", () => {
|
||||
// biome-ignore lint/style/useNamingConvention: api is in snake_case
|
||||
page_size: pageSizeDefault,
|
||||
search: "",
|
||||
hideClosedUes: true,
|
||||
department: [] as string[],
|
||||
// biome-ignore lint/style/useNamingConvention: api is in snake_case
|
||||
credit_type: [] as string[],
|
||||
@@ -38,6 +39,7 @@ document.addEventListener("alpine:init", () => {
|
||||
10,
|
||||
);
|
||||
this.search = url.get("search") || "";
|
||||
this.hideClosedUes = url.get("hideClosed") || true;
|
||||
this.department = url.getAll("department");
|
||||
this.credit_type = url.getAll("credit_type");
|
||||
/* The semester is easier to use on the backend as an enum (spring/autumn/both/none)
|
||||
@@ -58,7 +60,13 @@ document.addEventListener("alpine:init", () => {
|
||||
this.to_change = [];
|
||||
}, 50);
|
||||
|
||||
const searchParams = ["search", "department", "credit_type", "semester"];
|
||||
const searchParams = [
|
||||
"search",
|
||||
"hideClosedUes",
|
||||
"department",
|
||||
"credit_type",
|
||||
"semester",
|
||||
];
|
||||
const paginationParams = ["page", "page_size"];
|
||||
|
||||
for (const param of searchParams) {
|
||||
@@ -87,7 +95,8 @@ document.addEventListener("alpine:init", () => {
|
||||
// biome-ignore lint/style/useNamingConvention: api is in snake_case
|
||||
credit_type: this.credit_type.length > 0 ? this.credit_type : undefined,
|
||||
semester: this.semester.length > 0 ? this.semester : undefined,
|
||||
|
||||
// biome-ignore lint/style/useNamingConvention: api is snake_case
|
||||
is_open: this.hideClosedUes ? true : undefined,
|
||||
department: this.department.length > 0 ? this.department : undefined,
|
||||
search: this.search || undefined,
|
||||
},
|
||||
|
||||
@@ -44,6 +44,10 @@
|
||||
x-model.debounce.500ms="search"
|
||||
/>
|
||||
</fieldset>
|
||||
<fieldset>
|
||||
<input type="checkbox" class="switch" x-model="hideClosedUes" id="hide-closed-ues" name="hide-closed-ues">
|
||||
<label for="hide-closed-ues">{% trans %}Hide closed UEs{% endtrans %}</label>
|
||||
</fieldset>
|
||||
<div class="row gap-3x margin-bottom radio-guide">
|
||||
<fieldset>
|
||||
{% set departments = [
|
||||
|
||||
Reference in New Issue
Block a user