TSK-1804: Workbasket list now resets to page 1 when filtering

This commit is contained in:
Tristan 2022-02-14 12:47:46 +01:00 committed by Tristan2357
parent 0049ffecf6
commit ac99c30e3b
3 changed files with 24 additions and 15 deletions

View File

@ -61,5 +61,6 @@
[type]="type" [type]="type"
[expanded]="expanded" [expanded]="expanded"
[numberOfItems]="(workbasketsSummary$ | async)?.length" [numberOfItems]="(workbasketsSummary$ | async)?.length"
[resetPaging]="resetPagingSubject.asObservable()"
(changePage)="changePage($event)"> (changePage)="changePage($event)">
</taskana-shared-pagination> </taskana-shared-pagination>

View File

@ -4,7 +4,6 @@ import { Observable, Subject } from 'rxjs';
import { WorkbasketSummaryRepresentation } from 'app/shared/models/workbasket-summary-representation'; import { WorkbasketSummaryRepresentation } from 'app/shared/models/workbasket-summary-representation';
import { WorkbasketSummary } from 'app/shared/models/workbasket-summary'; import { WorkbasketSummary } from 'app/shared/models/workbasket-summary';
import { Direction, Sorting, WorkbasketQuerySortParameter } from 'app/shared/models/sorting'; import { Direction, Sorting, WorkbasketQuerySortParameter } from 'app/shared/models/sorting';
import { Orientation } from 'app/shared/models/orientation';
import { WorkbasketService } from 'app/shared/services/workbasket/workbasket.service'; import { WorkbasketService } from 'app/shared/services/workbasket/workbasket.service';
import { OrientationService } from 'app/shared/services/orientation/orientation.service'; import { OrientationService } from 'app/shared/services/orientation/orientation.service';
@ -46,26 +45,21 @@ export class WorkbasketListComponent implements OnInit, OnDestroy {
requestInProgress: boolean; requestInProgress: boolean;
requestInProgressLocal = false; requestInProgressLocal = false;
resetPagingSubject = new Subject<null>();
@Input() expanded: boolean; @Input() expanded: boolean;
@ViewChild('wbToolbar', { static: true })
private toolbarElement: ElementRef;
@Select(WorkbasketSelectors.workbasketsSummary) @Select(WorkbasketSelectors.workbasketsSummary)
workbasketsSummary$: Observable<WorkbasketSummary[]>; workbasketsSummary$: Observable<WorkbasketSummary[]>;
@Select(WorkbasketSelectors.workbasketsSummaryRepresentation) @Select(WorkbasketSelectors.workbasketsSummaryRepresentation)
workbasketsSummaryRepresentation$: Observable<WorkbasketSummaryRepresentation>; workbasketsSummaryRepresentation$: Observable<WorkbasketSummaryRepresentation>;
@Select(WorkbasketSelectors.selectedWorkbasket) @Select(WorkbasketSelectors.selectedWorkbasket)
selectedWorkbasket$: Observable<Workbasket>; selectedWorkbasket$: Observable<Workbasket>;
@Select(FilterSelectors.getWorkbasketListFilter) @Select(FilterSelectors.getWorkbasketListFilter)
getWorkbasketListFilter$: Observable<WorkbasketQueryFilterParameter>; getWorkbasketListFilter$: Observable<WorkbasketQueryFilterParameter>;
destroy$ = new Subject<void>(); destroy$ = new Subject<void>();
@ViewChild('workbasket') workbasketList: MatSelectionList; @ViewChild('workbasket') workbasketList: MatSelectionList;
@ViewChild('wbToolbar', { static: true })
private toolbarElement: ElementRef;
constructor( constructor(
private store: Store, private store: Store,
@ -99,21 +93,21 @@ export class WorkbasketListComponent implements OnInit, OnDestroy {
this.workbasketService this.workbasketService
.workbasketSavedTriggered() .workbasketSavedTriggered()
.pipe(takeUntil(this.destroy$)) .pipe(takeUntil(this.destroy$))
.subscribe((value) => { .subscribe(() => {
this.performRequest(); this.performRequest();
}); });
this.orientationService this.orientationService
.getOrientation() .getOrientation()
.pipe(takeUntil(this.destroy$)) .pipe(takeUntil(this.destroy$))
.subscribe((orientation: Orientation) => { .subscribe(() => {
this.refreshWorkbasketList(); this.refreshWorkbasketList();
}); });
this.importExportService this.importExportService
.getImportingFinished() .getImportingFinished()
.pipe(takeUntil(this.destroy$)) .pipe(takeUntil(this.destroy$))
.subscribe((value: Boolean) => { .subscribe(() => {
this.refreshWorkbasketList(); this.refreshWorkbasketList();
}); });
@ -128,7 +122,7 @@ export class WorkbasketListComponent implements OnInit, OnDestroy {
this.workbasketService this.workbasketService
.getWorkbasketActionToolbarExpansion() .getWorkbasketActionToolbarExpansion()
.pipe(takeUntil(this.destroy$)) .pipe(takeUntil(this.destroy$))
.subscribe((value) => { .subscribe(() => {
this.requestInProgressService.setRequestInProgress(true); this.requestInProgressService.setRequestInProgress(true);
setTimeout(() => { setTimeout(() => {
this.refreshWorkbasketList(); this.refreshWorkbasketList();
@ -169,7 +163,8 @@ export class WorkbasketListComponent implements OnInit, OnDestroy {
const domain = this.filterBy.domain; const domain = this.filterBy.domain;
this.filterBy = { ...filterBy }; this.filterBy = { ...filterBy };
this.filterBy.domain = domain; this.filterBy.domain = domain;
this.performRequest(); this.resetPagingSubject.next(null);
// this.performRequest();
} }
changePage(page) { changePage(page) {

View File

@ -11,6 +11,8 @@ import {
} from '@angular/core'; } from '@angular/core';
import { Page } from 'app/shared/models/page'; import { Page } from 'app/shared/models/page';
import { MatPaginator } from '@angular/material/paginator'; import { MatPaginator } from '@angular/material/paginator';
import { Observable, Subject } from 'rxjs';
import { takeUntil } from 'rxjs/operators';
@Component({ @Component({
selector: 'taskana-shared-pagination', selector: 'taskana-shared-pagination',
@ -30,6 +32,9 @@ export class PaginationComponent implements OnInit, OnChanges {
@Input() @Input()
expanded: boolean = true; expanded: boolean = true;
@Input()
resetPaging: Observable<null>;
@Output() @Output()
changePage = new EventEmitter<number>(); changePage = new EventEmitter<number>();
@ -38,6 +43,8 @@ export class PaginationComponent implements OnInit, OnChanges {
@ViewChild('pagination') paginationWrapper: ElementRef; @ViewChild('pagination') paginationWrapper: ElementRef;
destroy$ = new Subject<void>();
hasItems = true; hasItems = true;
pageSelected = 1; pageSelected = 1;
pageNumbers: number[]; pageNumbers: number[];
@ -45,6 +52,7 @@ export class PaginationComponent implements OnInit, OnChanges {
ngOnInit() { ngOnInit() {
this.changeLabel(); this.changeLabel();
if (this.resetPaging) this.resetPaging.pipe(takeUntil(this.destroy$)).subscribe(() => this.goToPage(1));
} }
ngOnChanges(changes: SimpleChanges): void { ngOnChanges(changes: SimpleChanges): void {
@ -123,4 +131,9 @@ export class PaginationComponent implements OnInit, OnChanges {
input.focus(); input.focus();
input.select(); input.select();
} }
ngOnDestroy() {
this.destroy$.next();
this.destroy$.complete();
}
} }