Skip to content
Snippets Groups Projects
Commit f7dbfb69 authored by François Grand's avatar François Grand
Browse files

refactor: PAB: optimise table space by moving up values of the basin section (length, width, ZRMB)

refs #607
parent 6610d19f
No related branches found
No related tags found
2 merge requests!225Release v4.17.0,!207Draft: Resolve "PAB : optimiser l'espace occupé par le tableau de la géométrie de la passe"
......@@ -540,58 +540,58 @@ export class PabTableComponent implements AfterViewInit, AfterViewChecked, OnIni
for (const cloison of this.model.children) {
// as much rows as the greatest number of parameters among its devices
const maxNbParams = this.findMaxNumberOfDeviceParameters(cloison);
for (let i = 0; i < maxNbParams; i++) {
for (let r = 0; r < maxNbParams; r++) {
// build device params row
const deviceParamRow = { selectable: cloison, cells: [] };
// basin number and ZRAM
if (i === 0) {
// basin number, LB, BB, ZRMB and ZRAM
if (r === 0) {
// basin number
deviceParamRow.cells.push({
value: childIndex + 1,
rowspan: maxNbParams + 1,
rowspan: maxNbParams,
class: "basin_number",
selectable: cloison
});
// 3 empty cells
deviceParamRow.cells.push({
colspan: 3,
rowspan: maxNbParams - 1,
selectable: cloison
});
// ZRAM
deviceParamRow.cells.push({
model: cloison.prms.ZRAM,
title: this.formService.expandVariableNameAndUnit(CalculatorType.Pab, "ZRAM")
});
}
// basin cells on the last but 1 row
if (i === maxNbParams - 1) {
// Longueur bassin
deviceParamRow.cells.push({
model: cloison.prms.LB,
title: this.formService.expandVariableNameAndUnit(CalculatorType.Pab, "LB")
});
// Largeur bassin
deviceParamRow.cells.push({
model: cloison.prms.BB,
title: this.formService.expandVariableNameAndUnit(CalculatorType.Pab, "BB")
});
// Cote radier mi bassin
deviceParamRow.cells.push({
model: cloison.prms.ZRMB,
title: this.formService.expandVariableNameAndUnit(CalculatorType.Pab, "ZRMB")
});
// ZRAM
deviceParamRow.cells.push({
model: cloison.prms.ZRAM,
title: this.formService.expandVariableNameAndUnit(CalculatorType.Pab, "ZRAM")
});
}
// 1 empty cell below ZRAM
if (i === 1) {
else if (r === 1) {
// 1 row for QA editor
const qaParam = new NgParameter(cloison.prms.QA, this.pabTable.form);
qaParam.radioConfig = ParamRadioConfig.VAR;
deviceParamRow.cells.push({
rowspan: maxNbParams,
selectable: cloison
model: qaParam,
colspan: 4,
rowspan: maxNbParams - 1,
qa: true,
title: this.formService.expandVariableNameAndUnit(CalculatorType.Pab, "QA")
});
}
// device param cells : 3 cells for each device
for (const ouvrage of cloison.structures) {
const nvParam = ouvrage.getNthVisibleParam(i);
const nvParam = ouvrage.getNthVisibleParam(r);
const nvParamTitle = nvParam ? this.formService.expandVariableNameAndUnit(CalculatorType.Pab, nvParam.symbol) : "";
const childStructParamCount = this.nubVisibleParameterCount(ouvrage);
// cell 1 : device type
if (i === 0) { // 1st row
if (r === 0) { // 1st row
deviceParamRow.cells.push({
model: ouvrage,
modelValue: ouvrage.getPropValue("loiDebit"),
......@@ -600,75 +600,42 @@ export class PabTableComponent implements AfterViewInit, AfterViewChecked, OnIni
});
}
// fill space below device type selector
if (i === 1) {
else if (r === 1) {
deviceParamRow.cells.push({
rowspan: (maxNbParams - 1),
selectable: ouvrage
});
}
// cell 2 : param name
if (nvParam) {
// cell 2 : param name
deviceParamRow.cells.push({
value: nvParam.symbol,
title: nvParamTitle,
selectable: ouvrage
});
} else {
deviceParamRow.cells.push({
selectable: ouvrage
});
}
// cell 3 : param value
if (nvParam) {
// cell 3 : param value
deviceParamRow.cells.push({
model: nvParam,
title: nvParamTitle,
selectable: ouvrage
});
} else {
deviceParamRow.cells.push({
selectable: ouvrage
});
}
}
// fill horizontal space
const devDiff = (maxNbDevices - cloison.structures.length);
if (i === 0) {
for (let j = 0; j < devDiff; j++) {
deviceParamRow.cells.push({
colspan: 3,
rowspan: maxNbParams,
selectable: cloison,
selectableColumn: cloison.structures.length + j
});
else if (r === childStructParamCount) {
// fill remaining space
const remaining = maxNbParams - childStructParamCount;
if (remaining > 0) {
deviceParamRow.cells.push({
colspan: 2,
rowspan: remaining,
selectable: cloison
});
}
}
}
// done !
this.rows.push(deviceParamRow);
}
// 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")
}
]
};
// as many pairs of columns as the maximum number of devices
qaRow.cells.push({
colspan: maxNbDevices * 3,
// selectable: cloison @TODO oui ou non ?
});
// done !
this.rows.push(qaRow);
childIndex ++;
childIndex++;
}
// B.2 many rows for downwall
......@@ -790,18 +757,20 @@ export class PabTableComponent implements AfterViewInit, AfterViewChecked, OnIni
return maxNbDevices;
}
private nubVisibleParameterCount(n: Nub) {
let res = 0;
for (const p of n.parameterIterator) {
if (p.visible) {
res++;
}
}
return res;
}
private findMaxNumberOfDeviceParameters(struct: ParallelStructure): number {
let maxNbParams = 1;
for (const d of struct.getChildren()) {
let nbParams = 0;
for (const p of d.parameterIterator) {
if (p.visible) {
// console.log("(counting)", p.symbol);
nbParams ++;
}
}
// console.log(">>> child params: ", nbParams);
maxNbParams = Math.max(maxNbParams, nbParams);
for (const child of struct.getChildren()) {
maxNbParams = Math.max(maxNbParams, this.nubVisibleParameterCount(child));
}
return maxNbParams;
}
......
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