diff --git a/src/app/components/fieldset-container/fieldset-container.component.ts b/src/app/components/fieldset-container/fieldset-container.component.ts index 65bdb84ebfe9ffb7d4d42053cfd5f58e5ca3ab67..45b87262e5329b8039177d1b4a22fe2014f720b5 100644 --- a/src/app/components/fieldset-container/fieldset-container.component.ts +++ b/src/app/components/fieldset-container/fieldset-container.component.ts @@ -126,7 +126,7 @@ export class FieldsetContainerComponent implements DoCheck, AfterViewInit { private updateValidity() { this._isValid = false; - if (this._fieldsetComponents !== undefined && this._fieldsetComponents.length > 0) { + if (this._fieldsetComponents?.length > 0) { this._isValid = this._fieldsetComponents.reduce( // callback ( diff --git a/src/app/components/fixedvar-results/fixedvar-results.component.ts b/src/app/components/fixedvar-results/fixedvar-results.component.ts index eb491d2d98d78157c5a04b760105413d772684f1..04136deb595d22df2e9952c7a456a34d5edb102c 100644 --- a/src/app/components/fixedvar-results/fixedvar-results.component.ts +++ b/src/app/components/fixedvar-results/fixedvar-results.component.ts @@ -192,6 +192,6 @@ export class FixedVarResultsComponent extends ResultsComponentDirective implemen } public get hasResults(): boolean { - return this._fixedResults !== undefined && this._fixedResults.hasResults; + return this._fixedResults?.hasResults; } } diff --git a/src/app/components/jet-results/jet-results.component.ts b/src/app/components/jet-results/jet-results.component.ts index 0e5c86aa3810c9756a8d59b42d7636a0ca8e00c0..04e068fb078cb272d709c71ba9cf2abdaafeaca1 100644 --- a/src/app/components/jet-results/jet-results.component.ts +++ b/src/app/components/jet-results/jet-results.component.ts @@ -18,9 +18,9 @@ export class JetResultsComponent extends FixedVarResultsComponent { public get hasResults(): boolean { return ( - (this._fixedResults !== undefined && this._fixedResults.hasResults) + (this._fixedResults?.hasResults) || - (this._varResults !== undefined && this._varResults.hasResults) + (this._varResults?.hasResults) ); } diff --git a/src/app/components/log/log.component.ts b/src/app/components/log/log.component.ts index 622fdd914984ab8da3955b5b6147be420a9a7f5f..350e544fe160b83a103414507c14678005bbb1f5 100644 --- a/src/app/components/log/log.component.ts +++ b/src/app/components/log/log.component.ts @@ -34,11 +34,11 @@ export class LogComponent { } public get hasEntries(): boolean { - return this._log !== undefined && this._log.messages.length !== 0; + return this._log?.messages?.length > 0; } public get messages(): Message[] { - return this._log.messages; + return this._log?.messages; } public set log(log: cLog) { diff --git a/src/app/components/pab-table/pab-table.component.ts b/src/app/components/pab-table/pab-table.component.ts index 012f8773efe740d1c97475789dbeba12459f0a3c..b3c8934ecfc243a544c9a43a4aad2c119288d9b6 100644 --- a/src/app/components/pab-table/pab-table.component.ts +++ b/src/app/components/pab-table/pab-table.component.ts @@ -96,7 +96,7 @@ export class PabTableComponent implements AfterViewInit, OnInit { /** returns true if the cell has an underlying model (ie. is editable) */ public hasModel(cell: any): boolean { - return (cell !== undefined && cell.model !== undefined); + return (cell?.model !== undefined); } /** returns true if the cell is an editable number */ @@ -124,7 +124,7 @@ export class PabTableComponent implements AfterViewInit, OnInit { /** "title" tooltip to display in a cell */ public cellTitle(cell: any) { - if (cell !== undefined && cell.title !== undefined) { + if (cell?.title !== undefined) { return cell.title; } else { return ""; @@ -132,14 +132,14 @@ export class PabTableComponent implements AfterViewInit, OnInit { } public rowSpan(cell: any) { - if (cell !== undefined && cell.rowspan) { + if (cell?.rowspan) { return cell.rowspan; } return undefined; } public colSpan(cell: any) { - if (cell !== undefined && cell.colspan) { + if (cell?.colspan) { return cell.colspan; } return undefined; diff --git a/src/app/components/pb-schema/pb-schema.component.ts b/src/app/components/pb-schema/pb-schema.component.ts index 735e7dea7409370252fb56059560465df8cea134..7a9ed20fefa5dcd666d319d21865d2ff55a81bbd 100644 --- a/src/app/components/pb-schema/pb-schema.component.ts +++ b/src/app/components/pb-schema/pb-schema.component.ts @@ -326,11 +326,11 @@ export class PbSchemaComponent implements AfterViewInit, AfterContentInit, OnIni // automatic child addition when clearing children) if (this._selectedItem instanceof PbCloison) { // if no downstream connections remain, connect to river downstream - if (this._selectedItem.bassinAmont !== undefined && this._selectedItem.bassinAmont.cloisonsAval.length === 0) { + if (this._selectedItem.bassinAmont?.cloisonsAval.length === 0) { this.model.addChild(new PbCloison(this._selectedItem.bassinAmont, undefined)); } // if no upstream connections remain, connect to river upstream - if (this._selectedItem.bassinAval !== undefined && this._selectedItem.bassinAval.cloisonsAmont.length === 0) { + if (this._selectedItem.bassinAval?.cloisonsAmont.length === 0) { this.model.addChild(new PbCloison(undefined, this._selectedItem.bassinAval)); } } diff --git a/src/app/components/remous-results/remous-results.component.ts b/src/app/components/remous-results/remous-results.component.ts index db14a54ceea12f5b03ac76e54b617cb3c10e8114..ecf98435acc8ee520cfc22476a2dada00e93198b 100644 --- a/src/app/components/remous-results/remous-results.component.ts +++ b/src/app/components/remous-results/remous-results.component.ts @@ -142,7 +142,7 @@ export class RemousResultsComponent extends ResultsComponentDirective implements } public get hasResults(): boolean { - return this._remousResults !== undefined && this._remousResults.hasResults; + return this._remousResults?.hasResults; } public get hasData(): boolean { @@ -315,7 +315,7 @@ export class RemousResultsComponent extends ResultsComponentDirective implements } // hauteur normale - if (this._remousResults.hautNormale !== undefined && this._remousResults.hautNormale.ok) { + if (this._remousResults.hautNormale?.ok) { const Yn = this._remousResults.hautNormale.vCalc; gr1.drawSimpleLine(Yn + ZF1, Yn + ZF2, 5, "#A4C537", this.uitextTirantNormal @@ -323,7 +323,7 @@ export class RemousResultsComponent extends ResultsComponentDirective implements } // hauteur critique - if (this._remousResults.hautCritique !== undefined && this._remousResults.hautCritique.ok) { + if (this._remousResults.hautCritique?.ok) { const Yc = this._remousResults.hautCritique.vCalc; gr1.drawSimpleLine(Yc + ZF1, Yc + ZF2, 6, "#FF0000", this.uitextTirantCritique diff --git a/src/app/formulaire/definition/form-definition.ts b/src/app/formulaire/definition/form-definition.ts index e70898a3a87ec9de755d805d6aeeb70478565b9c..f378eba7093f3c86186bcaac888ceca88e9587d3 100644 --- a/src/app/formulaire/definition/form-definition.ts +++ b/src/app/formulaire/definition/form-definition.ts @@ -379,7 +379,7 @@ export abstract class FormulaireDefinition extends FormulaireNode implements Obs public isDisplayed(id: string) { const fe = <FormulaireElement>this.getFormulaireNodeById(id); - return fe !== undefined && fe.isDisplayed; + return fe?.isDisplayed; } /** diff --git a/src/app/formulaire/definition/form-section-parametree.ts b/src/app/formulaire/definition/form-section-parametree.ts index b1d6dcf4a35fdd659e9d5bf15a5f448de054be4f..743880b5da19f5ae0542af1402223df2537a29db 100644 --- a/src/app/formulaire/definition/form-section-parametree.ts +++ b/src/app/formulaire/definition/form-section-parametree.ts @@ -55,9 +55,9 @@ export class FormulaireSectionParametree extends FormulaireSection { } public get hasResults(): boolean { - return (this._fixedResults !== undefined && this._fixedResults.hasResults) - || (this._varResults !== undefined && this._varResults.hasResults) - || (this._sectionResults !== undefined && this._sectionResults.hasResults); + return (this._fixedResults?.hasResults) + || (this._varResults?.hasResults) + || (this._sectionResults?.hasResults); } public get results(): CalculatorResults[] { diff --git a/src/app/formulaire/elements/select-field.ts b/src/app/formulaire/elements/select-field.ts index 0cd055aeac0862e1f3199751ccc110a73b511fe3..6a0183d2209e9641d413dcd6d02ec714c32aef9f 100644 --- a/src/app/formulaire/elements/select-field.ts +++ b/src/app/formulaire/elements/select-field.ts @@ -192,11 +192,11 @@ export class SelectField extends Field { // @WARNING for localisation, @see hack in this.updateLocalisation() // 1. calculated param const ntc = (nub as Solveur).nubToCalculate; - if (ntc !== undefined && ntc.calculatedParam !== undefined) { // some nubs have no calculatedParam, for ex. SectionParam + if (ntc?.calculatedParam !== undefined) { // some nubs have no calculatedParam, for ex. SectionParam this.addEntry(new SelectEntry(this._entriesBaseId + "none", "")); } // 2. extra results - if (ntc !== undefined && ntc.resultsFamilies !== undefined) { + if (ntc?.resultsFamilies !== undefined) { for (const er of Object.keys(ntc.resultsFamilies)) { const e: SelectEntry = new SelectEntry(this._entriesBaseId + er, er); this.addEntry(e);