Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

i18n buttons and changes for aot i18n ng #11

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 14 additions & 13 deletions src/wizard.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ import { WizardStepComponent } from './wizard-step.component';
<ng-content></ng-content>
</div>
<div class="card-footer" [hidden]="isCompleted">
<button type="button" class="btn btn-secondary float-left" (click)="previous()" [hidden]="!hasPrevStep || !activeStep.showPrev">Previous</button>
<button type="button" class="btn btn-secondary float-right" (click)="next()" [disabled]="!activeStep.isValid" [hidden]="!hasNextStep || !activeStep.showNext">Next</button>
<button type="button" class="btn btn-secondary float-right" (click)="complete()" [disabled]="!activeStep.isValid" [hidden]="hasNextStep">Done</button>
<button type="button" class="btn btn-secondary float-left" (click)="previous()" [hidden]="!hasPrevStep || !activeStep.showPrev" i18n>Previous</button>
<button type="button" class="btn btn-secondary float-right" (click)="next()" [disabled]="!activeStep.isValid" [hidden]="!hasNextStep || !activeStep.showNext" i18n>Next</button>
<button type="button" class="btn btn-secondary float-right" (click)="complete()" [disabled]="!activeStep.isValid" [hidden]="hasNextStep" i18n>Done</button>
</div>
</div>`
,
Expand All @@ -33,13 +33,13 @@ import { WizardStepComponent } from './wizard-step.component';
'.disabled { color: #ccc; }',
'.completed { cursor: default; }'
]
})
})
export class WizardComponent implements OnInit, AfterContentInit {
@ContentChildren(WizardStepComponent)
wizardSteps: QueryList<WizardStepComponent>;

private _steps: Array<WizardStepComponent> = [];
private _isCompleted: boolean = false;
private _steps: Array<WizardStepComponent> = [];
private _isCompleted: boolean = false;

@Output()
onStepChanged: EventEmitter<WizardStepComponent> = new EventEmitter<WizardStepComponent>();
Expand All @@ -54,35 +54,35 @@ export class WizardComponent implements OnInit, AfterContentInit {
this.steps[0].isActive = true;
}

private get steps(): Array<WizardStepComponent> {
get steps(): Array<WizardStepComponent> {
return this._steps.filter(step => !step.hidden);
}

private get isCompleted(): boolean {
get isCompleted(): boolean {
return this._isCompleted;
}

private get activeStep(): WizardStepComponent {
get activeStep(): WizardStepComponent {
return this.steps.find(step => step.isActive);
}

private set activeStep(step: WizardStepComponent) {
set activeStep(step: WizardStepComponent) {
if (step !== this.activeStep && !step.isDisabled) {
this.activeStep.isActive = false;
step.isActive = true;
this.onStepChanged.emit(step);
}
}

private get activeStepIndex(): number {
get activeStepIndex(): number {
return this.steps.indexOf(this.activeStep);
}

private get hasNextStep(): boolean {
get hasNextStep(): boolean {
return this.activeStepIndex < this.steps.length - 1;
}

private get hasPrevStep(): boolean {
get hasPrevStep(): boolean {
return this.activeStepIndex > 0;
}

Expand Down Expand Up @@ -116,3 +116,4 @@ export class WizardComponent implements OnInit, AfterContentInit {
}

}