2016-09-20 20:30:39 +02:00
|
|
|
import {Injectable} from "@angular/core";
|
2016-09-22 00:15:11 +02:00
|
|
|
import {Step} from "./step";
|
2016-09-20 22:34:31 +02:00
|
|
|
|
2016-09-20 20:30:39 +02:00
|
|
|
@Injectable()
|
2016-09-20 22:34:31 +02:00
|
|
|
export class InputComponentManagerService {
|
2016-09-22 00:15:11 +02:00
|
|
|
private components:Step[] = [];
|
2016-09-20 20:30:39 +02:00
|
|
|
|
|
|
|
public constructor() {
|
|
|
|
}
|
|
|
|
|
2016-09-22 00:15:11 +02:00
|
|
|
public register(component:Step):void {
|
2016-09-20 20:30:39 +02:00
|
|
|
this.components.push(component);
|
|
|
|
}
|
|
|
|
|
2016-09-22 00:15:11 +02:00
|
|
|
public getAllComponents():Step[] {
|
2016-09-20 20:30:39 +02:00
|
|
|
return this.components;
|
|
|
|
}
|
|
|
|
|
2016-09-22 00:15:11 +02:00
|
|
|
public getNext(component:Step):Step {
|
2016-09-20 20:30:39 +02:00
|
|
|
let index:number = component.index;
|
|
|
|
if (index == this.components.length - 1) {
|
|
|
|
this.addComponent();
|
|
|
|
}
|
|
|
|
return this.components[index + 1];
|
|
|
|
}
|
|
|
|
|
2016-09-22 00:15:11 +02:00
|
|
|
public getFirst():Step {
|
2016-09-20 20:30:39 +02:00
|
|
|
if (this.components.length == 0) {
|
|
|
|
this.addComponent();
|
|
|
|
}
|
|
|
|
return this.components[0];
|
|
|
|
}
|
|
|
|
|
|
|
|
private addComponent():void {
|
2016-09-22 00:15:11 +02:00
|
|
|
this.register(new Step(this.components.length));
|
2016-09-20 20:30:39 +02:00
|
|
|
}
|
|
|
|
}
|