Skip to content

Commit 2c158a3

Browse files
committed
fix updating sectionGroup seats
1 parent ec4ba03 commit 2c158a3

File tree

3 files changed

+12
-3
lines changed

3 files changed

+12
-3
lines changed

app/course/directives/courseTable.js

+9-3
Original file line numberDiff line numberDiff line change
@@ -511,6 +511,9 @@ let courseTable = function ($rootScope, $timeout, CourseActionCreators, $compile
511511
var sectionGroup = _.findWhere(scope.view.state.sectionGroups.list, { courseId: courseId, termCode: termCode }); // eslint-disable-line no-undef
512512
var plannedSeats = $el.val() === "" ? null : parseInt($el.val());
513513

514+
const course = scope.view.state.courses.list[courseId];
515+
const isNumericSection = isNumber(course.sequencePattern);
516+
514517
if (isNaN(plannedSeats)) { return; }
515518

516519
if (sectionGroup) {
@@ -525,8 +528,10 @@ let courseTable = function ($rootScope, $timeout, CourseActionCreators, $compile
525528

526529
// Save existing sectionGroup
527530
sectionGroup.plannedSeats = plannedSeats;
528-
if (plannedSeats >= proposedSectionSeatTotal) {
529-
CourseActionCreators.updateSectionGroup(sectionGroup);
531+
if (!isNumericSection) {
532+
if (plannedSeats >= proposedSectionSeatTotal) {
533+
CourseActionCreators.updateSectionGroup(sectionGroup);
534+
}
530535

531536
// Check if any overflowed sections can be updated. If yes, update them.
532537
if (currentSectionSeatTotal !== proposedSectionSeatTotal) {
@@ -535,10 +540,11 @@ let courseTable = function ($rootScope, $timeout, CourseActionCreators, $compile
535540
}
536541

537542
// If sequence is numeric sync the seats on the section to the new sectionGroup value
538-
if (sectionGroup.sections.length === 1 && isNumber(sectionGroup.sections[0].sequenceNumber)) {
543+
if (isNumericSection && sectionGroup.sections.length === 1) {
539544
let section = scope.view.state.sections.list[sectionGroup.sections[0].id];
540545
section.seats = sectionGroup.plannedSeats;
541546
CourseActionCreators.updateSection(section);
547+
CourseActionCreators.updateSectionGroup(sectionGroup);
542548
}
543549
} else if (plannedSeats) {
544550
// Create a new sectionGroup

app/course/directives/sectionGroupDetails/sectionGroupDetails.js

+2
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,8 @@ let sectionGroupDetails = function (CourseActionCreators, Term) {
7575
return Number(proposedSectionSeats !== originalSectionSeats) + acc;
7676
}, 0);
7777

78+
if (outOfSyncSections === 0) { return; } // prevent extra update on input blur
79+
7880
// sync with sectionGroup if single numeric section
7981
if (proposedSections.length === 1 && isNumber(section.sequenceNumber)) {
8082
sectionGroup.plannedSeats = section.seats;

app/course/services/courseStateService.js

+1
Original file line numberDiff line numberDiff line change
@@ -298,6 +298,7 @@ class CourseStateService {
298298
return sectionGroups;
299299
case ActionTypes.UPDATE_SECTION:
300300
var sectionGroup = sectionGroups.selectedSectionGroup || sectionGroups.list[action.payload.section.sectionGroupId];
301+
sectionGroup.sections = sectionGroup.sections.map(slotSection => slotSection.id === action.payload.section.id ? action.payload.section : slotSection);
301302
sectionGroup.requiresAttention = action.payload.requiresAttention;
302303
return sectionGroups;
303304
case ActionTypes.REMOVE_SECTION:

0 commit comments

Comments
 (0)