mirror of
https://github.com/codeninjasllc/codecombat.git
synced 2024-11-23 23:58:02 -05:00
Refactor MainLadderView to use view in template
This commit is contained in:
parent
48786372d8
commit
58eaec8e6b
2 changed files with 4 additions and 10 deletions
|
@ -2,13 +2,13 @@ extends /templates/base
|
|||
|
||||
block content
|
||||
|
||||
each campaign in campaigns
|
||||
each campaign in view.campaigns
|
||||
.campaign-container
|
||||
h1
|
||||
a(href="/play/#{campaign.levels[0].levelPath || 'level'}/#{campaign.levels[0].id}", data-i18n="play.campaign_#{campaign.id}")= campaign.name
|
||||
p.campaign-description(data-i18n="[html]play.campaign_#{campaign.id}_description")!= campaign.description
|
||||
each level in campaign.levels
|
||||
a(href=level.disabled ? "/play/ladder" : "/play/ladder/#{level.id}", disabled=level.disabled, class=levelStatusMap[level.id] || '', title=level.description)
|
||||
a(href=level.disabled ? "/play/ladder" : "/play/ladder/#{level.id}", disabled=level.disabled, class=view.levelStatusMap[level.id] || '', title=level.description)
|
||||
.level
|
||||
if level.image
|
||||
img.level-image(src="#{level.image}", alt="#{level.name}").img-rounded
|
||||
|
@ -19,7 +19,7 @@ block content
|
|||
span(data-i18n="play.level_difficulty") Difficulty:
|
||||
each i in Array(level.difficulty)
|
||||
| ★
|
||||
- var playCount = levelPlayCountMap[level.id]
|
||||
- var playCount = view.levelPlayCountMap[level.id]
|
||||
if playCount
|
||||
span.spl.spr - #{playCount.sessions}
|
||||
span(data-i18n="play.players") players
|
||||
|
|
|
@ -22,6 +22,7 @@ module.exports = class LadderHomeView extends RootView
|
|||
@sessions = @supermodel.loadCollection(new LevelSessionsCollection(), 'your_sessions', {cache: false}, 0).model
|
||||
@listenToOnce @sessions, 'sync', @onSessionsLoaded
|
||||
@getLevelPlayCounts()
|
||||
@campaigns = campaigns
|
||||
|
||||
onSessionsLoaded: (e) ->
|
||||
for session in @sessions.models
|
||||
|
@ -47,13 +48,6 @@ module.exports = class LadderHomeView extends RootView
|
|||
}, 0
|
||||
levelPlayCountsRequest.load()
|
||||
|
||||
getRenderData: (context={}) ->
|
||||
context = super(context)
|
||||
context.levelStatusMap = @levelStatusMap
|
||||
context.levelPlayCountMap = @levelPlayCountMap
|
||||
context.campaigns = campaigns
|
||||
context
|
||||
|
||||
heroArenas = [
|
||||
{
|
||||
name: 'Ace of Coders'
|
||||
|
|
Loading…
Reference in a new issue