Adding comments to front end method for setting up registrants.
authorSteve Sutton <steve@gaslightmedia.com>
Thu, 14 Dec 2017 21:20:33 +0000 (16:20 -0500)
committerSteve Sutton <steve@gaslightmedia.com>
Thu, 14 Dec 2017 21:20:33 +0000 (16:20 -0500)
Commenting this so I know what the setRegistrant code is trying to do

js/frontRegApp.js
js/models/front/regEvent.js
js/views/front/regClass.js

index 415f81f..6cff1e7 100644 (file)
@@ -147,25 +147,34 @@ app.Models.Front.RegEvent = Backbone.Model.extend({
     // setClassRegistrants
     // To setup the registrant
     // Has to create a regTime first for the class
-    // Then is can add the registrant into that regTime model.
+    // Then is can add the registrant into that regTime model collection.
     setClassRegistrants: function( registrants ){
         for ( var i = 0; i < registrants.length; i++ ) {
+            // Find the class that this registrant belongs to.
             var foundClass = this.classes.findWhere({ id: registrants[i].class_id });
+            // console.log( foundClass );
             if ( foundClass != undefined ) {
                 // Try looking through the class times
+                // console.log( registrants[i].reg_time );
+                // console.log( foundClass.get('times') );
+                // Using the registrants reg_time lookup the regTime
                 // var foundRegTime = foundClass.regTimes.findWhere({id: registrants[i].reg_time});
                 var foundRegTime = _.findWhere(foundClass.get('times'), { id: registrants[i].reg_time });
+                // console.log( foundRegTime );
                 if ( foundRegTime ) {
+                    // Set the reg_event for this reg_time to the class we found for registrant
                     foundRegTime.reg_event = foundClass.get('reg_event');
 
                     // Now add the time if needed
+                    // First check to see if there's not one added already (regTime).
                     var hasRegTime = _.findWhere(foundClass, { reg_time: foundRegTime.id });
                     if ( !hasRegTime ) {
+                        // Here we have to add the regTime into the class.
                         foundClass.regTimes.create( foundRegTime );
                         hasRegTime = foundClass.regTimes.findWhere({ id: foundRegTime.id });
                         hasRegTime.set({ parent: foundClass });
                     }
-                    // Add the registrant
+                    // Add the registrant to the regTime.
                     var nRegTime = foundClass.regTimes.findWhere({id: hasRegTime.get('id')});
                     nRegTime.registrants.create( registrants[i] );
                 }
@@ -503,7 +512,7 @@ app.Views.Front.RegClass = Backbone.View.extend({
             this.model.regTimes.create( newTime );
         }
 
-        console.log( classTimes );
+        // console.log( classTimes );
 
         return this;
     },
index 3ef61ae..4ca8e08 100644 (file)
@@ -31,25 +31,34 @@ app.Models.Front.RegEvent = Backbone.Model.extend({
     // setClassRegistrants
     // To setup the registrant
     // Has to create a regTime first for the class
-    // Then is can add the registrant into that regTime model.
+    // Then is can add the registrant into that regTime model collection.
     setClassRegistrants: function( registrants ){
         for ( var i = 0; i < registrants.length; i++ ) {
+            // Find the class that this registrant belongs to.
             var foundClass = this.classes.findWhere({ id: registrants[i].class_id });
+            // console.log( foundClass );
             if ( foundClass != undefined ) {
                 // Try looking through the class times
+                // console.log( registrants[i].reg_time );
+                // console.log( foundClass.get('times') );
+                // Using the registrants reg_time lookup the regTime
                 // var foundRegTime = foundClass.regTimes.findWhere({id: registrants[i].reg_time});
                 var foundRegTime = _.findWhere(foundClass.get('times'), { id: registrants[i].reg_time });
+                // console.log( foundRegTime );
                 if ( foundRegTime ) {
+                    // Set the reg_event for this reg_time to the class we found for registrant
                     foundRegTime.reg_event = foundClass.get('reg_event');
 
                     // Now add the time if needed
+                    // First check to see if there's not one added already (regTime).
                     var hasRegTime = _.findWhere(foundClass, { reg_time: foundRegTime.id });
                     if ( !hasRegTime ) {
+                        // Here we have to add the regTime into the class.
                         foundClass.regTimes.create( foundRegTime );
                         hasRegTime = foundClass.regTimes.findWhere({ id: foundRegTime.id });
                         hasRegTime.set({ parent: foundClass });
                     }
-                    // Add the registrant
+                    // Add the registrant to the regTime.
                     var nRegTime = foundClass.regTimes.findWhere({id: hasRegTime.get('id')});
                     nRegTime.registrants.create( registrants[i] );
                 }
index f7b9097..5bfb2c4 100644 (file)
@@ -21,7 +21,7 @@ app.Views.Front.RegClass = Backbone.View.extend({
             this.model.regTimes.create( newTime );
         }
 
-        console.log( classTimes );
+        // console.log( classTimes );
 
         return this;
     },