mirror of
https://github.com/codeninjasllc/codecombat.git
synced 2024-12-18 11:32:25 -05:00
31 lines
747 B
CoffeeScript
31 lines
747 B
CoffeeScript
RootView = require 'views/core/RootView'
|
|
template = require 'templates/common/user'
|
|
User = require 'models/User'
|
|
|
|
module.exports = class UserView extends RootView
|
|
template: template
|
|
className: 'user-view'
|
|
viewName: null # Used for the breadcrumbs
|
|
|
|
constructor: (@userID, options) ->
|
|
super options
|
|
@listenTo @, 'userNotFound', @ifUserNotFound
|
|
@fetchUser @userID
|
|
|
|
fetchUser: ->
|
|
if @isMe()
|
|
@user = me
|
|
@onLoaded()
|
|
@user = new User _id: @userID
|
|
@supermodel.loadModel @user, cache: false
|
|
|
|
isMe: -> @userID in [me.id, me.get('slug')]
|
|
|
|
onLoaded: ->
|
|
@userData = @user unless @user?.isAnonymous()
|
|
@userID = @user.id
|
|
super()
|
|
|
|
ifUserNotFound: ->
|
|
console.warn 'user not found'
|
|
@render()
|