Skip to content

Commit

Permalink
feat(lookup): fazendo lookup cancelar requisiçoes ao fechar modal
Browse files Browse the repository at this point in the history
DTHFUI-8000
  • Loading branch information
LuanPonick committed Feb 5, 2024
1 parent 535cf44 commit d428c55
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,8 @@ export abstract class PoLookupModalBaseComponent implements OnDestroy, OnInit {
this.language = languageService.getShortLanguage();
}

ngOnDestroy() {
// Metodo responsavel por cancelar todas as requisiçoes pendentes
unsubscribeAllSubscriptions() {
if (this.filterSubscription) {
this.filterSubscription.unsubscribe();
}
Expand All @@ -279,6 +280,10 @@ export abstract class PoLookupModalBaseComponent implements OnDestroy, OnInit {
}
}

ngOnDestroy() {
this.unsubscribeAllSubscriptions();
}

ngOnInit() {
this.setAdvancedFilterModalProperties();
this.initializeData();
Expand Down Expand Up @@ -336,7 +341,7 @@ export abstract class PoLookupModalBaseComponent implements OnDestroy, OnInit {

search(): void {
this.page = 1;

this.unsubscribeAllSubscriptions();
if (this.searchValue) {
this.isLoading = true;
this.disclaimerGroup.disclaimers = [];
Expand All @@ -348,6 +353,9 @@ export abstract class PoLookupModalBaseComponent implements OnDestroy, OnInit {
}

searchFilteredItems(): void {
if (this.isLoading) {
this.unsubscribeAllSubscriptions();
}
this.searchSubscription = this.getFilteredItems(this.searchValue)
.pipe(
catchError(error => {
Expand All @@ -362,6 +370,10 @@ export abstract class PoLookupModalBaseComponent implements OnDestroy, OnInit {
}

showMoreEvent() {
if (this.isLoading) {
this.unsubscribeAllSubscriptions();
}

this.page++;
this.isLoading = true;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
[p-primary-action]="isAdvancedFilter ? primaryActionAdvancedFilter : primaryAction"
[p-secondary-action]="isAdvancedFilter ? secondaryActionAdvancedFilter : secondaryAction"
[p-title]="isAdvancedFilter ? advancedFilterModalTitle : title"
(p-close)="unsubscribeAllSubscriptions()"
>
<div [hidden]="isAdvancedFilter">
<po-field-container class="po-lookup-header po-pull-right" [p-optional]="false">
Expand Down

0 comments on commit d428c55

Please sign in to comment.