Browse Source

UI: Add routes tab settings replaceUrl

pull/8911/head
Vladyslav_Prykhodko 3 years ago
parent
commit
054b190144
  1. 1
      ui-ngx/src/app/modules/home/components/router-tabs.component.html
  2. 6
      ui-ngx/src/app/modules/home/components/router-tabs.component.ts
  3. 9
      ui-ngx/src/app/modules/home/home.component.ts
  4. 10
      ui-ngx/src/app/modules/home/pages/account/account-routing.module.ts

1
ui-ngx/src/app/modules/home/components/router-tabs.component.html

@ -20,6 +20,7 @@
<nav fxFlex *ngIf="!routerOutlet?.activatedRouteData?.hideTabs && !hideCurrentTabs && (tabs$ | async).length > 1" mat-tab-nav-bar mat-stretch-tabs="false" class="tb-router-tabs" [tabPanel]="tabPanel">
<a *ngFor="let tab of tabs$ | async"
routerLink="{{tab.path}}"
replaceUrl="{{ replaceUrl }}"
routerLinkActive
#rla="routerLinkActive"
mat-tab-link

6
ui-ngx/src/app/modules/home/components/router-tabs.component.ts

@ -39,6 +39,8 @@ export class RouterTabsComponent extends PageComponent implements OnInit {
hideCurrentTabs = false;
replaceUrl = false;
tabs$: Observable<Array<MenuSection>>;
constructor(protected store: Store<AppState>,
@ -67,6 +69,10 @@ export class RouterTabsComponent extends PageComponent implements OnInit {
);
}
if (this.activatedRoute.snapshot.data.replaceUrl) {
this.replaceUrl = true;
}
this.activatedRoute.data.subscribe(
(data) => this.buildTabsHeaderComponent(data)
);

9
ui-ngx/src/app/modules/home/home.component.ts

@ -14,7 +14,7 @@
/// limitations under the License.
///
import { AfterViewInit, Component, ElementRef, OnInit, ViewChild } from '@angular/core';
import { AfterViewInit, Component, ElementRef, Inject, OnInit, ViewChild } from '@angular/core';
import { fromEvent } from 'rxjs';
import { Store } from '@ngrx/store';
import { debounceTime, distinctUntilChanged, tap } from 'rxjs/operators';
@ -27,10 +27,10 @@ import { MediaBreakpoints } from '@shared/models/constants';
import screenfull from 'screenfull';
import { MatSidenav } from '@angular/material/sidenav';
import { AuthState } from '@core/auth/auth.models';
import { WINDOW } from '@core/services/window.service';
import { instanceOfSearchableComponent, ISearchableComponent } from '@home/models/searchable-component.models';
import { ActiveComponentService } from '@core/services/active-component.service';
import { RouterTabsComponent } from '@home/components/router-tabs.component';
import { Router } from '@angular/router';
@Component({
selector: 'tb-home',
@ -65,8 +65,8 @@ export class HomeComponent extends PageComponent implements AfterViewInit, OnIni
hideLoadingBar = false;
constructor(protected store: Store<AppState>,
@Inject(WINDOW) private window: Window,
private activeComponentService: ActiveComponentService,
private router: Router,
public breakpointObserver: BreakpointObserver) {
super(store);
}
@ -120,8 +120,7 @@ export class HomeComponent extends PageComponent implements AfterViewInit, OnIni
}
goBack() {
const dashboardId = this.authState.userDetails.additionalInfo.defaultDashboardId;
this.router.navigate(['dashboard', dashboardId]).then(() => {});
this.window.history.back();
}
activeComponentChanged(activeComponent: any) {

10
ui-ngx/src/app/modules/home/pages/account/account-routing.module.ts

@ -14,12 +14,15 @@
/// limitations under the License.
///
import { NgModule } from '@angular/core';
import { inject, NgModule } from '@angular/core';
import { RouterModule, Routes } from '@angular/router';
import { RouterTabsComponent } from '@home/components/router-tabs.component';
import { Authority } from '@shared/models/authority.enum';
import { securityRoutes } from '@home/pages/security/security-routing.module';
import { profileRoutes } from '@home/pages/profile/profile-routing.module';
import { getCurrentAuthState } from '@core/auth/auth.selectors';
import { Store } from '@ngrx/store';
import { AppState } from '@core/core.state';
const routes: Routes = [
{
@ -31,7 +34,10 @@ const routes: Routes = [
label: 'account.account',
icon: 'account_circle'
},
useChildrenRoutesForTabs: true
useChildrenRoutesForTabs: true,
},
resolve: {
replaceUrl: () => getCurrentAuthState(inject(Store<AppState>)).forceFullscreen
},
children: [
{

Loading…
Cancel
Save