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

This commit is contained in:
attiyaishaque
2018-04-16 12:30:56 +05:00
parent 0f9db0cb89
commit 9abdd0af3d
2 changed files with 29 additions and 0 deletions

View File

@@ -135,6 +135,7 @@
},
'submit .forum-new-post-form': 'createPost',
'change .post-option-input': 'postOptionChange',
'change .js-group-select': 'groupOptionChange',
'click .cancel': 'cancel',
'click .add-post-cancel': 'cancel',
'reset .forum-new-post-form': 'updateStyles',
@@ -146,6 +147,7 @@
NewPostView.prototype.toggleGroupDropdown = function($target) {
if ($target.data('divided')) {
$('.js-group-select').prop('disabled', false);
$('.js-group-select').val('').prop('selected', true);
return $('.group-selector-wrapper').removeClass('disabled');
} else {
$('.js-group-select').val('').prop('disabled', true);
@@ -257,6 +259,14 @@
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;
}(Backbone.View));
}

View File

@@ -95,6 +95,25 @@
$('.post-topic').trigger('change');
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() {
var expectedGroupId,
self = this;