codecombat/app/views/user/achievements.coffee

29 lines
1,010 B
CoffeeScript
Raw Normal View History

UserView = require 'views/kinds/UserView'
template = require 'templates/user/achievements'
{me} = require 'lib/auth'
Achievement = require 'models/Achievement'
2014-07-06 17:38:57 -04:00
EarnedAchievement = require 'models/EarnedAchievement'
AchievementCollection = require 'collections/AchievementCollection'
2014-07-06 17:38:57 -04:00
EarnedAchievementCollection = require 'collections/EarnedAchievementCollection'
2014-07-06 17:16:00 -04:00
module.exports = class UserAchievementsView extends UserView
id: 'user-achievements-view'
template: template
events:
'userLoaded': 'onUserLoaded'
constructor: (options, nameOrID) ->
super options, nameOrID
onUserLoaded: (user) ->
2014-07-07 06:44:44 -04:00
super user
2014-07-07 09:03:28 -04:00
@achievements = @supermodel.loadCollection(new AchievementCollection, 'achievements').model
@earnedAchievements = @supermodel.loadCollection(new EarnedAchievementCollection(@user), 'earnedAchievements').model
2014-07-07 06:44:44 -04:00
2014-07-07 09:03:28 -04:00
getRenderData: ->
context = super()
context.achievements = @achievements.models
context.earnedAchievements = @earnedAchievements.models
context