diff --git a/static/src/app/statistic/stats.component.html b/static/src/app/statistic/stats.component.html
index 7378a3c..61455a5 100644
--- a/static/src/app/statistic/stats.component.html
+++ b/static/src/app/statistic/stats.component.html
@@ -6,9 +6,9 @@
(campaignDelete)="deleteCampaign($event)">
-
+
diff --git a/static/src/app/statistic/war/war-list/war-list.component.ts b/static/src/app/statistic/war/war-list/war-list.component.ts
index 55cc855..a9f288d 100644
--- a/static/src/app/statistic/war/war-list/war-list.component.ts
+++ b/static/src/app/statistic/war/war-list/war-list.component.ts
@@ -1,4 +1,4 @@
-import {AfterViewInit, Component, Input, OnChanges, SimpleChanges} from '@angular/core';
+import {AfterViewInit, Component, Input, OnChanges, OnInit, SimpleChanges} from '@angular/core';
import {ActivatedRoute, Router} from '@angular/router';
import {Campaign, War} from '../../../models/model-interfaces';
import {WarService} from '../../../services/logs/war.service';
@@ -11,7 +11,7 @@ import {RouteConfig} from '../../../app.config';
templateUrl: './war-list.component.html',
styleUrls: ['./war-list.component.css']
})
-export class WarListComponent implements OnChanges, AfterViewInit {
+export class WarListComponent implements OnChanges {
@Input() campaign: Campaign;
@@ -19,7 +19,7 @@ export class WarListComponent implements OnChanges, AfterViewInit {
selectedWarId: string | number;
- initialized = false;
+ changeCount = 0;
public readonly highscore = 'HIGHSCORE';
@@ -30,12 +30,9 @@ export class WarListComponent implements OnChanges, AfterViewInit {
private route: ActivatedRoute) {
}
- ngAfterViewInit() {
- this.initialized = true;
- }
-
ngOnChanges(changes: SimpleChanges) {
- if (this.initialized && changes.campaign) {
+ if (this.changeCount <= 1) {
+ this.changeCount++;
const url = this.router.url;
const subPathWar = 'war/';
const subPathHighscore = 'highscore/';
@@ -54,6 +51,8 @@ export class WarListComponent implements OnChanges, AfterViewInit {
}
}
}
+ } else if (changes.campaign) {
+ this.selectOverview(this.campaign._id);
}
}
@@ -72,9 +71,6 @@ export class WarListComponent implements OnChanges, AfterViewInit {
selectOverview(campaignId) {
if (this.selectedWarId !== campaignId) {
this.selectedWarId = campaignId;
- setTimeout(_ => {
- window.dispatchEvent(new Event('resize'));
- });
this.router.navigate([{outlets: {'right': ['overview', campaignId]}}], {relativeTo: this.route});
}
}
@@ -99,12 +95,12 @@ export class WarListComponent implements OnChanges, AfterViewInit {
deleteWar(war: War) {
if (confirm('Soll die Schlacht ' + war.title + ' wirklich gelöscht werden?')) {
this.warService.deleteWar(war._id)
- .subscribe((res) => {
- if (this.selectedWarId === war._id) {
- this.selectOverview('all');
- }
- this.campaign.wars.splice(this.campaign.wars.indexOf(war), 1);
- });
+ .subscribe((res) => {
+ if (this.selectedWarId === war._id) {
+ this.selectOverview('all');
+ }
+ this.campaign.wars.splice(this.campaign.wars.indexOf(war), 1);
+ });
}
}
}