Move more forum nav rendering logic to front end

The cohort selector is rendered only for a privileged user in a cohorted
course, and that logic is now in an Underscore template instead of Mako.
This commit is contained in:
Greg Price
2014-09-04 18:22:19 -04:00
parent cd0ea052ed
commit 1de17fb745
4 changed files with 32 additions and 14 deletions

View File

@@ -8,7 +8,11 @@ if Backbone?
@discussion = options['discussion']
@course_settings = options['course_settings']
@nav = new DiscussionThreadListView(collection: @discussion, el: $(".forum-nav"))
@nav = new DiscussionThreadListView(
collection: @discussion,
el: $(".forum-nav"),
courseSettings: @course_settings
)
@nav.on "thread:selected", @navigateToThread
@nav.on "thread:removed", @navigateToAllThreads
@nav.on "threads:rendered", @setActiveThread

View File

@@ -13,7 +13,8 @@ if Backbone?
"change .forum-nav-filter-main-control": "chooseFilter"
"change .forum-nav-filter-cohort-control": "chooseCohort"
initialize: ->
initialize: (options) ->
@courseSettings = options.courseSettings
@displayedCollection = new Discussion(@collection.models, pages: @collection.pages)
@collection.on "change", @reloadDisplayedCollection
@discussionIds=""
@@ -121,7 +122,12 @@ if Backbone?
render: ->
@timer = 0
@$el.html(@template())
@$el.html(
@template({
isCohorted: @courseSettings.get("is_cohorted"),
isPrivilegedUser: DiscussionUtil.isPrivilegedUser()
})
)
@$(".forum-nav-sort-control").val(@collection.sort_preference)
$(window).bind "load", @updateSidebar