plitting up tier in different poules / components

This commit is contained in:
Joachim 2018-09-08 14:35:44 +02:00
parent 6c57a2b0cd
commit 2ca6434815
6 changed files with 40 additions and 17 deletions

View File

@ -3,13 +3,18 @@ import {CommonModule} from '@angular/common';
import {RouterModule, Routes} from '@angular/router'; import {RouterModule, Routes} from '@angular/router';
import {TierComponent} from './content/tier/tier.component'; import {TierComponent} from './content/tier/tier.component';
import {ChampionshipComponent} from './championship/championship.component'; import {ChampionshipComponent} from './championship/championship.component';
import {PouleComponent} from './content/poule/poule.component';
const routes: Routes = [ const routes: Routes = [
{ {
path: 'championship/:idchampionship', path: 'championship/:idchampionship',
component: ChampionshipComponent, component: ChampionshipComponent,
children: [ children: [
{path: 'tier/:tier', component: TierComponent}, {
path: 'tier/:tier', component: TierComponent, children: [
{path: 'poule/:poule', component: PouleComponent}
]
},
] ]
}, },
]; ];

View File

@ -6,7 +6,7 @@
"topmenu" "topmenu"
"content" "content"
"reclame"; "reclame";
grid-template-rows: auto 1fr 200px; grid-template-rows: auto 1fr 50px;
} }
app-reclamespinner { app-reclamespinner {

View File

@ -19,3 +19,4 @@
.timecell { .timecell {
font-family: monospace; font-family: monospace;
} }

View File

@ -1,20 +1,18 @@
import {Component, Input, OnChanges, OnInit, SimpleChanges} from '@angular/core'; import {Component, Input, OnChanges, OnInit, SimpleChanges} from '@angular/core';
import {ChampionshipService} from '../../championship.service'; import {ChampionshipService} from '../../championship.service';
import {ActivatedRoute} from '@angular/router';
import {map} from 'rxjs/operators';
import {combineLatest} from 'rxjs';
@Component({ @Component({
selector: 'app-poule', selector: 'app-poule',
templateUrl: './poule.component.html', templateUrl: './poule.component.html',
styleUrls: ['./poule.component.scss'] styleUrls: ['./poule.component.scss']
}) })
export class PouleComponent implements OnInit, OnChanges { export class PouleComponent implements OnInit {
@Input()
poule: number; poule: number;
@Input()
idChampionship: number; idChampionship: number;
@Input()
tier: number; tier: number;
protected teams: any[] = []; protected teams: any[] = [];
@ -23,11 +21,25 @@ export class PouleComponent implements OnInit, OnChanges {
private timesIndexed: {}; private timesIndexed: {};
protected maxLaps = 0; protected maxLaps = 0;
constructor(private championshipService: ChampionshipService) { constructor(private championshipService: ChampionshipService, private route: ActivatedRoute) {
} }
ngOnInit() { ngOnInit() {
this.loadData(); const tier$ = this.route.parent.params.pipe(map(v => v['tier']));
const poule$ = this.route.params.pipe(map(v => v['poule']));
const championship$ = this.route.parent.parent.params.pipe(map(v => v['idchampionship']));
combineLatest(tier$, poule$, championship$).subscribe(([tier, poule, championship]) => {
console.log('tier/poule/champ changed');
console.log(tier);
console.log(poule);
console.log(championship);
this.tier = tier;
this.poule = poule;
this.idChampionship = championship;
this.loadData();
});
} }
private loadData() { private loadData() {
@ -145,9 +157,4 @@ export class PouleComponent implements OnInit, OnChanges {
return null; return null;
} }
} }
ngOnChanges(changes: SimpleChanges): void {
this.loadData();
}
} }

View File

@ -1,3 +1,9 @@
<div id="poulecontainer"> <div class="button-row">
<app-poule *ngFor="let poule of poules" [poule]="poule" [idChampionship]="idChampionship" [tier]="tier"></app-poule> <!--pick a year-->
<button mat-raised-button *ngFor="let poule of poules" routerLink="./poule/{{poule}}" routerLinkActive="active">
Poule {{poule}}
</button>
</div> </div>
<router-outlet></router-outlet>

View File

@ -8,3 +8,7 @@ app-poule {
#poulecontainer { #poulecontainer {
display: grid; display: grid;
} }
button.active {
background-color: #1dd21d;
}