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

correction du message d'erreur console...

correction du message d'erreur console ExpressionChangedAfterItHasBeenCheckedError concernant la classe CSS de la calculette active dans la barre de navigation supérieure
parent 1c976d87
No related branches found
No related tags found
No related merge requests found
import { Component, ApplicationRef } from '@angular/core';
//import { Component, ChangeDetectorRef, ApplicationRef, AfterViewChecked } from '@angular/core';
import { Component, ApplicationRef, OnInit, OnDestroy } from '@angular/core';
//import { MdDialog } from '@angular/material';
import { Router } from '@angular/router';
import { setTimeout } from 'timers';
import { ComputeNodeType, ComputeNode } from 'jalhyd';
......@@ -12,7 +12,6 @@ import { ErrorService } from './services/error/error.service';
// import { AlertDialog } from './components/alert-dialog/alert-dialog.component';
import { FormulaireService } from './services/formulaire/formulaire.service';
import { FormulaireDefinition, CalculatorType } from './formulaire/formulaire-definition';
import { OnInit, OnDestroy } from '@angular/core/src/metadata/lifecycle_hooks';
@Component({
......@@ -25,6 +24,12 @@ export class AppComponent implements OnInit, OnDestroy, Observer {
private _calculators: any[] = [];
/**
* id du formulaire courant
* on utilise pas directement FormulaireService.currentFormId pour éviter l'erreur ExpressionChangedAfterItHasBeenCheckedError
*/
private _currentFormId: number;
// constructor(private intlService: InternationalisationService, private appRef: ApplicationRef, private dialog: MdDialog, private errorService: ErrorService) { }
constructor(private intlService: InternationalisationService,
private appRef: ApplicationRef,
......@@ -115,6 +120,16 @@ export class AppComponent implements OnInit, OnDestroy, Observer {
this.toList();
break;
case "currentFormChanged":
/*
utilisation de setTimeout() pour éviter le message console ExpressionChangedAfterItHasBeenCheckedError
relatif au getter getHighlightClass() (qui change de valeur quand le formulaire courant change)
*/
setTimeout(() => {
this._currentFormId = data["formId"];
}, 1);
break;
case "closeForm":
const form: FormulaireDefinition = data["form"];
this.closeCalculator(form);
......@@ -182,8 +197,10 @@ export class AppComponent implements OnInit, OnDestroy, Observer {
// MAJ affichage
if (newId == -1)
if (newId == -1) {
this.toList();
this._currentFormId = -1;
}
else
this.toCalc(newId);
}
......@@ -197,7 +214,7 @@ export class AppComponent implements OnInit, OnDestroy, Observer {
}
private getHighlightClass(uid: number) {
return uid == this.formulaireService.currentFormId ? "blue darken-2" : "";
return uid == this._currentFormId ? "blue darken-2" : "";
}
// flag d'affichage des repères des colonnes Bootstrap : uniquement en mode dev
......
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