Skip to content
Snippets Groups Projects
Commit ab837b45 authored by mathias.chouet's avatar mathias.chouet
Browse files

PreBarrage: remember selected schema node and displayed panel (input or results)

parent 456bc381
No related branches found
No related tags found
1 merge request!93Resolve "Ajout du module Prébarrage"
...@@ -125,9 +125,6 @@ export class GenericCalculatorComponent implements OnInit, DoCheck, AfterViewChe ...@@ -125,9 +125,6 @@ export class GenericCalculatorComponent implements OnInit, DoCheck, AfterViewChe
/** Allows trigerring afterFirstViewChecked() just after calculator is loaded */ /** Allows trigerring afterFirstViewChecked() just after calculator is loaded */
private firstViewChecked = false; private firstViewChecked = false;
/** For PreBarrage only: if true, show input data in the right panel, else show results */
public showPBInputData = true;
public get ID() { public get ID() {
if (this._formulaire) { if (this._formulaire) {
return this._formulaire.uid; return this._formulaire.uid;
...@@ -136,6 +133,21 @@ export class GenericCalculatorComponent implements OnInit, DoCheck, AfterViewChe ...@@ -136,6 +133,21 @@ export class GenericCalculatorComponent implements OnInit, DoCheck, AfterViewChe
} }
} }
/** For PreBarrage only: if true, show input data in the right panel, else show results */
public get showPBInputData(): boolean {
if (this.isPB) {
return (this._formulaire as FormulairePrebarrage).showInputData;
} else {
return false; // whatever, should never happen
}
}
public set showPBInputData(v: boolean) {
if (this.isPB) {
(this._formulaire as FormulairePrebarrage).showInputData = v;
} // else do nothing, should never happen
}
constructor( constructor(
@Inject(forwardRef(() => AppComponent)) private appComponent: AppComponent, @Inject(forwardRef(() => AppComponent)) private appComponent: AppComponent,
private route: ActivatedRoute, private route: ActivatedRoute,
......
import { Component, ViewChild, ElementRef } from "@angular/core"; import { Component, ViewChild, ElementRef } from "@angular/core";
import { PreBarrage, PbBassin } from "jalhyd"; import { PreBarrage, PbBassin, ParamDefinition, ParamValueMode } from "jalhyd";
import { I18nService } from "../../services/internationalisation.service"; import { I18nService } from "../../services/internationalisation.service";
import { ResultsComponentDirective } from "../fixedvar-results/results.component"; import { ResultsComponentDirective } from "../fixedvar-results/results.component";
...@@ -35,6 +35,26 @@ export class PbResultsTableComponent extends ResultsComponentDirective { ...@@ -35,6 +35,26 @@ export class PbResultsTableComponent extends ResultsComponentDirective {
super(); super();
} }
/**
* Returns value at index i for parameter p, whether it is variating
* or not, calculated or not
* @param p parameter
* @param i index
*/
protected getIthValue(p: ParamDefinition, i: number): string {
let value: number;
if (p.hasMultipleValues) {
if (p.valueMode === ParamValueMode.CALCUL) {
value = p.parentNub.result.resultElements[i].vCalc;
} else {
value = p.getInferredValuesList()[i];
}
} else {
value = p.V;
}
return fv(value);
}
public set results(r: PrebarrageResults) { public set results(r: PrebarrageResults) {
this._pbResults = r; this._pbResults = r;
...@@ -51,6 +71,8 @@ export class PbResultsTableComponent extends ResultsComponentDirective { ...@@ -51,6 +71,8 @@ export class PbResultsTableComponent extends ResultsComponentDirective {
// values to build the data from // values to build the data from
const vi = pr.variableIndex; const vi = pr.variableIndex;
// @TODO results.size ? To extend values lists…
// refresh headers here if language changed // refresh headers here if language changed
this._headers = pr.headers; this._headers = pr.headers;
...@@ -59,9 +81,9 @@ export class PbResultsTableComponent extends ResultsComponentDirective { ...@@ -59,9 +81,9 @@ export class PbResultsTableComponent extends ResultsComponentDirective {
this._dataSet.push([ this._dataSet.push([
this.intlService.localizeText("INFO_LIB_AMONT"), this.intlService.localizeText("INFO_LIB_AMONT"),
"", "", "", "",
fv(pb.prms.Z1.V), this.getIthValue(pb.prms.Z1, vi),
"", "", "", "",
fv(pb.prms.Q.V) this.getIthValue(pb.prms.Q, vi),
]); ]);
} }
...@@ -89,9 +111,9 @@ export class PbResultsTableComponent extends ResultsComponentDirective { ...@@ -89,9 +111,9 @@ export class PbResultsTableComponent extends ResultsComponentDirective {
this._dataSet.push([ this._dataSet.push([
this.intlService.localizeText("INFO_LIB_AVAL"), this.intlService.localizeText("INFO_LIB_AVAL"),
"", "", "", "",
fv(pb.prms.Z2.V), this.getIthValue(pb.prms.Z2, vi),
"", "", "", "",
fv(pb.prms.Q.V) this.getIthValue(pb.prms.Q, vi),
]); ]);
} }
} }
......
...@@ -84,11 +84,15 @@ export class PbSchemaComponent implements AfterViewInit, AfterContentInit, OnIni ...@@ -84,11 +84,15 @@ export class PbSchemaComponent implements AfterViewInit, AfterContentInit, OnIni
}); });
this.nativeElement = this.schema.nativeElement; this.nativeElement = this.schema.nativeElement;
this.render(); this.render();
// reset form to river properties (clodo timeout to prevent ExpressionChangedAfterItHasBeenCheckedError) // restore previously selected item
setTimeout(() => { this._selectedItem = this.pbSchema.form.selectedItem;
this.unselect(); if (this._selectedItem !== undefined) {
}, 10); // @WARNING clodo timeout to prevent ExpressionChangedAfterItHasBeenCheckedError
// @TODO find a way to remember last selected item ? Through a service ? // and select schema node after schema is refreshed by ngAfterViewInit()
setTimeout(() => {
this.selectNodeOnSchema(this._selectedItem);
}, 20); // timeout has to be greater than the 10ms of ngAfterViewInit()
}
} }
private render() { private render() {
...@@ -497,7 +501,6 @@ export class PbSchemaComponent implements AfterViewInit, AfterContentInit, OnIni ...@@ -497,7 +501,6 @@ export class PbSchemaComponent implements AfterViewInit, AfterContentInit, OnIni
this.model.hasUpDownConnection() this.model.hasUpDownConnection()
&& ! this.model.hasBasinNotConnected() && ! this.model.hasBasinNotConnected()
); );
console.log("schéma valide", this._isValid);
this.validChange.emit(); this.validChange.emit();
} }
......
...@@ -31,14 +31,17 @@ export class FormulairePrebarrage extends FormulaireFixedVar { ...@@ -31,14 +31,17 @@ export class FormulairePrebarrage extends FormulaireFixedVar {
protected _pbResults: PrebarrageResults; protected _pbResults: PrebarrageResults;
/** if true, show input data in the right panel, else show results */
public showInputData = true;
constructor() { constructor() {
super(); super();
this._pbResults = new PrebarrageResults(); this._pbResults = new PrebarrageResults();
} }
/* public get pbNub(): PreBarrage { public get selectedItem(): PbBassin | PbCloison {
return this.currentNub as PreBarrage; return this._selectedItem;
} */ }
public get pbResults(): PrebarrageResults { public get pbResults(): PrebarrageResults {
return this._pbResults; return this._pbResults;
......
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