From ae8bde3f4de4e820663e3cf3c4c11fb956565af2 Mon Sep 17 00:00:00 2001 From: Etienne Delclaux Date: Mon, 28 Oct 2024 18:17:45 +0100 Subject: [PATCH] feat: make the observer tab loadable --- .../syntheseModule/taxon-sheet/loadable.ts | 19 +++++++++++++++++++ .../tab-observers.component.html | 1 + .../tab-observers/tab-observers.component.ts | 15 +++++++++++---- 3 files changed, 31 insertions(+), 4 deletions(-) create mode 100644 frontend/src/app/syntheseModule/taxon-sheet/loadable.ts diff --git a/frontend/src/app/syntheseModule/taxon-sheet/loadable.ts b/frontend/src/app/syntheseModule/taxon-sheet/loadable.ts new file mode 100644 index 0000000000..4561510d9b --- /dev/null +++ b/frontend/src/app/syntheseModule/taxon-sheet/loadable.ts @@ -0,0 +1,19 @@ +export class Loadable { + _isLoading: boolean; + + constructor(isLoading: boolean = false) { + this._isLoading = isLoading; + } + + startLoading() { + this._isLoading = true; + } + + stopLoading() { + this._isLoading = false; + } + + get isLoading(): boolean { + return this._isLoading; + } +} diff --git a/frontend/src/app/syntheseModule/taxon-sheet/tab-observers/tab-observers.component.html b/frontend/src/app/syntheseModule/taxon-sheet/tab-observers/tab-observers.component.html index 06e8c244b8..5547e2e902 100644 --- a/frontend/src/app/syntheseModule/taxon-sheet/tab-observers/tab-observers.component.html +++ b/frontend/src/app/syntheseModule/taxon-sheet/tab-observers/tab-observers.component.html @@ -35,6 +35,7 @@ [externalSorting]="true" (sort)="onSort($event)" [sorts]="[{ prop: sort.sortBy, dir: sort.sortOrder }]" + [loadingIndicator]="isLoading" > { @@ -65,16 +69,19 @@ export class TabObserversComponent implements OnInit { this.fetchObservers(); } - fetchObservers() { + async fetchObservers() { + this.startLoading(); const taxon = this._tss.taxon.getValue(); + this.items = []; if (!taxon) { - this.items = []; this.pagination = DEFAULT_PAGINATION; this.sort = this.DEFAULT_SORT; + this.stopLoading(); return; } this._syntheseDataService .getSyntheseTaxonSheetObservers(taxon.cd_ref, this.pagination, this.sort) + .pipe(finalize(() => this.stopLoading())) .subscribe((data) => { // Store result this.items = data.items;