2016-09-20 20:30:39 +02:00
|
|
|
import {Injectable} from "@angular/core";
|
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-20 20:30:39 +02:00
|
|
|
private components:any[] = [];
|
|
|
|
|
|
|
|
public constructor() {
|
|
|
|
}
|
|
|
|
|
|
|
|
public register(component:any):void {
|
|
|
|
this.components.push(component);
|
|
|
|
}
|
|
|
|
|
|
|
|
public getAllComponents():any[] {
|
|
|
|
return this.components;
|
|
|
|
}
|
|
|
|
|
|
|
|
public getNext(component:any):any {
|
|
|
|
let index:number = component.index;
|
|
|
|
if (index == this.components.length - 1) {
|
|
|
|
this.addComponent();
|
|
|
|
}
|
|
|
|
return this.components[index + 1];
|
|
|
|
}
|
|
|
|
|
|
|
|
public getFirst():any {
|
|
|
|
if (this.components.length == 0) {
|
|
|
|
this.addComponent();
|
|
|
|
}
|
|
|
|
return this.components[0];
|
|
|
|
}
|
|
|
|
|
|
|
|
private addComponent():void {
|
|
|
|
this.register({
|
|
|
|
content: "",
|
|
|
|
selectedConverter: undefined,
|
|
|
|
index: this.components.length,
|
|
|
|
error: false,
|
|
|
|
message: ""
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|