File

core/tabs/tabs-outlet.component.ts

Implements

OnDestroy AfterContentInit OnChanges

Metadata

Index

Properties
Methods
Inputs
HostBindings
Accessors

Constructor

constructor(router: Router, renderer: Renderer2, header: HeaderService, tabsService: TabsService, activatedRoute: ActivatedRoute)
Parameters :
Name Type Optional
router Router No
renderer Renderer2 No
header HeaderService No
tabsService TabsService No
activatedRoute ActivatedRoute No

Inputs

context
Type : any
hasHeader
Type : boolean
Default value : false

Identifies if the current view has a header element.

navigatorOpen
Type : boolean
Default value : false
openFirstTab
Type : boolean
Default value : true
orientation
Type : "vertical" | "horizontal"
Default value : 'vertical'
outletName
Type : string | undefined
tabs
Type : Tab[]
Default value : []

HostBindings

class.navigator-open
Type : boolean
class.page-tabs
Type : any
class.page-tabs-horizontal
Type : boolean
class.page-tabs-vertical
Type : boolean

Methods

isActive
isActive(tab: Tab)
Parameters :
Name Type Optional
tab Tab No
Returns : any
navigateTo
navigateTo(path: string | any[])
Parameters :
Name Type Optional
path string | any[] No
Returns : void
ngAfterContentInit
ngAfterContentInit()
Returns : void
ngOnChanges
ngOnChanges(changes: SimpleChanges)
Parameters :
Name Type Optional
changes SimpleChanges No
Returns : void
ngOnDestroy
ngOnDestroy()
Returns : void
ngOnInit
ngOnInit()
Returns : void
scroll
scroll(direction: "right" | "left")
Parameters :
Name Type Optional Default value
direction "right" | "left" No 'right'
Returns : void
trackByPath
trackByPath(index: unknown, tab: Tab)
Parameters :
Name Type Optional
index unknown No
tab Tab No
Returns : any

Properties

extras
Type : NavigationExtras
Default value : { queryParamsHandling: 'preserve', relativeTo: this.activatedRoute }
showLeft
Type : unknown
Default value : false
showRight
Type : unknown
Default value : false

Accessors

isNavigatorOpen
getisNavigatorOpen()
hasTabs
gethasTabs()
isHorizontal
getisHorizontal()
isVertical
getisVertical()
<div
  class="tabContainer"
  [ngClass]="{ 'hidden-xs': !outletName }"
  #container
>
  @if (showLeft || showRight) {
    <button
      class="tabs-slider tabs-slider-left"
      title="{{ 'Scroll to the left' | translate }}"
      type="button"
      #left
      [disabled]="!showLeft"
      (click)="scroll('left')"
    >
      <i [c8yIcon]="'chevron-left'"></i>
    </button>
  }
  @if (showRight || showLeft) {
    <button
      class="tabs-slider tabs-slider-right"
      title="{{ 'Scroll to the right' | translate }}"
      type="button"
      #right
      [disabled]="!showRight"
      (click)="scroll('right')"
    >
      <i [c8yIcon]="'chevron-right'"></i>
    </button>
  }
  @if (!outletName) {
    <div
      class="nav nav-tabs nav-tabsc8y"
      role="list"
      #tabsContainer
    >
      @for (tab of tabs; track tab) {
        @if (!tab.component && !tab.hide) {
          <div
            role="listitem"
            [attr.data-cy]="'c8y-tab--tab-item-' + tab.label"
            [ngClass]="{ active: rla?.isActive }"
          >
            <a
              [routerLink]="tab.path"
              routerLinkActive
              [queryParamsHandling]="'preserve'"
              #rla="routerLinkActive"
              [ngClass]="{ 'p-r-24': !tab.template && tab?.badge }"
              (click)="tab.onSelect?.emit()"
            >
              @if (!tab.template && tab?.icon) {
                <i [c8yIcon]="tab?.icon"></i>
              }
              @if (!tab.template && !tab.component) {
                <span
                  title="{{ tab?.skipLabelTranslation ? tab?.label : (tab?.label | translate) }}"
                >
                  {{ tab?.skipLabelTranslation ? tab?.label : (tab?.label | translate) }}
                </span>
              }
              @if (!tab.template && tab?.badge) {
                <span
                  class="dashboard-template-marker"
                  tooltip="{{ tab?.tooltipText | translate }}"
                  placement="bottom"
                  container="body"
                  [adaptivePosition]="false"
                  [delay]="300"
                ></span>
              }
            </a>
            <ng-container *ngTemplateOutlet="tab.template; injector: tab.injector"></ng-container>
          </div>
        }
        <ng-container *ngComponentOutlet="tab.component; injector: tab.injector"></ng-container>
      }
    </div>
  }

  @if (outletName) {
    <div
      class="component-tabs nav nav-tabs nav-tabsc8y"
      #tabsContainer
    >
      @for (tab of tabs; track trackByPath($index, tab)) {
        <div
          [ngClass]="{ active: tab.isActive }"
          [routerLink]="tab.path"
          [routerLinkActive]="tab.path ? 'active' : ''"
          [queryParamsHandling]="'preserve'"
        >
          @let tabLabel = tab?.skipLabelTranslation ? tab?.label : (tab?.label | translate);
          @let tabTitle = tab?.title ? tab?.title : (tab?.title | translate);
          <a
            class="pointer"
            title="{{ tabLabel ?? tabTitle }}"
            (click)="tab.onSelect?.emit()"
          >
            @if (tab?.icon && tab?.label) {
              <i [c8yIcon]="tab?.icon"></i>
            }
            @if (tab?.label) {
              <span>{{ tabLabel }}</span>
            }
            <ng-container *ngTemplateOutlet="tab.template; injector: tab.injector"></ng-container>
          </a>
        </div>
      }
    </div>
  }
</div>

@if (!outletName) {
  <div class="visible-xs mobile-tabs">
    <ul class="list-unstyled d-flex m-b-0">
      <li class="c8y-select-wrapper flex-grow">
        <select
          (change)="navigateTo($event.target.value)"
          #select
        >
          @for (tab of tabs; track tab) {
            @if (!tab.component) {
              <option
                [value]="tab.path"
                [selected]="isActive(tab)"
              >
                {{ tab?.skipLabelTranslation ? tab?.label : (tab?.label | translate) }}
              </option>
            }
          }
        </select>
      </li>
      @for (tab of tabs; track tab) {
        @if (tab.component) {
          <ng-container
            *c8yComponentOutlet="tab.component; environmentInjector: tab.injector"
          ></ng-container>
        }
      }
    </ul>
  </div>
}

results matching ""

    No results matching ""