clr-angular-static-fix
Version:
1. Install Clarity Icons package through npm:
80 lines (66 loc) • 2.28 kB
text/typescript
/*
* Copyright (c) 2016-2018 VMware, Inc. All Rights Reserved.
* This software is released under MIT license.
* The full license information can be found in LICENSE in the root directory of this project.
*/
import { Component, Input } from '@angular/core';
import { PageCollectionService } from './providers/page-collection.service';
import { WizardNavigationService } from './providers/wizard-navigation.service';
import { ClrWizardPage } from './wizard-page';
export class ClrWizardStepnavItem {
public page: ClrWizardPage;
constructor(public navService: WizardNavigationService, public pageCollection: PageCollectionService) {}
private pageGuard(): void {
if (!this.page) {
throw new Error('Wizard stepnav item is not associated with a wizard page.');
}
}
public get id(): string {
this.pageGuard();
return this.pageCollection.getStepItemIdForPage(this.page);
}
public get isDisabled(): boolean {
this.pageGuard();
return this.page.disabled || this.navService.wizardStopNavigation || this.navService.wizardDisableStepnav;
}
public get isCurrent(): boolean {
this.pageGuard();
return this.page.current;
}
public get isComplete(): boolean {
this.pageGuard();
return this.page.completed;
}
public get canNavigate(): boolean {
this.pageGuard();
return this.pageCollection.previousPageIsCompleted(this.page);
}
click(): void {
this.pageGuard();
// if we click on our own stepnav or a disabled stepnav, we don't want to do anything
if (this.isDisabled || this.isCurrent) {
return;
}
this.navService.goTo(this.page);
}
}