Cherry picked Adolfo's commits and addressed Braden's observations
This commit is contained in:
committed by
Alex Dusenbery
parent
40f37608fa
commit
94bea7a707
@@ -126,7 +126,8 @@
|
||||
course_settings: this.courseSettings,
|
||||
topicId: discussionId,
|
||||
startHeader: this.startHeader,
|
||||
is_commentable_divided: response.is_commentable_divided
|
||||
is_commentable_divided: response.is_commentable_divided,
|
||||
user_group_id: response.user_group_id,
|
||||
});
|
||||
|
||||
this.newPostView.render();
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
initialize: function(options) {
|
||||
this.course_settings = options.course_settings;
|
||||
this.currentTopicId = options.topicId;
|
||||
this.group_name = options.group_name;
|
||||
_.bindAll(this,
|
||||
'handleTopicEvent'
|
||||
);
|
||||
|
||||
@@ -42,6 +42,7 @@
|
||||
}
|
||||
this.course_settings = options.course_settings;
|
||||
this.is_commentable_divided = options.is_commentable_divided;
|
||||
this.user_group_id = options.user_group_id;
|
||||
this.topicId = options.topicId;
|
||||
this.discussionBoardView = options.discussionBoardView;
|
||||
};
|
||||
@@ -53,6 +54,7 @@
|
||||
_.extend(context, {
|
||||
group_options: this.getGroupOptions(),
|
||||
is_commentable_divided: this.is_commentable_divided,
|
||||
is_discussion_division_enabled: this.course_settings.get('is_discussion_division_enabled'),
|
||||
mode: this.mode,
|
||||
startHeader: this.startHeader,
|
||||
form_id: this.mode + (this.topicId ? '-' + this.topicId : '')
|
||||
@@ -68,10 +70,17 @@
|
||||
if (this.isTabMode()) {
|
||||
this.topicView = new DiscussionTopicMenuView({
|
||||
topicId: this.topicId,
|
||||
course_settings: this.course_settings
|
||||
course_settings: this.course_settings,
|
||||
group_name: this.getGroupName()
|
||||
});
|
||||
this.topicView.on('thread:topic_change', this.toggleGroupDropdown);
|
||||
this.topicView.on('thread:topic_change', this.toggleGroupDropDown);
|
||||
if (this.course_settings.get('is_discussion_division_enabled')) {
|
||||
this.topicView.on('thread:topic_change', this.updateVisibilityMessage);
|
||||
}
|
||||
this.addField(this.topicView.render());
|
||||
} else {
|
||||
this.group_name = this.getGroupName();
|
||||
this.updateVisibilityMessage(null, this.is_commentable_divided);
|
||||
}
|
||||
return DiscussionUtil.makeWmdEditor(this.$el, $.proxy(this.$, this), 'js-post-body');
|
||||
};
|
||||
@@ -100,6 +109,26 @@
|
||||
}
|
||||
};
|
||||
|
||||
NewPostView.prototype.getGroupName = function() {
|
||||
var userGroupId;
|
||||
var group;
|
||||
var group_name = null;
|
||||
if (this.course_settings.get('is_discussion_division_enabled')) {
|
||||
userGroupId = $('#discussion-container').data('user-group-id');
|
||||
if (!userGroupId) {
|
||||
userGroupId = this.user_group_id;
|
||||
}
|
||||
group = this.course_settings.get('groups').find(function(group) {
|
||||
return group.id == userGroupId;
|
||||
});
|
||||
if (group) {
|
||||
group_name = group.name;
|
||||
}
|
||||
}
|
||||
|
||||
return group_name;
|
||||
};
|
||||
|
||||
NewPostView.prototype.events = {
|
||||
'keypress .forum-new-post-form input:not(.wmd-input)': function(event) {
|
||||
return DiscussionUtil.ignoreEnterKey(event);
|
||||
@@ -121,6 +150,17 @@
|
||||
}
|
||||
};
|
||||
|
||||
NewPostView.prototype.updateVisibilityMessage = function($target, force_divided) {
|
||||
var visEl = $('.group-visibility .field-label-text');
|
||||
var visTemplate = edx.HtmlUtils.template($('#new-post-visibility-template').html());
|
||||
var group_name = null;
|
||||
if (($target && $target.data('divided')) || force_divided) {
|
||||
group_name = this.group_name;
|
||||
}
|
||||
|
||||
edx.HtmlUtils.setHtml(visEl, visTemplate({group_name: group_name}));
|
||||
};
|
||||
|
||||
NewPostView.prototype.postOptionChange = function(event) {
|
||||
var $optionElem, $target;
|
||||
$target = $(event.target);
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
<% if (group_name) { %>
|
||||
<%-
|
||||
interpolate(
|
||||
gettext('This post will be visible only to %(group_name)s.'),
|
||||
{group_name: group_name},
|
||||
true
|
||||
)
|
||||
%>
|
||||
<% } else { %>
|
||||
<%- gettext('This post will be visible to everyone.') %>
|
||||
<% } %>
|
||||
@@ -29,6 +29,13 @@
|
||||
</div>
|
||||
</label>
|
||||
</div>
|
||||
<% } else if (is_discussion_division_enabled) { %>
|
||||
<div class="post-field group-visibility">
|
||||
<label class="field-label">
|
||||
<!-- Wrapper for the visibility message filled out by a separate template -->
|
||||
<span class="field-label-text"></span>
|
||||
</label>
|
||||
</div>
|
||||
<% } %>
|
||||
<div class="post-field">
|
||||
<label class="field-label">
|
||||
|
||||
@@ -205,11 +205,13 @@ def inline_discussion(request, course_key, discussion_id):
|
||||
threads = [utils.prepare_content(thread, course_key, is_staff) for thread in threads]
|
||||
with function_trace("add_courseware_context"):
|
||||
add_courseware_context(threads, course, request.user)
|
||||
course_discussion_settings = get_course_discussion_settings(course.id)
|
||||
|
||||
return utils.JsonResponse({
|
||||
'is_commentable_divided': is_commentable_divided(course_key, discussion_id),
|
||||
'discussion_data': threads,
|
||||
'user_info': user_info,
|
||||
'user_group_id': get_group_id_for_user(request.user, course_discussion_settings),
|
||||
'annotated_content_info': annotated_content_info,
|
||||
'page': query_params['page'],
|
||||
'num_pages': query_params['num_pages'],
|
||||
|
||||
@@ -13,10 +13,29 @@
|
||||
|
||||
<%
|
||||
template_names = [
|
||||
'thread', 'thread-show', 'thread-edit', 'thread-response', 'thread-response-show', 'thread-response-edit',
|
||||
'response-comment-show', 'response-comment-edit', 'thread-list-item', 'search-alert',
|
||||
'new-post', 'new-post-menu-entry', 'new-post-menu-category', 'new-post-alert', 'topic', 'post-user-display',
|
||||
'inline-discussion', 'pagination', 'profile-thread', 'customwmd-prompt', 'nav-loading', 'thread-type'
|
||||
'thread',
|
||||
'thread-show',
|
||||
'thread-edit',
|
||||
'thread-response',
|
||||
'thread-response-show',
|
||||
'thread-response-edit',
|
||||
'response-comment-show',
|
||||
'response-comment-edit',
|
||||
'thread-list-item',
|
||||
'search-alert',
|
||||
'new-post',
|
||||
'new-post-menu-entry',
|
||||
'new-post-menu-category',
|
||||
'new-post-alert',
|
||||
'new-post-visibility',
|
||||
'topic',
|
||||
'post-user-display',
|
||||
'inline-discussion',
|
||||
'pagination',
|
||||
'profile-thread',
|
||||
'customwmd-prompt',
|
||||
'nav-loading',
|
||||
'thread-type'
|
||||
]
|
||||
|
||||
## same, but without trailing "-template" in script ID - these templates does not contain any free variables
|
||||
|
||||
Reference in New Issue
Block a user