@sumaris-net/ngx-components 2.4.23-rc2 → 2.4.23-rc4
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.
- package/esm2020/src/app/core/form/entity/entity-editor.class.mjs +54 -20
- package/esm2020/src/app/shared/shared-routing.module.mjs +11 -4
- package/fesm2015/sumaris-net.ngx-components.mjs +59 -23
- package/fesm2015/sumaris-net.ngx-components.mjs.map +1 -1
- package/fesm2020/sumaris-net.ngx-components.mjs +61 -21
- package/fesm2020/sumaris-net.ngx-components.mjs.map +1 -1
- package/package.json +1 -1
- package/src/app/core/form/entity/entity-editor.class.d.ts +8 -0
|
@@ -60,7 +60,7 @@ import { timer, merge, fromEvent, BehaviorSubject, Subscription, Subject, isObse
|
|
|
60
60
|
import { filter, map, takeUntil, first, switchMap, tap, debounceTime, startWith, distinctUntilChanged, mergeMap, catchError, throttleTime, skip, bufferWhen, mapTo, take } from 'rxjs/operators';
|
|
61
61
|
import { trigger, transition, style, animate, state } from '@angular/animations';
|
|
62
62
|
import * as i1 from '@ionic/angular';
|
|
63
|
-
import { IonicModule, Platform, ToastController, IonicSafeString, createAnimation, IonicRouteStrategy, ModalController, AlertController, IonContent, IonItem, IonModal, IonInfiniteScroll } from '@ionic/angular';
|
|
63
|
+
import { IonicModule, Platform, ToastController, IonicSafeString, createAnimation, IonicRouteStrategy, ModalController, AlertController, IonContent, IonRouterOutlet, IonItem, IonModal, IonInfiniteScroll } from '@ionic/angular';
|
|
64
64
|
import { Capacitor } from '@capacitor/core';
|
|
65
65
|
import { Keyboard } from '@capacitor/keyboard';
|
|
66
66
|
import * as i1$2 from '@ngx-translate/core';
|
|
@@ -19708,9 +19708,15 @@ class CustomReuseStrategy extends IonicRouteStrategy {
|
|
|
19708
19708
|
const futureId = future.params[pathIdParam] === 'new'
|
|
19709
19709
|
? (future.queryParams[pathIdParam] || future.queryParams['id'] || 'new') // e.g. path like '/new/?id=<ID>'
|
|
19710
19710
|
: future.params[pathIdParam]; // e.g. path like '/<ID>'
|
|
19711
|
-
// Reuse if same ID,
|
|
19712
|
-
|
|
19713
|
-
|
|
19711
|
+
// Reuse if same ID, using a futureId, if exists
|
|
19712
|
+
if (isNotNil(futureId)) {
|
|
19713
|
+
// Allow reuse when changing from /new to /new?id=:id
|
|
19714
|
+
if (currId === 'new' && isNil(curr.queryParams[pathIdParam]) && future.params[pathIdParam] === 'new' && isNotNil(future.queryParams[pathIdParam])) {
|
|
19715
|
+
return true;
|
|
19716
|
+
}
|
|
19717
|
+
// Allow reuse same id, expect when expected '/new'
|
|
19718
|
+
return futureId !== 'new' && futureId === currId;
|
|
19719
|
+
}
|
|
19714
19720
|
}
|
|
19715
19721
|
return result;
|
|
19716
19722
|
}
|
|
@@ -28076,6 +28082,7 @@ class AppEntityEditor extends AppTabEditor {
|
|
|
28076
28082
|
};
|
|
28077
28083
|
this.settings = injector.get(LocalSettingsService);
|
|
28078
28084
|
this.errorTranslator = injector.get(FormErrorTranslator);
|
|
28085
|
+
this.routerOutlet = injector.get(IonRouterOutlet);
|
|
28079
28086
|
this.cd = injector.get(ChangeDetectorRef);
|
|
28080
28087
|
this.dateFormat = injector.get(DateFormatService);
|
|
28081
28088
|
this.toastController = injector.get(ToastController);
|
|
@@ -28314,17 +28321,14 @@ class AppEntityEditor extends AppTabEditor {
|
|
|
28314
28321
|
const queryParams = { ...this.queryParams };
|
|
28315
28322
|
// Open the next tab
|
|
28316
28323
|
this.updateTabIndex(opts && opts.openTabIndex);
|
|
28317
|
-
// Update queryParams
|
|
28318
|
-
queryParams.tab = this.selectedTabIndex;
|
|
28319
|
-
queryParams[this._pathIdAttribute] = isNotNil(data?.id) ? data.id : 'new';
|
|
28320
28324
|
// Update route location
|
|
28321
|
-
await this.updateRoute(data, queryParams);
|
|
28325
|
+
await this.updateRoute(data, { ...queryParams, tab: this.selectedTabIndex });
|
|
28322
28326
|
}
|
|
28323
28327
|
/**
|
|
28324
28328
|
* Update the route location, and open the next tab
|
|
28325
28329
|
*/
|
|
28326
28330
|
updateTabIndex(tabIndex) {
|
|
28327
|
-
if (isNotNil(tabIndex) && tabIndex !== this.selectedTabIndex) {
|
|
28331
|
+
if (isNotNil(tabIndex) && tabIndex >= 0 && tabIndex !== this.selectedTabIndex) {
|
|
28328
28332
|
this.selectedTabIndex = tabIndex;
|
|
28329
28333
|
this.markForCheck();
|
|
28330
28334
|
}
|
|
@@ -28614,7 +28618,7 @@ class AppEntityEditor extends AppTabEditor {
|
|
|
28614
28618
|
let parentUrl = this.defaultBackHref;
|
|
28615
28619
|
// Remove query params
|
|
28616
28620
|
if (withQueryParams !== true && parentUrl && parentUrl.indexOf('?') !== -1) {
|
|
28617
|
-
parentUrl = parentUrl.
|
|
28621
|
+
parentUrl = parentUrl.substring(0, parentUrl.indexOf('?'));
|
|
28618
28622
|
}
|
|
28619
28623
|
return parentUrl;
|
|
28620
28624
|
}
|
|
@@ -28640,19 +28644,55 @@ class AppEntityEditor extends AppTabEditor {
|
|
|
28640
28644
|
this.markForCheck();
|
|
28641
28645
|
}
|
|
28642
28646
|
}
|
|
28643
|
-
|
|
28644
|
-
|
|
28645
|
-
|
|
28646
|
-
|
|
28647
|
-
|
|
28648
|
-
|
|
28649
|
-
|
|
28650
|
-
|
|
28651
|
-
|
|
28647
|
+
/**
|
|
28648
|
+
* Update the route, without reloading the component
|
|
28649
|
+
* @param data
|
|
28650
|
+
* @param queryParams
|
|
28651
|
+
* @protected
|
|
28652
|
+
*/
|
|
28653
|
+
async updateRoute(data, queryParams) {
|
|
28654
|
+
const currId = this.route.snapshot.paramMap.get(this.pathIdAttribute);
|
|
28655
|
+
const futureId = isNotNil(data.id) ? data.id.toString() : 'new';
|
|
28656
|
+
this.queryParams = {
|
|
28657
|
+
...this.queryParams,
|
|
28658
|
+
...queryParams
|
|
28659
|
+
};
|
|
28660
|
+
if (currId === futureId) {
|
|
28661
|
+
// Update queryParam only (not the path)
|
|
28662
|
+
if (!equals(this.route.snapshot.queryParams, this.queryParams)) {
|
|
28663
|
+
if (this.debug)
|
|
28664
|
+
console.debug('[entity-editor] Updating route using queryParams: ', queryParams);
|
|
28665
|
+
return await this.router.navigate(['.'], {
|
|
28666
|
+
relativeTo: this.route,
|
|
28667
|
+
queryParams: this.queryParams
|
|
28668
|
+
});
|
|
28669
|
+
}
|
|
28652
28670
|
}
|
|
28653
28671
|
else {
|
|
28654
|
-
|
|
28655
|
-
|
|
28672
|
+
// Current route was '/new' => change to '/new?id=:id' (to allow CustomReuseStrategy to detect that route can be reused)
|
|
28673
|
+
if (currId === 'new') {
|
|
28674
|
+
const res = await this.router.navigate(['.'], {
|
|
28675
|
+
relativeTo: this.route,
|
|
28676
|
+
replaceUrl: true,
|
|
28677
|
+
queryParams: {
|
|
28678
|
+
...this.queryParams,
|
|
28679
|
+
[this.pathIdAttribute]: futureId
|
|
28680
|
+
}
|
|
28681
|
+
});
|
|
28682
|
+
if (!res)
|
|
28683
|
+
return false;
|
|
28684
|
+
}
|
|
28685
|
+
const path = this.computePageUrl(isNotNil(data.id) ? data.id : 'new');
|
|
28686
|
+
const commands = (path && typeof path === 'string') ? path.split('/').slice(1) : path;
|
|
28687
|
+
if (isNotEmptyArray(commands)) {
|
|
28688
|
+
if (this.debug)
|
|
28689
|
+
console.debug('[entity-editor] Updating route to: ' + path);
|
|
28690
|
+
return await this.router.navigate(commands, {
|
|
28691
|
+
replaceUrl: true,
|
|
28692
|
+
queryParams: this.queryParams
|
|
28693
|
+
});
|
|
28694
|
+
}
|
|
28695
|
+
return Promise.reject('Missing page URL');
|
|
28656
28696
|
}
|
|
28657
28697
|
}
|
|
28658
28698
|
}
|