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

correction des messages console 'ExpressionChangedAfterItHasBeenCheck'

parent 54fd3062
No related branches found
No related tags found
1 merge request!12Resolve "Ajout de la calculette "Ouvrages hydrauliques""
Showing with 49 additions and 31 deletions
......@@ -44,8 +44,8 @@ export class NgBaseParam extends Observable {
templateUrl: "../generic-input/generic-input.component.html",
})
export class BaseParamInputComponent extends GenericInputComponent {
constructor(private intlService: InternationalisationService) {
super();
constructor(private intlService: InternationalisationService, cdRef: ChangeDetectorRef) {
super(cdRef);
}
/**
......
import { Output, EventEmitter, AfterViewChecked } from "@angular/core";
import { Output, EventEmitter, AfterViewChecked, OnChanges } from "@angular/core";
export abstract class BaseComponent implements AfterViewChecked {
export abstract class BaseComponent implements AfterViewChecked, OnChanges {
/**
* true après le 1er affichage du composant
*/
......@@ -32,8 +32,12 @@ export abstract class BaseComponent implements AfterViewChecked {
}
}
public ngOnChanges() {
}
/**
* appelé une fois, après l'affichage complet du composant
*/
protected abstract afterFirstViewChecked();
protected afterFirstViewChecked() {
}
}
\ No newline at end of file
import { Input, Output, EventEmitter } from "@angular/core";
import { Input, Output, EventEmitter, ChangeDetectorRef } from "@angular/core";
import { BaseComponent } from "../base/base.component";
......@@ -79,6 +79,10 @@ export abstract class GenericInputComponent extends BaseComponent {
*/
private _errorMessageModel: string;
constructor(private cdRef: ChangeDetectorRef) {
super();
}
private get isDisabled(): boolean {
return this._inputDisabled;
}
......@@ -90,6 +94,14 @@ export abstract class GenericInputComponent extends BaseComponent {
this.onChange.emit({ "action": "valid", "value": this.isValid });
}
/**
* détection des changements dans l'UI par le ChangeDetector du framework
*/
protected detectChanges() {
if (this.cdRef != undefined)
this.cdRef.detectChanges();
}
/**
* calcul de la validité globale du composant (UI+modèle)
*/
......@@ -107,6 +119,7 @@ export abstract class GenericInputComponent extends BaseComponent {
private validateUI() {
let { isValid, message } = this.validateUIValue(this._uiValue);
this._errorMessageUI = message;
this.detectChanges();
this.setUIValid(isValid);
return isValid;
}
......@@ -121,6 +134,7 @@ export abstract class GenericInputComponent extends BaseComponent {
private validateModel() {
let { isValid, message } = this.validateModelValue(this.getModelValue());
this._errorMessageModel = message;
this.detectChanges();
this.setModelValid(isValid);
}
......@@ -162,6 +176,7 @@ export abstract class GenericInputComponent extends BaseComponent {
this._model = v;
this.afterSetModel();
this.updateAll();
this.detectChanges();
}
/**
......@@ -192,10 +207,9 @@ export abstract class GenericInputComponent extends BaseComponent {
}
/**
* appelé après le 1er affichage du composant
* @see BaseComponent
* appelé quand les @Input changent
*/
protected afterFirstViewChecked() {
public ngOnChanges() {
this.updateAll();
}
......
......@@ -28,13 +28,13 @@ export class NgParamInputComponent extends GenericInputComponent implements Obse
*/
private _tmp: number;
constructor(private intlService: InternationalisationService) {
super();
constructor(private intlService: InternationalisationService, cdRef: ChangeDetectorRef) {
super(cdRef);
}
/**
* appelé avant le changement de modèle
*/
* appelé avant le changement de modèle
*/
protected beforeSetModel() {
if (this._paramDef != undefined)
this._paramDef.removeObserver(this);
......
import { Component, ViewChild, Input, Output, EventEmitter, AfterViewChecked } from "@angular/core";
import { Component, ViewChild, Input, Output, EventEmitter, OnChanges } from "@angular/core";
import { InternationalisationService } from "../../services/internationalisation/internationalisation.service";
import { NgParameter, ParamRadioConfig } from "../../formulaire/ngparam";
......@@ -25,7 +25,7 @@ import { FormulaireService } from "../../services/formulaire/formulaire.service"
}`
]
})
export class ParamFieldLineComponent implements AfterViewChecked {
export class ParamFieldLineComponent implements OnChanges {
@Input("param")
private _param: NgParameter;
......@@ -257,7 +257,7 @@ export class ParamFieldLineComponent implements AfterViewChecked {
this.emitValidity()
}
public ngAfterViewChecked() {
public ngOnChanges() {
this._ngParamInputComponent.model = this._param;
this._ngParamInputComponent.showError = this.isRadioFixChecked;
}
......
import { Component, Input } from "@angular/core";
import { Component, Input, ChangeDetectorRef } from "@angular/core";
import { NumericalString } from "jalhyd";
......@@ -11,8 +11,8 @@ import { NgParameter } from "../../formulaire/ngparam";
templateUrl: "../generic-input/generic-input.component.html"
})
export class NgParamMaxComponent extends GenericInputComponent {
constructor(private intlService: InternationalisationService) {
super();
constructor(private intlService: InternationalisationService, cdRef: ChangeDetectorRef) {
super(cdRef);
}
/**
......
import { Component, Input } from "@angular/core";
import { Component, Input, ChangeDetectorRef } from "@angular/core";
import { NumericalString } from "jalhyd";
......@@ -11,8 +11,8 @@ import { NgParameter } from "../../formulaire/ngparam";
templateUrl: "../generic-input/generic-input.component.html"
})
export class NgParamMinComponent extends GenericInputComponent {
constructor(private intlService: InternationalisationService) {
super();
constructor(private intlService: InternationalisationService, cdRef: ChangeDetectorRef) {
super(cdRef);
}
/**
......
import { Component, Input } from "@angular/core";
import { Component, Input, ChangeDetectorRef } from "@angular/core";
import { NumericalString } from "jalhyd";
......@@ -11,8 +11,8 @@ import { NgParameter } from "../../formulaire/ngparam";
templateUrl: "../generic-input/generic-input.component.html"
})
export class NgParamStepComponent extends GenericInputComponent {
constructor(private intlService: InternationalisationService) {
super();
constructor(private intlService: InternationalisationService, cdRef: ChangeDetectorRef) {
super(cdRef);
}
/**
......
......@@ -317,10 +317,10 @@ export class ParamValuesComponent extends BaseComponent implements AfterViewChec
this._param.valueMode = next;
}
/**
* appelé au 1er affichage du composant
/**
* appelé quand les @Input changent
*/
protected afterFirstViewChecked() {
ngOnChanges() {
if (this.isMinMax)
this._doInitMinmax = true;
else
......
import { Component, Input } from "@angular/core";
import { Component, Input, ChangeDetectorRef } from "@angular/core";
import { GenericInputComponent } from "../generic-input/generic-input.component";
import { InternationalisationService } from "../../services/internationalisation/internationalisation.service";
......@@ -10,8 +10,8 @@ import { Message } from "jalhyd";
templateUrl: "../generic-input/generic-input.component.html"
})
export class ValueListComponent extends GenericInputComponent {
constructor(private intlService: InternationalisationService) {
super();
constructor(private intlService: InternationalisationService, cdRef: ChangeDetectorRef) {
super(cdRef);
}
/**
......
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