From 99b6c3950e2402faf8d5c49b97ab24ef03ad879b Mon Sep 17 00:00:00 2001 From: "Albert St. Aubin" Date: Wed, 7 Jun 2017 09:54:59 -0400 Subject: [PATCH] update to correct timing bug with render of Discussions --- .../discussions_management/views/discussions.js | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/lms/static/js/discussions_management/views/discussions.js b/lms/static/js/discussions_management/views/discussions.js index e4c12417a0..82ac76301f 100644 --- a/lms/static/js/discussions_management/views/discussions.js +++ b/lms/static/js/discussions_management/views/discussions.js @@ -37,12 +37,18 @@ render: function() { var numberAvailableSchemes = this.discussionSettings.attributes.available_division_schemes.length; + HtmlUtils.setHtml(this.$el, this.template({ availableSchemes: this.getDivisionSchemeData(this.discussionSettings.attributes.division_scheme), // eslint-disable-line max-len layoutClass: numberAvailableSchemes === 2 ? THREE_COLUMN_CLASS : TWO_COLUMN_CLASS })); this.updateTopicVisibility(this.getSelectedScheme(), this.getTopicNav()); this.renderTopics(); + + if (this.isSchemeAvailable(COHORT) || + (!this.isSchemeAvailable(COHORT) && this.getSelectedScheme() === COHORT)) { + this.showCohortSchemeControl(true); + } return this; }, @@ -88,6 +94,16 @@ }, cohortStateUpdate: function(state) { + var cohortIndex; + if (state.is_cohorted && !this.isSchemeAvailable(COHORT)) { + this.discussionSettings.attributes.available_division_schemes.push(COHORT); + } else if (!state.is_cohorted && this.getSelectedScheme() !== COHORT) { + cohortIndex = this.discussionSettings.attributes.available_division_schemes.indexOf(COHORT); + if (cohortIndex > -1) { + this.discussionSettings.attributes.available_division_schemes.splice(cohortIndex, 1); + } + } + if (!this.isSchemeAvailable(ENROLLMENT_TRACK)) { this.showDiscussionManagement(state.is_cohorted); }