mirror of
https://github.com/codeninjasllc/codecombat.git
synced 2024-11-28 10:06:08 -05:00
Fix supermodel with resource value and fix ladder view under supermodel resource management.
This commit is contained in:
parent
375aca2c0a
commit
7321052c18
5 changed files with 11 additions and 28 deletions
|
@ -192,7 +192,6 @@ class Resource extends Backbone.Model
|
||||||
@isLoaded = false
|
@isLoaded = false
|
||||||
@model = null
|
@model = null
|
||||||
@loadDeferred = null
|
@loadDeferred = null
|
||||||
@value = 1
|
|
||||||
|
|
||||||
addDependency: (depRes) ->
|
addDependency: (depRes) ->
|
||||||
return if depRes.isLoaded
|
return if depRes.isLoaded
|
||||||
|
@ -282,8 +281,7 @@ class RequestResource extends Resource
|
||||||
|
|
||||||
class SomethingResource extends Resource
|
class SomethingResource extends Resource
|
||||||
constructor: (name, value) ->
|
constructor: (name, value) ->
|
||||||
super(value)
|
super(name, value)
|
||||||
@name = name
|
|
||||||
@loadDeferred = $.Deferred()
|
@loadDeferred = $.Deferred()
|
||||||
|
|
||||||
load: ->
|
load: ->
|
||||||
|
|
|
@ -22,6 +22,7 @@ module.exports = class PatchesView extends CocoView
|
||||||
@patches = new PatchesCollection([], {}, @model, @status)
|
@patches = new PatchesCollection([], {}, @model, @status)
|
||||||
@patchesRes = @supermodel.addModelResource(@patches, 'patches')
|
@patchesRes = @supermodel.addModelResource(@patches, 'patches')
|
||||||
@patchesRes.load()
|
@patchesRes.load()
|
||||||
|
@listenTo(@patchesRes, 'resource:loaded', @load)
|
||||||
|
|
||||||
load: ->
|
load: ->
|
||||||
return unless @patchesRes.loaded
|
return unless @patchesRes.loaded
|
||||||
|
@ -48,7 +49,7 @@ module.exports = class PatchesView extends CocoView
|
||||||
reloadPatches: ->
|
reloadPatches: ->
|
||||||
@loaded = false
|
@loaded = false
|
||||||
@initPatches()
|
@initPatches()
|
||||||
@load()
|
# @load()
|
||||||
@render()
|
@render()
|
||||||
|
|
||||||
openPatchModal: (e) ->
|
openPatchModal: (e) ->
|
||||||
|
|
|
@ -89,16 +89,6 @@ module.exports = class LadderTabView extends CocoView
|
||||||
levelFrag = "#{@level.get('original')}.#{@level.get('version').major}"
|
levelFrag = "#{@level.get('original')}.#{@level.get('version').major}"
|
||||||
url = "/db/level/#{levelFrag}/leaderboard_facebook_friends"
|
url = "/db/level/#{levelFrag}/leaderboard_facebook_friends"
|
||||||
|
|
||||||
###
|
|
||||||
jqxhr = $.ajax url, {
|
|
||||||
data: { friendIDs: (f.id for f in @facebookData) }
|
|
||||||
method: 'POST'
|
|
||||||
success: @onFacebookFriendSessionsLoaded
|
|
||||||
}
|
|
||||||
|
|
||||||
@addRequestToLoad(jqxhr, 'facebook_friend_sessions', 'loadFacebookFriendSessions')
|
|
||||||
###
|
|
||||||
|
|
||||||
@fbFriendSessionRes = @supermodel.addRequestResource('facebook_friend_sessions', {
|
@fbFriendSessionRes = @supermodel.addRequestResource('facebook_friend_sessions', {
|
||||||
url: url
|
url: url
|
||||||
data: { friendIDs: (f.id for f in @facebookData) }
|
data: { friendIDs: (f.id for f in @facebookData) }
|
||||||
|
@ -140,14 +130,7 @@ module.exports = class LadderTabView extends CocoView
|
||||||
loadGPlusFriendSessions: ->
|
loadGPlusFriendSessions: ->
|
||||||
levelFrag = "#{@level.get('original')}.#{@level.get('version').major}"
|
levelFrag = "#{@level.get('original')}.#{@level.get('version').major}"
|
||||||
url = "/db/level/#{levelFrag}/leaderboard_gplus_friends"
|
url = "/db/level/#{levelFrag}/leaderboard_gplus_friends"
|
||||||
###
|
|
||||||
jqxhr = $.ajax url, {
|
|
||||||
data: { friendIDs: (f.id for f in @gplusData) }
|
|
||||||
method: 'POST'
|
|
||||||
success: @onGPlusFriendSessionsLoaded
|
|
||||||
}
|
|
||||||
@addRequestToLoad(jqxhr, 'gplus_friend_sessions', 'loadGPlusFriendSessions')
|
|
||||||
###
|
|
||||||
@gpFriendSessionRes = @supermodel.addRequestResource('gplus_friend_sessions', {
|
@gpFriendSessionRes = @supermodel.addRequestResource('gplus_friend_sessions', {
|
||||||
url: url
|
url: url
|
||||||
data: { friendIDs: (f.id for f in @gplusData) }
|
data: { friendIDs: (f.id for f in @gplusData) }
|
||||||
|
@ -172,10 +155,10 @@ module.exports = class LadderTabView extends CocoView
|
||||||
@leaderboards[team.id]?.destroy()
|
@leaderboards[team.id]?.destroy()
|
||||||
teamSession = _.find @sessions.models, (session) -> session.get('team') is team.id
|
teamSession = _.find @sessions.models, (session) -> session.get('team') is team.id
|
||||||
@leaderboards[team.id] = new LeaderboardData(@level, team.id, teamSession)
|
@leaderboards[team.id] = new LeaderboardData(@level, team.id, teamSession)
|
||||||
# @addResourceToLoad @leaderboards[team.id], 'leaderboard', 3
|
|
||||||
@leaderboardRes = @supermodel.addModelResource(@leaderboards[team.id], 'leaderboard', 3)
|
@leaderboardRes = @supermodel.addModelResource(@leaderboards[team.id], 'leaderboard', 3)
|
||||||
@leaderboardRes.load()
|
@leaderboardRes.load()
|
||||||
|
|
||||||
|
onLoaded: -> @render()
|
||||||
render: ->
|
render: ->
|
||||||
super()
|
super()
|
||||||
|
|
||||||
|
@ -303,7 +286,6 @@ class LeaderboardData extends CocoClass
|
||||||
|
|
||||||
constructor: (@level, @team, @session) ->
|
constructor: (@level, @team, @session) ->
|
||||||
super()
|
super()
|
||||||
@fetch()
|
|
||||||
|
|
||||||
fetch: ->
|
fetch: ->
|
||||||
@topPlayers = new LeaderboardCollection(@level, {order:-1, scoreOffset: HIGHEST_SCORE, team: @team, limit: @limit})
|
@topPlayers = new LeaderboardCollection(@level, {order:-1, scoreOffset: HIGHEST_SCORE, team: @team, limit: @limit})
|
||||||
|
|
|
@ -15,12 +15,15 @@ module.exports = class SimulateTabView extends CocoView
|
||||||
constructor: (options) ->
|
constructor: (options) ->
|
||||||
super(options)
|
super(options)
|
||||||
@simulatorsLeaderboardData = new SimulatorsLeaderboardData(me)
|
@simulatorsLeaderboardData = new SimulatorsLeaderboardData(me)
|
||||||
@addResourceToLoad(@simulatorsLeaderboardData, 'top_simulators')
|
@simulatorsLeaderboardDataRes = @supermodel.addModelResource(@simulatorsLeaderboardData, 'top_simulators')
|
||||||
|
@simulatorsLeaderboardDataRes.load()
|
||||||
|
|
||||||
@simulator = new Simulator()
|
@simulator = new Simulator()
|
||||||
@listenTo(@simulator, 'statusUpdate', @updateSimulationStatus)
|
@listenTo(@simulator, 'statusUpdate', @updateSimulationStatus)
|
||||||
|
|
||||||
onLoaded: ->
|
onLoaded: ->
|
||||||
super()
|
super()
|
||||||
|
@render()
|
||||||
|
|
||||||
getRenderData: ->
|
getRenderData: ->
|
||||||
ctx = super()
|
ctx = super()
|
||||||
|
@ -81,7 +84,6 @@ class SimulatorsLeaderboardData extends CocoClass
|
||||||
|
|
||||||
constructor: (@me) ->
|
constructor: (@me) ->
|
||||||
super()
|
super()
|
||||||
@fetch()
|
|
||||||
|
|
||||||
fetch: ->
|
fetch: ->
|
||||||
@topSimulators = new SimulatorsLeaderboardCollection({order:-1, scoreOffset: -1, limit: 20})
|
@topSimulators = new SimulatorsLeaderboardCollection({order:-1, scoreOffset: -1, limit: 20})
|
||||||
|
|
|
@ -48,7 +48,7 @@ module.exports = class LadderView extends RootView
|
||||||
|
|
||||||
onLoaded: ->
|
onLoaded: ->
|
||||||
@teams = teamDataFromLevel @level
|
@teams = teamDataFromLevel @level
|
||||||
super()
|
@render()
|
||||||
|
|
||||||
getRenderData: ->
|
getRenderData: ->
|
||||||
ctx = super()
|
ctx = super()
|
||||||
|
|
Loading…
Reference in a new issue