Skip to content
Snippets Groups Projects
Commit 9abdd0af authored by attiyaishaque's avatar attiyaishaque
Browse files

Discussion moderators, TA's and admins see the posts according to cohorts.

parent 0f9db0cb
No related merge requests found
...@@ -135,6 +135,7 @@ ...@@ -135,6 +135,7 @@
}, },
'submit .forum-new-post-form': 'createPost', 'submit .forum-new-post-form': 'createPost',
'change .post-option-input': 'postOptionChange', 'change .post-option-input': 'postOptionChange',
'change .js-group-select': 'groupOptionChange',
'click .cancel': 'cancel', 'click .cancel': 'cancel',
'click .add-post-cancel': 'cancel', 'click .add-post-cancel': 'cancel',
'reset .forum-new-post-form': 'updateStyles', 'reset .forum-new-post-form': 'updateStyles',
...@@ -146,6 +147,7 @@ ...@@ -146,6 +147,7 @@
NewPostView.prototype.toggleGroupDropdown = function($target) { NewPostView.prototype.toggleGroupDropdown = function($target) {
if ($target.data('divided')) { if ($target.data('divided')) {
$('.js-group-select').prop('disabled', false); $('.js-group-select').prop('disabled', false);
$('.js-group-select').val('').prop('selected', true);
return $('.group-selector-wrapper').removeClass('disabled'); return $('.group-selector-wrapper').removeClass('disabled');
} else { } else {
$('.js-group-select').val('').prop('disabled', true); $('.js-group-select').val('').prop('disabled', true);
...@@ -257,6 +259,14 @@ ...@@ -257,6 +259,14 @@
return setTimeout(function() { return self.$('.post-option-input').trigger('change'); }, 1); return setTimeout(function() { return self.$('.post-option-input').trigger('change'); }, 1);
}; };
NewPostView.prototype.groupOptionChange = function(event) {
var $target = $(event.target),
data = $target.data();
this.group_name = this.$('.js-group-select option:selected').text();
data.divided = true;
this.updateVisibilityMessage($target);
};
return NewPostView; return NewPostView;
}(Backbone.View)); }(Backbone.View));
} }
......
...@@ -95,6 +95,25 @@ ...@@ -95,6 +95,25 @@
$('.post-topic').trigger('change'); $('.post-topic').trigger('change');
return checkVisibility(this.view, true, false, false); return checkVisibility(this.view, true, false, false);
}); });
it('visibility message changes when group is changed', function() {
DiscussionSpecHelper.makeModerator();
checkVisibility(this.view, true, false, true);
$('option:contains(Topic)').prop('selected', true);
$('.post-topic').trigger('change');
expect($('.js-group-select option:selected').text())
.toEqual('All Groups');
expect($('.group-visibility').text().trim())
.toEqual('This post will be visible only to All Groups.');
$('.js-group-select option:contains(Cohort1)').prop('selected', true);
$('.js-group-select').trigger('change');
expect($('.js-group-select option:selected').text())
.toEqual('Cohort1');
expect($('.group-visibility').text().trim())
.toEqual('This post will be visible only to Cohort1.');
return checkVisibility(this.view, true, false, false);
});
it('allows the user to make a group selection', function() { it('allows the user to make a group selection', function() {
var expectedGroupId, var expectedGroupId,
self = this; self = this;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment