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

Patch lifecycle issue when switching from a PreBarrage to another

parent 9be37a78
No related branches found
No related tags found
No related merge requests found
......@@ -81,9 +81,13 @@
fxFlex.lt-md="1 0 500px"
fxFlex.lt-sm="1 0 300px">
<pb-schema [pbSchema]="formElements[0]" (radio)=onRadioClick($event)
(validChange)=onElementValid() (nodeSelected)="onPBNodeSelected($event)">
</pb-schema>
<!-- without this loop, injecting formElements[0] in <pb-schema> makes it not
trigger lifecycle hooks when switching from a PreBarrage module to another… -->
<ng-template ngFor let-fe [ngForOf]="formElements">
<pb-schema *ngIf="isPbSchema(fe)" [pbSchema]="fe" (radio)=onRadioClick($event)
(validChange)=onElementValid() (nodeSelected)="onPBNodeSelected($event)">
</pb-schema>
</ng-template>
<div fxHide.sm fxFlex.gt-sm="0 0 16px"></div>
</div>
......
......@@ -2,12 +2,12 @@ import { Component, Input, Output, EventEmitter, OnInit, AfterViewInit, ViewChil
import { MatDialog } from "@angular/material/dialog";
import {
PreBarrage, PbBassin, PbBassinParams, PbCloison, CreateStructure, LoiDebit, Structure, Observer, IObservable
PreBarrage, PbBassin, PbBassinParams, PbCloison, Observer, IObservable
} from "jalhyd";
import * as mermaid from "mermaid";
import { HotkeysService, Hotkey } from 'angular2-hotkeys';
import { HotkeysService, Hotkey } from "angular2-hotkeys";
import { I18nService } from "../../services/internationalisation.service";
import { PbSchema } from "../../formulaire/elements/pb-schema";
......@@ -115,10 +115,12 @@ export class PbSchemaComponent implements AfterViewInit, AfterContentInit, OnIni
}
public ngAfterViewInit(): void {
this.refreshEventListeners();
this.updateValidity();
// subscribe to "refresh" event passed indirectly by FormulairePbCloison (change upstream/downstream basin)
this.pbSchema.addObserver(this);
// @WARNING clodo trick to prevent blank diagram when switching from a PreBarrage to another
setTimeout(() => {
this.refresh();
}, 10);
}
/** Add click listener on every node and link in the graph */
......@@ -360,6 +362,7 @@ export class PbSchemaComponent implements AfterViewInit, AfterContentInit, OnIni
public onCopyClick() {
const wall = this._selectedItem as PbCloison;
const wallCopy = new PbCloison(wall.bassinAmont, wall.bassinAval);
wallCopy.loadObjectRepresentation(wall.objectRepresentation());
this.model.addChild(wallCopy);
this.unselect();
this.refresh();
......
......@@ -446,12 +446,6 @@ export abstract class FormulaireDefinition extends FormulaireNode implements Obs
return new TopFormulaireElementIterator(this);
}
/**
* Appelé par CalculatorComponent lorsque le Formulaire est chargé dans la vue,
* c'est à dire lorsqu'on affiche un module de calcul à l'écran
*/
public onCalculatorInit() {}
// interface Observer
public update(sender: any, data: any) {
......
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