added sorting of players-teams-score in confidential page.
This commit is contained in:
1 parent
a314f5d804
commit
ff993beb55
4 files changed
+91
-11
No files matched your search
@@ -0,0 +1,19 @@
|
||||
define(['m'], function(m) {
|
||||
return function(size){
|
||||
return m("svg[viewBox='0 0 107.95 87.723']",{width: size, height: size}, [
|
||||
m("defs[id='defs16']"),
|
||||
m("g[id='layer1'][transform='translate(-310.1 -167.39)']", [
|
||||
m("g[id='g13542'][transform='translate(-2.4761 19.309)']", [
|
||||
m("path[d='m378.31 207.24c15.43-1.4 26.66-5.66 26.66-10.69 0-0.41-0.27-0.8-0.42-1.2 0.91 0.23 1.83 0.46 2.83 0.46 5.57 0 10.07-3.78 10.07-8.44 0-4.65-4.5-8.41-10.07-8.41-0.68 0-1.29 0.22-1.93 0.33 0.56-1.86 0.95-3.77 0.95-5.79 0-12.33-11.17-22.34-24.95-22.34-9.77 0-18.13 5.09-22.23 12.4-1.64-0.92-3.47-1.48-5.4-1.48-5.83 0-10.68 4.69-12.18 11.06-2.56-1.01-5.52-1.64-8.7-1.64-9.54 0-17.29 5.23-17.29 11.67 0 5.81 6.35 10.59 14.6 11.47-0.37 0.63-0.66 1.25-0.66 1.91 0 4.25 8.01 7.94 19.79 9.83'][id='path8749']", {style: {"stroke-linejoin": "round", "stroke": "#6798e9", "stroke-linecap": "round", "stroke-miterlimit": ".5", "stroke-width": "12.154", "fill": "none"}}),
|
||||
m("path[d='m338.14 223.91c-8.25 7.27 1.43 13.47 5.12 3.49l2.83-9.26-7.95 5.77z'][id='path8734']", {style: {"stroke": "#6798e9", "stroke-miterlimit": "3.2", "stroke-width": "8", "fill": "#6798e9"}}),
|
||||
m("path[d='m367.18 225.11c-8.25 7.27 1.44 13.47 5.13 3.49l2.83-9.26-7.96 5.77z'][id='path8736']", {style: {"stroke": "#6798e9", "stroke-miterlimit": "3.2", "stroke-width": "8", "fill": "#6798e9"}}),
|
||||
m("path[d='m360.42 209.77c-8.25 7.27 1.44 13.47 5.12 3.49l2.83-9.26-7.95 5.77z'][id='path8738']", {style: {"stroke": "#6798e9", "stroke-miterlimit": "3.2", "stroke-width": "8", "fill": "#6798e9"}}),
|
||||
m("path[d='m378.31 207.24c15.43-1.4 26.66-5.66 26.66-10.69 0-0.41-0.27-0.8-0.42-1.2 0.91 0.23 1.83 0.46 2.83 0.46 5.57 0 10.07-3.78 10.07-8.44 0-4.65-4.5-8.41-10.07-8.41-0.68 0-1.29 0.22-1.93 0.33 0.56-1.86 0.95-3.77 0.95-5.79 0-12.33-11.17-22.34-24.95-22.34-9.77 0-18.13 5.09-22.23 12.4-1.64-0.92-3.47-1.48-5.4-1.48-5.83 0-10.68 4.69-12.18 11.06-2.56-1.01-5.52-1.64-8.7-1.64-9.54 0-17.29 5.23-17.29 11.67 0 5.81 6.35 10.59 14.6 11.47-0.37 0.63-0.66 1.25-0.66 1.91 0 4.25 8.01 7.94 19.79 9.83'][id='path10281']", {style: {"stroke-linejoin": "round", "stroke": "#6798e9", "stroke-linecap": "round", "stroke-miterlimit": ".5", "stroke-width": "12.154", "fill": "none"}}),
|
||||
m("path[d='m338.14 223.91c-8.25 7.27 1.43 13.47 5.12 3.49l2.83-9.26-7.95 5.77z'][id='path10283']", {style: {"stroke": "#6798e9", "stroke-miterlimit": "3.2", "stroke-width": "8", "fill": "#6798e9"}}),
|
||||
m("path[d='m367.18 225.11c-8.25 7.27 1.44 13.47 5.13 3.49l2.83-9.26-7.96 5.77z'][id='path10285']", {style: {"stroke": "#6798e9", "stroke-miterlimit": "3.2", "stroke-width": "8", "fill": "#6798e9"}}),
|
||||
m("path[d='m360.42 209.77c-8.25 7.27 1.44 13.47 5.12 3.49l2.83-9.26-7.95 5.77z'][id='path10287']", {style: {"stroke": "#6798e9", "stroke-miterlimit": "3.2", "stroke-width": "8", "fill": "#6798e9"}})
|
||||
])
|
||||
])
|
||||
]);
|
||||
};
|
||||
});
|
||||
@@ -1,4 +1,4 @@
|
||||
define(['m', '_', 'util', 'resultParser', 'teams', 'views/topNavBar', 'views/footer'], function(m, _, util, resultParser, teams, topNavBar, footer) {
|
||||
define(['m', '_', 'util', 'resultParser', 'teams', 'views/topNavBar', 'views/footer', 'images/rain.svg'], function(m, _, util, resultParser, teams, topNavBar, footer, rainSvg) {
|
||||
var statsView = {};
|
||||
|
||||
statsView.controller = function(){
|
||||
@@ -85,9 +85,17 @@ define(['m', '_', 'util', 'resultParser', 'teams', 'views/topNavBar', 'views/foo
|
||||
return !_.isNumber(points) ? '-' : points + '';
|
||||
};
|
||||
|
||||
schedulView._gameName = function(game){
|
||||
if(game.rain){
|
||||
return [rainSvg('1.5em'), " ", game.time];
|
||||
}
|
||||
return [game.time, " ", m('span', {style: {visibility: 'hidden'}}, rainSvg('1.5em'))];
|
||||
};
|
||||
|
||||
schedulView._gameRow = function(game){
|
||||
|
||||
return m('tr',[
|
||||
m('td', game.time),
|
||||
m('td', schedulView._gameName(game)),
|
||||
m('td', schedulView._getTeamTag(game.home)),
|
||||
m('td', schedulView._asGamePoints(game.home_points)),
|
||||
m('td', 'vs'),
|
||||
|
||||
@@ -76,36 +76,86 @@ define(['m', '_', 'teams', 'views/topNavBar', 'views/footer'], function (m, _ ,
|
||||
|
||||
var confidentialTable = {};
|
||||
|
||||
confidentialTable._sortFunction = function(sortingElm){
|
||||
|
||||
};
|
||||
|
||||
confidentialTable._sortPlayers = function(sorting, playerList){
|
||||
var sortingKeys = _.map(sorting(), 'key');
|
||||
var sortingDirections = _.map(sorting(), function(o){
|
||||
return o.direction == 1 ? 'desc' : 'asc';
|
||||
});
|
||||
return _.orderBy(playerList, sortingKeys, sortingDirections);
|
||||
};
|
||||
|
||||
confidentialTable.controller = function(model){
|
||||
var players = m.prop([]);
|
||||
var ctrl = {};
|
||||
ctrl.model = model;
|
||||
ctrl.players = m.request({method: "GET", url: "api/players.json"}).then(players);
|
||||
|
||||
ctrl.players = m.request({method: "GET", url: "api/players.json"})
|
||||
.then(players);
|
||||
ctrl.sortPlayers = function(){
|
||||
ctrl.players(confidentialTable._sortPlayers(ctrl.model.sorting, ctrl.players()));
|
||||
};
|
||||
return ctrl;
|
||||
};
|
||||
|
||||
confidentialTable.arrows = function(){
|
||||
confidentialTable._getSortDict = function(sorting){
|
||||
var ret = {};
|
||||
_.each(sorting(), function(elm){
|
||||
ret[elm.key] = elm.direction;
|
||||
});
|
||||
return ret;
|
||||
|
||||
};
|
||||
|
||||
confidentialTable._isSortingUp = function(sorting, key){
|
||||
var dict = confidentialTable._getSortDict(sorting);
|
||||
return dict[key] === 1;
|
||||
};
|
||||
|
||||
confidentialTable._isSortingDown = function(sorting, key){
|
||||
var dict = confidentialTable._getSortDict(sorting);
|
||||
return dict[key] === -1;
|
||||
};
|
||||
|
||||
confidentialTable.arrows = function(sorting, key){
|
||||
var sortUp = confidentialTable._isSortingUp(sorting, key);
|
||||
var sortDown = confidentialTable._isSortingDown(sorting, key);
|
||||
var style = {
|
||||
display: 'inline-block',
|
||||
'line-height': '0.5em',
|
||||
'margin-right': '1em',
|
||||
'font-size': '0.7em'
|
||||
};
|
||||
var sortedStyle = {color: '#8cc14c', 'font-weight': 'bold'};
|
||||
return m('span', {style: style},
|
||||
m('i.fa.fa-chevron-up'),
|
||||
m('i.fa.fa-chevron-up', {style: sortUp ? sortedStyle: {}}),
|
||||
m('br'),
|
||||
m('i.fa.fa-chevron-down')
|
||||
m('i.fa.fa-chevron-down', {style: sortDown ? sortedStyle: {}})
|
||||
);
|
||||
};
|
||||
|
||||
confidentialTable.tableHeader = function(){
|
||||
confidentialTable._setSorting = function(sorting, key){
|
||||
var newDirection = {key: key, direction: -1 * confidentialTable._getSortDict(sorting)[key]};
|
||||
var directions = _.filter(sorting(), function(o){
|
||||
return o.key != key;
|
||||
});
|
||||
sorting([newDirection].concat(directions));
|
||||
};
|
||||
|
||||
confidentialTable.tableHeader = function(sorting){
|
||||
var setSorting = function(key){
|
||||
return _.partial(confidentialTable._setSorting, sorting, key);
|
||||
};
|
||||
return m('thead',
|
||||
m('tr', [
|
||||
m('th', confidentialTable.arrows(), 'Équipe'),
|
||||
m('th', confidentialTable.arrows(), 'Nom'),
|
||||
m('th', {onclick: setSorting('team')}, confidentialTable.arrows(sorting, 'team'), 'Équipe'),
|
||||
m('th', {onclick: setSorting('name')}, confidentialTable.arrows(sorting, 'name'), 'Nom'),
|
||||
m('th.uk-hidden-small', 'Courriel'),
|
||||
m('th.uk-hidden-small', 'Téléphone'),
|
||||
m('th', confidentialTable.arrows(), 'Cote')
|
||||
m('th', {onclick: setSorting('score')}, confidentialTable.arrows(sorting, 'score'), 'Cote')
|
||||
]));
|
||||
};
|
||||
|
||||
@@ -147,8 +197,9 @@ define(['m', '_', 'teams', 'views/topNavBar', 'views/footer'], function (m, _ ,
|
||||
};
|
||||
|
||||
confidentialTable.view = function(ctrl){
|
||||
ctrl.sortPlayers();
|
||||
return m('table.uk-table.uk-table-hover.uk-table-striped',
|
||||
confidentialTable.tableHeader(),
|
||||
confidentialTable.tableHeader(ctrl.model.sorting),
|
||||
confidentialTable.tableBody(ctrl.players(),
|
||||
ctrl.model.activatedTeams(),
|
||||
ctrl.model.activatedScores()
|
||||
@@ -162,6 +213,7 @@ define(['m', '_', 'teams', 'views/topNavBar', 'views/footer'], function (m, _ ,
|
||||
var model = {};
|
||||
model.activatedTeams = m.prop(['bleu', 'rouge', 'jaune', 'gris']);
|
||||
model.activatedScores = m.prop([1, 2, 3, 4, 5]);
|
||||
model.sorting = m.prop([{key: 'team', direction: 1}, {key: 'score', direction: -1}, {key: 'name', direction: 1}]);
|
||||
return model;
|
||||
};
|
||||
|
||||
|
||||
Reference in new issue
Block a user