<h3 i18n *ngIf="id && showSearchForm">{{providerRecord.currentProvider?.record.name()}} ({{providerRecord.currentProvider?.record.code()}})</h3>
<div class="row">
-<div class="col-lg-auto">
+<div class="col-lg-auto" [hidden]="!id">
<eg-acq-provider-summary-pane #acqSearchProviderSummary
(summaryToggled)="onSummaryToggled($event)" [providerId]="id">
</eg-acq-provider-summary-pane>
).subscribe(routeEvent => {
if (routeEvent instanceof NavigationEnd) {
if (this.previousUrl != null &&
- routeEvent.url === '/staff/acq/provider' &&
- this.previousUrl === routeEvent.url) {
+ routeEvent.url === '/staff/acq/provider') {
this.acqProviderResults.resetSearch();
+ this.showSearchForm = true;
+ this.id = null;
}
this.previousUrl = routeEvent.url;
}
this.defaultTabType =
this.store.getLocalItem('eg.acq.provider.default_tab') || 'details';
+ const keepSearchForm = history.state.hasOwnProperty('keepSearchForm') ?
+ history.state.keepSearchForm :
+ false;
+ if (keepSearchForm) {
+ this.showSearchForm = true;
+ }
+
if (idParam) {
- this.showSearchForm = false;
+ if (!keepSearchForm) {
+ this.showSearchForm = false;
+ }
this.id = idParam;
if (!tabTypeParam) {
this.activeTab = this.defaultTabType;
}
if (tabTypeParam) {
- this.showSearchForm = false;
+ if (!keepSearchForm) {
+ this.showSearchForm = false;
+ }
if (this.validTabTypes.includes(tabTypeParam)) {
this.activeTab = tabTypeParam;
} else {
this.showSearchForm = false;
}
this.activeTab = this.defaultTabType;
- this.router.navigate(['/staff', 'acq', 'provider', this.id, this.activeTab]);
+ this.router.navigate(
+ ['/staff', 'acq', 'provider', this.id, this.activeTab],
+ { state: { keepSearchForm: !hideSearchForm } }
+ );
});
};
import {NgModule} from '@angular/core';
-import {RouterModule, Routes} from '@angular/router';
+import {RouterModule, Routes, UrlMatchResult} from '@angular/router';
import {AcqProviderComponent} from './acq-provider.component';
import {ProviderResolver, CanLeaveAcqProviderGuard} from './resolver.service';
const routes: Routes = [
- { path: '',
- component: AcqProviderComponent,
- runGuardsAndResolvers: 'always'
- },
- { path: ':id',
- component: AcqProviderComponent,
- resolve: { providerResolver : ProviderResolver },
- runGuardsAndResolvers: 'always'
- },
- { path: ':id/:tab',
+ { matcher: (segments) => {
+ // using a custom matcher so that we
+ // don't force a component re-initialization
+ // when navigating from the search form to a
+ // provider record
+ if (segments.length === 0) {
+ return {
+ consumed: segments,
+ posParams: {}
+ };
+ } else if (segments.length === 1) {
+ return {
+ consumed: segments,
+ posParams: {
+ id: segments[0],
+ }
+ };
+ } else if (segments.length > 1) {
+ return {
+ consumed: segments,
+ posParams: {
+ id: segments[0],
+ tab: segments[1],
+ }
+ };
+ }
+ return <UrlMatchResult>(null as any);
+ },
component: AcqProviderComponent,
resolve: { providerResolver : ProviderResolver },
canDeactivate: [CanLeaveAcqProviderGuard],