From b86441cb7403f56cc0a3bc5267c8d7b1334745f7 Mon Sep 17 00:00:00 2001
From: "francois.grand" <francois.grand@irstea.fr>
Date: Thu, 25 Jan 2018 14:44:00 +0100
Subject: [PATCH] modifs GraphTypeSelectComponent/ResultsGraphComponent suite
 au remaniement sur GenericSelectComponent

---
 .../results-graph/results-graph.component.ts    | 17 ++++++-----------
 1 file changed, 6 insertions(+), 11 deletions(-)

diff --git a/src/app/components/results-graph/results-graph.component.ts b/src/app/components/results-graph/results-graph.component.ts
index 83b55ff98..ceba3ed60 100644
--- a/src/app/components/results-graph/results-graph.component.ts
+++ b/src/app/components/results-graph/results-graph.component.ts
@@ -7,16 +7,15 @@ import { GenericSelectComponent } from '../generic-select/generic-select.compone
     selector: "graph-type",
     templateUrl: "../generic-select/generic-select.component.html"
 })
-export class GraphTypeSelectComponent extends GenericSelectComponent {
+export class GraphTypeSelectComponent extends GenericSelectComponent<GraphType> {
     private _entries: GraphType[] = [GraphType.Histogram, GraphType.Scatter];
     private _entriesLabels: string[] = ["Histogramme", "XY"];
 
-    protected get entries(): any[] {
+    protected get entries(): GraphType[] {
         return this._entries;
     }
 
-    protected entryLabel(entry: any): string {
-        // return entry;
+    protected entryLabel(entry: GraphType): string {
         const i = this._entries.indexOf(entry);
         return this._entriesLabels[i];
     }
@@ -26,11 +25,9 @@ export class GraphTypeSelectComponent extends GenericSelectComponent {
     selector: 'results-graph',
     templateUrl: './results-graph.component.html'
 })
-export class ResultsGraphComponent { //implements AfterViewInit {
+export class ResultsGraphComponent {
     private _results: FixedVarResults;
 
-    private _currentGraphType: GraphType;
-
     @ViewChild(GraphTypeSelectComponent)
     private _graphTypeComponent: GraphTypeSelectComponent;
 
@@ -56,12 +53,11 @@ export class ResultsGraphComponent { //implements AfterViewInit {
 
     public set results(r: FixedVarResults) {
         this._results = r;
-        this._currentGraphType = r.graphType;
-        this._graphTypeComponent.selectedValue = this._currentGraphType;
+        this._graphTypeComponent.selectedValue = r.graphType;
     }
 
     public updateView() {
-        switch (this._currentGraphType) {
+        switch (this._graphTypeComponent.selectedValue) {
             case GraphType.Histogram:
                 this.graph_type = "bar";
                 this.generateBarGraph();
@@ -80,7 +76,6 @@ export class ResultsGraphComponent { //implements AfterViewInit {
     }
 
     private onGraphTypeSelectChange(event) {
-        this._currentGraphType = event;
         this.updateView();
     }
 
-- 
GitLab