Fix switch view selection on stats page (CC-50)
parent
e23ed09b25
commit
06123a2301
|
@ -6,9 +6,9 @@
|
|||
(campaignDelete)="deleteCampaign($event)">
|
||||
</campaign-navigation>
|
||||
|
||||
<div *ngIf="selectedCampaign._id !== 'all'"
|
||||
class="side-bar"
|
||||
[ngClass]="{collapsed: collapsed}">
|
||||
<div class="side-bar"
|
||||
[ngClass]="{collapsed: collapsed}"
|
||||
[style.display]="selectedCampaign._id === 'all' ? 'none' : 'block'">
|
||||
<war-list
|
||||
[collapsed]="collapsed"
|
||||
[campaign]="selectedCampaign">
|
||||
|
|
|
@ -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});
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue