Fixed some bugs with the new ladder view when you haven't played before.

This commit is contained in:
Scott Erickson 2014-03-03 09:20:14 -08:00
parent 5bb56ac818
commit d3b6836a06
3 changed files with 41 additions and 37 deletions

View file

@ -7,7 +7,6 @@
div#columns.row
for team in teams
div.matches-column.col-md-6
if team.matches.length
table.table.table-bordered.table-condensed
tr
@ -18,6 +17,7 @@ div#columns.row
span
span Matches
if team.session
button.btn.btn-sm.btn-warning.pull-right.rank-button(data-session-id=team.session.id)
span.unavailable.hidden No New Code to Rank
span.rank.hidden Rank My Game!
@ -45,8 +45,9 @@ div#columns.row
- var text = match.state === 'win' ? 'Watch your victory' : 'Defeat the ' + team.otherTeam
a(href="/play/level/#{levelID}?team=#{teamID}&opponent=#{match.sessionID}")= text
else
div.alert.alert-warning
| No ranked matches played yet!
| Play some competitors on the right and then come back to get your game ranked.
if !team.matches.length
tr
td(colspan=4).alert.alert-warning
| No ranked matches for this team!
| Play against some competitors and then come back here to get your game ranked.

View file

@ -62,9 +62,9 @@ module.exports = class MyMatchesTabView extends CocoView
for team in @teams
team.session = (s for s in @sessions.models when s.get('team') is team.id)[0]
team.readyToRank = @readyToRank(team.session)
team.matches = (convertMatch(match) for match in team.session.get('matches') or [])
team.matches = (convertMatch(match) for match in team.session?.get('matches') or [])
team.matches.reverse()
team.score = (team.session.get('totalScore') or 10).toFixed(2)
team.score = (team.session?.get('totalScore') or 10).toFixed(2)
ctx
@ -77,8 +77,8 @@ module.exports = class MyMatchesTabView extends CocoView
@setRankingButtonText button, if @readyToRank(session) then 'rank' else 'unavailable'
readyToRank: (session) ->
c1 = session.get('code')
c2 = session.get('submittedCode')
c1 = session?.get('code')
c2 = session?.get('submittedCode')
c1 and not _.isEqual(c1, c2)
rankSession: (e) ->

View file

@ -2,6 +2,7 @@ View = require 'views/kinds/ModalView'
template = require 'templates/play/ladder/play_modal'
ThangType = require 'models/ThangType'
{me} = require 'lib/auth'
LeaderboardCollection = require 'collections/LeaderboardCollection'
module.exports = class LadderPlayModal extends View
id: "ladder-play-modal"
@ -19,7 +20,7 @@ module.exports = class LadderPlayModal extends View
# PART 1: Load challengers from the db unless some are in the matches
startLoadingChallengersMaybe: ->
matches = @session.get('matches')
matches = @session?.get('matches')
if matches?.length then @loadNames() else @loadChallengers()
loadChallengers: ->
@ -126,8 +127,10 @@ class ChallengersData
@hardPlayer = new LeaderboardCollection(@level, {order:-1, scoreOffset: score + 5, limit: 1, team: @otherTeam})
@hardPlayer.fetch()
@hardPlayer.once 'sync', @challengerLoaded, @
console.log 'fetching challengers yes'
challengerLoaded: ->
console.log 'challenger loaded'
if @allLoaded()
@loaded = true
@trigger 'sync'