Commit 4843facd by E. Kolpakov Committed by Jonathan Piacenti

Discussion course routes correction

parent 6d43e0e3
if Backbone? if Backbone?
class @DiscussionRouter extends Backbone.Router class @DiscussionRouter extends Backbone.Router
initialize: (options) -> initialize: (options) ->
@route("#{DiscussionUtil.route_prefix}", "allThreads") @allThreadsRoute = DiscussionUtil.route_prefix
@route("#{DiscussionUtil.route_prefix}:forum_name/threads/:thread_id", "showThread") @singleThreadRoute = @getSingleThreadRoute(":forum_name", ":thread_id")
@route(@allThreadsRoute, "allThreads")
@route(@singleThreadRoute, "showThread")
@discussion = options['discussion'] @discussion = options['discussion']
@course_settings = options['course_settings'] @course_settings = options['course_settings']
...@@ -30,6 +33,12 @@ if Backbone? ...@@ -30,6 +33,12 @@ if Backbone?
$('.new-post-btn').bind "click", @showNewPost $('.new-post-btn').bind "click", @showNewPost
$('.new-post-btn').bind "keydown", (event) => DiscussionUtil.activateOnSpace(event, @showNewPost) $('.new-post-btn').bind "keydown", (event) => DiscussionUtil.activateOnSpace(event, @showNewPost)
getSingleThreadRoute: (commentable_id, thread_id) ->
base_route = "#{commentable_id}/threads/#{thread_id}"
if DiscussionUtil.route_prefix
base_route = "#{DiscussionUtil.route_prefix}/#{base_route}"
base_route
allThreads: -> allThreads: ->
@nav.updateSidebar() @nav.updateSidebar()
@nav.goHome() @nav.goHome()
...@@ -70,10 +79,10 @@ if Backbone? ...@@ -70,10 +79,10 @@ if Backbone?
navigateToThread: (thread_id) => navigateToThread: (thread_id) =>
thread = @discussion.get(thread_id) thread = @discussion.get(thread_id)
@navigate("#{DiscussionUtil.route_prefix}#{thread.get("commentable_id")}/threads/#{thread_id}", trigger: true) @navigate(@getSingleThreadRoute(thread.get("commentable_id"), thread_id), trigger: true)
navigateToAllThreads: => navigateToAllThreads: =>
@navigate("#{DiscussionUtil.route_prefix}", trigger: true) @navigate(@allThreadsRoute, trigger: true)
showNewPost: (event) => showNewPost: (event) =>
$('.forum-content').fadeOut( $('.forum-content').fadeOut(
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment