This repository has been archived by the owner on Apr 24, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(tournaments): Clicking on match title will display popup of matc…
…h summary closes #87
- Loading branch information
Showing
11 changed files
with
106 additions
and
27 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
|
||
script(type="text/ng-template", id="/dialog/bracket-information") | ||
md-dialog | ||
|
||
.md-dialog-content | ||
h2.md-title Match {{ title }} | ||
|
||
md-list | ||
md-list-item.md-2-line(ng-repeat="player in players") | ||
.md-avatar.subhead {{ player.ordinal }} | ||
.md-list-item-text | ||
h3 {{ player.displayName }} | ||
Total Points Scored: {{ player.score }} | ||
.md-actions | ||
md-button.md-primary(ng-click="cancel()", aria-label="close") Close |
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
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
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,40 @@ | ||
import site from '../../app'; | ||
|
||
site.controller('bracketInformationController', ($scope, $mdDialog, $filter, placeService, title, match, players) => { | ||
|
||
$scope.title = title; | ||
$scope.cancel = $mdDialog.cancel; | ||
$scope.players = []; | ||
|
||
for(let i = 0; i < match.score.length; i++) { | ||
const player = players[match.p[i] - 1]; | ||
$scope.players.push({ | ||
displayName: player.alias ? `${player.alias} (${player.name})` : player.name, | ||
score: match.score[i] | ||
}); | ||
} | ||
|
||
$scope.players = $filter('orderBy')($scope.players, 'score', true); | ||
|
||
// state machine for determining ordinals ('1st', '2nd' and so on) | ||
const state = (() => { | ||
let lastScore = 0; | ||
let currentPlace = 0; | ||
let ordinal = placeService.getPlaceString(1); | ||
return { | ||
getOrdinal: (score) => { | ||
currentPlace++; | ||
if(lastScore === score) { | ||
return ordinal; | ||
} | ||
|
||
lastScore = score; | ||
return ordinal = placeService.getPlaceString(currentPlace); | ||
} | ||
}; | ||
})(); | ||
|
||
_.each($scope.players, (player) => { | ||
player.ordinal = state.getOrdinal(player.score); | ||
}); | ||
}); |
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,12 @@ | ||
import site from '../app'; | ||
|
||
site.service('placeService', () => { | ||
This comment has been minimized.
Sorry, something went wrong. |
||
|
||
return { | ||
getPlaceString: (numberPlace) => { | ||
const postStrings = ['th', 'st', 'nd', 'rd']; | ||
const baseNumber = numberPlace % 100; | ||
return numberPlace + (postStrings[(baseNumber - 20) % 10] || postStrings[baseNumber] || postStrings[0]); | ||
} | ||
}; | ||
}); |
Bit of a gotcha, but all of the services are ProperCase, to distinguish them from other things (ie, locals) upon being injected.