2014-07-06 14:45:27 -04:00
|
|
|
RootView = require 'views/kinds/RootView'
|
|
|
|
template = require 'templates/kinds/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
|
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
|
|
|
|
|
|
|
|
fetchUser: (id) ->
|
2014-08-07 16:03:00 -04:00
|
|
|
if @isMe()
|
|
|
|
@user = me
|
|
|
|
@onLoaded()
|
|
|
|
@user = new User _id: id
|
|
|
|
@supermodel.loadModel @user, 'user'
|
2014-07-06 15:10:28 -04:00
|
|
|
|
|
|
|
getRenderData: ->
|
|
|
|
context = super()
|
2014-07-15 10:15:21 -04:00
|
|
|
context.viewName = @viewName
|
2014-07-09 12:12:31 -04:00
|
|
|
context.user = @user unless @user?.isAnonymous()
|
2014-07-06 15:10:28 -04:00
|
|
|
context
|
|
|
|
|
2014-07-14 06:14:43 -04:00
|
|
|
isMe: -> @userID is me.id
|
2014-07-06 16:48:33 -04:00
|
|
|
|
2014-08-07 16:03:00 -04:00
|
|
|
onLoaded: ->
|
|
|
|
super()
|
2014-07-09 12:12:31 -04:00
|
|
|
|
|
|
|
ifUserNotFound: ->
|
|
|
|
console.warn 'user not found'
|
2014-07-14 06:14:43 -04:00
|
|
|
@render()
|