Restrict menu items based on game stage
This commit is contained in:
parent
79b928c775
commit
7cd399db07
@ -7,6 +7,9 @@ const { Controller } = require('libflitter')
|
|||||||
* are used as handlers for routes specified in the route files.
|
* are used as handlers for routes specified in the route files.
|
||||||
*/
|
*/
|
||||||
class Home extends Controller {
|
class Home extends Controller {
|
||||||
|
static get services() {
|
||||||
|
return [...super.services, 'sports_data']
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Serve the main welcome page.
|
* Serve the main welcome page.
|
||||||
@ -18,6 +21,15 @@ class Home extends Controller {
|
|||||||
return res.redirect('/auth/login')
|
return res.redirect('/auth/login')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async get_status(req, res, next) {
|
||||||
|
return res.api({
|
||||||
|
team_id: req.user_team.id,
|
||||||
|
team_name: req.user_team.team_name,
|
||||||
|
current_week: await this.sports_data.current_play_week(),
|
||||||
|
is_draft_stage: await this.sports_data.is_draft_stage(),
|
||||||
|
})
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = Home
|
module.exports = Home
|
||||||
|
@ -55,6 +55,8 @@ const index = {
|
|||||||
|
|
||||||
'/matchups': ['controller::Scores.get_weekly_scores'],
|
'/matchups': ['controller::Scores.get_weekly_scores'],
|
||||||
'/league-standings': ['controller::Scores.get_league_standings'],
|
'/league-standings': ['controller::Scores.get_league_standings'],
|
||||||
|
|
||||||
|
'/status': ['controller::Home.get_status'],
|
||||||
},
|
},
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
import {Component} from '../../lib/vues6.js'
|
import {Component} from '../../lib/vues6.js'
|
||||||
import {router} from '../module/routing.js'
|
import {router} from '../module/routing.js'
|
||||||
|
import {api} from '../module/api.js'
|
||||||
|
|
||||||
const template = `
|
const template = `
|
||||||
<div class="top-level-container">
|
<div class="top-level-container">
|
||||||
@ -48,11 +49,21 @@ class TopLevelComponent extends Component {
|
|||||||
{ title: 'Draft Board', page: 'draft-board' },
|
{ title: 'Draft Board', page: 'draft-board' },
|
||||||
]
|
]
|
||||||
|
|
||||||
|
status = {}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called when the component is initialized.
|
* Called when the component is initialized.
|
||||||
* @return {Promise<void>}
|
* @return {Promise<void>}
|
||||||
*/
|
*/
|
||||||
async vue_on_create() {
|
async vue_on_create() {
|
||||||
|
this.status = await api.get_status()
|
||||||
|
|
||||||
|
if ( this.status.is_draft_stage ) {
|
||||||
|
this.navbar_items = this.navbar_items.filter(x => !['my-team/add-players', 'scores', 'league'].includes(x.page))
|
||||||
|
} else {
|
||||||
|
this.navbar_items = this.navbar_items.filter(x => !['draft-board'].includes(x.page))
|
||||||
|
}
|
||||||
|
|
||||||
// Listen for navigation changes.
|
// Listen for navigation changes.
|
||||||
this.router_subscription = router.subscribe((path, args) => this.on_route_change(path, args))
|
this.router_subscription = router.subscribe((path, args) => this.on_route_change(path, args))
|
||||||
this.current_route = router.current_route
|
this.current_route = router.current_route
|
||||||
|
@ -3,6 +3,10 @@ class API {
|
|||||||
this.base_url = APP_BASE_PATH.replace('/app/', '/api/v1/')
|
this.base_url = APP_BASE_PATH.replace('/app/', '/api/v1/')
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async get_status() {
|
||||||
|
return this.get_request('status')
|
||||||
|
}
|
||||||
|
|
||||||
async get_standings() {
|
async get_standings() {
|
||||||
return this.get_request('league-standings')
|
return this.get_request('league-standings')
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user