From 0d87209fa810ee436cdef77bf524d437bdaec3d8 Mon Sep 17 00:00:00 2001 From: Ruben Vereecken Date: Mon, 21 Jul 2014 19:06:22 +0200 Subject: [PATCH] Recently played is now shown on account page --- .../RecentlyPlayedCollection.coffee | 2 +- app/templates/account/home.jade | 19 +++++++++++++++++++ app/views/account/home.coffee | 3 +++ app/views/user/achievements.coffee | 2 +- bower.json | 1 + 5 files changed, 25 insertions(+), 2 deletions(-) diff --git a/app/collections/RecentlyPlayedCollection.coffee b/app/collections/RecentlyPlayedCollection.coffee index 1325781df..ff76aaf5b 100644 --- a/app/collections/RecentlyPlayedCollection.coffee +++ b/app/collections/RecentlyPlayedCollection.coffee @@ -1,4 +1,4 @@ -CocoCollection = require './CocoCollections' +CocoCollection = require './CocoCollection' LevelSession = require 'models/LevelSession' module.exports = class RecentlyPlayedCollection extends CocoCollection diff --git a/app/templates/account/home.jade b/app/templates/account/home.jade index 57ea5799f..20413b226 100644 --- a/app/templates/account/home.jade +++ b/app/templates/account/home.jade @@ -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 diff --git a/app/views/account/home.coffee b/app/views/account/home.coffee index 91368c9bf..41953afaf 100644 --- a/app/views/account/home.coffee +++ b/app/views/account/home.coffee @@ -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: -> diff --git a/app/views/user/achievements.coffee b/app/views/user/achievements.coffee index 2a70501e4..1a8d4dc52 100644 --- a/app/views/user/achievements.coffee +++ b/app/views/user/achievements.coffee @@ -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 diff --git a/bower.json b/bower.json index 91a04f9cc..e979e2f49 100644 --- a/bower.json +++ b/bower.json @@ -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",