|
|
|
@ -1,11 +1,14 @@ |
|
|
|
import { Injectable, NgZone } from '@angular/core'; |
|
|
|
import { Router } from '@angular/router'; |
|
|
|
import { Injectable } from '@angular/core'; |
|
|
|
import { Action, createSelector, Selector, State, StateContext } from '@ngxs/store'; |
|
|
|
import snq from 'snq'; |
|
|
|
import { AddReplaceableComponent } from '../actions/replaceable-components.actions'; |
|
|
|
import { ReplaceableComponents } from '../models/replaceable-components'; |
|
|
|
import { noop } from '../utils/common-utils'; |
|
|
|
import { ReplaceableComponentsService } from '../services/replaceable-components.service'; |
|
|
|
|
|
|
|
// tslint:disable: max-line-length
|
|
|
|
/** |
|
|
|
* @deprecated To be deleted in v4.0. Use ReplaceableComponentsService instead. See the doc (https://docs.abp.io/en/abp/latest/UI/Angular/Component-Replacement)
|
|
|
|
*/ |
|
|
|
@State<ReplaceableComponents.State>({ |
|
|
|
name: 'ReplaceableComponentsState', |
|
|
|
defaults: { replaceableComponents: [] } as ReplaceableComponents.State, |
|
|
|
@ -30,23 +33,7 @@ export class ReplaceableComponentsState { |
|
|
|
return selector; |
|
|
|
} |
|
|
|
|
|
|
|
constructor(private ngZone: NgZone, private router: Router) {} |
|
|
|
|
|
|
|
// TODO: Create a shared service for route reload and more
|
|
|
|
private reloadRoute() { |
|
|
|
const { shouldReuseRoute } = this.router.routeReuseStrategy; |
|
|
|
const setRouteReuse = (reuse: typeof shouldReuseRoute) => { |
|
|
|
this.router.routeReuseStrategy.shouldReuseRoute = reuse; |
|
|
|
}; |
|
|
|
|
|
|
|
setRouteReuse(() => false); |
|
|
|
this.router.navigated = false; |
|
|
|
|
|
|
|
this.ngZone.run(async () => { |
|
|
|
await this.router.navigateByUrl(this.router.url).catch(noop); |
|
|
|
setRouteReuse(shouldReuseRoute); |
|
|
|
}); |
|
|
|
} |
|
|
|
constructor(private service: ReplaceableComponentsService) {} |
|
|
|
|
|
|
|
@Action(AddReplaceableComponent) |
|
|
|
replaceableComponentsAction( |
|
|
|
@ -69,6 +56,7 @@ export class ReplaceableComponentsState { |
|
|
|
replaceableComponents, |
|
|
|
}); |
|
|
|
|
|
|
|
if (reload) this.reloadRoute(); |
|
|
|
console.log(this.service); |
|
|
|
this.service.add(payload, reload); |
|
|
|
} |
|
|
|
} |
|
|
|
|