From ab0c6101fc3749dc136cfb163f185397d5d03a41 Mon Sep 17 00:00:00 2001 From: "mathias.chouet" <mathias.chouet@irstea.fr> Date: Wed, 26 Aug 2020 14:35:49 +0200 Subject: [PATCH] Work on #431 - make QA variable in PAB --- jalhyd_branch | 2 +- .../pab-table/pab-table.component.html | 9 +++ .../pab-table/pab-table.component.scss | 10 +++ .../pab-table/pab-table.component.ts | 66 +++++++++++++------ .../param-field-line.component.ts | 12 +++- src/styles.scss | 49 ++++++++++++++ 6 files changed, 124 insertions(+), 24 deletions(-) diff --git a/jalhyd_branch b/jalhyd_branch index f95555f7a..47cea4573 100644 --- a/jalhyd_branch +++ b/jalhyd_branch @@ -1 +1 @@ -204-ajout-de-la-fonctionnalite-respect-des-criteres-2 +261-pab-pouvoir-lier-et-varier-le-debit-d-attrait diff --git a/src/app/components/pab-table/pab-table.component.html b/src/app/components/pab-table/pab-table.component.html index 96efe09a1..777573a7f 100644 --- a/src/app/components/pab-table/pab-table.component.html +++ b/src/app/components/pab-table/pab-table.component.html @@ -96,6 +96,15 @@ </mat-option> </mat-select> + <div *ngIf="isQA(cell)" class="qaFieldLineContainer"> + <div class="qaLabel"> + {{ cell.title }} + </div> + <param-field-line class="qaFieldLine" [param]="cell.model" (radio)="inputValueChanged($event, cell)" + (input)="inputValueChanged($event, cell)"> + </param-field-line> + </div> + <span *ngIf="! hasModel(cell)">{{ cellValue(cell) }}</span> </td> </tr> diff --git a/src/app/components/pab-table/pab-table.component.scss b/src/app/components/pab-table/pab-table.component.scss index abd5be33c..5b64df679 100644 --- a/src/app/components/pab-table/pab-table.component.scss +++ b/src/app/components/pab-table/pab-table.component.scss @@ -47,3 +47,13 @@ mat-card-content { } } } + +.qaFieldLineContainer { + padding: 0 10px; +} + +.qaLabel { + margin-top: 13px; + margin-right: 10px; + font-weight: bold; +} diff --git a/src/app/components/pab-table/pab-table.component.ts b/src/app/components/pab-table/pab-table.component.ts index 012f8773e..8b3946f70 100644 --- a/src/app/components/pab-table/pab-table.component.ts +++ b/src/app/components/pab-table/pab-table.component.ts @@ -1,6 +1,6 @@ import { Component, Input, Output, EventEmitter, OnInit, AfterViewInit } from "@angular/core"; -import { LoiDebit } from "jalhyd"; +import { LoiDebit, ParamCalculability } from "jalhyd"; import { MatDialog } from "@angular/material/dialog"; @@ -27,6 +27,7 @@ import { NotificationsService } from "../../services/notifications.service"; import { PabTable } from "../../formulaire/elements/pab-table"; import { DialogEditPabComponent } from "../dialog-edit-pab/dialog-edit-pab.component"; import { AppComponent } from "../../app.component"; +import { NgParameter, ParamRadioConfig } from "../../formulaire/elements/ngparam"; /** * The big editable data grid for calculator type "Pab" (component) @@ -101,7 +102,7 @@ export class PabTableComponent implements AfterViewInit, OnInit { /** returns true if the cell is an editable number */ public isNumberInput(cell: any): boolean { - return this.hasModel(cell) && ! this.isSelect(cell); + return this.hasModel(cell) && ! this.isSelect(cell) && ! this.isQA(cell); } /** returns true if the cell is a select box */ @@ -109,6 +110,11 @@ export class PabTableComponent implements AfterViewInit, OnInit { return this.hasModel(cell) && (cell.options !== undefined); } + /** returns true if the cell is a QA (Attraction flow) editor */ + public isQA(cell: any): boolean { + return this.hasModel(cell) && cell.qa; + } + /** value to display in a cell, if it is not editable */ public cellValue(cell: any) { if (cell === undefined) { @@ -166,8 +172,12 @@ export class PabTableComponent implements AfterViewInit, OnInit { */ public isInvalid(cell: any): boolean { let valid = true; - if (this.hasModel(cell) && cell.model instanceof ParamDefinition) { - valid = valid && cell.model.isValid; + if (this.hasModel(cell)) { + if (cell.model instanceof ParamDefinition) { + valid = valid && cell.model.isValid; + } else if (cell.model instanceof NgParameter) { // for QA (currently has domain ANY but that might change) + valid = valid && cell.model.paramDefinition.isValid; + } } if (cell.uiValidity !== undefined) { valid = valid && cell.uiValidity; @@ -443,7 +453,7 @@ export class PabTableComponent implements AfterViewInit, OnInit { const nDigits = this.appSetupService.displayPrecision; for (const c of this.model.children) { for (const p of c.parameterIterator) { - if (p.visible) { + if (p.visible && p.symbol !== "QA") { // QA might vary ! p.singleValue = round(p.singleValue, nDigits); } } @@ -461,7 +471,7 @@ export class PabTableComponent implements AfterViewInit, OnInit { bs = bs.concat(this.model.downWall); this.headers.push({ title: this.i18nService.localizeText("INFO_PAB_BASSIN"), - colspan: 6, + colspan: 5, selectable: bs }); // 1 header for each device of the wall having the most devices (including downwall) @@ -476,7 +486,7 @@ export class PabTableComponent implements AfterViewInit, OnInit { // A. build columns set this.cols = []; - // 6 cols for basin + // 5 cols for basin this.cols.push({ title: this.i18nService.localizeText("INFO_PAB_NUM_BASSIN"), selectable: bs @@ -489,10 +499,10 @@ export class PabTableComponent implements AfterViewInit, OnInit { title: this.formService.expandVariableNameAndUnit(CalculatorType.Pab, "BB"), selectable: bs }); - this.cols.push({ + /* this.cols.push({ title: this.formService.expandVariableNameAndUnit(CalculatorType.Pab, "QA"), selectable: bs - }); + }); */ this.cols.push({ title: this.formService.expandVariableNameAndUnit(CalculatorType.Pab, "ZRMB"), selectable: bs @@ -543,14 +553,14 @@ export class PabTableComponent implements AfterViewInit, OnInit { // basin number deviceParamRow.cells.push({ value: childIndex + 1, - rowspan: maxNbParams + 1, + rowspan: maxNbParams + 2, class: "basin_number", selectable: cloison }); - // 4 empty cells + // 3 empty cells deviceParamRow.cells.push({ - colspan: 4, - rowspan: maxNbParams , + colspan: 3, + rowspan: maxNbParams, selectable: cloison }); // ZRAM @@ -562,7 +572,7 @@ export class PabTableComponent implements AfterViewInit, OnInit { // 1 empty cell if (i === 1) { deviceParamRow.cells.push({ - rowspan: maxNbParams, + rowspan: maxNbParams + 1, selectable: cloison }); } @@ -639,10 +649,6 @@ export class PabTableComponent implements AfterViewInit, OnInit { model: cloison.prms.BB, title: this.formService.expandVariableNameAndUnit(CalculatorType.Pab, "BB") }, - { - model: cloison.prms.QA, - title: this.formService.expandVariableNameAndUnit(CalculatorType.Pab, "QA") - }, { model: cloison.prms.ZRMB, title: this.formService.expandVariableNameAndUnit(CalculatorType.Pab, "ZRMB") @@ -652,11 +658,29 @@ export class PabTableComponent implements AfterViewInit, OnInit { // fill horizontal space for (let i = 0; i < maxNbDevices; i++) { basinRow.cells.push({ - colspan: 3 + colspan: 3, + rowspan: 2 }); } // done ! this.rows.push(basinRow); + // 1 row for QA editor + const qaParam = new NgParameter(cloison.prms.QA, this.pabTable.form); + qaParam.radioConfig = ParamRadioConfig.VAR; + const qaRow: { selectable: any, cells: any[] } = { + selectable: undefined, + cells: [ + { + model: qaParam, + colspan: 3, + qa: true, + title: this.formService.expandVariableNameAndUnit(CalculatorType.Pab, "QA") + } + ] + }; + this.rows.push(qaRow); + // done ! + childIndex ++; } @@ -681,9 +705,9 @@ export class PabTableComponent implements AfterViewInit, OnInit { class: "basin_number", selectable: this.model.downWall }); - // 4 empty cells + // 3 empty cells deviceParamRowDW.cells.push({ - colspan: 4, + colspan: 3, rowspan: maxNbParamsDW , selectable: this.model.downWall }); diff --git a/src/app/components/param-field-line/param-field-line.component.ts b/src/app/components/param-field-line/param-field-line.component.ts index 22b7a92ad..614521e14 100644 --- a/src/app/components/param-field-line/param-field-line.component.ts +++ b/src/app/components/param-field-line/param-field-line.component.ts @@ -4,7 +4,7 @@ import { I18nService } from "../../services/internationalisation.service"; import { NgParameter, ParamRadioConfig } from "../../formulaire/elements/ngparam"; import { NgParamInputComponent } from "../ngparam-input/ngparam-input.component"; import { ServiceFactory } from "../../services/service-factory"; -import { ParamValueMode, ParallelStructure, ParamCalculability } from "jalhyd"; +import { ParamValueMode, ParallelStructure, ParamCalculability, Pab } from "jalhyd"; import { FormulaireService } from "../../services/formulaire.service"; import { ParamLinkComponent } from "../param-link/param-link.component"; import { ParamValuesComponent } from "../param-values/param-values.component"; @@ -173,7 +173,7 @@ export class ParamFieldLineComponent implements OnChanges { return this._formService.getLinkableValues(this.param).length > 0; } - // ou un seul module de calcul "ouvrages parallèles" + // ou un seul module de calcul "ouvrages parallèles" avec au moins 2 ouvrages if (this._formService.formulaires[0].currentNub instanceof ParallelStructure) { const ps: ParallelStructure = this._formService.formulaires[0].currentNub; if (ps.structures.length > 1) { @@ -181,6 +181,14 @@ export class ParamFieldLineComponent implements OnChanges { } } + // ou un seul module de calcul "PAB" avec au mois 2 ouvrages + if (this._formService.formulaires[0].currentNub instanceof Pab) { + const pab: Pab = this._formService.formulaires[0].currentNub; + if (pab.children.length > 1) { + return this._formService.getLinkableValues(this.param).length > 0; + } + } + } return false; } diff --git a/src/styles.scss b/src/styles.scss index 11ffd2a86..1fea90f17 100644 --- a/src/styles.scss +++ b/src/styles.scss @@ -136,6 +136,55 @@ field-set { } } +.qaFieldLineContainer { + + .qaFieldLine { + .mat-button-toggle-label-content { + line-height: 24px !important; + } + } + + ngparam-input { + height: 38px; + margin-top: 0; + } + + param-values { + margin-top: 0; + } + + param-link { + margin-top: 0; + + .status-icons-container { + display: none; + } + } + + mat-form-field { + + .mat-form-field-wrapper { + padding-bottom: 5px; + } + + input.form-control.mat-input-element { + width: 100%; + } + + button.param-values-more { + display: none; + } + + .mat-form-field-underline { + display: none; + } + + mat-error.mat-error { + display: none; + } + } +} + .pab-data-table { .editable-cell-bg { -- GitLab