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

#48 MAJ de la valeur dans le champ de saisie d'un paramètre quand on change...

 #48 MAJ de la valeur dans le champ de saisie d'un paramètre quand on change la valeur pointée dans le select
parent fadb25db
No related branches found
No related tags found
1 merge request!22Resolve "Lier des paramètres ou des résultats entre les calculettes"
...@@ -115,6 +115,18 @@ export class NgParamInputComponent extends GenericInputComponent implements Obse ...@@ -115,6 +115,18 @@ export class NgParamInputComponent extends GenericInputComponent implements Obse
this._tmp = data["value"]; this._tmp = data["value"];
this.updateAndValidateUI(); this.updateAndValidateUI();
} }
break;
// changement de valueMode du paramètre ou de valeur à laquelle il est lié
case "valueModeChange":
case "valueLinkChange":
this._tmp = data["value"];
this.updateAndValidateUI();
break;
} }
} }
public ngOnDestroy() {
this._paramDef.removeObserver(this);
}
} }
import { Component, Input, Output, EventEmitter, OnChanges } from "@angular/core"; import { Component, Input, Output, EventEmitter, OnChanges, OnDestroy } from "@angular/core";
import { NgParameter } from "../../formulaire/ngparam"; import { NgParameter } from "../../formulaire/ngparam";
import { ServiceFactory } from "../../services/service-factory"; import { ServiceFactory } from "../../services/service-factory";
...@@ -9,7 +9,8 @@ import { FormulaireService } from "../../services/formulaire/formulaire.service" ...@@ -9,7 +9,8 @@ import { FormulaireService } from "../../services/formulaire/formulaire.service"
selector: "param-link", selector: "param-link",
templateUrl: "./param-link.component.html" templateUrl: "./param-link.component.html"
}) })
export class ParamLinkComponent implements OnChanges, Observer { export class ParamLinkComponent implements OnChanges, Observer, OnDestroy {
// paramètre géré (qui sera lié à une valeur, cad qui importe cette valeur)
@Input("param") @Input("param")
private _param: NgParameter; private _param: NgParameter;
...@@ -116,9 +117,17 @@ export class ParamLinkComponent implements OnChanges, Observer { ...@@ -116,9 +117,17 @@ export class ParamLinkComponent implements OnChanges, Observer {
} }
public ngOnChanges() { public ngOnChanges() {
if (this._param !== undefined)
this._param.removeObserver(this);
this._param.addObserver(this);
this.updateParamList(); this.updateParamList();
} }
public ngOnDestroy() {
this._param.removeObserver(this);
}
// interface Observer // interface Observer
public update(sender: any, data: any) { public update(sender: any, data: any) {
......
...@@ -120,8 +120,15 @@ export class NgParameter extends InputField { ...@@ -120,8 +120,15 @@ export class NgParameter extends InputField {
* crée le lien avec un paramètre * crée le lien avec un paramètre
*/ */
public linkToParameter(n: Nub, p: ParamDefinition) { public linkToParameter(n: Nub, p: ParamDefinition) {
this.valueMode = ParamValueMode.LINK; const changed: boolean = this.paramDefinition.referencedObject !== n || this.paramDefinition.referenceDesc !== p.symbol;
this.paramDefinition.defineReference(n, p.symbol); if (changed) {
this.valueMode = ParamValueMode.LINK;
this._paramDef.defineReference(n, p.symbol);
this.notifyObservers({
"action": "valueLinkChange",
"value": this._paramDef.getValue()
});
}
} }
get isDefined(): boolean { get isDefined(): boolean {
...@@ -144,8 +151,13 @@ export class NgParameter extends InputField { ...@@ -144,8 +151,13 @@ export class NgParameter extends InputField {
public set valueMode(m: ParamValueMode) { public set valueMode(m: ParamValueMode) {
// undefined si on clique en dehors du select après l'avoir ouvert (cad sans avoir fait de sélection) // undefined si on clique en dehors du select après l'avoir ouvert (cad sans avoir fait de sélection)
// et au même niveau, cad à côté du bouton et non à côté du menu déroulant // et au même niveau, cad à côté du bouton et non à côté du menu déroulant
if (m != undefined) if (m !== undefined && this._paramDef.valueMode !== m) {
this._paramDef.valueMode = m; this._paramDef.valueMode = m;
this.notifyObservers({
"action": "valueModeChange",
"value": this._paramDef.getValue()
});
}
} }
public checkMin(min: number): boolean { public checkMin(min: number): boolean {
......
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