From 4b5a34930130a30fb2dd774b295870bd65eb3529 Mon Sep 17 00:00:00 2001
From: "francois.grand" <francois.grand@irstea.fr>
Date: Tue, 5 Dec 2017 09:46:27 +0100
Subject: [PATCH] =?UTF-8?q?d=C3=A9coupage=20du=20fichier=20src/app/calcula?=
 =?UTF-8?q?tors/generic/formulaire.ts=20en=20plusieurs,=20un=20par=20class?=
 =?UTF-8?q?e?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 .../generic/calculator.component.ts           |  33 +-
 .../calculator-results.component.ts           |  12 +-
 .../check-field-line.component.ts             |   8 +-
 .../field-set/field-set.component.ts          |   8 +-
 .../param-field-line.component.ts             |  10 +-
 .../param-input/param-input.component.ts      |  14 +-
 .../select-field-line.component.ts            |   9 +-
 src/app/formulaire/check-field.ts             |  26 ++
 src/app/formulaire/dependency-condition.ts    |  16 +
 src/app/formulaire/dependency.ts              |  32 ++
 src/app/formulaire/existence-dependency.ts    |  13 +
 src/app/formulaire/field.ts                   |  28 ++
 src/app/formulaire/fieldset.ts                |  48 +++
 .../formulaire-definition.ts}                 | 320 +-----------------
 src/app/formulaire/formulaire-element.ts      |  44 +++
 src/app/formulaire/input-field.ts             |  20 ++
 .../generic => formulaire}/ngparam.ts         |  12 +-
 src/app/formulaire/select-entry.ts            |  13 +
 src/app/formulaire/select-field.ts            |  70 ++++
 .../formulaire/value-dependency-condition.ts  |  16 +
 src/app/formulaire/value-dependency.ts        |  16 +
 .../services/formulaire/formulaire.service.ts |  15 +-
 src/app/services/param/param.service.ts       |   7 +-
 23 files changed, 429 insertions(+), 361 deletions(-)
 create mode 100644 src/app/formulaire/check-field.ts
 create mode 100644 src/app/formulaire/dependency-condition.ts
 create mode 100644 src/app/formulaire/dependency.ts
 create mode 100644 src/app/formulaire/existence-dependency.ts
 create mode 100644 src/app/formulaire/field.ts
 create mode 100644 src/app/formulaire/fieldset.ts
 rename src/app/{calculators/generic/formulaire.ts => formulaire/formulaire-definition.ts} (67%)
 create mode 100644 src/app/formulaire/formulaire-element.ts
 create mode 100644 src/app/formulaire/input-field.ts
 rename src/app/{calculators/generic => formulaire}/ngparam.ts (88%)
 create mode 100644 src/app/formulaire/select-entry.ts
 create mode 100644 src/app/formulaire/select-field.ts
 create mode 100644 src/app/formulaire/value-dependency-condition.ts
 create mode 100644 src/app/formulaire/value-dependency.ts

diff --git a/src/app/calculators/generic/calculator.component.ts b/src/app/calculators/generic/calculator.component.ts
index 6cb695927..b66fba840 100644
--- a/src/app/calculators/generic/calculator.component.ts
+++ b/src/app/calculators/generic/calculator.component.ts
@@ -1,20 +1,27 @@
-import { Component, OnInit, DoCheck, ViewChild, Input } from '@angular/core';
-import { Response } from '@angular/http';
+import { Component, OnInit, DoCheck, ViewChild, Input } from "@angular/core";
+import { Response } from "@angular/http";
 import { Observable } from "rxjs/Observable";
-import 'rxjs/add/operator/toPromise';
+import "rxjs/add/operator/toPromise";
 
 import { ComputeNode, ComputeNodeType, ParamsEquation, Nub, acSection, RegimeUniforme, MethodeResolution, CourbeRemousParams, CourbeRemous, cLog } from "jalhyd";
 
-import { ParamService } from '../../services/param/param.service';
-import { HttpService } from '../../services/http/http.service';
-import { FormulaireService } from '../../services/formulaire/formulaire.service';
-import { InternationalisationService } from '../../services/internationalisation/internationalisation.service';
-import { FieldSet, InputField, SelectField, FormulaireDefinition, CalculatorType, Dependency, ExistenceDependency, ValueDependency } from '../../calculators/generic/formulaire';
-import { NgParameter, ParamRadioConfig } from './ngparam';
-import { CalculatorResultsComponent } from '../../components/calculator-results/calculator-results.component';
-import { SectionResultsComponent } from '../../components/section-results/section-results.component';
-import { RemousResultsComponent } from '../../components/remous-results/remous-results.component';
-import { Observer } from '../../services/observer';
+import { ParamService } from "../../services/param/param.service";
+import { HttpService } from "../../services/http/http.service";
+import { FormulaireService } from "../../services/formulaire/formulaire.service";
+import { InternationalisationService } from "../../services/internationalisation/internationalisation.service";
+import { FieldSet } from "../../formulaire/fieldset";
+import { InputField } from "../../formulaire/input-field";
+import { SelectField } from "../../formulaire/select-field";
+import { FormulaireDefinition } from "../../formulaire/formulaire-definition";
+import { CalculatorType } from "../../formulaire/formulaire-definition";
+import { Dependency } from "../../formulaire/dependency";
+import { ExistenceDependency } from "../../formulaire/existence-dependency";
+import { ValueDependency } from "../../formulaire/value-dependency";
+import { NgParameter, ParamRadioConfig } from "../../formulaire/ngparam";
+import { CalculatorResultsComponent } from "../../components/calculator-results/calculator-results.component";
+import { SectionResultsComponent } from "../../components/section-results/section-results.component";
+import { RemousResultsComponent } from "../../components/remous-results/remous-results.component";
+import { Observer } from "../../services/observer";
 
 @Component({
     selector: 'hydrocalc',
diff --git a/src/app/components/calculator-results/calculator-results.component.ts b/src/app/components/calculator-results/calculator-results.component.ts
index 8fced4bd3..2b24f73d4 100644
--- a/src/app/components/calculator-results/calculator-results.component.ts
+++ b/src/app/components/calculator-results/calculator-results.component.ts
@@ -1,11 +1,11 @@
-import { Component } from '@angular/core';
+import { Component } from "@angular/core";
 
-import { NgParameter } from '../../calculators/generic/ngparam';
-import { InternationalisationService } from '../../services/internationalisation/internationalisation.service';
+import { NgParameter } from "../../formulaire/ngparam";
+import { InternationalisationService } from "../../services/internationalisation/internationalisation.service";
 
 @Component({
-    selector: 'calc-results',
-    templateUrl: './calculator-results.component.html',
+    selector: "calc-results",
+    templateUrl: "./calculator-results.component.html",
     styles: [`
     .result_right {
         text-align: right;
@@ -65,7 +65,7 @@ export class CalculatorResultsComponent {
     /*
     * config du graphe
     */
-    private graph_type = 'line';
+    private graph_type = "line";
     private graph_data = {};
     private graph_options = {
         responsive: true,
diff --git a/src/app/components/check-field-line/check-field-line.component.ts b/src/app/components/check-field-line/check-field-line.component.ts
index 1e2b528a0..877a4e92d 100644
--- a/src/app/components/check-field-line/check-field-line.component.ts
+++ b/src/app/components/check-field-line/check-field-line.component.ts
@@ -1,10 +1,10 @@
-import { Component, Input, Output, EventEmitter } from '@angular/core';
+import { Component, Input, Output, EventEmitter } from "@angular/core";
 
-import { CheckField } from '../../calculators/generic/formulaire';
-import { FormulaireService } from '../../services/formulaire/formulaire.service';
+import { CheckField } from "../../formulaire/check-field";
+import { FormulaireService } from "../../services/formulaire/formulaire.service";
 
 @Component({
-    selector: 'check-field-line',
+    selector: "check-field-line",
     templateUrl: "./check-field-line.component.html",
 })
 export class CheckFieldLineComponent {
diff --git a/src/app/components/field-set/field-set.component.ts b/src/app/components/field-set/field-set.component.ts
index 7f9214963..e89d6bd4d 100644
--- a/src/app/components/field-set/field-set.component.ts
+++ b/src/app/components/field-set/field-set.component.ts
@@ -1,9 +1,9 @@
-import { Component, Input, Output, EventEmitter } from '@angular/core';
+import { Component, Input, Output, EventEmitter } from "@angular/core";
 
-import { ParamDefinition } from 'jalhyd';
+import { ParamDefinition } from "jalhyd";
 
-import { NgParameter, ParamRadioConfig } from '../../calculators/generic/ngparam';
-import { FieldSet } from '../../calculators/generic/formulaire';
+import { NgParameter, ParamRadioConfig } from "../../formulaire/ngparam";
+import { FieldSet } from "../../formulaire/fieldset";
 
 @Component({
     selector: "field-set",
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 6c9722d27..8781c20f4 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
@@ -1,10 +1,10 @@
-import { Component, Input, Output, DoCheck, EventEmitter } from '@angular/core';
+import { Component, Input, Output, DoCheck, EventEmitter } from "@angular/core";
 
-import { ComputeNodeType } from 'jalhyd';
+import { ComputeNodeType } from "jalhyd";
 
-import { ParamService } from '../../services/param/param.service';
-import { InternationalisationService } from '../../services/internationalisation/internationalisation.service';
-import { NgParameter, ParamRadioConfig } from '../../calculators/generic/ngparam';
+import { ParamService } from "../../services/param/param.service";
+import { InternationalisationService } from "../../services/internationalisation/internationalisation.service";
+import { NgParameter, ParamRadioConfig } from "../../formulaire/ngparam";
 
 @Component({
     selector: "param-field-line",
diff --git a/src/app/components/param-input/param-input.component.ts b/src/app/components/param-input/param-input.component.ts
index 018cc3031..930aa16a9 100644
--- a/src/app/components/param-input/param-input.component.ts
+++ b/src/app/components/param-input/param-input.component.ts
@@ -1,16 +1,16 @@
 // cf. https://blog.thoughtram.io/angular/2016/07/27/custom-form-controls-in-angular-2.html
 
-import { Component, Input, forwardRef, OnInit, DoCheck, ChangeDetectorRef } from '@angular/core';
-import { ControlValueAccessor, NG_VALUE_ACCESSOR, NG_VALIDATORS, FormControl } from '@angular/forms';
+import { Component, Input, forwardRef, OnInit, DoCheck, ChangeDetectorRef } from "@angular/core";
+import { ControlValueAccessor, NG_VALUE_ACCESSOR, NG_VALIDATORS, FormControl } from "@angular/forms";
 
-import { ComputeNodeType, ParamDefinition, NumericalString, Message, MessageCode } from 'jalhyd';
+import { ComputeNodeType, ParamDefinition, NumericalString, Message, MessageCode } from "jalhyd";
 
-import { ParamService } from '../../services/param/param.service';
-import { InternationalisationService, LanguageCode } from '../../services/internationalisation/internationalisation.service';
-import { NgParameter } from '../../calculators/generic/ngparam';
+import { ParamService } from "../../services/param/param.service";
+import { InternationalisationService, LanguageCode } from "../../services/internationalisation/internationalisation.service";
+import { NgParameter } from "../../formulaire/ngparam";
 
 @Component({
-    selector: 'param-input',
+    selector: "param-input",
     /* OK
     <input placeholder="{{_paramDef.symbol}}" [ngModel]="_paramDef.v" (ngModelChange)="setValue($event)"/>
     <p *ngIf="_message">{{_message}}</p>
diff --git a/src/app/components/select-field-line/select-field-line.component.ts b/src/app/components/select-field-line/select-field-line.component.ts
index 921beb3f3..ab7b20d0b 100644
--- a/src/app/components/select-field-line/select-field-line.component.ts
+++ b/src/app/components/select-field-line/select-field-line.component.ts
@@ -1,10 +1,11 @@
-import { Component, Input, Output, EventEmitter } from '@angular/core';
+import { Component, Input, Output, EventEmitter } from "@angular/core";
 
-import { SelectField, SelectEntry } from '../../calculators/generic/formulaire';
-import { FormulaireService } from '../../services/formulaire/formulaire.service';
+import { SelectField, } from "../../formulaire/select-field";
+import { SelectEntry } from "../../formulaire/select-entry";
+import { FormulaireService } from "../../services/formulaire/formulaire.service";
 
 @Component({
-    selector: 'select-field-line',
+    selector: "select-field-line",
     templateUrl: "./select-field-line.component.html",
     styles: [
         // Titre de la ligne
diff --git a/src/app/formulaire/check-field.ts b/src/app/formulaire/check-field.ts
new file mode 100644
index 000000000..645f27425
--- /dev/null
+++ b/src/app/formulaire/check-field.ts
@@ -0,0 +1,26 @@
+import { ComputeNodeType } from "jalhyd";
+
+import { Field, FieldType } from "./field";
+import { Dependency } from "./dependency";
+import { DependencyConditionType } from "./dependency-condition";
+
+export class CheckField extends Field {
+    private _value: boolean;
+
+    constructor(nodeType: ComputeNodeType, id: string) {
+        super(nodeType, id, FieldType.Check);
+        this._value = false;
+    }
+
+    public getValue(): boolean {
+        return this._value;
+    }
+
+    public setValue(val: boolean) {
+        this._value = val;
+    }
+
+    protected verifyDependency(d: Dependency): boolean {
+        throw "CheckField.verifyDependency() : type de condition '" + DependencyConditionType[d.masterCondition.type] + "' non pris en charge";
+    }
+}
diff --git a/src/app/formulaire/dependency-condition.ts b/src/app/formulaire/dependency-condition.ts
new file mode 100644
index 000000000..876e46426
--- /dev/null
+++ b/src/app/formulaire/dependency-condition.ts
@@ -0,0 +1,16 @@
+export enum DependencyConditionType {
+    HasValue, IsVariable, IsDisplayed
+}
+
+export class DependencyCondition {
+    constructor(private _type: DependencyConditionType) {
+    }
+
+    public get type() {
+        return this._type;
+    }
+
+    public toString(): string {
+        return "cond=" + DependencyConditionType[this._type];
+    }
+}
diff --git a/src/app/formulaire/dependency.ts b/src/app/formulaire/dependency.ts
new file mode 100644
index 000000000..0f4936374
--- /dev/null
+++ b/src/app/formulaire/dependency.ts
@@ -0,0 +1,32 @@
+import { FormulaireElement } from "./formulaire-element";
+import { DependencyCondition } from "./dependency-condition";
+
+export abstract class Dependency {
+    private _master: FormulaireElement;
+
+    private _slave: FormulaireElement;
+
+    private _masterCondition: DependencyCondition;
+
+    constructor(m: FormulaireElement, s: FormulaireElement, mc: DependencyCondition) {
+        this._master = m;
+        this._slave = s;
+        this._masterCondition = mc;
+    }
+
+    public get masterElement(): FormulaireElement {
+        return this._master;
+    }
+
+    public get slaveElement(): FormulaireElement {
+        return this._slave;
+    }
+
+    public get masterCondition(): DependencyCondition {
+        return this._masterCondition;
+    }
+
+    public toString(): string {
+        return "master=" + this._master.toString() + "\n  " + this._masterCondition.toString() + "\n  slave=" + this._slave.toString();
+    }
+}
\ No newline at end of file
diff --git a/src/app/formulaire/existence-dependency.ts b/src/app/formulaire/existence-dependency.ts
new file mode 100644
index 000000000..d9485e625
--- /dev/null
+++ b/src/app/formulaire/existence-dependency.ts
@@ -0,0 +1,13 @@
+import { Dependency } from "./dependency";
+
+export class ExistenceDependency extends Dependency {
+    /**
+     * true : l'élément slave est affiché si le master est affiché
+     * false : l'élément slave est affiché si le master n'est pas affiché
+     */
+    // private _direct: boolean;
+
+    public toString() {
+        return "existdep\n  " + super.toString();
+    }
+}
diff --git a/src/app/formulaire/field.ts b/src/app/formulaire/field.ts
new file mode 100644
index 000000000..7c8d8e5be
--- /dev/null
+++ b/src/app/formulaire/field.ts
@@ -0,0 +1,28 @@
+import { ComputeNodeType } from "jalhyd";
+
+import { FormulaireElement } from "./formulaire-element";
+
+export enum FieldType {
+    Input, Select, Check
+}
+
+export abstract class Field extends FormulaireElement {
+    constructor(nodeType: ComputeNodeType, id: string, private _fieldType: FieldType) {
+        super(nodeType, id);
+    }
+
+    public get isInput(): boolean {
+        return this._fieldType == FieldType.Input;
+    }
+
+    public get isSelect(): boolean {
+        return this._fieldType == FieldType.Select;
+    }
+
+    public get isCheck(): boolean {
+        return this._fieldType == FieldType.Check;
+    }
+
+    public abstract getValue(): any;
+    public abstract setValue(val: any): void;
+}
diff --git a/src/app/formulaire/fieldset.ts b/src/app/formulaire/fieldset.ts
new file mode 100644
index 000000000..4da0abba7
--- /dev/null
+++ b/src/app/formulaire/fieldset.ts
@@ -0,0 +1,48 @@
+import { ComputeNodeType } from "jalhyd";
+
+import { FormulaireElement } from "./formulaire-element";
+import { Dependency } from "./dependency";
+import { DependencyConditionType } from "./dependency-condition";
+import { Field } from "./field";
+import { NgParameter } from "./ngparam";
+
+
+export class FieldSet extends FormulaireElement {
+    private _fields: Field[];
+
+    constructor(nodeType: ComputeNodeType, id: string) {
+        super(nodeType, id);
+        this._fields = [];
+    }
+
+    public get fields() {
+        return this._fields;
+    }
+
+    public addField(f: Field) {
+        this._fields.push(f);
+    }
+
+    public get hasInputs(): boolean {
+        for (let f of this._fields)
+            if (f instanceof NgParameter)
+                return true;
+        return false;
+    }
+
+    public getInput(i: number): NgParameter {
+        let n = 0;
+        for (let f of this._fields) {
+            if (f instanceof NgParameter) {
+                if (n == i)
+                    return f;
+                n++;
+            }
+        }
+        return undefined;
+    }
+
+    protected verifyDependency(d: Dependency): boolean {
+        throw "FieldSet.verifyDependency() : type de condition '" + DependencyConditionType[d.masterCondition.type] + "' non pris en charge";
+    }
+}
\ No newline at end of file
diff --git a/src/app/calculators/generic/formulaire.ts b/src/app/formulaire/formulaire-definition.ts
similarity index 67%
rename from src/app/calculators/generic/formulaire.ts
rename to src/app/formulaire/formulaire-definition.ts
index 34df5eb45..caf1ad4ee 100644
--- a/src/app/calculators/generic/formulaire.ts
+++ b/src/app/formulaire/formulaire-definition.ts
@@ -1,14 +1,25 @@
-import { ComputeNodeType, ParamDefinition } from 'jalhyd';
+import { ComputeNodeType } from "jalhyd";
+
+import { ParamService } from "../services/param/param.service";
+import { Field } from "./field";
+import { NgParameter, ParamRadioConfig } from "./ngparam";
+import { CheckField } from "./check-field";
+import { SelectField } from "./select-field";
+import { SelectEntry } from "./select-entry";
+import { FieldSet } from "./fieldset";
+import { Dependency } from "./dependency";
+import { DependencyCondition, DependencyConditionType } from "./dependency-condition";
+import { FormulaireElement } from "./formulaire-element";
+import { ValueDependency } from "./value-dependency";
+import { ValueDependencyCondition } from "./value-dependency-condition";
+import { ExistenceDependency } from "./existence-dependency";
 
-import { NgParameter, ParamRadioConfig } from '../generic/ngparam';
-import { ParamService } from '../../services/param/param.service';
-import { StringMap } from '../../stringmap';
-import { logObject } from '../../util';
 
 export enum CalculatorType {
     ConduiteDistributrice, LechaptCalmon, SectionParametree, RegimeUniforme, CourbeRemous
 }
 
+
 export class FormulaireDefinition {
     /**
      * objet JSON chargé depuis le fichier de configuration de la calculette
@@ -457,302 +468,3 @@ export class FormulaireDefinition {
         return this.getFormulaireElementById(id).isDisplayed;
     }
 }
-
-export abstract class FormulaireElement {
-    private _nodeType: ComputeNodeType;
-    private _id: string;
-    public isDisplayed: boolean;
-    public label: string;
-
-    constructor(nodeType: ComputeNodeType, id: string) {
-        this._nodeType = nodeType;
-        this._id = id;
-        this.isDisplayed = true;
-    }
-
-    get computeNodeType(): ComputeNodeType {
-        return this._nodeType;
-    }
-
-    get id(): string {
-        return this._id;
-    }
-
-    protected abstract verifyDependency(d: Dependency): boolean;
-
-    public verifiesDependency(d: Dependency): boolean {
-        if (d.masterCondition.type == DependencyConditionType.IsDisplayed)
-            return this.isDisplayed;
-
-        return this.verifyDependency(d);
-    }
-
-    public updateLocalisation(loc: StringMap) {
-        this.label = loc[this.id];
-    }
-
-    public toString() {
-        return "id:" + this._id + (this.isDisplayed ? " displayed" : " NOT displayed") + " label:" + this.label;
-    }
-}
-
-export enum FieldType {
-    Input, Select, Check
-}
-
-export abstract class Field extends FormulaireElement {
-    constructor(nodeType: ComputeNodeType, id: string, private _fieldType: FieldType) {
-        super(nodeType, id);
-    }
-
-    public get isInput(): boolean {
-        return this._fieldType == FieldType.Input;
-    }
-
-    public get isSelect(): boolean {
-        return this._fieldType == FieldType.Select;
-    }
-
-    public get isCheck(): boolean {
-        return this._fieldType == FieldType.Check;
-    }
-
-    public abstract getValue(): any;
-    public abstract setValue(val: any): void;
-}
-
-export class FieldSet extends FormulaireElement {
-    private _fields: Field[];
-
-    constructor(nodeType: ComputeNodeType, id: string) {
-        super(nodeType, id);
-        this._fields = [];
-    }
-
-    public get fields() {
-        return this._fields;
-    }
-
-    public addField(f: Field) {
-        this._fields.push(f);
-    }
-
-    public get hasInputs(): boolean {
-        for (let f of this._fields)
-            if (f instanceof NgParameter)
-                return true;
-        return false;
-    }
-
-    public getInput(i: number): NgParameter {
-        let n = 0;
-        for (let f of this._fields) {
-            if (f instanceof NgParameter) {
-                if (n == i)
-                    return f;
-                n++;
-            }
-        }
-        return undefined;
-    }
-
-    protected verifyDependency(d: Dependency): boolean {
-        throw "FieldSet.verifyDependency() : type de condition '" + DependencyConditionType[d.masterCondition.type] + "' non pris en charge";
-    }
-}
-
-export class SelectEntry {
-    private _value: string;
-    public label: string;
-
-    constructor(v: string, l: string) {
-        this._value = v;
-        this.label = l;
-    }
-
-    get value(): string {
-        return this._value;
-    }
-}
-
-export class SelectField extends Field {
-    private _entries: SelectEntry[];
-
-    public selectedEntry: SelectEntry;
-
-    public get entries() {
-        return this._entries;
-    }
-
-    constructor(nodeType: ComputeNodeType, id: string) {
-        super(nodeType, id, FieldType.Select);
-        this._entries = [];
-    }
-
-    public addEntry(e: SelectEntry) {
-        this._entries.push(e);
-        if (this.selectedEntry == undefined)
-            this.selectedEntry = e;
-    }
-
-    public getValue() {
-        if (this.selectedEntry == undefined)
-            return undefined;
-        return this.selectedEntry.value;
-    }
-
-    public setValue(val: string) {
-        for (let e of this._entries)
-            if (e.value === val) {
-                this.selectedEntry = e;
-                return;
-            }
-    }
-
-    public getLabel() {
-        if (this.selectedEntry == undefined)
-            return undefined;
-        return this.selectedEntry.label;
-    }
-
-    protected verifyDependency(d: Dependency): boolean {
-        switch (d.masterCondition.type) {
-            case DependencyConditionType.HasValue:
-                let mc: ValueDependencyCondition = <ValueDependencyCondition>d.masterCondition;
-                return this.selectedEntry.value === mc.value;
-
-            default:
-                throw "SelectField.verifyDependency() : type de condition '" + DependencyConditionType[d.masterCondition.type] + "' non pris en charge";
-        }
-    }
-
-    public updateLocalisation(loc: StringMap) {
-        super.updateLocalisation(loc);
-
-        for (let e of this._entries) {
-            e.label = loc[e.value];
-        }
-    }
-}
-
-export class CheckField extends Field {
-    private _value: boolean;
-
-    constructor(nodeType: ComputeNodeType, id: string) {
-        super(nodeType, id, FieldType.Check);
-        this._value = false;
-    }
-
-    public getValue(): boolean {
-        return this._value;
-    }
-
-    public setValue(val: boolean) {
-        this._value = val;
-    }
-
-    protected verifyDependency(d: Dependency): boolean {
-        throw "CheckField.verifyDependency() : type de condition '" + DependencyConditionType[d.masterCondition.type] + "' non pris en charge";
-    }
-}
-
-export abstract class InputField extends Field {
-    private _value: any;
-
-    constructor(type: ComputeNodeType, id: string) {
-        super(type, id, FieldType.Input);
-    }
-
-    public getValue() {
-        return this._value;
-    }
-
-    public setValue(val: any) {
-        this._value = val;
-    }
-}
-
-export enum DependencyConditionType {
-    HasValue, IsVariable, IsDisplayed
-}
-
-export class DependencyCondition {
-    constructor(private _type: DependencyConditionType) {
-    }
-
-    public get type() {
-        return this._type;
-    }
-
-    public toString(): string {
-        return "cond=" + DependencyConditionType[this._type];
-    }
-}
-
-export class ValueDependencyCondition extends DependencyCondition {
-    constructor(private _value: any) {
-        super(DependencyConditionType.HasValue);
-    }
-
-    public get value(): any {
-        return this._value;
-    }
-
-    public toString(): string {
-        return super.toString() + " " + this._value;
-    }
-}
-
-export abstract class Dependency {
-    private _master: FormulaireElement;
-
-    private _slave: FormulaireElement;
-
-    private _masterCondition: DependencyCondition;
-
-    constructor(m: FormulaireElement, s: FormulaireElement, mc: DependencyCondition) {
-        this._master = m;
-        this._slave = s;
-        this._masterCondition = mc;
-    }
-
-    public get masterElement(): FormulaireElement {
-        return this._master;
-    }
-
-    public get slaveElement(): FormulaireElement {
-        return this._slave;
-    }
-
-    public get masterCondition(): DependencyCondition {
-        return this._masterCondition;
-    }
-
-    public toString(): string {
-        return "master=" + this._master.toString() + "\n  " + this._masterCondition.toString() + "\n  slave=" + this._slave.toString();
-    }
-}
-
-export class ValueDependency extends Dependency {
-    public slaveValue: any;
-
-    constructor(m: FormulaireElement, s: FormulaireElement, masterValue: any) {
-        super(m, s, new ValueDependencyCondition(masterValue));
-    }
-
-    public toString() {
-        return "valdep\n  " + super.toString() + "\n  slave val " + this.slaveValue;
-    }
-}
-
-export class ExistenceDependency extends Dependency {
-    /**
-     * true : l'élément slave est affiché si le master est affiché
-     * false : l'élément slave est affiché si le master n'est pas affiché
-     */
-    // private _direct: boolean;
-
-    public toString() {
-        return "existdep\n  " + super.toString();
-    }
-}
diff --git a/src/app/formulaire/formulaire-element.ts b/src/app/formulaire/formulaire-element.ts
new file mode 100644
index 000000000..82104104b
--- /dev/null
+++ b/src/app/formulaire/formulaire-element.ts
@@ -0,0 +1,44 @@
+import { ComputeNodeType } from "jalhyd";
+
+import { Dependency } from "./dependency"
+import { DependencyConditionType } from "./dependency-condition"
+import { StringMap } from "../stringmap";
+
+
+export abstract class FormulaireElement {
+    private _nodeType: ComputeNodeType;
+    private _id: string;
+    public isDisplayed: boolean;
+    public label: string;
+
+    constructor(nodeType: ComputeNodeType, id: string) {
+        this._nodeType = nodeType;
+        this._id = id;
+        this.isDisplayed = true;
+    }
+
+    get computeNodeType(): ComputeNodeType {
+        return this._nodeType;
+    }
+
+    get id(): string {
+        return this._id;
+    }
+
+    protected abstract verifyDependency(d: Dependency): boolean;
+
+    public verifiesDependency(d: Dependency): boolean {
+        if (d.masterCondition.type == DependencyConditionType.IsDisplayed)
+            return this.isDisplayed;
+
+        return this.verifyDependency(d);
+    }
+
+    public updateLocalisation(loc: StringMap) {
+        this.label = loc[this.id];
+    }
+
+    public toString() {
+        return "id:" + this._id + (this.isDisplayed ? " displayed" : " NOT displayed") + " label:" + this.label;
+    }
+}
diff --git a/src/app/formulaire/input-field.ts b/src/app/formulaire/input-field.ts
new file mode 100644
index 000000000..828cad3e4
--- /dev/null
+++ b/src/app/formulaire/input-field.ts
@@ -0,0 +1,20 @@
+import { ComputeNodeType } from "jalhyd";
+
+import { Field, FieldType } from "./field"
+
+
+export abstract class InputField extends Field {
+    private _value: any;
+
+    constructor(type: ComputeNodeType, id: string) {
+        super(type, id, FieldType.Input);
+    }
+
+    public getValue() {
+        return this._value;
+    }
+
+    public setValue(val: any) {
+        this._value = val;
+    }
+}
diff --git a/src/app/calculators/generic/ngparam.ts b/src/app/formulaire/ngparam.ts
similarity index 88%
rename from src/app/calculators/generic/ngparam.ts
rename to src/app/formulaire/ngparam.ts
index dcd8c8334..3c5a5d761 100644
--- a/src/app/calculators/generic/ngparam.ts
+++ b/src/app/formulaire/ngparam.ts
@@ -1,7 +1,10 @@
-import { ComputeNodeType, ParamDefinition, ParamDomainValue } from 'jalhyd';
+import { ParamDefinition, ParamDomainValue } from "jalhyd";
 
-import { InputField, Dependency, DependencyConditionType, ValueDependencyCondition } from './formulaire';
-import { StringMap } from '../../stringmap';
+import { InputField } from "./input-field";
+import { Dependency } from "./dependency";
+import { DependencyCondition, DependencyConditionType } from "./dependency-condition";
+import { ValueDependencyCondition } from "./value-dependency-condition";
+import { StringMap } from "../stringmap";
 
 export enum ParamRadioConfig {
     /**
@@ -20,8 +23,9 @@ export enum ParamRadioConfig {
     CAL
 };
 
+
 /**
- * class englobante de ParamDefinition (champs supplémentaires pour l'affichage, radio boutons, ...)
+ * classe englobante de ParamDefinition (champs supplémentaires pour l'affichage, radio boutons, ...)
  */
 export class NgParameter extends InputField {
     public unit: string;
diff --git a/src/app/formulaire/select-entry.ts b/src/app/formulaire/select-entry.ts
new file mode 100644
index 000000000..07c1eae7e
--- /dev/null
+++ b/src/app/formulaire/select-entry.ts
@@ -0,0 +1,13 @@
+export class SelectEntry {
+    private _value: string;
+    public label: string;
+
+    constructor(v: string, l: string) {
+        this._value = v;
+        this.label = l;
+    }
+
+    get value(): string {
+        return this._value;
+    }
+}
diff --git a/src/app/formulaire/select-field.ts b/src/app/formulaire/select-field.ts
new file mode 100644
index 000000000..812b4b119
--- /dev/null
+++ b/src/app/formulaire/select-field.ts
@@ -0,0 +1,70 @@
+import { ComputeNodeType } from "jalhyd";
+
+import { Field } from "./field";
+import { SelectEntry } from "./select-entry";
+import { FieldType } from "./field";
+import { Dependency } from "./dependency";
+import { DependencyConditionType } from "./dependency-condition";
+import { ValueDependencyCondition } from "./value-dependency-condition";
+import { StringMap } from "../stringmap";
+
+
+export class SelectField extends Field {
+    private _entries: SelectEntry[];
+
+    public selectedEntry: SelectEntry;
+
+    public get entries() {
+        return this._entries;
+    }
+
+    constructor(nodeType: ComputeNodeType, id: string) {
+        super(nodeType, id, FieldType.Select);
+        this._entries = [];
+    }
+
+    public addEntry(e: SelectEntry) {
+        this._entries.push(e);
+        if (this.selectedEntry == undefined)
+            this.selectedEntry = e;
+    }
+
+    public getValue() {
+        if (this.selectedEntry == undefined)
+            return undefined;
+        return this.selectedEntry.value;
+    }
+
+    public setValue(val: string) {
+        for (let e of this._entries)
+            if (e.value === val) {
+                this.selectedEntry = e;
+                return;
+            }
+    }
+
+    public getLabel() {
+        if (this.selectedEntry == undefined)
+            return undefined;
+        return this.selectedEntry.label;
+    }
+
+    protected verifyDependency(d: Dependency): boolean {
+        switch (d.masterCondition.type) {
+            case DependencyConditionType.HasValue:
+                let mc: ValueDependencyCondition = <ValueDependencyCondition>d.masterCondition;
+                return this.selectedEntry.value === mc.value;
+
+            default:
+                throw "SelectField.verifyDependency() : type de condition '" + DependencyConditionType[d.masterCondition.type] + "' non pris en charge";
+        }
+    }
+
+    public updateLocalisation(loc: StringMap) {
+        super.updateLocalisation(loc);
+
+        for (let e of this._entries) {
+            e.label = loc[e.value];
+        }
+    }
+}
\ No newline at end of file
diff --git a/src/app/formulaire/value-dependency-condition.ts b/src/app/formulaire/value-dependency-condition.ts
new file mode 100644
index 000000000..b0e309568
--- /dev/null
+++ b/src/app/formulaire/value-dependency-condition.ts
@@ -0,0 +1,16 @@
+import { DependencyCondition, DependencyConditionType } from "./dependency-condition";
+
+
+export class ValueDependencyCondition extends DependencyCondition {
+    constructor(private _value: any) {
+        super(DependencyConditionType.HasValue);
+    }
+
+    public get value(): any {
+        return this._value;
+    }
+
+    public toString(): string {
+        return super.toString() + " " + this._value;
+    }
+}
diff --git a/src/app/formulaire/value-dependency.ts b/src/app/formulaire/value-dependency.ts
new file mode 100644
index 000000000..bd02ee74e
--- /dev/null
+++ b/src/app/formulaire/value-dependency.ts
@@ -0,0 +1,16 @@
+import { Dependency } from "./dependency";
+import { FormulaireElement } from "./formulaire-element";
+import { ValueDependencyCondition } from "./value-dependency-condition";
+
+
+export class ValueDependency extends Dependency {
+    public slaveValue: any;
+
+    constructor(m: FormulaireElement, s: FormulaireElement, masterValue: any) {
+        super(m, s, new ValueDependencyCondition(masterValue));
+    }
+
+    public toString() {
+        return "valdep\n  " + super.toString() + "\n  slave val " + this.slaveValue;
+    }
+}
diff --git a/src/app/services/formulaire/formulaire.service.ts b/src/app/services/formulaire/formulaire.service.ts
index 7c40331e9..db9439187 100644
--- a/src/app/services/formulaire/formulaire.service.ts
+++ b/src/app/services/formulaire/formulaire.service.ts
@@ -1,14 +1,17 @@
-import { Injectable } from '@angular/core';
-import { Response } from '@angular/http';
+import { Injectable } from "@angular/core";
+import { Response } from "@angular/http";
 
 import { ComputeNodeType, ParamsEquation, acSection, Nub, ConduiteDistrib, ConduiteDistribParams } from "jalhyd";
 import { LechaptCalmon, LechaptCalmonParams, ParamsSectionTrapez, cSnTrapez } from "jalhyd";
 import { ParamsSectionRectang, cSnRectang, ParamsSectionCirc, cSnCirc, ParamsSectionPuiss, cSnPuiss } from "jalhyd";
 
-import { ParamService } from '../param/param.service';
-import { HttpService } from '../../services/http/http.service';
-import { FormulaireDefinition, FormulaireElement, CalculatorType, SelectField, CheckField } from '../../calculators/generic/formulaire';
-import { StringMap } from '../../stringmap';
+import { ParamService } from "../param/param.service";
+import { HttpService } from "../../services/http/http.service";
+import { FormulaireDefinition, CalculatorType } from "../../formulaire/formulaire-definition";
+import { FormulaireElement } from "../../formulaire/formulaire-element";
+import { SelectField } from "../../formulaire/select-field";
+import { CheckField } from "../../formulaire/check-field";
+import { StringMap } from "../../stringmap";
 
 @Injectable()
 export class FormulaireService {
diff --git a/src/app/services/param/param.service.ts b/src/app/services/param/param.service.ts
index d952660c1..a7ccb3a8e 100644
--- a/src/app/services/param/param.service.ts
+++ b/src/app/services/param/param.service.ts
@@ -1,13 +1,12 @@
 import {
     ParamDomain, ComputeNodeType, ComputeNodeParameters, ParamsEquation, ParamsSectionRectang, ParamDefinition,
     ParamDomainValue, ParamCalculability
-} from 'jalhyd';
+} from "jalhyd";
 
-import { NgParameter } from "../../calculators/generic/ngparam";
-import { logObject } from '../../util';
+import { NgParameter } from "../../formulaire/ngparam";
+import { logObject } from "../../util";
 
 export class ParamService {
-    // private _params: ParamDefinition[];
     private _params: NgParameter[];
 
     constructor() {
-- 
GitLab