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

Branchement des FormControl Angular sur le validateur maison

parent c8e09064
No related branches found
No related tags found
1 merge request!29Resolve "Remplacer mdbootstrap par angular-material"
......@@ -2,10 +2,6 @@
<form [formGroup]="loadSessionForm">
<!-- <input type="file" required [(ngModel)]="file"
name="fileSelection" #fileSelection="ngModel"> -->
<div mat-dialog-content>
<mat-form-field>
......
<div class="fixed-results-container" *ngIf="hasFixedParameters">
<!-- table des résultats fixés -->
<table mat-table [dataSource]="dataSet">
......@@ -14,7 +13,5 @@
<tr mat-header-row *matHeaderRowDef="tableColumns"></tr>
<tr mat-row *matRowDef="let row; columns: tableColumns;"></tr>
<!-- <tr *ngIf="hasParameterResult" vertical-result-element [result-element]=resultElement [_label]=resultLabel> -->
</table>
</div>
......@@ -44,6 +44,10 @@ mat-card {
&#calc-card-results {
margin-left: 1em;
margin-right: 1em;
mat-card-header {
margin-bottom: 1em;
}
}
// @WARNING ::ng-deep est déprécié, mais y a rien d'autre pour
......
<mat-form-field>
<input matInput class="form-control" type="text" inputmode="numeric"
[id]="inputId" [disabled]="isDisabled" [(ngModel)]="uiValue" [placeholder]="title"
required>
<input matInput #inputControl="ngModel" class="form-control" type="text" inputmode="numeric"
[id]="inputId" [name]="inputId" [disabled]="isDisabled" [(ngModel)]="uiValue" [placeholder]="title"
pattern="-?([0-9]+\.)?[0-9]+" required>
<mat-error>{{ errorMessage }}</mat-error>
</mat-form-field>
import { Input, Output, EventEmitter, ChangeDetectorRef, OnChanges } from "@angular/core";
import { Input, Output, EventEmitter, ChangeDetectorRef, OnChanges, ViewChild } from "@angular/core";
import { NgModel } from "@angular/forms";
import { BaseComponent } from "../base/base.component";
import { isNumeric } from "jalhyd";
......@@ -75,6 +75,8 @@ export abstract class GenericInputComponent extends BaseComponent implements OnC
*/
private _errorMessageModel: string;
@ViewChild("inputControl") inputField: NgModel;
constructor(private cdRef: ChangeDetectorRef) {
super();
// generate "unique" input id
......@@ -132,6 +134,12 @@ export abstract class GenericInputComponent extends BaseComponent implements OnC
if (this.isValid !== old) {
this.emitValidChanged();
}
// répercussion des erreurs sur le Form angular, pour faire apparaître/disparaître les mat-error
if (b) {
this.inputField.control.setErrors(null);
} else {
this.inputField.control.setErrors({ "incorrect": true });
}
}
private validateModel() {
......
......@@ -2,7 +2,7 @@
import { Component, ChangeDetectorRef, OnDestroy } from "@angular/core";
import { isNumeric, Message, Observer } from "jalhyd";
import { Message, Observer } from "jalhyd";
import { I18nService } from "../../services/internationalisation/internationalisation.service";
import { NgParameter } from "../../formulaire/ngparam";
......
......@@ -7,6 +7,8 @@ import { LogComponent } from "../../components/log/log.component";
import { RemousResults } from "../../results/remous-results";
import { CalculatorResults } from "../../results/calculator-results";
import { VarResultsComponent } from "../fixedvar-results/var-results.component";
import { ApplicationSetupService } from "../../services/app-setup/app-setup.service";
import { ServiceFactory } from "../../services/service-factory";
/**
* données pour une ligne dans le graphe
......@@ -32,6 +34,8 @@ class LineData {
*/
private _data = {};
private appSetup: ApplicationSetupService;
/**
* profondeur à laquelle est dessinée la ligne
* les profondeurs les plus petites sont dessinées derrière les profondeurs les plus grandes
......@@ -44,6 +48,7 @@ class LineData {
for (let i = this._tx.length - 1; i >= 0; i--) {
this._ty.push(null);
}
this.appSetup = ServiceFactory.instance.applicationSetupService;
}
public getYat(x: number) {
......
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