Skip to content
Snippets Groups Projects
Commit 0e321a7e authored by Alex ORLUC's avatar Alex ORLUC
Browse files

FIX #14568 TIME 0:25 fix scroll event after re search (when scroll reach end of data)

parent 45607ba8
No related branches found
No related tags found
No related merge requests found
...@@ -95,7 +95,7 @@ ...@@ -95,7 +95,7 @@
</ion-item> </ion-item>
</ion-virtual-scroll> </ion-virtual-scroll>
</ion-list> </ion-list>
<ion-infinite-scroll *ngIf="count > 0" threshold="100px" (ionInfinite)="loadData($event)"> <ion-infinite-scroll threshold="100px" (ionInfinite)="loadData($event)">
<ion-infinite-scroll-content loadingSpinner="bubbles" loadingText="Loading more data..."> <ion-infinite-scroll-content loadingSpinner="bubbles" loadingText="Loading more data...">
</ion-infinite-scroll-content> </ion-infinite-scroll-content>
</ion-infinite-scroll> </ion-infinite-scroll>
......
...@@ -2,7 +2,7 @@ import { DatePipe } from '@angular/common'; ...@@ -2,7 +2,7 @@ import { DatePipe } from '@angular/common';
import { HttpClient } from '@angular/common/http'; import { HttpClient } from '@angular/common/http';
import { Component, OnInit, TemplateRef, ViewChild, ViewContainerRef } from '@angular/core'; import { Component, OnInit, TemplateRef, ViewChild, ViewContainerRef } from '@angular/core';
import { Router } from '@angular/router'; import { Router } from '@angular/router';
import { ActionSheetController, AlertController, LoadingController, MenuController } from '@ionic/angular'; import { ActionSheetController, AlertController, IonInfiniteScroll, LoadingController, MenuController } from '@ionic/angular';
import { TranslateService } from '@ngx-translate/core'; import { TranslateService } from '@ngx-translate/core';
import { of } from 'rxjs'; import { of } from 'rxjs';
import { catchError, exhaustMap, tap } from 'rxjs/operators'; import { catchError, exhaustMap, tap } from 'rxjs/operators';
...@@ -82,10 +82,13 @@ export class SearchComponent implements OnInit { ...@@ -82,10 +82,13 @@ export class SearchComponent implements OnInit {
limit: number = 10; limit: number = 10;
count: number = 0; count: number = 0;
openedLine = ''; openedLine = '';
reActiveInfinite: any;
@ViewChild('appVisaWorkflow', { static: false }) appVisaWorkflow: VisaWorkflowComponent; @ViewChild('appVisaWorkflow', { static: false }) appVisaWorkflow: VisaWorkflowComponent;
@ViewChild('rightContent', { static: true }) rightContent: TemplateRef<any>; @ViewChild('rightContent', { static: true }) rightContent: TemplateRef<any>;
@ViewChild(IonInfiniteScroll) infiniteScroll: IonInfiniteScroll;
constructor( constructor(
public http: HttpClient, public http: HttpClient,
private translate: TranslateService, private translate: TranslateService,
...@@ -138,7 +141,6 @@ export class SearchComponent implements OnInit { ...@@ -138,7 +141,6 @@ export class SearchComponent implements OnInit {
} }
onSubmit() { onSubmit() {
console.log(this.formatDatas());
this.search(); this.search();
this.menu.close('right-menu'); this.menu.close('right-menu');
} }
...@@ -226,6 +228,7 @@ export class SearchComponent implements OnInit { ...@@ -226,6 +228,7 @@ export class SearchComponent implements OnInit {
tap((data: any) => { tap((data: any) => {
this.ressources = this.formatListDatas(data.documents); this.ressources = this.formatListDatas(data.documents);
this.count = data.count; this.count = data.count;
this.infiniteScroll.disabled = false;
resolve(true); resolve(true);
}), }),
catchError((err: any) => { catchError((err: any) => {
...@@ -238,17 +241,22 @@ export class SearchComponent implements OnInit { ...@@ -238,17 +241,22 @@ export class SearchComponent implements OnInit {
} }
loadData(event: any) { loadData(event: any) {
this.offset = this.offset + this.limit; if (this.count <= this.limit) {
event.target.complete();
this.http.post('../rest/search/documents?limit=' + this.limit + '&offset=' + this.offset, this.formatDatas()).pipe( event.target.disabled = true;
tap((data: any) => { } else {
this.ressources = this.ressources.concat(this.formatListDatas(data.documents)); this.offset = this.offset + this.limit;
event.target.complete();
if (this.count === this.ressources.length) { this.http.post('../rest/search/documents?limit=' + this.limit + '&offset=' + this.offset, this.formatDatas()).pipe(
event.target.disabled = true; tap((data: any) => {
} this.ressources = this.ressources.concat(this.formatListDatas(data.documents));
}) event.target.complete();
).subscribe(); if (this.count === this.ressources.length) {
event.target.disabled = true;
}
})
).subscribe();
}
} }
async interruptWorkflow(item: any) { async interruptWorkflow(item: any) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment