2014-07-06 14:45:27 -04:00
|
|
|
UserView = require 'views/kinds/UserView'
|
|
|
|
template = require 'templates/user/achievements'
|
|
|
|
{me} = require 'lib/auth'
|
2014-07-06 16:48:33 -04:00
|
|
|
Achievement = require 'models/Achievement'
|
2014-07-06 17:38:57 -04:00
|
|
|
EarnedAchievement = require 'models/EarnedAchievement'
|
2014-07-06 16:48:33 -04:00
|
|
|
AchievementCollection = require 'collections/AchievementCollection'
|
2014-07-06 17:38:57 -04:00
|
|
|
EarnedAchievementCollection = require 'collections/EarnedAchievementCollection'
|
2014-07-06 14:45:27 -04:00
|
|
|
|
2014-07-06 17:16:00 -04:00
|
|
|
module.exports = class UserAchievementsView extends UserView
|
2014-07-06 14:45:27 -04:00
|
|
|
id: 'user-achievements-view'
|
|
|
|
template: template
|
|
|
|
|
2014-07-06 16:48:33 -04:00
|
|
|
events:
|
|
|
|
'userLoaded': 'onUserLoaded'
|
2014-07-06 14:45:27 -04:00
|
|
|
|
2014-07-06 16:48:33 -04:00
|
|
|
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
|