From aa28aa0e025304c616cb618a7f019621e20356ec Mon Sep 17 00:00:00 2001 From: genja Date: Tue, 9 Jun 2026 19:00:11 +0200 Subject: [PATCH] sorting logic in UI fixed --- .../person-list/person-list.component.ts | 52 ++++++++++++++----- 1 file changed, 38 insertions(+), 14 deletions(-) diff --git a/webapp/src/app/modules/person-list/person-list.component.ts b/webapp/src/app/modules/person-list/person-list.component.ts index 1cee49fc..24648ef7 100644 --- a/webapp/src/app/modules/person-list/person-list.component.ts +++ b/webapp/src/app/modules/person-list/person-list.component.ts @@ -162,7 +162,7 @@ export class PersonListComponent { ? Number.parseInt(params['pageSize'], 10) : 10; const institutionName = params['institutionName'] || ''; - const sortBy = params['sortBy'] || null + const sortBy = params['sortBy'] || null; const sortOrder = params['sortOrder'] || this.defaultOrderValue; const yearFilterEnabled = params['yearFilterEnabled'] === 'true'; const filterMode = @@ -179,8 +179,13 @@ export class PersonListComponent { this.selectedTopics = new Set(topics); this.currentPage = page; this.paginationService.selection = pageSize; - this.sortValueControl.setValue(sortBy); - this.sortOrderControl.setValue(sortOrder); + + if (this.sortValueControl.value !== sortBy) { + this.sortValueControl.setValue(sortBy, { emitEvent: false }); + this.sortOrderControl.setValue(sortOrder, { emitEvent: false }); + this.updateSortOrderState(this.sortValueControl.value); + } + // Sync search box & institution input if (this.searchValue() !== query) { @@ -217,21 +222,40 @@ export class PersonListComponent { this.total = persons.meta?.count; this.loadingState.set(false); }); - // listen for sorting selectors changes - this.sortValueControl.valueChanges.subscribe((value) => { - if (!value) { - this.sortOrderControl.setValue(this.defaultOrderValue) - this.sortOrderControl.disable(); - } else { - this.sortOrderControl.enable(); - } + + // listen for sorting selectors changes + this.sortValueControl.valueChanges + .pipe(takeUntilDestroyed(this.destroyRef)) + .subscribe((value) => { + if (!value) { + this.sortOrderControl.setValue(this.defaultOrderValue, { + emitEvent: false, + }); + this.sortOrderControl.disable(); + } else { + this.sortOrderControl.enable(); + } + this.applySidebarFilters(); - }); - this.sortOrderControl.valueChanges.subscribe(() => { + }); + + this.sortOrderControl.valueChanges + .pipe(takeUntilDestroyed(this.destroyRef)) + .subscribe(() => { this.applySidebarFilters(); - }); + }); } + private updateSortOrderState(value: any) { + if (!value) { + this.sortOrderControl.setValue(this.defaultOrderValue, { + emitEvent: false, + }); + this.sortOrderControl.disable({ emitEvent: false }); + } else { + this.sortOrderControl.enable({ emitEvent: false }); + } + } // Getters for filtered results getPersons(): CustomAuthor[] { return this.persons;