Add classes to group of elements for cohort selector.
Retriggring Jenkins build
This commit is contained in:
@@ -317,7 +317,7 @@ browser and pasting the output. When that file changes, this one should be rege
|
||||
<ul class="post-errors" style="display: none"></ul>
|
||||
<div class="forum-new-post-form-wrapper"></div>
|
||||
<% if (cohort_options) { %>
|
||||
<div class="post-field">
|
||||
<div class="post-field group-selector-wrapper<% if (!is_commentable_cohorted) { %> disabled<% } %>">
|
||||
<label class="field-label">
|
||||
<span class="field-label-text">
|
||||
Visible To:
|
||||
|
||||
@@ -10,21 +10,29 @@ describe "NewPostView", ->
|
||||
)
|
||||
@discussion = new Discussion([], {pages: 1})
|
||||
|
||||
checkVisibility = (view, expectedVisible, expectedDisabled) =>
|
||||
view.render()
|
||||
expect(view.$(".js-group-select").is(":visible")).toEqual(expectedVisible)
|
||||
disabled = view.$(".js-group-select").prop("disabled")
|
||||
if expectedVisible and ! expectedDisabled
|
||||
checkVisibility = (view, expectedVisible, expectedDisabled, noRender) =>
|
||||
if !noRender
|
||||
view.render()
|
||||
# Can also be undefined if the element does not exist.
|
||||
expect(view.$('.group-selector-wrapper').is(":visible") or false).toEqual(expectedVisible)
|
||||
disabled = view.$(".js-group-select").prop("disabled") or false
|
||||
group_disabled = view.$('.group-selector-wrapper').hasClass('disabled')
|
||||
if expectedVisible and !expectedDisabled
|
||||
expect(disabled).toEqual(false)
|
||||
expect(group_disabled).toEqual(false)
|
||||
else if expectedDisabled
|
||||
expect(disabled).toEqual(true)
|
||||
expect(group_disabled).toEqual(true)
|
||||
|
||||
describe "cohort selector", ->
|
||||
beforeEach ->
|
||||
@course_settings = new DiscussionCourseSettings({
|
||||
"category_map": {
|
||||
"children": ["Topic"],
|
||||
"entries": {"Topic": {"is_cohorted": true, "id": "topic"}}
|
||||
"children": ["Topic", "General"],
|
||||
"entries": {
|
||||
"Topic": {"is_cohorted": true, "id": "topic"},
|
||||
"General": {"is_cohorted": false, "id": "general"}
|
||||
}
|
||||
},
|
||||
"allow_anonymous": false,
|
||||
"allow_anonymous_to_peers": false,
|
||||
@@ -38,6 +46,7 @@ describe "NewPostView", ->
|
||||
el: $("#fixture-element"),
|
||||
collection: @discussion,
|
||||
course_settings: @course_settings,
|
||||
is_commententable_cohorted: true,
|
||||
mode: "tab"
|
||||
)
|
||||
|
||||
@@ -52,6 +61,19 @@ describe "NewPostView", ->
|
||||
DiscussionSpecHelper.makeModerator()
|
||||
checkVisibility(@view, true)
|
||||
|
||||
it "only enables the cohort selector when applicable", ->
|
||||
DiscussionSpecHelper.makeModerator()
|
||||
# We start on the cohorted discussion
|
||||
checkVisibility(@view, true)
|
||||
# Select the uncohorted topic
|
||||
$('.topic-title:contains(General)').click()
|
||||
# The menu should now be visible but disabled.
|
||||
checkVisibility(@view, true, true, true)
|
||||
# Select the cohorted topic again
|
||||
$('.topic-title:contains(Topic)').click()
|
||||
# It should be visible and enabled once more.
|
||||
checkVisibility(@view, true, false, true)
|
||||
|
||||
it "allows the user to make a cohort selection", ->
|
||||
DiscussionSpecHelper.makeModerator()
|
||||
@view.render()
|
||||
|
||||
@@ -19,6 +19,8 @@ if Backbone?
|
||||
})
|
||||
@$el.html(_.template($("#new-post-template").html(), context))
|
||||
threadTypeTemplate = _.template($("#thread-type-template").html());
|
||||
if $('.js-group-select').is(':disabled')
|
||||
$('.group-selector-wrapper').addClass('disabled')
|
||||
@addField(threadTypeTemplate({form_id: _.uniqueId("form-")}));
|
||||
if @isTabMode()
|
||||
@topicView = new DiscussionTopicMenuView {
|
||||
@@ -52,8 +54,10 @@ if Backbone?
|
||||
toggleGroupDropdown: ($target) ->
|
||||
if $target.data('cohorted')
|
||||
$('.js-group-select').prop('disabled', false);
|
||||
$('.group-selector-wrapper').removeClass('disabled')
|
||||
else
|
||||
$('.js-group-select').val('').prop('disabled', true);
|
||||
$('.group-selector-wrapper').addClass('disabled')
|
||||
|
||||
postOptionChange: (event) ->
|
||||
$target = $(event.target)
|
||||
|
||||
@@ -387,7 +387,7 @@
|
||||
<ul class="post-errors" style="display: none"></ul>
|
||||
<div class="forum-new-post-form-wrapper"></div>
|
||||
${'<% if (cohort_options) { %>'}
|
||||
<div class="post-field">
|
||||
<div class="post-field group-selector-wrapper${'<% if (!is_commentable_cohorted) { %>'} disabled${'<% } %>'}" >
|
||||
<label class="field-label">
|
||||
<span class="field-label-text">
|
||||
## Translators: This labels the selector for which group of students can view a post
|
||||
|
||||
Reference in New Issue
Block a user