From b86f5394d6d6f18e422ec56759034a18faa4d052 Mon Sep 17 00:00:00 2001 From: Florian Hartwich Date: Sat, 12 Aug 2017 22:27:23 +0200 Subject: [PATCH] Fix design for campaign overview --- api/routes/wars.js | 2 +- .../overview/stats-overview.component.ts | 21 ++++++++--------- .../statistic/war-list/war-list.component.css | 7 ++++++ .../war-list/war-list.component.html | 20 ++++++++++++---- .../statistic/war-list/war-list.component.ts | 23 ++++++++++--------- 5 files changed, 45 insertions(+), 28 deletions(-) diff --git a/api/routes/wars.js b/api/routes/wars.js index e98ca43..d50277c 100644 --- a/api/routes/wars.js +++ b/api/routes/wars.js @@ -41,7 +41,7 @@ wars.route('/') } if (wars) { campaigns.forEach(campaign => { - let entry = {title: campaign.title, wars: []}; + let entry = {_id: campaign._id, title: campaign.title, wars: []}; wars.forEach((war) => { if (String(campaign._id) === String(war.campaign)) { entry.wars.push(war); diff --git a/static/src/app/statistic/overview/stats-overview.component.ts b/static/src/app/statistic/overview/stats-overview.component.ts index 9187fa5..2243779 100644 --- a/static/src/app/statistic/overview/stats-overview.component.ts +++ b/static/src/app/statistic/overview/stats-overview.component.ts @@ -28,8 +28,6 @@ export class StatisticOverviewComponent { this.route.params .map(params => params['id']) .subscribe((id) => { - console.log(id); - if (this.warService.campaigns) { this.initWars(this.warService.campaigns, id); } else { @@ -41,18 +39,17 @@ export class StatisticOverviewComponent { } initWars(campaigns, id) { + let wars = []; let itemsProcessed = 0; - - campaigns - .filter(campaign => id === 'all' || campaign._id === id) - .forEach(campaign => { - wars = wars.concat(campaign.wars); - itemsProcessed++; - if (itemsProcessed === campaigns.length) { - this.initChart(wars); - } - }) + campaigns = campaigns.filter(campaign => id === 'all' || campaign._id === id); + campaigns.forEach(campaign => { + wars = wars.concat(campaign.wars); + itemsProcessed++; + if (itemsProcessed === campaigns.length) { + this.initChart(wars); + } + }) } initChart(wars: any[]) { diff --git a/static/src/app/statistic/war-list/war-list.component.css b/static/src/app/statistic/war-list/war-list.component.css index c072fcd..3a4d680 100644 --- a/static/src/app/statistic/war-list/war-list.component.css +++ b/static/src/app/statistic/war-list/war-list.component.css @@ -6,3 +6,10 @@ .rank-list { width: 100%; } + +:host /deep/ .card-header { + background-color: slategray; + padding: 15px; + color: white; + font-weight: 600; +} diff --git a/static/src/app/statistic/war-list/war-list.component.html b/static/src/app/statistic/war-list/war-list.component.html index be9b7e2..d1e440c 100644 --- a/static/src/app/statistic/war-list/war-list.component.html +++ b/static/src/app/statistic/war-list/war-list.component.html @@ -6,22 +6,34 @@
+ [ngClass]="{selected : selectedWarId == 'all'}" (click)="selectOverview('all')">
- + -
+
{{campaign.title}}
+ +
+
+ +
+
+
{ if (this.selectedWarId === war._id) { - this.selectOverview(); + this.selectOverview('all'); } this.campaigns.splice(this.campaigns.indexOf(war), 1); }) } } - open(event) { - console.log(event); - } }