codecombat/app/views/common/UserView.coffee

32 lines
747 B
CoffeeScript
Raw Normal View History

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'
2014-07-15 10:15:21 -04:00
viewName: null # Used for the breadcrumbs
constructor: (@userID, options) ->
super options
@listenTo @, 'userNotFound', @ifUserNotFound
@fetchUser @userID
2014-08-14 11:25:41 -04:00
fetchUser: ->
if @isMe()
@user = me
@onLoaded()
2014-08-14 11:25:41 -04:00
@user = new User _id: @userID
2016-02-18 11:44:40 -05:00
@supermodel.loadModel @user, cache: false
isMe: -> @userID in [me.id, me.get('slug')]
onLoaded: ->
@userData = @user unless @user?.isAnonymous()
@userID = @user.id
super()
2014-08-14 11:25:41 -04:00
ifUserNotFound: ->
console.warn 'user not found'
@render()