Skip to content

Commit

Permalink
new dashboard wip
Browse files Browse the repository at this point in the history
Change-Id: I01fdfda226ef3007b61f7b9071a67e17b4e2763d
  • Loading branch information
Ryan Florence committed May 15, 2012
1 parent 4eb733f commit d010385
Show file tree
Hide file tree
Showing 68 changed files with 1,843 additions and 59 deletions.
8 changes: 3 additions & 5 deletions app/coffeescripts/backbone-ext/View.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ define [
##
# Extends render to add support for chid views and element filtering
render: (opts = {}) ->
@renderViews() if @options.views
@filter() unless opts.noFilter is true
@renderViews() if @options.views
this

##
Expand All @@ -48,9 +48,7 @@ define [
# @api private
renderView: (view, className) =>
target = @$('.' + className).first()
view.$el = target
view.el = target[0]
view.delegateEvents()
view.setElement target
view.render()

##
Expand All @@ -64,7 +62,7 @@ define [
createBinding: (index, el) ->
$el = $ el
attribute = $el.data 'bind'
@model.bind "change:#{attribute}", (model, value) =>
@model.on "change:#{attribute}", (model, value) =>
$el.html value

#_createBehavior: (index, el) ->
Expand Down
29 changes: 29 additions & 0 deletions app/coffeescripts/bundles/home.coffee
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
require [
'jquery'
'Backbone'
'compiled/home/views/DashboardView'
'compiled/home/views/QuickStartBar/QuickStartBarView'
'compiled/home/views/ActivityFeed/ActivityFeedView'
'compiled/home/views/SideBar/SideBarView'
'compiled/home/views/ActivityFeed/ActivityFeedFilterView'
'compiled/home/views/ActivityFeed/ActivityFeedItemsView'
'compiled/home/views/SideBar/TodoView'
'compiled/home/views/SideBar/ComingUpView'
], ($, {View}, DashboardView, QuickStartBarView, ActivityFeedView, SideBarView, ActivityFeedFilterView, ActivityFeedItemsView, TodoView, ComingUpView) ->

$ ->
@dashboard = new DashboardView

el: document.getElementById('content')

views:
quickStartBar: new QuickStartBarView
activityFeed: new ActivityFeedView
views:
activityFeedFilter: new ActivityFeedFilterView
activityFeedItems: new ActivityFeedItemsView
dashboardAside: new SideBarView
views:
todo: new TodoView
comingUp: new ComingUpView

70 changes: 70 additions & 0 deletions app/coffeescripts/home/all.coffee
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
##
# Controls the activity feed and the panel that filters it
class ActivityFeedView extends View
views:
'.activityFeedFilter': ActivityFeedFilterView
'.activityFeedItems' : ActivityFeedItemView

##
# Filters the activity feed
class ActivityFeedFilterView extends DrawerView
views:
'.courseList' : CourseListView
'.community' : CommunityView

##
# List of courses that filters the activity feed
class CourseListView extends NavListView

##
# A course item in a CourseListView
class CourseListItemView extends View

##
# Community items that filter the activity feed
class CommunityView extends NavListView

##
# A group item the a CommunityView
class GroupItemView extends NavListView

##
# Controls the items in an ActivityFeed
class ActivityFeedItemsView extends View
views:
'.activityFeedItemsFilterView': ActivityFeedItemsFilterView

##
# Filters the items in an ActivityFeedItemsView
class ActivityFeedItemsFilterView extends View

##
# Controls an activity feed item
class ActivityFeedItemView extends View

##
# Controls the todos and coming up items on the dashboard
class DashboardAsideView extends View
views:
'.todoView' : TodoView
'.comingUpView': ComingUpView

##
# Controls the todo items on the Dashboard
class TodoView extends AsideListView
class TodoItemView extends AsideListItemView

##
# Controls the coming up items on the Dashboard
class ComingUpView extends AsideListView
class ComingUpItemView extends AsideListItemView

##
# Creates LMS objects quickly from one interface
class QuickStartBarView

##
# Controls the global dashboard actions
class DashboardActionsView


6 changes: 6 additions & 0 deletions app/coffeescripts/home/collections/CourseCollection.coffee
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
define ['Backbone'], ({Model, Collection}) ->

class CourseCollection extends Collection
model: Model.extend()
url: 'api/v1/courses'

6 changes: 6 additions & 0 deletions app/coffeescripts/home/collections/TodoCollection.coffee
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
define ['Backbone'], ({Collection, Model}) ->

class TodoCollection extends Collection
url: '/api/v1/users/self/todo'
model: Model.extend()

12 changes: 12 additions & 0 deletions app/coffeescripts/home/models/QuickStartAssignment.coffee
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
define ['Backbone'], ({Model}) ->

class QuickStartAssignment extends Model

defaults:
title: 'No Title'
description: 'No Description'
due_at: null
points_possible: null
grading_type: 'points'
submission_types: 'online_upload,online_text_entry'

Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
define ['Backbone'], ({Model}) ->

class Announcement extends Model

12 changes: 12 additions & 0 deletions app/coffeescripts/home/models/quickStartBar/Assignment.coffee
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
define ['Backbone'], ({Model}) ->

class Assignment extends Model

defaults:
title: 'No Title'
description: 'No Description'
due_at: null
points_possible: null
grading_type: 'points'
submission_types: 'online_upload,online_text_entry'

4 changes: 4 additions & 0 deletions app/coffeescripts/home/models/quickStartBar/Discussion.coffee
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
define ['Backbone'], ({Model}) ->

class Discussion extends Model

4 changes: 4 additions & 0 deletions app/coffeescripts/home/models/quickStartBar/Message.coffee
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
define ['Backbone'], ({Model}) ->

class Message extends Model

4 changes: 4 additions & 0 deletions app/coffeescripts/home/models/quickStartBar/Pin.coffee
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
define ['Backbone'], ({Model}) ->

class Pin extends Model

13 changes: 13 additions & 0 deletions app/coffeescripts/home/quickStartBarTemplates.coffee
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
##
# Exports all the form templates for the quick start bar
# as an object.

define [
'jst/quickStartBar/assignment'
'jst/quickStartBar/announcement'
'jst/quickStartBar/message'
'jst/quickStartBar/pin'
], (assignment, announcement, message, pin) ->

{assignment, announcement, message, pin}

19 changes: 19 additions & 0 deletions app/coffeescripts/home/util/activityFeedItemViewFactory.coffee
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
define [
'compiled/home/views/ActivityFeed/items/ActivityFeedItemView'
'compiled/home/views/ActivityFeed/items/Announcement'
'compiled/home/views/ActivityFeed/items/Collaboration'
'compiled/home/views/ActivityFeed/items/Conference'
'compiled/home/views/ActivityFeed/items/Conversation'
'compiled/home/views/ActivityFeed/items/DiscussionTopic'
'compiled/home/views/ActivityFeed/items/Message'
'compiled/home/views/ActivityFeed/items/Submission'
], (ActivityFeedItemView) ->

activityFeedItemViewFactory = (activityFeedItem) ->
type = activityFeedItem.toJSON().type
View = ActivityFeedItemView[type]
if View
new View model: activityFeedItem
else
new ActivityFeedItemView model: activityFeedItem

Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
define [
'Backbone'
'compiled/home/collections/CourseCollection'
], ({View}, CourseCollection) ->

class ActivityFeedFilterView extends View

events:
'click a': 'clickFilter'

initialize: ->
@courseCollection = new CourseCollection
@courseCollection.on 'add', @addCourse
@courseCollection.on 'reset', => @courseCollection.each @addCourse
@courseCollection.fetch
# remove the "loading..." indicator element
success: => @$('.courseList li:first').remove()

clickFilter: (event) ->
event.preventDefault()
$el = $ event.target
value = $el.data 'value'
@filterFeed value

filterFeed: (query) ->
console.log "clicked: #{query}"

addCourse: (course) =>
id = course.get 'id'
course_code = course.get 'course_code'
@$('.courseList').append "<li><a href='#' data-value='course:#{id}'>#{course_code}</a></li>"

render: ->
@$el.html """
<header class="toolbar">&nbsp;</header>
<div class="list-view">
<ul class="filterList">
<li><a href="#" class="selected" data-value="everything">Everything</a>
</ul>
<header>Courses</header>
<ul class="courseList">
<li><a>Loading...</a></li>
</ul>
<header>Canvas Network</header>
<ul class="community">
<li><a href="#" data-value="peopleIFollow">People I Follow</a>
<li><a href="#" data-value="popular">Popular</a>
<li><a href="#" data-value="questions">Questions</a>
</ul>
<ul class="communityUserCommunities filterList">
<li><a href="#">TODO: fake data</a>
</ul>
</div>
"""
super

Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
define [
'Backbone'
'compiled/home/util/activityFeedItemViewFactory'
], ({View, Collection, Model}, activityFeedItemViewFactory) ->

class ActivityFeedItemsCollection extends Collection
model: Model.extend()
url: '/api/v1/users/self/activity_stream'

class ActivityFeedItemsView extends View

initialize: ->
@collection ?= new ActivityFeedItemsCollection
@collection.on 'add', @addActivityFeedItem
@collection.on 'reset', @resetActivityFeedItems
@collection.fetch()

addActivityFeedItem: (activityFeedItem) =>
view = activityFeedItemViewFactory activityFeedItem
view.render()
@$itemList.append view.el

resetActivityFeedItems: =>
@collection.each @addActivityFeedItem

render: ->
@$el.html """
<header class="activityFeedItemsToolbar toolbar border border-trbl border-round-t">
<div class="row-fluid">
<div class="span5">
<h2 class="header"><i class="icon-drawer-toggle">☭</i>Recent Activity</h2>
</div>
<div class="span7">
<ul class="activityFeedItemsFilter nav nav-links">
<li><a href="#" class="active">All</a>
<li><a href="#">Announcements</a>
<li><a href="#">Discussions</a>
<li><a href="#">Messages</a>
</ul>
</div>
</div>
</header>
<ul class="activityFeedItemsList"></ul>
"""
@cacheElements()
super

cacheElements: ->
@$itemList = @$ '.activityFeedItemsList'

19 changes: 19 additions & 0 deletions app/coffeescripts/home/views/ActivityFeed/ActivityFeedView.coffee
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
define ['Backbone'], ({View}) ->

##
# Controls the activity feed and the panel that filters it
class ActivityFeedView extends View

events:
'click .icon-drawer-toggle': 'toggleDrawer'

toggleDrawer: ->
@$el.toggleClass 'drawerClosed'

render: ->
@$el.html """
<div class="activityFeedFilter content-box border border-tbl border-round-tl"></div>
<div class="activityFeedItems content-box border border-trbl border-round-t box-shadow"></div>
"""
super

Loading

0 comments on commit d010385

Please sign in to comment.