@ecodev/natural 45.4.1 → 45.4.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,11 +1,11 @@
1
1
  import '@angular/localize/init';
2
2
  import * as i0 from '@angular/core';
3
3
  import { Directive, Component, Inject, Injectable, HostBinding, HostListener, InjectionToken, Optional, Input, NgModule, EventEmitter, ChangeDetectionStrategy, Output, ContentChildren, Pipe, TemplateRef, ViewEncapsulation, ViewChild, Injector, Self, ContentChild, createEnvironmentInjector, createComponent, PLATFORM_ID, ErrorHandler } from '@angular/core';
4
- import { Subject, BehaviorSubject, of, timer, switchMap as switchMap$1, endWith, last, EMPTY, Observable, first as first$1, combineLatest, ReplaySubject, debounceTime as debounceTime$1, raceWith, take as take$1, mergeMap, shareReplay as shareReplay$1, catchError, forkJoin, map as map$1, merge as merge$1, tap as tap$1, asyncScheduler, takeUntil as takeUntil$1 } from 'rxjs';
4
+ import { Subject, BehaviorSubject, of, timer, switchMap as switchMap$1, endWith, last, EMPTY, Observable, first as first$1, combineLatest, catchError, ReplaySubject, debounceTime as debounceTime$1, raceWith, take as take$1, mergeMap, shareReplay as shareReplay$1, forkJoin, map as map$1, merge as merge$1, tap as tap$1, asyncScheduler, takeUntil as takeUntil$1 } from 'rxjs';
5
5
  import * as i3 from '@angular/forms';
6
6
  import { FormGroup, FormArray, Validators, UntypedFormGroup, UntypedFormArray, UntypedFormControl, FormsModule, FormControl, FormControlDirective, FormControlName, ReactiveFormsModule } from '@angular/forms';
7
7
  import * as i2$1 from '@angular/router';
8
- import { Router, ActivatedRoute, NavigationEnd, RouterModule, NavigationError, DefaultUrlSerializer } from '@angular/router';
8
+ import { Router, ActivatedRoute, NavigationStart, NavigationEnd, RouterModule, NavigationError, DefaultUrlSerializer } from '@angular/router';
9
9
  import { merge, isObject, isArray, pickBy, isEmpty, cloneDeep, uniq, groupBy, mergeWith, defaultsDeep, omit, kebabCase, clone, pick, isEqual, defaults, intersection, flatten, differenceWith } from 'lodash-es';
10
10
  import * as i1 from '@angular/material/dialog';
11
11
  import { MAT_DIALOG_DATA, MatDialogModule } from '@angular/material/dialog';
@@ -3061,6 +3061,21 @@ class NaturalAbstractList extends NaturalAbstractPanel {
3061
3061
  this.variablesManager.defaults('sorting', { sorting: this.defaultSorting });
3062
3062
  this.dataSource = new NaturalDataSource(this.getDataObservable());
3063
3063
  this.selection.clear();
3064
+ // Update natural search when history changes (back/forward buttons)
3065
+ // History state is detectable only on NavigationStart (popstate trigger)
3066
+ // But we need parameters from url after NavigationEnd. So proceed in two steps with a flag.
3067
+ let isPopState = false;
3068
+ this.router.events
3069
+ .pipe(takeUntil(this.ngUnsubscribe), filter(event => event instanceof NavigationStart && event.navigationTrigger === 'popstate'))
3070
+ .subscribe(() => {
3071
+ isPopState = true;
3072
+ });
3073
+ this.router.events
3074
+ .pipe(takeUntil(this.ngUnsubscribe), filter(event => event instanceof NavigationEnd && isPopState))
3075
+ .subscribe(() => {
3076
+ isPopState = false; // reset flag
3077
+ this.naturalSearchSelections = fromUrl(this.persistenceService.getFromUrl('ns', this.route));
3078
+ });
3064
3079
  }
3065
3080
  /**
3066
3081
  * Persist search and then launch whatever is required to refresh the list
@@ -3735,7 +3750,7 @@ class NaturalAbstractModelService {
3735
3750
  variables: manager.variables.value,
3736
3751
  fetchPolicy: fetchPolicy,
3737
3752
  })
3738
- .valueChanges.pipe(filter(r => !!r.data), this.mapAll());
3753
+ .valueChanges.pipe(catchError(() => EMPTY), filter(r => !!r.data), this.mapAll());
3739
3754
  }));
3740
3755
  }
3741
3756
  /**
@@ -9613,8 +9628,11 @@ class NaturalRelationsComponent extends NaturalAbstractController {
9613
9628
  return;
9614
9629
  }
9615
9630
  this.loading = true;
9616
- const queryRef = this.service.watchAll(this.variablesManager).pipe(takeUntil(this.ngUnsubscribe));
9617
- queryRef.pipe(finalize(() => (this.loading = false))).subscribe(() => (this.loading = false));
9631
+ const queryRef = this.service.watchAll(this.variablesManager).pipe(takeUntil(this.ngUnsubscribe), tap$1({
9632
+ next: () => (this.loading = false),
9633
+ complete: () => (this.loading = false),
9634
+ error: () => (this.loading = false),
9635
+ }));
9618
9636
  this.dataSource = new NaturalDataSource(queryRef);
9619
9637
  }
9620
9638
  getSelectKey() {