@sumaris-net/ngx-components 2.4.23-rc3 → 2.4.23-rc5
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 +48 -23
- package/esm2020/src/app/shared/shared-routing.module.mjs +19 -7
- package/fesm2015/sumaris-net.ngx-components.mjs +57 -27
- package/fesm2015/sumaris-net.ngx-components.mjs.map +1 -1
- package/fesm2020/sumaris-net.ngx-components.mjs +63 -27
- 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 +6 -0
|
@@ -19695,9 +19695,9 @@ class CustomReuseStrategy extends IonicRouteStrategy {
|
|
|
19695
19695
|
* @param curr
|
|
19696
19696
|
*/
|
|
19697
19697
|
shouldReuseRoute(future, curr) {
|
|
19698
|
-
const
|
|
19698
|
+
const reuse = super.shouldReuseRoute(future, curr);
|
|
19699
19699
|
// Is sam route config
|
|
19700
|
-
if (
|
|
19700
|
+
if (future.routeConfig && future.routeConfig === curr.routeConfig) {
|
|
19701
19701
|
// Read the parameter name, where id is stored
|
|
19702
19702
|
const pathIdParam = future.routeConfig.data && future.routeConfig.data.pathIdParam || 'id';
|
|
19703
19703
|
// Read the current route id
|
|
@@ -19708,11 +19708,22 @@ 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
|
+
if (!reuse) {
|
|
19714
|
+
// Allow reuse when changing from /new to /new?id=:id
|
|
19715
|
+
if (currId === 'new' && isNil(curr.queryParams[pathIdParam]) && future.params[pathIdParam] === 'new' && isNotNil(future.queryParams[pathIdParam])) {
|
|
19716
|
+
return true;
|
|
19717
|
+
}
|
|
19718
|
+
// Allow reuse same id, expect when expected '/new'
|
|
19719
|
+
return futureId !== 'new' && futureId === currId;
|
|
19720
|
+
}
|
|
19721
|
+
else {
|
|
19722
|
+
console.log(`Router reuse={reuse} from /${curr.params[pathIdParam]} to /${future.params[pathIdParam]}`);
|
|
19723
|
+
}
|
|
19724
|
+
}
|
|
19714
19725
|
}
|
|
19715
|
-
return
|
|
19726
|
+
return reuse;
|
|
19716
19727
|
}
|
|
19717
19728
|
}
|
|
19718
19729
|
CustomReuseStrategy.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.12", ngImport: i0, type: CustomReuseStrategy, deps: null, target: i0.ɵɵFactoryTarget.Injectable });
|
|
@@ -28315,17 +28326,14 @@ class AppEntityEditor extends AppTabEditor {
|
|
|
28315
28326
|
const queryParams = { ...this.queryParams };
|
|
28316
28327
|
// Open the next tab
|
|
28317
28328
|
this.updateTabIndex(opts && opts.openTabIndex);
|
|
28318
|
-
// Update queryParams
|
|
28319
|
-
queryParams.tab = this.selectedTabIndex;
|
|
28320
|
-
queryParams[this._pathIdAttribute] = isNotNil(data?.id) ? data.id : 'new';
|
|
28321
28329
|
// Update route location
|
|
28322
|
-
await this.updateRoute(data, queryParams);
|
|
28330
|
+
await this.updateRoute(data, { ...queryParams, tab: this.selectedTabIndex });
|
|
28323
28331
|
}
|
|
28324
28332
|
/**
|
|
28325
28333
|
* Update the route location, and open the next tab
|
|
28326
28334
|
*/
|
|
28327
28335
|
updateTabIndex(tabIndex) {
|
|
28328
|
-
if (isNotNil(tabIndex) && tabIndex !== this.selectedTabIndex) {
|
|
28336
|
+
if (isNotNil(tabIndex) && tabIndex >= 0 && tabIndex !== this.selectedTabIndex) {
|
|
28329
28337
|
this.selectedTabIndex = tabIndex;
|
|
28330
28338
|
this.markForCheck();
|
|
28331
28339
|
}
|
|
@@ -28615,7 +28623,7 @@ class AppEntityEditor extends AppTabEditor {
|
|
|
28615
28623
|
let parentUrl = this.defaultBackHref;
|
|
28616
28624
|
// Remove query params
|
|
28617
28625
|
if (withQueryParams !== true && parentUrl && parentUrl.indexOf('?') !== -1) {
|
|
28618
|
-
parentUrl = parentUrl.
|
|
28626
|
+
parentUrl = parentUrl.substring(0, parentUrl.indexOf('?'));
|
|
28619
28627
|
}
|
|
28620
28628
|
return parentUrl;
|
|
28621
28629
|
}
|
|
@@ -28641,27 +28649,55 @@ class AppEntityEditor extends AppTabEditor {
|
|
|
28641
28649
|
this.markForCheck();
|
|
28642
28650
|
}
|
|
28643
28651
|
}
|
|
28652
|
+
/**
|
|
28653
|
+
* Update the route, without reloading the component
|
|
28654
|
+
* @param data
|
|
28655
|
+
* @param queryParams
|
|
28656
|
+
* @protected
|
|
28657
|
+
*/
|
|
28644
28658
|
async updateRoute(data, queryParams) {
|
|
28645
|
-
const
|
|
28646
|
-
const
|
|
28647
|
-
|
|
28648
|
-
this.queryParams
|
|
28649
|
-
|
|
28650
|
-
|
|
28651
|
-
|
|
28652
|
-
|
|
28653
|
-
|
|
28659
|
+
const currId = this.route.snapshot.paramMap.get(this.pathIdAttribute);
|
|
28660
|
+
const futureId = isNotNil(data.id) ? data.id.toString() : 'new';
|
|
28661
|
+
this.queryParams = {
|
|
28662
|
+
...this.queryParams,
|
|
28663
|
+
...queryParams
|
|
28664
|
+
};
|
|
28665
|
+
if (currId === futureId) {
|
|
28666
|
+
// Update queryParam only (not the path)
|
|
28667
|
+
if (!equals(this.route.snapshot.queryParams, this.queryParams)) {
|
|
28668
|
+
if (this.debug)
|
|
28669
|
+
console.debug('[entity-editor] Updating route using queryParams: ', queryParams);
|
|
28670
|
+
return await this.router.navigate(['.'], {
|
|
28671
|
+
relativeTo: this.route,
|
|
28654
28672
|
queryParams: this.queryParams
|
|
28655
28673
|
});
|
|
28656
28674
|
}
|
|
28657
|
-
finally {
|
|
28658
|
-
// Re enabling router animation
|
|
28659
|
-
this.routerOutlet.animated = true;
|
|
28660
|
-
}
|
|
28661
28675
|
}
|
|
28662
28676
|
else {
|
|
28663
|
-
|
|
28664
|
-
|
|
28677
|
+
// Current route was '/new' => change to '/new?id=:id' (to allow CustomReuseStrategy to detect that route can be reused)
|
|
28678
|
+
if (currId === 'new') {
|
|
28679
|
+
const res = await this.router.navigate(['.'], {
|
|
28680
|
+
relativeTo: this.route,
|
|
28681
|
+
replaceUrl: true,
|
|
28682
|
+
queryParams: {
|
|
28683
|
+
...this.queryParams,
|
|
28684
|
+
[this.pathIdAttribute]: futureId
|
|
28685
|
+
}
|
|
28686
|
+
});
|
|
28687
|
+
if (!res)
|
|
28688
|
+
return false;
|
|
28689
|
+
}
|
|
28690
|
+
const path = this.computePageUrl(isNotNil(data.id) ? data.id : 'new');
|
|
28691
|
+
const commands = (path && typeof path === 'string') ? path.split('/').slice(1) : path;
|
|
28692
|
+
if (isNotEmptyArray(commands)) {
|
|
28693
|
+
if (this.debug)
|
|
28694
|
+
console.debug('[entity-editor] Updating route to: ' + path);
|
|
28695
|
+
return await this.router.navigate(commands, {
|
|
28696
|
+
replaceUrl: true,
|
|
28697
|
+
queryParams: this.queryParams
|
|
28698
|
+
});
|
|
28699
|
+
}
|
|
28700
|
+
return Promise.reject('Missing page URL');
|
|
28665
28701
|
}
|
|
28666
28702
|
}
|
|
28667
28703
|
}
|