This repository has been archived by the owner on Apr 24, 2020. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(tournaments): there is now an upcoming matches view
closes #62
- Loading branch information
Showing
10 changed files
with
239 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
script(type="text/ng-template", id="/tournaments/upcoming") | ||
|
||
.header-bar(layout="row", hide-sm) | ||
div(flex) | ||
|
||
.text-center.md-title(flex) | ||
span(ng-show="!ref.public && !hasAccess") Unavailable | ||
span(ng-show="ref.public || hasAccess") {{tournamentName}}{{trn.isDone() ? ' (Complete)' : ' (' + matchesLeft() + ' matches left)'}} | ||
|
||
.text-right.auto-vert-margin(flex, layout="row", layout-align="end center") | ||
.hide-underline(ng-show="ref.public && hasAccess") | ||
md-button.md-fab.md-mini.md-accent.copy-url(data-clipboard-text="{{url}}", aria-label="copy url to clipboard") | ||
ng-md-icon(size="20", icon="link", style="fill:white") | ||
md-button.md-fab.md-mini.color-facebook(ng-click="share('facebook')", aria-label="share on facebook") | ||
ng-md-icon(size="20", icon="facebook", style="fill:white") | ||
md-button.md-fab.md-mini.color-twitter(ng-click="share('twitter')", aria-label="share on twitter") | ||
ng-md-icon(size="20", icon="twitter", style="fill:white") | ||
md-button.md-fab.md-mini.color-google(ng-click="share('google')", aria-label="share on google+") | ||
ng-md-icon(size="20", icon="google-plus", style="fill:white") | ||
|
||
.header-bar(layout="row", hide-gt-sm) | ||
.text-center.md-title(flex) | ||
span(ng-show="!ref.public && !hasAccess") Unavailable | ||
span(ng-show="ref.public || hasAccess") {{tournamentName}}{{trn.isDone() ? ' (Complete)' : ' (' + matchesLeft() + ' matches left)'}} | ||
|
||
.abs-position-bottom-right | ||
|
||
md-fab-speed-dial.md-scale(md-direction="up", md-open="isOpen", ng-mouseleave="isOpen = false") | ||
md-fab-trigger.align-with-text | ||
|
||
md-button.md-fab.md-primary(aria-label="menu view bracket", ng-click="isOpen = true", ng-mouseenter="isOpen = true") | ||
ng-md-icon(size="24", icon="menu", style="fill: white") | ||
|
||
md-fab-actions(ng-if="isOpen") | ||
md-button.md-fab.md-raised.md-accent(aria-label="view bracket", ng-click="viewBracket()") | ||
ng-md-icon(size="24", icon="call_merge", style="fill: white") | ||
md-tooltip(md-direction="left") View bracket | ||
|
||
md-content.duel-area(flex, layout="column", layout-align="start center") | ||
|
||
md-card.upcoming-match(ng-repeat="match in trn.matches | orderBy:isReady:true", upcoming-highlight="isReady(match)", layout-gt-sm="row", layout-sm="column", layout-sm-align="center center", ng-if="!noRender(match) && shouldShow(match)", ng-class="{small: $mdMedia('sm')}") | ||
.round-station-container(layout="row", layout-align="start center", flex, flex-offset="10") | ||
|
||
.subhead.match-id.padding-15.text-center(flex-gt-sm="30", flex-sm="50") {{getMatchIdString(match)}} | ||
.station.padding-15(flex-gt-sm="70", flex-sm="50", layout="row", layout-align="start center") | ||
ng-md-icon(icon="tv", style="fill:{{isReady(match) < 2 ? '#000' : '#fff'}}") | ||
span(ng-class="{indeterminate: !getStation(match)}") {{getStation(match) || 'TBD'}} | ||
.player-container.padding-15(flex="65", layout="row", layout-wrap) | ||
.player.padding-5(flex="50", ng-repeat="player in match.p track by $index") | ||
span(ng-class="{indeterminate: match.p[$index] === 0}") {{getName(match.p[$index]-1) || getString(match.id, $index) || '???'}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
import site from '../../app'; | ||
|
||
site.controller('upcomingController', ($scope, $mdMedia, $state, $stateParams, $firebaseObject, $timeout, FirebaseURL, SidebarManagement, EnsureLoggedIn, TournamentInformation) => { | ||
SidebarManagement.hasSidebar = false; | ||
EnsureLoggedIn.check(false); | ||
|
||
$scope.$mdMedia = $mdMedia; | ||
|
||
$scope.strings = []; | ||
|
||
$scope.viewBracket = () => $state.go('tournamentInProgress', $stateParams); | ||
|
||
$scope.matchesLeft = () => TournamentInformation.matchesLeft($scope.trn); | ||
|
||
$scope.shouldShow = (match) => !match.m && !_.all(match.p, p => p === 0); | ||
|
||
$scope.getString = (id, idx) => TournamentInformation.getString($scope.strings, id, idx); | ||
$scope.noRender = TournamentInformation.noRender; | ||
$scope.getMatchIdString = TournamentInformation.getMatchIdString; | ||
$scope.getStation = (match) => $scope.ref.stations[TournamentInformation.getMatchStationIdString(match)]; | ||
|
||
const hasAnyZeroes = (match) => _.any(match.p, p => p === 0); | ||
|
||
$scope.isReady = (match) => { | ||
if($scope.noRender(match) || !$scope.shouldShow(match)) return; | ||
console.log($scope.getMatchIdString(match), ~~!!$scope.getStation(match), ~~!hasAnyZeroes(match)); | ||
return ~~!!$scope.getStation(match) + ~~!hasAnyZeroes(match); | ||
}; | ||
|
||
$scope.ref = $firebaseObject(new Firebase(`${FirebaseURL}/users/${atob($stateParams.userId)}/players/${$stateParams.setId}/tournaments/${$stateParams.tournamentId}`)); | ||
|
||
$scope.getName = (idx) => TournamentInformation.playerName($scope.bucket[idx]); | ||
|
||
$scope.loadTournament = (ref, makeNew = false) => { | ||
$scope.tournamentName = $scope.ref.name; | ||
|
||
$scope.bucket = ref.players; | ||
|
||
const tournamentProto = TournamentInformation.determineTournament(ref.options); | ||
|
||
$scope.trn = ref.trn && !makeNew ? tournamentProto.restore($scope.bucket.length, ref.options, ref.trn) : new tournamentProto($scope.bucket.length, ref.options); | ||
|
||
TournamentInformation.reset($scope.trn); | ||
|
||
// cache them ids | ||
_.each($scope.trn.matches, $scope.getMatchIdString); | ||
|
||
if(!_.contains(['groupstage', 'ffa', 'masters'], ref.options.type)) { | ||
$timeout(() => $scope.strings = TournamentInformation.loadTournamentWinnerStrings($scope.trn), 0); | ||
} | ||
}; | ||
|
||
$scope.ref.$watch(() => $scope.loadTournament($scope.ref)); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import site from '../app'; | ||
|
||
site.directive('upcomingHighlight', () => { | ||
return { | ||
restrict: 'A', | ||
scope: { | ||
upcomingHighlight: '&' | ||
}, | ||
link: (scope, element) => { | ||
scope.$watch(() => scope.upcomingHighlight(), (newVal) => { | ||
if(newVal < 2) return; | ||
const ref = $('body > md-toolbar'); | ||
if(newVal) { | ||
$(element).css('background-color', ref.css('background-color')).css('color', ref.css('color')); | ||
} else { | ||
$(element).css('background-color', '').css('color', ''); | ||
} | ||
}); | ||
} | ||
}; | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.