Skip to content

ActivityPub-federated video streaming platform using P2P directly in your web browser

Fix default values for filters component

Chocobozzz12a09b0608c5
diff --git a/client/src/app/+admin/system/jobs/jobs.component.ts b/client/src/app/+admin/system/jobs/jobs.component.ts
index 1da15d2e59..ec3084c15f 100644
--- a/client/src/app/+admin/system/jobs/jobs.component.ts
+++ b/client/src/app/+admin/system/jobs/jobs.component.ts
@@ -91,8 +91,6 @@ export class JobsComponent {
}
]
- defaultInputFilterValues: Partial<DataLoaderParameter>
-
columns: TableColumnInfo<ColumnName>[] = [
{ id: 'id', class: 'job-id', label: $localize`ID`, sortable: false },
{ id: 'type', class: 'job-type', label: $localize`Type`, sortable: false },
diff --git a/client/src/app/shared/shared-forms/advanced-input-filter.component.ts b/client/src/app/shared/shared-forms/advanced-input-filter.component.ts
index 5f0b1d22b6..cf8b79a35f 100644
--- a/client/src/app/shared/shared-forms/advanced-input-filter.component.ts
+++ b/client/src/app/shared/shared-forms/advanced-input-filter.component.ts
@@ -170,14 +170,20 @@ export class AdvancedInputFilterComponent<ServiceParameters extends Record<strin
readonly hasFilters = computed(() => this.filters().length > 0)
private routeSub: Subscription
+ private defaultValuesToLoad: Partial<ServiceParameters> = {}
// ---------------------------------------------------------------------------
// Lifecycle
// ---------------------------------------------------------------------------
ngOnInit () {
+ this.defaultValuesToLoad = this.defaultValues() || {}
+
this.routeSub = this.route.queryParams.subscribe(params => {
- const initial = parseQueryParamsToAdvancedFilters(this.filters(), params, this.defaultValues())
+ const initial = parseQueryParamsToAdvancedFilters(this.filters(), params, this.defaultValuesToLoad)
+
+ // Only load defaults values on initial load
+ this.defaultValuesToLoad = {}
this.filterState.set({ ...initial })
this.activeFilters.set({ ...initial })
@@ -193,7 +199,9 @@ export class AdvancedInputFilterComponent<ServiceParameters extends Record<strin
// ---------------------------------------------------------------------------
isOptionSelected (def: OptionsFilterDef<ServiceParameters>, optionValue: string): boolean {
- return this.filterState()[def.key] === optionValue
+ const current = this.filterState()[def.key]
+
+ return current === optionValue || current + '' === optionValue
}
onOptionClick (def: OptionsFilterDef<ServiceParameters>, optionValue: string) {
@@ -277,6 +285,7 @@ export class AdvancedInputFilterComponent<ServiceParameters extends Record<strin
applyFilters (dropdown: NgbDropdown) {
this.activeFilters.set({ ...this.filterState() })
+
this.emitOutputs()
dropdown.close()
diff --git a/client/src/app/shared/shared-tables/table.component.ts b/client/src/app/shared/shared-tables/table.component.ts
index a9724cc314..963ad90cfa 100644
--- a/client/src/app/shared/shared-tables/table.component.ts
+++ b/client/src/app/shared/shared-tables/table.component.ts
@@ -142,6 +142,7 @@ export class TableComponent<
readonly defaultInputFilterValues = input<Partial<DataLoaderOptions>>()
private inputFilterValues: Partial<DataLoaderOptions> = {}
+ private defaultInputFilterValuesToLoad: Partial<DataLoaderOptions> = {}
private loadDataSub: Subscription
@@ -202,6 +203,10 @@ export class TableComponent<
start: 0
}
+ if (this.defaultInputFilterValues()) {
+ this.defaultInputFilterValuesToLoad = this.defaultInputFilterValues()
+ }
+
this.loadTableSettings()
this.loadSelectedColumns()
this.subscribeToQueryChanges()
@@ -451,7 +456,12 @@ export class TableComponent<
if (queryParams.sortField !== undefined) this.sort.field = queryParams.sortField
if (this.inputFilters()) {
- this.loadFilters(parseQueryParamsToAdvancedFilters(this.inputFilters(), this.route.snapshot.queryParams))
+ this.loadFilters(
+ parseQueryParamsToAdvancedFilters(this.inputFilters(), this.route.snapshot.queryParams, this.defaultInputFilterValuesToLoad)
+ )
+
+ // Only load default values when loading the page
+ this.defaultInputFilterValuesToLoad = {}
}
this.customParseQueryParams()(queryParams)