diff --git a/src/app/app.module.ts b/src/app/app.module.ts index 059c34d50c5b202c8865a3ab6fe161f492104f85..3367199a616e52e5bead36943bb476fd693e52c1 100644 --- a/src/app/app.module.ts +++ b/src/app/app.module.ts @@ -77,6 +77,7 @@ import { DialogConfirmEmptySessionComponent } from "./components/dialog-confirm- import { DialogConfirmCloseCalcComponent } from "./components/dialog-confirm-close-calc/dialog-confirm-close-calc.component"; import { DialogEditParamComputedComponent } from "./components/dialog-edit-param-computed/dialog-edit-param-computed.component"; import { DialogEditParamValuesComponent } from "./components/dialog-edit-param-values/dialog-edit-param-values.component"; +import { DialogGeneratePABComponent } from "./components/dialog-generate-pab/dialog-generate-pab.component"; import { DialogLoadSessionComponent } from "./components/dialog-load-session/dialog-load-session.component"; import { DialogSaveSessionComponent } from "./components/dialog-save-session/dialog-save-session.component"; @@ -146,6 +147,7 @@ const appRoutes: Routes = [ DialogConfirmEmptySessionComponent, DialogEditParamComputedComponent, DialogEditParamValuesComponent, + DialogGeneratePABComponent, DialogLoadSessionComponent, DialogSaveSessionComponent, FieldSetComponent, @@ -181,6 +183,7 @@ const appRoutes: Routes = [ DialogConfirmEmptySessionComponent, DialogEditParamComputedComponent, DialogEditParamValuesComponent, + DialogGeneratePABComponent, DialogSaveSessionComponent, DialogLoadSessionComponent ], diff --git a/src/app/components/dialog-generate-pab/dialog-generate-pab.component.html b/src/app/components/dialog-generate-pab/dialog-generate-pab.component.html new file mode 100644 index 0000000000000000000000000000000000000000..f404ad3632c23454f43b316b0dfc8b8207482ed3 --- /dev/null +++ b/src/app/components/dialog-generate-pab/dialog-generate-pab.component.html @@ -0,0 +1,59 @@ +<h1 mat-dialog-title [innerHTML]="uitextGeneratePAB"></h1> + +<form id="form-generate-pab"> + + <div mat-dialog-content> + + <mat-form-field> + <input matInput required [placeholder]="uitextDebit" pattern="^([0-9]*\.)?([0-9]+[Ee]-?)?[0-9]+$" + [(ngModel)]="debit" name="debit" #inputDebit="ngModel"> + </mat-form-field> + <mat-error *ngIf="inputDebit.invalid && (inputDebit.dirty || inputDebit.touched)"> + <div *ngIf="inputDebit.errors.required || inputDebit.errors.pattern"> + {{ uitextMustBePositive }} + </div> + </mat-error> + + <mat-form-field> + <input matInput required [placeholder]="uitextCoteAmont" pattern="^-?([0-9]*\.)?([0-9]+[Ee]-?)?[0-9]+$" + [(ngModel)]="coteAmont" name="coteAmont" #inputCoteAmont="ngModel"> + </mat-form-field> + <mat-error *ngIf="inputCoteAmont.invalid && (inputCoteAmont.dirty || inputCoteAmont.touched)"> + <div *ngIf="inputCoteAmont.errors.required || inputCoteAmont.errors.pattern"> + {{ uitextMustBeANumber }} + </div> + </mat-error> + + <mat-form-field> + <input matInput required [placeholder]="uitextCoteAval" pattern="^-?([0-9]*\.)?([0-9]+[Ee]-?)?[0-9]+$" + [(ngModel)]="coteAval" name="coteAval" #inputCoteAval="ngModel"> + </mat-form-field> + <mat-error *ngIf="inputCoteAval.invalid && (inputCoteAval.dirty || inputCoteAval.touched)"> + <div *ngIf="inputCoteAval.errors.required || inputCoteAval.errors.pattern"> + {{ uitextMustBeANumber }} + </div> + </mat-error> + + <mat-form-field> + <input matInput required [placeholder]="uitextNBBassins" pattern="^[1-9][0-9]*$" + [(ngModel)]="nbBassins" name="nbBassins" #inputNbBassins="ngModel"> + </mat-form-field> + <mat-error *ngIf="inputNbBassins.invalid && (inputNbBassins.dirty || inputNbBassins.touched)"> + <div *ngIf="inputNbBassins.errors.required || inputNbBassins.errors.pattern"> + {{ uitextMustBePositive }} + </div> + </mat-error> + + </div> + + <div mat-dialog-actions> + <button mat-raised-button color="primary" [mat-dialog-close]="false" cdkFocusInitial> + {{ uitextCancel }} + </button> + <button mat-raised-button type="submit" color="warn" (click)="generatePAB()" + [disabled]="(inputDebit.invalid || inputCoteAmont.invalid || inputCoteAval.invalid || inputNbBassins.invalid)"> + {{ uitextGenerate }} + </button> + </div> + +</form> diff --git a/src/app/components/dialog-generate-pab/dialog-generate-pab.component.scss b/src/app/components/dialog-generate-pab/dialog-generate-pab.component.scss new file mode 100644 index 0000000000000000000000000000000000000000..032bdab00204a605b43c50d7885803ff7da04d1b --- /dev/null +++ b/src/app/components/dialog-generate-pab/dialog-generate-pab.component.scss @@ -0,0 +1,18 @@ +#form-generate-pab { + max-width: 350px; +} + +mat-form-field { + display: block; + + .mat-input-element { + font-size: .9em; + } +} + +mat-error { + font-weight: 500; + font-size: .8em; + margin-top: -1.2em; + margin-bottom: 1.2em; +} diff --git a/src/app/components/dialog-generate-pab/dialog-generate-pab.component.ts b/src/app/components/dialog-generate-pab/dialog-generate-pab.component.ts new file mode 100644 index 0000000000000000000000000000000000000000..0fc7928626554a2c86fae9bd460a7bb0d1758bd1 --- /dev/null +++ b/src/app/components/dialog-generate-pab/dialog-generate-pab.component.ts @@ -0,0 +1,74 @@ +import { MatDialogRef, MAT_DIALOG_DATA } from "@angular/material"; +import { Inject, Component } from "@angular/core"; + +import { I18nService } from "../../services/internationalisation/internationalisation.service"; +import { FormGroup, FormBuilder, Validators } from "@angular/forms"; + +@Component({ + selector: "dialog-generate-pab", + templateUrl: "dialog-generate-pab.component.html", + styleUrls: ["dialog-generate-pab.component.scss"] +}) +export class DialogGeneratePABComponent { + + public debit: number; + + public coteAmont: number; + + public coteAval: number; + + public nbBassins: number; + + constructor( + public dialogRef: MatDialogRef<DialogGeneratePABComponent>, + private intlService: I18nService, + private fb: FormBuilder, + @Inject(MAT_DIALOG_DATA) public data: any + ) { } + + public generatePAB() { + this.dialogRef.close({ + generate: true, + debit: this.debit, + coteAmont: this.coteAmont, + coteAval: this.coteAval, + nbBassins: this.nbBassins + }); + } + + public get uitextDebit() { + return this.intlService.localizeText("INFO_DIALOG_PAB_Q"); + } + + public get uitextCoteAmont() { + return this.intlService.localizeText("INFO_DIALOG_PAB_Z1"); + } + + public get uitextCoteAval() { + return this.intlService.localizeText("INFO_DIALOG_PAB_Z2"); + } + + public get uitextNBBassins() { + return this.intlService.localizeText("INFO_DIALOG_PAB_NB"); + } + + public get uitextMustBeANumber() { + return this.intlService.localizeText("ERROR_PARAM_MUST_BE_A_NUMBER"); + } + + public get uitextMustBePositive() { + return this.intlService.localizeText("ERROR_PARAM_MUST_BE_POSITIVE"); + } + + public get uitextGeneratePAB() { + return this.intlService.localizeText("INFO_CALCULATOR_RESULTS_GENERATE_PAB"); + } + + public get uitextGenerate() { + return this.intlService.localizeText("INFO_OPTION_GENERATE"); + } + + public get uitextCancel() { + return this.intlService.localizeText("INFO_OPTION_CANCEL"); + } +} diff --git a/src/app/components/generic-calculator/calculator.component.html b/src/app/components/generic-calculator/calculator.component.html index 27eb0116b79bdf0a9ae47fa11d3623aa758914f1..db06e3792b10cd0491c1110f404ae9858107af84 100644 --- a/src/app/components/generic-calculator/calculator.component.html +++ b/src/app/components/generic-calculator/calculator.component.html @@ -57,6 +57,10 @@ <mat-card-title> <h1 [innerHTML]="uitextResultsTitle"></h1> </mat-card-title> + <div fxFlex></div> + <button mat-raised-button color="accent" id="generate-pab" *ngIf="isPABCloisons" (click)="generatePAB()"> + {{ uitextGeneratePAB }} + </button> </mat-card-header> <mat-card-content> <calc-results id="resultsComp" (afterViewChecked)="onCalcResultsViewChecked()"></calc-results> diff --git a/src/app/components/generic-calculator/calculator.component.scss b/src/app/components/generic-calculator/calculator.component.scss index f6af036ebaeac433b6913ddb4fc34cc1ffdd06cb..c9cbd66b283bf1f3543a3101b9c9dcf91a80ce05 100644 --- a/src/app/components/generic-calculator/calculator.component.scss +++ b/src/app/components/generic-calculator/calculator.component.scss @@ -53,6 +53,10 @@ mat-card { mat-card-header { margin-bottom: 1em; + + #generate-pab { + height: min-content; + } } } diff --git a/src/app/components/generic-calculator/calculator.component.ts b/src/app/components/generic-calculator/calculator.component.ts index c6c4aaa8399883dd1d95f5d6e6c31ef8f2a12e1f..bc846c090ad0063b64088a026019be9b25f8ccea 100644 --- a/src/app/components/generic-calculator/calculator.component.ts +++ b/src/app/components/generic-calculator/calculator.component.ts @@ -1,8 +1,8 @@ import { Component, OnInit, DoCheck, OnDestroy, ViewChild, ViewChildren, - QueryList, AfterViewChecked, ElementRef, Renderer2 } from "@angular/core"; + QueryList, AfterViewChecked, ElementRef } from "@angular/core"; import { ActivatedRoute, Router } from "@angular/router"; -import { Observer, Session, ParamValueMode } from "jalhyd"; +import { Observer, Session, ParamValueMode, CalculatorType } from "jalhyd"; import { FormulaireService } from "../../services/formulaire/formulaire.service"; import { I18nService } from "../../services/internationalisation/internationalisation.service"; @@ -19,6 +19,7 @@ import { FieldsetContainerComponent } from "../fieldset-container/fieldset-conta import { ServiceFactory } from "../../services/service-factory"; import { MatDialog } from "@angular/material"; import { DialogConfirmCloseCalcComponent } from "../dialog-confirm-close-calc/dialog-confirm-close-calc.component"; +import { DialogGeneratePABComponent } from "../dialog-generate-pab/dialog-generate-pab.component"; @Component({ selector: "hydrocalc", @@ -100,8 +101,8 @@ export class GenericCalculatorComponent extends BaseComponent implements OnInit, private route: ActivatedRoute, private router: Router, private confirmCloseCalcDialog: MatDialog, - private _elementRef: ElementRef, - private renderer: Renderer2 + private generatePABDialog: MatDialog, + private _elementRef: ElementRef ) { super(); this.intlService = ServiceFactory.instance.i18nService; @@ -158,6 +159,10 @@ export class GenericCalculatorComponent extends BaseComponent implements OnInit, return this.intlService.localizeText("INFO_CALCULATOR_RESULTS_TITLE"); } + public get uitextGeneratePAB() { + return this.intlService.localizeText("INFO_CALCULATOR_RESULTS_GENERATE_PAB"); + } + /** * Triggered at calculator instanciation */ @@ -419,6 +424,30 @@ export class GenericCalculatorComponent extends BaseComponent implements OnInit, return false; } + public get isPABCloisons() { + return ( + this._formulaire + && this._formulaire.currentNub + && this._formulaire.currentNub.calcType === CalculatorType.Cloisons + ); + } + + public generatePAB() { + // création du dialogue de génération d'une passe à bassin + const dialogRef = this.generatePABDialog.open( + DialogGeneratePABComponent, + { disableClose: true } + ); + dialogRef.afterClosed().subscribe(result => { + if (result) { + if (result.generate) { + console.log("ON GÉNÈRE !!", result); + // this.doEmptySession(); + } + } + }); + } + public saveCalculator() { this.formulaireService.saveForm(this._formulaire); } diff --git a/src/locale/messages.en.json b/src/locale/messages.en.json index 6de25e2cae622715522d8480e1b6973f0ca8ed4b..fa3305255f91f5472f3bcdf4fa0c7fcb965b4986 100644 --- a/src/locale/messages.en.json +++ b/src/locale/messages.en.json @@ -15,6 +15,7 @@ "ERROR_NEWTON_DERIVEE_NULLE": "Null function derivative in Newton computation", "ERROR_PARAM_NULL": "Parameter value must not be NULL", "ERROR_PARAM_MUST_BE_A_NUMBER": "Please type a numeric value", + "ERROR_PARAM_MUST_BE_POSITIVE": "Please type a positive numeric value", "ERROR_PARAMDEF_CALC_UNDEFINED": "calculability of '%symbol%' parameter is undefined", "ERROR_PARAMDEF_VALUE_FIXED": "value of '%symbol%' parameter cannot be changed", "ERROR_PARAMDEF_VALUE_INTERVAL": "parameter '%symbol%': value %value% is out of [%minValue%, %maxValue%] interval", diff --git a/src/locale/messages.fr.json b/src/locale/messages.fr.json index f4a1dbc15fc65738158ac20ba215353664deeab2..a6ecf9213b9fbc66a24f7f73775cf65979f5e45b 100644 --- a/src/locale/messages.fr.json +++ b/src/locale/messages.fr.json @@ -15,6 +15,7 @@ "ERROR_NEWTON_DERIVEE_NULLE": "Dérivée nulle dans un calcul par la méthode de Newton", "ERROR_PARAM_NULL": "La valeur du paramètre ne peut pas être NULL", "ERROR_PARAM_MUST_BE_A_NUMBER": "Veuillez entrer une valeur numérique", + "ERROR_PARAM_MUST_BE_POSITIVE": "Veuillez entrer une valeur numérique positive", "ERROR_PARAMDEF_CALC_UNDEFINED": "La calculabilité du paramètre %symbol% n'est pas définie", "ERROR_PARAMDEF_VALUE_FIXED": "La valeur du paramètre %symbol% ne peut pas être changée", "ERROR_PARAMDEF_VALUE_INTERVAL": "Paramètre '%symbol%' : la valeur %value% est en dehors de l'intervalle [%minValue%, %maxValue%]", @@ -38,7 +39,7 @@ "INFO_CALCULATOR_CALC_NAME": "Nom du module de calcul", "INFO_CALCULATOR_CALCULER": "Calculer", "INFO_CALCULATOR_PARAMFIXES": "Paramètres fixés", - "INFO_CALCULATOR_RESULTS_GENERATE_PAB": "Générer une passe à bassin", + "INFO_CALCULATOR_RESULTS_GENERATE_PAB": "Générer une passe à bassins", "INFO_CALCULATOR_RESULTS_TITLE": "Résultats", "INFO_CALCULATOR_VALEURS": "Valeurs", "INFO_CLOISONS_TITRE": "Passe à bassin : Cloisons",