Skip to content
Snippets Groups Projects
Commit fadb25db authored by francois.grand's avatar francois.grand
Browse files

#48 ParamLinkComponent : MAJ de la liste des paramètres liables après création d'une calculette

parent 7c34821b
No related branches found
No related tags found
1 merge request!22Resolve "Lier des paramètres ou des résultats entre les calculettes"
......@@ -2,13 +2,14 @@ import { Component, Input, Output, EventEmitter, OnChanges } from "@angular/core
import { NgParameter } from "../../formulaire/ngparam";
import { ServiceFactory } from "../../services/service-factory";
import { ParamValueMode } from "jalhyd";
import { ParamValueMode, Observer } from "jalhyd";
import { FormulaireService } from "../../services/formulaire/formulaire.service";
@Component({
selector: "param-link",
templateUrl: "./param-link.component.html"
})
export class ParamLinkComponent implements OnChanges {
export class ParamLinkComponent implements OnChanges, Observer {
@Input("param")
private _param: NgParameter;
......@@ -31,8 +32,12 @@ export class ParamLinkComponent implements OnChanges {
*/
private _linkableParams: any[];
private _formService: FormulaireService;
constructor() {
this.onValid = new EventEmitter();
this._formService = ServiceFactory.instance.formulaireService;
this._formService.addObserver(this);
}
/**
......@@ -94,13 +99,35 @@ export class ParamLinkComponent implements OnChanges {
}
}
public ngOnChanges() {
this._linkableParams = ServiceFactory.instance.formulaireService.getLinkableParameters(this._param);
private updateParamList() {
// liste des paramètres liables
this._linkableParams = this._formService.getLinkableParameters(this._param);
// initialisation de l'indice courant
if (this._linkableParams.length > 0) {
this.linkTo(0);
if (this._currentIndex === -1)
this.linkTo(0);
this._message = undefined;
}
else
else {
this._currentIndex = -1;
this._message = "Aucun paramètre compatible trouvé";
}
}
public ngOnChanges() {
this.updateParamList();
}
// interface Observer
public update(sender: any, data: any) {
if (sender instanceof FormulaireService) {
switch (data["action"]) {
case "createForm":
this.updateParamList();
break;
}
}
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment