added basic playoff integration

This commit is contained in:
didier amyot committed 2017-08-08 22:22:51 -04:00
1 parent 7be88a2167
commit 9bf4830f7a
4 files changed
+82 -18

No files matched your search

+48 -7
View File
@@ -25,6 +25,12 @@ define(['m', '_', 'util', 'resultParser', 'teams', 'views/topNavBar', 'views/foo
]);
};
statsView.isStatForValidTeam = function(stat){
var teamNames = _.map(teams.teams(), 'name');
return _.includes(teamNames, stat.team);
}
statsView.mainTable = function(stats){
var orderedStats = _.reverse(_.sortBy(stats, ['victories', 'pointsFor']));
return m('table.uk-table.uk-table-hover.uk-table-striped',[
@@ -39,7 +45,10 @@ define(['m', '_', 'util', 'resultParser', 'teams', 'views/topNavBar', 'views/foo
m('th', 'DIF'),
m('th', 'PTS')
])),
m('tbody', _.map(orderedStats, statsView.getStatRow))
m('tbody', _(orderedStats)
.filter(statsView.isStatForValidTeam)
.map(statsView.getStatRow)
.value())
]);
};
@@ -66,14 +75,42 @@ define(['m', '_', 'util', 'resultParser', 'teams', 'views/topNavBar', 'views/foo
var tabView = {};
tabView.view = function(){
tabView.view = function(vnode, isPlayoff){
return m('div.uk-margin', m('h2', 'Calendrier 2017'),
m('ul.uk-tab', [
m('li.uk-active', m('a', 'Saison')),
m('li', m('a', 'Éliminatoire'))
m('li', {'class': isPlayoff || 'uk-active'},
m('a', {href: '#/calendrier'}, 'Saison')),
m('li', {'class': isPlayoff && 'uk-active'},
m('a', {href: '#/calendrier/playoff'}, 'Éliminatoire'))
]));
};
var playoffView = {};
playoffView.line = function(x1, y1, x2, y2){
return m('line', {'x1': x1,
'y1': y1,
'x2': x2,
'y2': y2,
style: 'stroke:rgb(255,0,0);stroke-width:2'})
}
playoffView.horizontalLine = function(x1, x2, y){
return playoffView.line(x1, y, x2, y);
};
playoffView.view = function(){
var width = 600;
var height = 600;
var padding = 40;
return m('div',
m('svg', {width: width, height: height},
playoffView.horizontalLine(padding, width/2 - padding, height/3),
playoffView.horizontalLine(padding, width/2 - padding, 2 * height/3),
));
}
var schedulView = {};
schedulView.controller = function(){
@@ -133,13 +170,17 @@ define(['m', '_', 'util', 'resultParser', 'teams', 'views/topNavBar', 'views/foo
calendarPage = {};
calendarPage.view = function(){
calendarPage.view = function(vnode){
var toto = vnode;
var isPlayoff = window.location.hash.endsWith('playoff');
var main = isPlayoff ? m.component(playoffView) : m.component(schedulView);
return [m.component(topNavBar),
m('div.uk-grid.uk-margin-top.uk-margin-bottom',
m('div.uk-width-large-3-5.uk-width-medium-4-5.uk-width-small-1-1.uk-container-center',[
m.component(statsView),
m.component(tabView),
m.component(schedulView)])),
m.component(tabView, isPlayoff),
main
])),
m.component(footer)];
};
+6 -3
View File
@@ -5,7 +5,7 @@ define(['m', '_', 'util'], function (m, _, util) {
topNavBar._urlMapping = [
{name: 'Accueil', path: '', fa: 'fa-home'},
{name: 'Nouvelles', path: 'nouvelles', fa: 'fa-newspaper-o'},
{name: 'Calendrier', path: 'calendrier', fa: 'fa-calendar'},
{name: 'Calendrier', path: 'calendrier', fa: 'fa-calendar', includeSubPath: true},
{name: 'Règlement', path: 'reglement', fa: 'fa-legal'},
{name: 'Membre', path: 'membre', fa: 'fa-lock'},
// {name: 'Historique', path: 'historique', fa: 'fa-history'},
@@ -22,7 +22,10 @@ define(['m', '_', 'util'], function (m, _, util) {
return '#/' + id_;
};
topNavBar._isActive = function(id_){
topNavBar._isActive = function(id_, includeSubPath){
if(includeSubPath){
return window.location.hash.startsWith(topNavBar._getUrlForId(id_));
}
return topNavBar._getUrlForId(id_) == window.location.hash;
};
topNavBar._getItemIcon = function(item){
@@ -30,7 +33,7 @@ define(['m', '_', 'util'], function (m, _, util) {
};
topNavBar._getLargeItem = function(item){
var class_ = topNavBar._isActive(item.path) ? 'uk-active' : '';
var class_ = topNavBar._isActive(item.path, item.includeSubPath) ? 'uk-active' : '';
var url = topNavBar._getUrlForId(item.path);
return m("li", {class: class_},
m("a", {href: url},