Add archive to standings page
This commit is contained in:
parent
4f939e5f08
commit
1e0afd634b
@ -27,9 +27,10 @@ export const routes: RouteRecordRaw[] = [
|
|||||||
props: castPlayersRouteParams
|
props: castPlayersRouteParams
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: '/standings',
|
path: '/standings/:seasonNumber',
|
||||||
name: 'standings',
|
name: 'standings',
|
||||||
component: () => import('../views/StandingsView.vue')
|
component: () => import('../views/StandingsView.vue'),
|
||||||
|
props: castStandingsRouteParams
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: '/leaderboards',
|
path: '/leaderboards',
|
||||||
@ -86,6 +87,12 @@ function castPlayersRouteParams(route: { params: { playerName: string, seasonNum
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function castStandingsRouteParams(route: { params: { seasonNumber: string } }) {
|
||||||
|
return {
|
||||||
|
seasonNumber: Number.isNaN(Number.parseInt(route.params.seasonNumber)) ? undefined : Number(route.params.seasonNumber)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function castScheduleRouteParams(route: { params: { seasonNumber: string, weekNumber: string } }) {
|
function castScheduleRouteParams(route: { params: { seasonNumber: string, weekNumber: string } }) {
|
||||||
return {
|
return {
|
||||||
seasonNumber: Number.isNaN(Number.parseInt(route.params.seasonNumber)) ? undefined : Number(route.params.seasonNumber),
|
seasonNumber: Number.isNaN(Number.parseInt(route.params.seasonNumber)) ? undefined : Number(route.params.seasonNumber),
|
||||||
|
|||||||
@ -8,7 +8,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-sm-12">
|
<div class="col-sm-12">
|
||||||
<h2 id="week-num">{{ weekNumber ? `Week ${weekNumber}` : '' }}</h2>
|
<h2 v-if="isCurrentSeason" id="week-num">{{ weekNumber ? `Week ${weekNumber}` : '' }}</h2>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@ -37,6 +37,18 @@
|
|||||||
<ExtendedStandingsTable :teamsByDivision="standingsByDivision" />
|
<ExtendedStandingsTable :teamsByDivision="standingsByDivision" />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<h3>
|
||||||
|
Standings Archive
|
||||||
|
</h3>
|
||||||
|
<span v-for="season in currentSeason" :key="season" style="padding-right: 1ch;">
|
||||||
|
<RouterLink v-if="season != seasonNumber" :to="{ name: 'standings', params: { seasonNumber: season } }">
|
||||||
|
S{{ season }}
|
||||||
|
</RouterLink>
|
||||||
|
<template v-else>
|
||||||
|
S{{ season }}
|
||||||
|
</template>
|
||||||
|
</span>
|
||||||
|
<div style="padding-bottom: 1em;"></div>
|
||||||
</div>
|
</div>
|
||||||
</main>
|
</main>
|
||||||
</template>
|
</template>
|
||||||
@ -56,22 +68,37 @@ export default {
|
|||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
seasonNumber: CURRENT_SEASON as number,
|
currentSeason: CURRENT_SEASON,
|
||||||
weekNumber: undefined as number | undefined,
|
weekNumber: undefined as number | undefined,
|
||||||
teamStandings: [] as TeamStanding[],
|
teamStandings: [] as TeamStanding[],
|
||||||
wildcardTeams: [] as TeamStanding[],
|
wildcardTeams: [] as TeamStanding[],
|
||||||
standingsByDivision: [[]] as TeamStanding[][]
|
standingsByDivision: [[]] as TeamStanding[][]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
props: {
|
||||||
|
seasonNumber: { type: Number, default: CURRENT_SEASON }
|
||||||
|
},
|
||||||
created() {
|
created() {
|
||||||
this.fetchData()
|
this.fetchData()
|
||||||
},
|
},
|
||||||
|
computed: {
|
||||||
|
isCurrentSeason(): boolean {
|
||||||
|
return this.seasonNumber == CURRENT_SEASON
|
||||||
|
}
|
||||||
|
},
|
||||||
|
watch: {
|
||||||
|
seasonNumber(newValue, oldValue) {
|
||||||
|
if (newValue !== oldValue) {
|
||||||
|
this.fetchData()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
methods: {
|
methods: {
|
||||||
async fetchData(): Promise<void> {
|
async fetchData(): Promise<void> {
|
||||||
const leagueInfo: LeagueInfo = await fetchCurrentLeagueInfo()
|
const leagueInfo: LeagueInfo = await fetchCurrentLeagueInfo()
|
||||||
this.weekNumber = leagueInfo.week
|
this.weekNumber = leagueInfo.week
|
||||||
|
|
||||||
this.teamStandings = await fetchStandings(CURRENT_SEASON)
|
this.teamStandings = await fetchStandings(this.seasonNumber)
|
||||||
this.wildcardTeams = this.teamStandings.filter(ts => ts.isWildcardTeam)
|
this.wildcardTeams = this.teamStandings.filter(ts => ts.isWildcardTeam)
|
||||||
|
|
||||||
const teamStandingsByDivisionAbbreviation: { [key: string]: TeamStanding[] } = {}
|
const teamStandingsByDivisionAbbreviation: { [key: string]: TeamStanding[] } = {}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user