sorting logic in UI fixed
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user