@@ -111,60 +111,48 @@ class RegistrarReconciliationReportActionCreators {
111111 } ) ;
112112 } ,
113113 updateSectionReconciliation : function ( updatedSection ) {
114- var sectionKey ;
114+ var sectionKeys ;
115115 var sections = RegistrarReconciliationReportStateService . _state . sections ;
116116 // When updatedSection is received after updateActivity()
117117 // Look for sectionKey by the id of the change
118118 if ( updatedSection . activityState ) {
119- sectionKey = sections . ids
119+ sectionKeys = sections . ids
120120 . filter ( function ( slotId ) {
121121 return sections . list [ slotId ] . activities
122122 . some ( function ( a ) { return a . id == updatedSection . id ; } ) ;
123123 } ) ;
124124 // When updatedSection is received after updateSection() or unAssignInstructor()
125125 // sectionKey is provided by updatedSection
126126 } else {
127- sectionKey = sections . sectionsKeyById [ updatedSection . id ] ;
127+ sectionKeys = [ sections . sectionsKeyById [ updatedSection . id ] ] ;
128128 }
129129
130+ sectionKeys . forEach ( function ( sectionKey ) {
130131 var slotSection = sections . list [ sectionKey ] ;
132+ if ( ! slotSection ) { return ; }
131133
132134 // Check if slot instructors has changes
133- var instructorsHasChanges = sections . ids
134- . some ( function ( slotSectionKey ) {
135- if ( sectionKey == slotSectionKey ) {
136- return sections . list [ slotSectionKey ] . instructors
137- . some ( function ( i ) { return i . noRemote || i . noLocal ; } ) ;
138- }
139- } ) ;
135+ var instructorsHasChanges = slotSection . instructors
136+ . some ( function ( i ) { return i . noRemote || i . noLocal ; } ) ;
140137
141138 // Check if slot activities has changes
142- var activitiesHasChanges = sections . ids
143- . some ( function ( slotSectionKey ) {
144- if ( sectionKey == slotSectionKey ) {
145- return sections . list [ slotSectionKey ] . activities
146- . some ( function ( i ) { return i . dwChanges || i . noLocal || i . noRemote ; } ) ;
147- }
148- } ) ;
149-
139+ var activitiesHasChanges = slotSection . activities
140+ . some ( function ( a ) { return a . dwChanges || a . noLocal || a . noRemote ; } ) ;
141+
150142 // Check if slot section has changes
151- var sectionHasChanges = slotSection ? .dwChanges ;
143+ var sectionHasChanges = slotSection . dwChanges ;
152144
153- var dwHasChanges ;
154- if ( instructorsHasChanges || activitiesHasChanges || sectionHasChanges ) {
155- dwHasChanges = true ;
156- } else {
157- dwHasChanges = false ;
158- }
145+ var dwHasChanges = ! ! ( instructorsHasChanges || activitiesHasChanges || sectionHasChanges ) ;
159146
160- var action = {
161- type : ActionTypes . UPDATE_SECTION_RECONCILIATION ,
162- payload : {
163- sectionKey : sectionKey ,
164- dwHasChanges : dwHasChanges
165- }
166- } ;
167- RegistrarReconciliationReportStateService . reduce ( action ) ;
147+ var action = {
148+ type : ActionTypes . UPDATE_SECTION_RECONCILIATION ,
149+ payload : {
150+ sectionKey : sectionKey ,
151+ dwHasChanges : dwHasChanges
152+ }
153+ } ;
154+ RegistrarReconciliationReportStateService . reduce ( action ) ;
155+ } ) ;
168156 } ,
169157 /**
170158 * Deletes an activity
0 commit comments