This repository has been archived on 2020-03-24. You can view files and clone it, but cannot push or open issues or pull requests.
quay/static/js/directives/ui/linear-workflow/linear-workflow.component.ts

57 lines
1.4 KiB
TypeScript
Raw Normal View History

2017-02-20 02:35:46 +00:00
import { Component, Output, Input } from 'angular-ts-decorators';
2017-02-21 23:59:26 +00:00
import { LinearWorkflowSectionComponent } from './linear-workflow-section.component';
2017-02-20 02:35:46 +00:00
2017-02-21 23:59:26 +00:00
/**
* A component that which displays a linear workflow of sections, each completed in order before the next
* step is made visible.
*/
2017-02-20 02:35:46 +00:00
@Component({
selector: 'linearWorkflow',
2017-02-21 23:59:26 +00:00
templateUrl: '/static/js/directives/ui/linear-workflow/linear-workflow.component.html',
transclude: true
2017-02-20 02:35:46 +00:00
})
export class LinearWorkflowComponent implements ng.IComponentController {
2017-02-21 23:59:26 +00:00
@Input('@') public doneTitle: string;
@Output() public onWorkflowComplete: (event: any) => void;
private sections: SectionInfo[] = [];
private currentSection: SectionInfo;
constructor() {
}
public $onInit(): void {
}
public addSection(section: LinearWorkflowSectionComponent): void {
this.sections.push({
index: this.sections.length,
section: section,
});
}
public onNextSection(): void {
if (this.currentSection.section.sectionValid) {
if (this.currentSection.index + 1 >= this.sections.length) {
this.onWorkflowComplete({});
}
else {
this.currentSection = this.sections[this.currentSection.index];
}
}
}
}
/**
* A type representing a section of the linear workflow.
*/
export type SectionInfo = {
index: number;
section: LinearWorkflowSectionComponent;
2017-02-20 02:35:46 +00:00
}