codecombat/app/views/account/MainAccountView.coffee

39 lines
1.3 KiB
CoffeeScript
Raw Normal View History

2014-07-15 10:15:21 -04:00
View = require 'views/kinds/RootView'
2014-08-12 07:41:14 -04:00
template = require 'templates/account/account_home'
2014-07-15 10:15:21 -04:00
{me} = require 'lib/auth'
User = require 'models/User'
2014-07-29 11:28:13 -04:00
AuthModalView = require 'views/modal/AuthModal'
RecentlyPlayedCollection = require 'collections/RecentlyPlayedCollection'
ThangType = require 'models/ThangType'
2014-07-15 10:15:21 -04:00
module.exports = class MainAccountView extends View
2014-08-12 07:41:14 -04:00
id: 'account-home'
2014-07-15 10:15:21 -04:00
template: template
constructor: (options) ->
super options
return unless me
@wizardType = ThangType.loadUniversalWizard()
@recentlyPlayed = new RecentlyPlayedCollection me.get('_id')
@supermodel.loadModel @wizardType, 'thang'
@supermodel.loadCollection @recentlyPlayed, 'recentlyPlayed'
onLoaded: ->
super()
2014-07-15 10:15:21 -04:00
2014-07-16 06:39:18 -04:00
getRenderData: ->
c = super()
c.subs = {}
2014-08-12 07:41:14 -04:00
enabledEmails = c.me.getEnabledEmails()
c.subs[sub] = 1 for sub in enabledEmails
c.hasEmailNotes = _.any enabledEmails, (sub) -> sub.contains 'Notes'
c.hasEmailNews = _.any enabledEmails, (sub) -> sub.contains('News') and sub isnt 'generalNews'
c.hasGeneralNews = 'generalNews' in enabledEmails
c.wizardSource = @wizardType.getPortraitSource colorConfig: me.get('wizard')?.colorConfig if @wizardType.loaded
c.recentlyPlayed = @recentlyPlayed.models
2014-07-16 06:39:18 -04:00
c
2014-07-15 10:15:21 -04:00
afterRender: ->
super()
@openModalView new AuthModalView if me.isAnonymous()