File

feature-libs/checkout/components/components/checkout-progress/checkout-progress.component.ts

Metadata

changeDetection ChangeDetectionStrategy.OnPush
selector cx-checkout-progress
templateUrl ./checkout-progress.component.html

Index

Properties
Methods
Accessors

Constructor

constructor(checkoutStepService: CheckoutStepService)
Parameters :
Name Type Optional
checkoutStepService CheckoutStepService No

Methods

getTabIndex
getTabIndex(stepIndex: number)
Parameters :
Name Type Optional
stepIndex number No
Returns : number
isActive
isActive(index: number)
Parameters :
Name Type Optional
index number No
Returns : boolean
isDisabled
isDisabled(index: number)
Parameters :
Name Type Optional
index number No
Returns : boolean

Properties

Private _steps$
Type : BehaviorSubject<CheckoutStep[]>
Default value : this.checkoutStepService.steps$
activeStepIndex
Type : number
activeStepIndex$
Type : Observable<number>
Default value : this.checkoutStepService.activeStepIndex$.pipe( tap((index) => (this.activeStepIndex = index)) )

Accessors

steps$
getsteps$()
import { ChangeDetectionStrategy, Component } from '@angular/core';
import { CheckoutStep } from '@spartacus/checkout/root';
import { BehaviorSubject, Observable } from 'rxjs';
import { tap } from 'rxjs/operators';
import { CheckoutStepService } from '../../services/checkout-step.service';

@Component({
  selector: 'cx-checkout-progress',
  templateUrl: './checkout-progress.component.html',
  changeDetection: ChangeDetectionStrategy.OnPush,
})
export class CheckoutProgressComponent {
  private _steps$: BehaviorSubject<CheckoutStep[]> =
    this.checkoutStepService.steps$;

  constructor(protected checkoutStepService: CheckoutStepService) {}

  activeStepIndex: number;
  activeStepIndex$: Observable<number> =
    this.checkoutStepService.activeStepIndex$.pipe(
      tap((index) => (this.activeStepIndex = index))
    );

  get steps$(): Observable<CheckoutStep[]> {
    return this._steps$.asObservable();
  }

  getTabIndex(stepIndex: number): number {
    return !this.isActive(stepIndex) && !this.isDisabled(stepIndex) ? 0 : -1;
  }

  isActive(index: number): boolean {
    return index === this.activeStepIndex;
  }

  isDisabled(index: number): boolean {
    return index > this.activeStepIndex;
  }
}
<section *ngIf="(activeStepIndex$ | async) !== undefined">
  <div class="cx-nav d-none d-lg-block d-xl-block">
    <ul class="cx-list">
      <ng-container *ngFor="let step of steps$ | async; let i = index">
        <li
          class="cx-item"
          [class.active]="isActive(i)"
          [class.disabled]="isDisabled(i)"
        >
          <a
            [routerLink]="{ cxRoute: step.routeName } | cxUrl"
            class="cx-link"
            [class.active]="isActive(i)"
            [class.disabled]="isDisabled(i)"
            [tabindex]="getTabIndex(i)"
            [innerHTML]="step.name | cxTranslate | cxMultiLine"
          >
          </a>
        </li>
      </ng-container>
    </ul>
  </div>
</section>
Legend
Html element
Component
Html element with directive

result-matching ""

    No results matching ""