Recently played is now shown on account page

This commit is contained in:
Ruben Vereecken 2014-07-21 19:06:22 +02:00
parent 1c6da9711b
commit 0d87209fa8
5 changed files with 25 additions and 2 deletions

View file

@ -1,4 +1,4 @@
CocoCollection = require './CocoCollections'
CocoCollection = require './CocoCollection'
LevelSession = require 'models/LevelSession'
module.exports = class RecentlyPlayedCollection extends CocoCollection

View file

@ -92,6 +92,25 @@ block content
.col-sm-6
h2 Recently Played
hr
if !recentlyPlayed
div Loading...
else if recentlyPlayed.length
table.table
tr
th Level
th Last Played
th Status
each session in recentlyPlayed
tr
td
a(href="/play/level/#{session.get('levelID')}")= session.get('levelName')
td= moment(session.get('changed')).fromNow()
if session.get('state').complete === true
td Completed
else
.panel.panel-default
.panel-body
div No games played during the past two weeks.
//block content
h2 Account

View file

@ -3,6 +3,7 @@ template = require 'templates/account/home'
{me} = require 'lib/auth'
User = require 'models/User'
AuthModalView = require 'views/modal/auth_modal'
RecentlyPlayedCollection = require 'collections/RecentlyPlayedCollection'
module.exports = class AccountHomeView extends View
id: 'account-home-view'
@ -11,11 +12,13 @@ module.exports = class AccountHomeView extends View
constructor: (options) ->
super options
return unless me
@recentlyPlayed = @supermodel.loadCollection(new RecentlyPlayedCollection(me.get('_id')), 'recentlyPlayed').model
getRenderData: ->
c = super()
c.subs = {}
c.subs[sub] = 1 for sub in c.me.getEnabledEmails()
c.recentlyPlayed = @recentlyPlayed.models
c
afterRender: ->

View file

@ -14,9 +14,9 @@ module.exports = class UserAchievementsView extends UserView
super options, userID
onUserLoaded: (user) ->
super user
@achievements = @supermodel.loadCollection(new AchievementCollection, 'achievements').model
@earnedAchievements = @supermodel.loadCollection(new EarnedAchievementCollection(@user), 'earnedAchievements').model
super user
onLoaded: ->
console.log @earnedAchievements

View file

@ -31,6 +31,7 @@
"i18next": "git://github.com/nwinter/i18next.git",
"firepad": "~0.1.2",
"marked": "~0.3.0",
"moment": "~2.5.0",
"aether": "~0.2.22",
"underscore.string": "~2.3.3",
"firebase": "~1.0.2",