Skip to content
Snippets Groups Projects
Commit fa7fd1b6 authored by François Grand's avatar François Grand
Browse files

feat: solver: set Ytarget to undefined if "empty fields" option is set

refs #601
parent 884d8d3c
No related branches found
No related tags found
2 merge requests!225Release v4.17.0,!203Resolve "Solveur multimodule: le module existe toujours après suppression"
Pipeline #140186 passed
......@@ -412,6 +412,7 @@ export class GenericCalculatorComponent implements OnInit, DoCheck, AfterViewChe
*/
protected afterFirstViewChecked() {
this.updateUIValidity();
this.formulaire.setFirstDisplayCompleted();
}
public onCloseForm() {
......
......@@ -62,6 +62,11 @@ export abstract class FormulaireDefinition extends FormulaireNode implements Obs
*/
protected _calcResults: CalculatorResults[];
/**
* Flag indiquant que le composant calculette est proche de la fin du 1er affichage (1er appel à AfterViewChecked)
*/
private _firstDisplay: boolean = true;
constructor(parent?: FormulaireNode) {
super(parent);
SessionSettings.instance.addObserver(this);
......@@ -81,6 +86,14 @@ export abstract class FormulaireDefinition extends FormulaireNode implements Obs
return this._calculateDisabled;
}
public get isFirstDisplay(): boolean {
return this._firstDisplay;
}
public setFirstDisplayCompleted() {
this._firstDisplay = false;
}
public getPropValue(key: string): any {
if (this._currentNub === undefined)
return this.defaultProperties[key];
......
import { IObservable, ParamDefinition, Nub } from "jalhyd";
import { IObservable, ParamDefinition, Nub, Props, Solveur } from "jalhyd";
import { NgParameter } from "../elements/ngparam";
import { FormulaireFixedVar } from "./form-fixedvar";
import { SelectField } from "../elements/select/select-field";
import { FieldSet } from "../elements/fieldset";
import { ServiceFactory } from "app/services/service-factory";
/**
* Formulaire pour les Solveurs
......@@ -34,6 +35,16 @@ export class FormulaireSolveur extends FormulaireFixedVar {
}
}
public initNub(props?: Props) {
super.initNub(props);
// subscribe to Ytarget to be able to reset it during form construction (with empty fields option set)
// cf. nghyd#601
const n: Solveur = this._currentNub as Solveur;
n.prms.Ytarget.addObserver(this);
}
// interface Observer
public update(sender: IObservable, data: any) {
......@@ -84,6 +95,12 @@ export class FormulaireSolveur extends FormulaireFixedVar {
// refresh parameters selector
this.refreshParameterEntries();
}
} else if (sender instanceof ParamDefinition) {
if (data.action === "paramdefinitionAfterValue" && sender.symbol === "Ytarget") {
if (this.isFirstDisplay && ServiceFactory.applicationSetupService.enableEmptyFieldsOnFormInit) {
sender.setValue(undefined);
}
}
}
}
......
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