Refactor Manage Trigger to Single Workflow (#2577)

* Refactor Manage Trigger to Single Workflow
This commit is contained in:
Alec Merdler 2017-05-22 13:59:12 -07:00 committed by GitHub
parent d122743129
commit 97256841bd
26 changed files with 1262 additions and 1077 deletions

View file

@ -26,10 +26,8 @@ export class LinearWorkflowComponent {
component: component,
});
if (this.sections.length == 1) {
this.currentSection = this.sections[0];
this.currentSection.component.sectionVisible = true;
this.currentSection.component.isCurrentSection = true;
if (this.sections.length > 0 && !this.currentSection) {
this.setNextSection(0);
}
}
@ -39,9 +37,7 @@ export class LinearWorkflowComponent {
}
else if (this.currentSection.component.sectionValid && this.currentSection.index + 1 < this.sections.length) {
this.currentSection.component.isCurrentSection = false;
this.currentSection = this.sections[this.currentSection.index + 1];
this.currentSection.component.sectionVisible = true;
this.currentSection.component.isCurrentSection = true;
this.setNextSection(this.currentSection.index + 1);
}
}
@ -50,6 +46,7 @@ export class LinearWorkflowComponent {
if (invalidSection.index <= this.currentSection.index) {
invalidSection.component.isCurrentSection = true;
this.currentSection = invalidSection;
this.sections.forEach((section) => {
if (section.index > invalidSection.index) {
section.component.sectionVisible = false;
@ -58,6 +55,17 @@ export class LinearWorkflowComponent {
});
}
}
private setNextSection(startingIndex: number = 0): void {
// Find the next section that is not set to be skipped
this.currentSection = this.sections.slice(startingIndex)
.filter(section => !section.component.skipSection)[0];
if (this.currentSection) {
this.currentSection.component.sectionVisible = true;
this.currentSection.component.isCurrentSection = true;
}
}
}