Show inline discussion component on Team view
TNL-2515
This commit is contained in:
@@ -10,10 +10,11 @@ if Backbone?
|
||||
"click .discussion-paginator a": "navigateToPage"
|
||||
|
||||
page_re: /\?discussion_page=(\d+)/
|
||||
initialize: ->
|
||||
initialize: (options) ->
|
||||
@toggleDiscussionBtn = @$(".discussion-show")
|
||||
# Set the page if it was set in the URL. This is used to allow deep linking to pages
|
||||
match = @page_re.exec(window.location.href)
|
||||
@context = options.context or "course" # allowed values are "course" or "standalone"
|
||||
if match
|
||||
@page = parseInt(match[1])
|
||||
else
|
||||
@@ -105,6 +106,7 @@ if Backbone?
|
||||
el: @$("article#thread_#{thread.id}"),
|
||||
model: thread,
|
||||
mode: "inline",
|
||||
context: @context,
|
||||
course_settings: @course_settings,
|
||||
topicId: discussionId
|
||||
)
|
||||
@@ -141,6 +143,7 @@ if Backbone?
|
||||
el: article,
|
||||
model: thread,
|
||||
mode: "inline",
|
||||
context: @context,
|
||||
course_settings: @course_settings,
|
||||
topicId: @$el.data("discussion-id")
|
||||
)
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
this.course_settings = options.course_settings;
|
||||
this.threadType = this.model.get('thread_type');
|
||||
this.topicId = this.model.get('commentable_id');
|
||||
this.context = options.context || 'course';
|
||||
_.bindAll(this);
|
||||
return this;
|
||||
},
|
||||
@@ -31,11 +32,15 @@
|
||||
threadTypeTemplate = _.template($("#thread-type-template").html());
|
||||
this.addField(threadTypeTemplate({form_id: formId}));
|
||||
this.$("#" + formId + "-post-type-" + this.threadType).attr('checked', true);
|
||||
this.topicView = new DiscussionTopicMenuView({
|
||||
topicId: this.topicId,
|
||||
course_settings: this.course_settings
|
||||
});
|
||||
this.addField(this.topicView.render());
|
||||
// Only allow the topic field for course threads, as standalone threads
|
||||
// cannot be moved.
|
||||
if (this.context === 'course') {
|
||||
this.topicView = new DiscussionTopicMenuView({
|
||||
topicId: this.topicId,
|
||||
course_settings: this.course_settings
|
||||
});
|
||||
this.addField(this.topicView.render());
|
||||
}
|
||||
DiscussionUtil.makeWmdEditor(this.$el, $.proxy(this.$, this), 'edit-post-body');
|
||||
return this;
|
||||
},
|
||||
@@ -53,13 +58,14 @@
|
||||
var title = this.$('.edit-post-title').val(),
|
||||
threadType = this.$(".post-type-input:checked").val(),
|
||||
body = this.$('.edit-post-body textarea').val(),
|
||||
commentableId = this.topicView.getCurrentTopicId(),
|
||||
postData = {
|
||||
title: title,
|
||||
thread_type: threadType,
|
||||
body: body,
|
||||
commentable_id: commentableId
|
||||
body: body
|
||||
};
|
||||
if (this.topicView) {
|
||||
postData.commentable_id = this.topicView.getCurrentTopicId();
|
||||
}
|
||||
|
||||
return DiscussionUtil.safeAjax({
|
||||
$elem: this.submitBtn,
|
||||
@@ -75,7 +81,9 @@
|
||||
this.$('.edit-post-title').val('').attr('prev-text', '');
|
||||
this.$('.edit-post-body textarea').val('').attr('prev-text', '');
|
||||
this.$('.wmd-preview p').html('');
|
||||
postData.courseware_title = this.topicView.getFullTopicName();
|
||||
if (this.topicView) {
|
||||
postData.courseware_title = this.topicView.getFullTopicName();
|
||||
}
|
||||
this.model.set(postData).unset('abbreviatedBody');
|
||||
this.trigger('thread:updated');
|
||||
if (this.threadType !== threadType) {
|
||||
|
||||
@@ -19,6 +19,7 @@ if Backbone?
|
||||
initialize: (options) ->
|
||||
super()
|
||||
@mode = options.mode or "inline" # allowed values are "tab" or "inline"
|
||||
@context = options.context or "course" # allowed values are "course" or "standalone"
|
||||
if @mode not in ["tab", "inline"]
|
||||
throw new Error("invalid mode: " + @mode)
|
||||
|
||||
@@ -300,6 +301,7 @@ if Backbone?
|
||||
container: @$('.thread-content-wrapper')
|
||||
model: @model
|
||||
mode: @mode
|
||||
context: @context
|
||||
course_settings: @options.course_settings
|
||||
)
|
||||
@editView.bind "thread:updated thread:cancel_edit", @closeEditView
|
||||
|
||||
@@ -87,7 +87,6 @@ if Backbone?
|
||||
url: url
|
||||
type: "POST"
|
||||
dataType: 'json'
|
||||
async: false # TODO when the rest of the stuff below is made to work properly..
|
||||
data:
|
||||
thread_type: thread_type
|
||||
title: title
|
||||
|
||||
Reference in New Issue
Block a user