2014-11-28 20:49:41 -05:00
|
|
|
RootView = require 'views/core/RootView'
|
|
|
|
template = require 'templates/common/user'
|
2014-07-06 14:45:27 -04:00
|
|
|
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
|
2014-07-06 14:45:27 -04:00
|
|
|
|
2014-07-21 13:49:16 -04:00
|
|
|
constructor: (@userID, options) ->
|
2014-07-06 15:10:28 -04:00
|
|
|
super options
|
2014-07-09 12:12:31 -04:00
|
|
|
@listenTo @, 'userNotFound', @ifUserNotFound
|
2014-07-14 06:14:43 -04:00
|
|
|
@fetchUser @userID
|
|
|
|
|
2014-08-14 11:25:41 -04:00
|
|
|
fetchUser: ->
|
2014-08-07 16:03:00 -04:00
|
|
|
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
|
2014-07-06 15:10:28 -04:00
|
|
|
|
2014-09-30 13:53:01 -04:00
|
|
|
isMe: -> @userID in [me.id, me.get('slug')]
|
2014-07-06 16:48:33 -04:00
|
|
|
|
2014-08-07 16:03:00 -04:00
|
|
|
onLoaded: ->
|
2016-05-26 06:19:02 -04:00
|
|
|
@userData = @user unless @user?.isAnonymous()
|
2014-09-30 13:53:01 -04:00
|
|
|
@userID = @user.id
|
2016-05-26 06:19:02 -04:00
|
|
|
super()
|
2014-08-14 11:25:41 -04:00
|
|
|
|
2014-07-09 12:12:31 -04:00
|
|
|
ifUserNotFound: ->
|
|
|
|
console.warn 'user not found'
|
2014-07-14 06:14:43 -04:00
|
|
|
@render()
|