Browse Source

🐛 exclude baseline domain

jmacura 3 năm trước cách đây
mục cha
commit
ceeab5dca8

+ 1 - 1
src/app/app.component.html

@@ -48,7 +48,7 @@
           </ng-container>
           </ng-container>
         </select>
         </select>
         <select [(ngModel)]="selectedDomain" (ngModelChange)="yearGraphService.redrawGraphs({domain: selectedDomain})">
         <select [(ngModel)]="selectedDomain" (ngModelChange)="yearGraphService.redrawGraphs({domain: selectedDomain})">
-          <ng-container *ngFor="let domain of sdmDihService.domains">
+          <ng-container *ngFor="let domain of sdmDihService.domains | filter:baselineFilter">
             <option [ngValue]="domain">{{domain}}</option>
             <option [ngValue]="domain">{{domain}}</option>
           </ng-container>
           </ng-container>
         </select>
         </select>

+ 4 - 0
src/app/app.component.ts

@@ -122,4 +122,8 @@ export class HslayersAppComponent {
       // );
       // );
     });
     });
   }
   }
+
+  baselineFilter = (item): boolean => {
+    return item !== 'baseline';
+  };
 }
 }

+ 3 - 0
src/app/discs-chart/discs.module.ts

@@ -5,6 +5,7 @@ import {NgModule} from '@angular/core';
 import {DiscComponent} from './disc.component';
 import {DiscComponent} from './disc.component';
 import {DiscLegendComponent} from './disc-legend.component';
 import {DiscLegendComponent} from './disc-legend.component';
 import {FactorYearGraphComponent} from './factor-year-graph/factor-year-graph.component';
 import {FactorYearGraphComponent} from './factor-year-graph/factor-year-graph.component';
+import {FilterPipe} from './filter.pipe';
 import {QuarterPipe} from './quarter.pipe';
 import {QuarterPipe} from './quarter.pipe';
 import {ScenarioFactorYearGraphComponent} from './scenario-factor-year-graph/scenario-factor-year-graph.component';
 import {ScenarioFactorYearGraphComponent} from './scenario-factor-year-graph/scenario-factor-year-graph.component';
 import {ScenarioYearGraphComponent} from './scenario-year-graph/scenario-year-graph.component';
 import {ScenarioYearGraphComponent} from './scenario-year-graph/scenario-year-graph.component';
@@ -19,6 +20,7 @@ import {YearGraphComponent} from './year-graph/year-graph.component';
     YearGraphComponent,
     YearGraphComponent,
     ScenarioFactorYearGraphComponent,
     ScenarioFactorYearGraphComponent,
     ScenarioYearGraphComponent,
     ScenarioYearGraphComponent,
+    FilterPipe,
   ],
   ],
   declarations: [
   declarations: [
     DiscComponent,
     DiscComponent,
@@ -27,6 +29,7 @@ import {YearGraphComponent} from './year-graph/year-graph.component';
     YearGraphComponent,
     YearGraphComponent,
     ScenarioFactorYearGraphComponent,
     ScenarioFactorYearGraphComponent,
     ScenarioYearGraphComponent,
     ScenarioYearGraphComponent,
+    FilterPipe,
     QuarterPipe,
     QuarterPipe,
   ],
   ],
   providers: [],
   providers: [],

+ 13 - 0
src/app/discs-chart/filter.pipe.ts

@@ -0,0 +1,13 @@
+import {Pipe, PipeTransform} from '@angular/core';
+
+@Pipe({
+  name: 'filter',
+})
+export class FilterPipe implements PipeTransform {
+  transform(
+    items: Array<any>,
+    filterCallback: (item: any) => boolean
+  ): Array<any> {
+    return items.filter((item) => filterCallback(item));
+  }
+}

+ 1 - 1
src/app/discs-chart/scenario-factor-year-graph/scenario-factor-year-graph.component.ts

@@ -20,11 +20,11 @@ export class ScenarioFactorYearGraphComponent implements OnInit {
   ) {}
   ) {}
 
 
   ngOnInit() {
   ngOnInit() {
-    this.filterScenarios();
     this.sdmDihService.dataLoads.subscribe((loaded) => {
     this.sdmDihService.dataLoads.subscribe((loaded) => {
       if (!loaded) {
       if (!loaded) {
         return;
         return;
       }
       }
+      this.filterScenarios();
     });
     });
     this.yearGraphService.graphRefreshes.subscribe(({domain}) => {
     this.yearGraphService.graphRefreshes.subscribe(({domain}) => {
       if (domain) {
       if (domain) {

+ 1 - 1
src/app/discs-chart/scenario-year-graph/scenario-year-graph.component.ts

@@ -20,11 +20,11 @@ export class ScenarioYearGraphComponent implements OnInit {
   ) {}
   ) {}
 
 
   ngOnInit() {
   ngOnInit() {
-    this.filterScenarios();
     this.sdmDihService.dataLoads.subscribe((loaded) => {
     this.sdmDihService.dataLoads.subscribe((loaded) => {
       if (!loaded) {
       if (!loaded) {
         return;
         return;
       }
       }
+      this.filterScenarios();
     });
     });
     this.yearGraphService.graphRefreshes.subscribe(({domain}) => {
     this.yearGraphService.graphRefreshes.subscribe(({domain}) => {
       if (domain) {
       if (domain) {