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

Fix #181 - prevent setting param to Calc mode when it would trigger a links loop

parent c20128d4
No related branches found
No related tags found
1 merge request!82Resolve "Ajout de la fonctionnalité "Respect des critères""
Pipeline #138296 canceled
......@@ -38,7 +38,7 @@
</mat-button-toggle>
<mat-button-toggle class="radio_cal" value="radio_cal" *ngIf="hasRadioCal()" (click)="onRadioClick('cal')"
[checked]="isRadioCalChecked">
[checked]="isRadioCalChecked" [disabled]="isRadioCalDisabled" [title]="radioCalTitle">
<span fxHide.xxs>{{ uitextParamCalculer }}</span>
<span fxHide.gt-xxs>C</span>
</mat-button-toggle>
......
......@@ -199,6 +199,30 @@ export class ParamFieldLineComponent implements OnChanges {
return ret;
}
/**
* Returns true if setting this parameter to Calc mode leads to a links loop
*/
public get isRadioCalDisabled(): boolean {
// find all Nubs that have to be calculated for this one to run
const nub = this.param.paramDefinition.originNub;
const requiredNubs = nub.getRequiredNubsDeep();
// if one of those Nubs depends on the parameter we're about to set
// to Calc mode, then we shouldn't do so
for (const r of requiredNubs) {
if (r.dependsOnParameter(this.param.paramDefinition)) {
return true;
}
}
return false;
}
public get radioCalTitle(): string {
if (this.isRadioCalDisabled) {
return this.intlService.localizeText("INFO_PARAMFIELD_CANNOT_CALC_LINKS_LOOP");
}
return "";
}
public onRadioClick(option: string) {
const oldValue = this.param.valueMode;
switch (option) {
......
......@@ -454,6 +454,7 @@
"INFO_PARAMFIELD_BOUNDARY_CONDITIONS": "Boundary conditions",
"INFO_PARAMFIELD_CALCULATED": "Calculated",
"INFO_PARAMFIELD_CALCULATION_FAILED": "Calculation failed",
"INFO_PARAMFIELD_CANNOT_CALC_LINKS_LOOP": "This parameter cannot be calculated (links loop)",
"INFO_PARAMFIELD_CHART_SELECT_X_AXIS": "Variable for X axis",
"INFO_PARAMFIELD_CHART_SELECT_Y_AXIS": "Variable for Y axis",
"INFO_PARAMFIELD_CHART_TYPE_HISTOGRAM": "Histogram",
......
......@@ -455,6 +455,7 @@
"INFO_PARAMFIELD_BOUNDARY_CONDITIONS": "Conditions aux limites",
"INFO_PARAMFIELD_CALCULATED": "Calculé",
"INFO_PARAMFIELD_CALCULATION_FAILED": "Échec du calcul",
"INFO_PARAMFIELD_CANNOT_CALC_LINKS_LOOP": "Ce paramètre ne peut être calculé (boucle dans les liens)",
"INFO_PARAMFIELD_CHART_SELECT_X_AXIS": "Variable en abscisse",
"INFO_PARAMFIELD_CHART_SELECT_Y_AXIS": "Variable en ordonnée",
"INFO_PARAMFIELD_CHART_TYPE_HISTOGRAM": "Histogramme",
......
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