Skip to content
This repository has been archived by the owner on Apr 24, 2020. It is now read-only.

Commit

Permalink
feat(tournaments): can now assign station numbers to tournament rounds
Browse files Browse the repository at this point in the history
closes #60
  • Loading branch information
seiyria committed Oct 17, 2015
1 parent 6ff8b71 commit 7ec6380
Show file tree
Hide file tree
Showing 9 changed files with 86 additions and 5 deletions.
9 changes: 9 additions & 0 deletions src/jade/directives/station.jade
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
script(type="text/ng-template", id="station")

.station.pointer.text-center.unentered(ng-click="edit()", ng-if="!editing && !editStuff.value", ng-class="{'clickable': canClick}")
ng-md-icon(size="16", icon="tv")

.station.text-center.entered(ng-click="edit()", ng-if="!editing && editStuff.value") {{editStuff.value}}

div(ng-if="editing")
input.station-input(ng-model="editStuff.value", ng-blur="unedit()", ng-keydown="watchKeyPresses($event)", maxlength="6")
5 changes: 4 additions & 1 deletion src/jade/partials/tournaments/types/duel.jade
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,11 @@ script(type="text/ng-template", id="tournament-duel")

div(ng-if="noRender(match)", flex)
div(ng-show="false") {{getIdForMatch(match)}}

.match-data(ng-if="!noRender(match)", layout="row", layout-align="center center")
.round-type.subhead {{match.id.s}}-{{toCharacter(getIdForMatch(match))}}
.round-type(flex, layout="column")
.subhead(flex) {{getMatchIdString(match)}}
station(flex, value="ref.stations[getMatchStationIdString(match)]", can-click="{{hasAccess}}", on-unedit="save()")

.match-name(layout="column")
.member.padding-5(ng-repeat="p in match.p track by $index", class="member-{{$index}}", hover-highlight, hover-name="{{getName(match.p[$index]-1)}}") {{getName(match.p[$index]-1) || getString(match.id, $index) || '???'}}
Expand Down
5 changes: 4 additions & 1 deletion src/jade/partials/tournaments/types/ffa.jade
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,11 @@ script(type="text/ng-template", id="tournament-ffa")

div(ng-if="noRender(match)", flex)
div(ng-show="false") {{getIdForMatch(match)}}

.match-data(ng-if="!noRender(match)", layout="row", layout-align="center center")
.round-type.subhead {{match.id.s}}-{{toCharacter(getIdForMatch(match))}}
.round-type(flex, layout="column")
.subhead(flex) {{getMatchIdString(match)}}
station(flex, value="ref.stations[getMatchStationIdString(match)]", can-click="{{hasAccess}}", on-unedit="save()")

.match-name(layout="column")
.member.padding-5(ng-repeat="p in match.p track by $index", class="member-{{$index}}", hover-highlight, hover-name="{{getName(match.p[$index]-1)}}") {{getName(match.p[$index]-1) || getString(match.id, $index) || '???'}}
Expand Down
5 changes: 4 additions & 1 deletion src/jade/partials/tournaments/types/groupstage.jade
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,11 @@ script(type="text/ng-template", id="tournament-groupstage")

div(ng-if="noRender(match)", flex)
div(ng-show="false") {{getIdForMatch(match)}}

.match-data(ng-if="!noRender(match)", layout="row", layout-align="center center")
.round-type.subhead {{match.id.s}}-{{toCharacter(getIdForMatch(match))}}
.round-type(flex, layout="column")
.subhead(flex) {{getMatchIdString(match)}}
station(flex, value="ref.stations[getMatchStationIdString(match)]", can-click="{{hasAccess}}", on-unedit="save()")

.match-name(layout="column")
.member.padding-5(ng-repeat="p in match.p track by $index", class="member-{{$index}}", hover-highlight, hover-name="{{getName(match.p[$index]-1)}}") {{getName(match.p[$index]-1) || getString(match.id, $index) || '???'}}
Expand Down
5 changes: 4 additions & 1 deletion src/jade/partials/tournaments/types/masters.jade
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,11 @@ script(type="text/ng-template", id="tournament-masters")

div(ng-if="noRender(match)", flex)
div(ng-show="false") {{getIdForMatch(match)}}

.match-data(ng-if="!noRender(match)", layout="row", layout-align="center center")
.round-type.subhead {{match.id.s}}-{{toCharacter(getIdForMatch(match))}}
.round-type(flex, layout="column")
.subhead(flex) {{getMatchIdString(match)}}
station(flex, value="ref.stations[getMatchStationIdString(match)]", can-click="{{hasAccess}}", on-unedit="save()")

.match-name(layout="column")
.member.padding-5(ng-repeat="p in match.p track by $index", class="member-{{$index}}", hover-highlight, hover-name="{{getName(match.p[$index]-1)}}") {{getName(match.p[$index]-1) || getString(match.id, $index) || '???'}}
Expand Down
1 change: 1 addition & 0 deletions src/js/_init.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import './directives/score';
import './directives/draw-to';
import './directives/hover-highlight';
import './directives/scroll-observe';
import './directives/station';

import './services/scoring';
import './services/userStatus';
Expand Down
9 changes: 8 additions & 1 deletion src/js/controllers/tournaments/inProgressCtrl.js
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,6 @@ site.controller('inProgressController', ($scope, $timeout, EnsureLoggedIn, Sideb
_.each(matchInfo, info => {
_.each($scope.trn.matches, match => {


if(isBad(match)) {
return;
}
Expand Down Expand Up @@ -229,6 +228,14 @@ site.controller('inProgressController', ($scope, $timeout, EnsureLoggedIn, Sideb
$scope.save();
};

$scope.getMatchIdString = (match) => {
return `${match.id.s}-${$scope.toCharacter($scope.getIdForMatch(match))}`;
};

$scope.getMatchStationIdString = (match) => {
return ''+match.id;
};

$scope.save = () => {
$scope.ref.trn = $scope.trn.state;
$scope.ref.matches = $scope.trn.matches;
Expand Down
38 changes: 38 additions & 0 deletions src/js/directives/station.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import site from '../app';

site.directive('station', ($timeout) => {
return {
restrict: 'E',
templateUrl: 'station',
scope: {
value: '=',
canClick: '@',
onUnedit: '&'
},
link: (scope, element, attrs) => {
scope.editing = false;
scope.editStuff = { value: scope.value };

scope.edit = () => {
if(!attrs.canClick) return;
scope.editing = true;
$timeout(() => {
$(element).find('.station-input').focus();
$(element).find('.station-input').select();
}, 0);
};

scope.unedit = () => {
scope.editing = false;
scope.onUnedit();
};

scope.watchKeyPresses = (e) => {
if(e.which !== 13) return;
scope.unedit();
};

scope.$watch('editStuff.value', (newVal) => scope.value = newVal);
}
};
});
14 changes: 14 additions & 0 deletions src/scss/site.scss
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,20 @@ $match-column-width: 130px;
font-weight: 500;
}

station {
.station {
font-size: 13px;

&.unentered:not(.clickable) {
display: none;
}
}

input {
width: 100%;
}
}

.max-height {
height: 100%;
}
Expand Down

0 comments on commit 7ec6380

Please sign in to comment.