diff --git a/jalhyd_branch b/jalhyd_branch index de50629b8fe9cf9d219fdf081f3ab2ecd5f9ecc4..47cea457363c1be429e2baf6b5bfb8207cb69e13 100644 --- a/jalhyd_branch +++ b/jalhyd_branch @@ -1 +1 @@ -278-prebarrage-calculable-avec-champs-vides-cassiopee-nghyd-470 +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 96efe09a17616653a2c7ab330be912aa9af2cc1a..777573a7fcf1a0b28ed2c66cce09d50d1428a8c3 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 abd5be33c92a9805a01f4605e3c0621dd8b48478..5b64df679eacf71bc3301892b8ee38a8ade5c77c 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 b3c8934ecfc243a544c9a43a4aad2c119288d9b6..bacee1c967c94c74355ce7a73e59b4e97f2662c0 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 22b7a92ad09a49c78ac0f54cb6ee01e44bc06fbc..614521e14795e18ecf40aa57f21ad1d69f7b6d80 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 4f086079ecf28da2a005d9c00a31a5a3c3b2f211..727ac59f10dfc8ecfcacbf0e53ba7e1037996c31 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 {