From 44376154523d3cc3110e27dc3e5d0d19c1288081 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Lukas=20Mau=C3=9F?= <lukas.mauss@mni.thm.de>
Date: Tue, 4 Dec 2018 14:39:06 +0100
Subject: [PATCH] Destructure statuses

---
 .../list-statistic.component.html             | 30 +++++++++----------
 .../list-statistic.component.ts               | 10 ++++---
 2 files changed, 21 insertions(+), 19 deletions(-)

diff --git a/src/app/components/shared/list-statistic/list-statistic.component.html b/src/app/components/shared/list-statistic/list-statistic.component.html
index 38d9106cd..25e324e3b 100644
--- a/src/app/components/shared/list-statistic/list-statistic.component.html
+++ b/src/app/components/shared/list-statistic/list-statistic.component.html
@@ -1,39 +1,39 @@
 <mat-toolbar></mat-toolbar>
 <mat-progress-bar class="progress-theme" mode="determinate" value="{{total}}"
-                  *ngIf="total > statusGood" color="primary"></mat-progress-bar>
+                  *ngIf="total > status.good" color="primary"></mat-progress-bar>
 <mat-progress-bar class="progress-theme" mode="determinate" value="{{total}}"
-                  *ngIf="total < statusGood && total >= statusOkay" color="accent"></mat-progress-bar>
+                  *ngIf="total < status.good && total >= status.okay" color="accent"></mat-progress-bar>
 <mat-progress-bar class="progress-theme" mode="determinate" value="{{total}}"
-                  *ngIf="total < statusOkay && total > statusEmpty" color="warn"></mat-progress-bar>
+                  *ngIf="total < status.okay && total > status.empty" color="warn"></mat-progress-bar>
 <mat-toolbar></mat-toolbar>
 <table mat-table [dataSource]="dataSource" class="mat-elevation-z8">
 
   <ng-container matColumnDef="content">
     <mat-header-cell *matHeaderCellDef> Content </mat-header-cell>
-    <mat-cell *matCellDef="let cp" [ngClass]="{'positiveC' : cp.percent >= statusGood,
-      'okayC' : cp.percent >= statusOkay && cp.percent < statusGood, 'negativeC' : cp.percent < statusOkay,
-      'emptyCC' : cp.percent < statusZero }">{{cp.content.subject}}</mat-cell>
+    <mat-cell *matCellDef="let cp" [ngClass]="{'positiveC' : cp.percent >= status.good,
+      'okayC' : cp.percent >= status.okay && cp.percent < status.good, 'negativeC' : cp.percent < status.okay,
+      'emptyCC' : cp.percent < status.zero }">{{cp.content.subject}}</mat-cell>
   </ng-container>
 
   <ng-container matColumnDef="percentage">
     <mat-header-cell *matHeaderCellDef> Percentage </mat-header-cell>
-    <mat-cell *matCellDef="let cp" [ngClass]="{'positiveC' : cp.percent >= statusGood,
-      'okayC' : cp.percent >= statusOkay && cp.percent < statusGood, 'negativeC' : cp.percent < statusOkay,
-      'emptyC' : cp.percent < statusZero }">{{cp.percent.toFixed() + ' %'}}</mat-cell>
+    <mat-cell *matCellDef="let cp" [ngClass]="{'positiveC' : cp.percent >= status.good,
+      'okayC' : cp.percent >= status.okay && cp.percent < status.good, 'negativeC' : cp.percent < status.okay,
+      'emptyC' : cp.percent < status.zero }">{{cp.percent.toFixed() + ' %'}}</mat-cell>
   </ng-container>
 
   <ng-container matColumnDef="counts">
     <mat-header-cell *matHeaderCellDef> Total </mat-header-cell>
-    <mat-cell *matCellDef="let cp" [ngClass]="{'positiveC' : cp.percent >= statusGood,
-      'okayC' : cp.percent >= statusOkay && cp.percent < statusGood, 'negativeC' : cp.percent < statusOkay,
-      'emptyC' : cp.percent < statusZero }">{{cp.counts}}</mat-cell>
+    <mat-cell *matCellDef="let cp" [ngClass]="{'positiveC' : cp.percent >= status.good,
+      'okayC' : cp.percent >= status.okay && cp.percent < status.good, 'negativeC' : cp.percent < status.okay,
+      'emptyC' : cp.percent < status.zero }">{{cp.counts}}</mat-cell>
   </ng-container>
 
   <ng-container matColumnDef="abstentions">
     <mat-header-cell *matHeaderCellDef> Abstentions </mat-header-cell>
-    <mat-cell *matCellDef="let cp" [ngClass]="{'positiveC' : cp.percent >= statusGood,
-      'okayC' : cp.percent >= statusOkay && cp.percent < statusGood, 'negativeC' : cp.percent < statusOkay,
-      'emptyC' : cp.percent < statusZero }">{{cp.abstentions}}</mat-cell>
+    <mat-cell *matCellDef="let cp" [ngClass]="{'positiveC' : cp.percent >= status.good,
+      'okayC' : cp.percent >= status.okay && cp.percent < status.good, 'negativeC' : cp.percent < status.okay,
+      'emptyC' : cp.percent < status.zero }">{{cp.abstentions}}</mat-cell>
   </ng-container>
 
   <mat-header-row *matHeaderRowDef="displayedColumns"></mat-header-row>
diff --git a/src/app/components/shared/list-statistic/list-statistic.component.ts b/src/app/components/shared/list-statistic/list-statistic.component.ts
index 23fbe9394..9cec4ae32 100644
--- a/src/app/components/shared/list-statistic/list-statistic.component.ts
+++ b/src/app/components/shared/list-statistic/list-statistic.component.ts
@@ -31,10 +31,12 @@ export class ListStatisticComponent implements OnInit {
   @Input() contentGroup: ContentGroup;
   contents: Content[] = [];
   displayedColumns = ['content', 'counts', 'abstentions', 'percentage'];
-  statusGood = 85;
-  statusOkay = 50;
-  statusEmpty = -1;
-  statusZero = 0;
+  status = {
+    good: 85 ,
+    okay: 50 ,
+    empty: -1,
+    zero: 0
+  };
   dataSource: ContentPercents[];
   total = 0;
   totalP = 0;
-- 
GitLab