Fix switch view selection on stats page (CC-50)

pull/44/head
HardiReady 2018-08-18 17:38:21 +02:00
parent e23ed09b25
commit 06123a2301
2 changed files with 16 additions and 20 deletions

View File

@ -6,9 +6,9 @@
(campaignDelete)="deleteCampaign($event)"> (campaignDelete)="deleteCampaign($event)">
</campaign-navigation> </campaign-navigation>
<div *ngIf="selectedCampaign._id !== 'all'" <div class="side-bar"
class="side-bar" [ngClass]="{collapsed: collapsed}"
[ngClass]="{collapsed: collapsed}"> [style.display]="selectedCampaign._id === 'all' ? 'none' : 'block'">
<war-list <war-list
[collapsed]="collapsed" [collapsed]="collapsed"
[campaign]="selectedCampaign"> [campaign]="selectedCampaign">

View File

@ -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 {ActivatedRoute, Router} from '@angular/router';
import {Campaign, War} from '../../../models/model-interfaces'; import {Campaign, War} from '../../../models/model-interfaces';
import {WarService} from '../../../services/logs/war.service'; import {WarService} from '../../../services/logs/war.service';
@ -11,7 +11,7 @@ import {RouteConfig} from '../../../app.config';
templateUrl: './war-list.component.html', templateUrl: './war-list.component.html',
styleUrls: ['./war-list.component.css'] styleUrls: ['./war-list.component.css']
}) })
export class WarListComponent implements OnChanges, AfterViewInit { export class WarListComponent implements OnChanges {
@Input() campaign: Campaign; @Input() campaign: Campaign;
@ -19,7 +19,7 @@ export class WarListComponent implements OnChanges, AfterViewInit {
selectedWarId: string | number; selectedWarId: string | number;
initialized = false; changeCount = 0;
public readonly highscore = 'HIGHSCORE'; public readonly highscore = 'HIGHSCORE';
@ -30,12 +30,9 @@ export class WarListComponent implements OnChanges, AfterViewInit {
private route: ActivatedRoute) { private route: ActivatedRoute) {
} }
ngAfterViewInit() {
this.initialized = true;
}
ngOnChanges(changes: SimpleChanges) { ngOnChanges(changes: SimpleChanges) {
if (this.initialized && changes.campaign) { if (this.changeCount <= 1) {
this.changeCount++;
const url = this.router.url; const url = this.router.url;
const subPathWar = 'war/'; const subPathWar = 'war/';
const subPathHighscore = 'highscore/'; 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) { selectOverview(campaignId) {
if (this.selectedWarId !== campaignId) { if (this.selectedWarId !== campaignId) {
this.selectedWarId = campaignId; this.selectedWarId = campaignId;
setTimeout(_ => {
window.dispatchEvent(new Event('resize'));
});
this.router.navigate([{outlets: {'right': ['overview', campaignId]}}], {relativeTo: this.route}); this.router.navigate([{outlets: {'right': ['overview', campaignId]}}], {relativeTo: this.route});
} }
} }