Compiled js file
authorSteve Sutton <steve@gaslightmedia.com>
Tue, 14 Nov 2017 20:30:06 +0000 (15:30 -0500)
committerSteve Sutton <steve@gaslightmedia.com>
Tue, 14 Nov 2017 20:30:06 +0000 (15:30 -0500)
some merging from the last pull.

js/frontRegApp.js

index bd22308..937caad 100644 (file)
@@ -109,6 +109,26 @@ app.Models.Front.RegClass = Backbone.Model.extend({
         this.regTimes = new app.Collections.Front.RegTimes( [] );
     },
 
+    // setRegistrants: function( registrants ) {
+    //     this.registrants.reset( registrants );
+    // },
+
+    // Check to see if the current login user in the list of registrants
+    // hasMe: function() {
+    //     return false;
+    //     if ( loginAccount ) {
+    //         var foundMe = this.registrants.findWhere({ account: loginAccount.get( 'id' ) });
+    //         if ( foundMe ) {
+    //             return true;
+    //         } else {
+    //             return false;
+    //         }
+    //         return true;
+    //     } else {
+    //         return false;
+    //     }
+    // },
+
 });
 
 // js/models/regEvent.js
@@ -145,13 +165,7 @@ app.Models.Front.RegEvent = Backbone.Model.extend({
             var foundClass = this.classes.findWhere({ id: registrants[i].class_id });
             // console.log(foundClass);
             if ( foundClass != undefined ) {
-                // Try looking through the class times
-                // console.log(foundClass);
-                // var foundRegTime = foundClass.regTimes.findWhere({id: registrants[i].reg_time});
-                var foundRegTime = _.findWhere(foundClass.get('times'), { id: registrants[i].reg_time });
-                // console.log(foundRegTime);
-                // return;
-                // var foundRegTime = _.findWhere(app.Times, { id: registrants[i].reg_time });
+                var foundRegTime = _.findWhere(app.Times, { id: registrants[i].reg_time });
                 // Now add the time if needed
                 var hasRegTime = _.findWhere(foundClass, { reg_time: foundRegTime.id });
                 // console.log(hasRegTime);
@@ -476,6 +490,11 @@ app.Views.Front.RegClass = Backbone.View.extend({
 
     events: {
         'click .addRegistrant': 'newEntry',
+        // 'click .glm-add-account': 'addAccount',
+        // 'click .glm-add-new-account': 'addNewAccount',
+        // 'click .add-new-registrant': 'addNew',
+        // 'click .add-new-registrant-cancel': 'cancelAddNew',
+        // 'click .timeSelection': 'updateTimeSelection',
         'click .fc-event-container': 'updateTimeSelection',
         'click .show-hide-address': 'toggleClass',
     },
@@ -485,24 +504,31 @@ app.Views.Front.RegClass = Backbone.View.extend({
     },
 
     updateTimeSelection: function(e){
+        console.log('updateTimeSelection called');
         var timeId = this.$('.timeSelection').val().trim();
+        console.log( timeId );
         // Check to see if the time is already in the collection
         // If it is then do nothing
-        var findRegTime = this.model.regTimes.where({ id: timeId });
+        console.log(this.model.regTimes.length);
 
+        var findRegTime = this.model.regTimes.where({ id: timeId });
+        console.log(findRegTime.length);
         if ( findRegTime.length == 0 ) {
+            console.log('regTime not found, creating one.');
             this.model.set({ selectedTime: timeId });
             // Add the RegTime model/view into this view
-            var classTimes = this.model.get('times');
-            var targetTime = {};
-            for ( var key in classTimes ) {
-                if ( classTimes[key].id == timeId ) {
-                    targetTime = classTimes[key];
+            // console.log( app.Times );
+            var targetTime = null;
+            for ( var i = 0; i < app.Times.length; i++ ) {
+                if ( app.Times[i].id == timeId ) {
+                    targetTime = app.Times[i];
                 }
             }
             if ( targetTime ) {
                 var selectedTime = new app.Models.Front.RegTime( targetTime );
                 selectedTime.set({parent: this.model});
+                console.log('creating time entry');
+                console.log(selectedTime);
                 this.model.regTimes.create( selectedTime );
             }
         }
@@ -599,6 +625,7 @@ app.Views.Front.RegClass = Backbone.View.extend({
                 $('.fc-event').css( 'background-color', '#3a67ad' );
                 $(this).css( 'background-color', 'red' );
                 jQuery( '.timeSelection' ).val( calEvent.reg_time );
+                // jQuery( '#add_reg-select-time-display' ).html( calEvent.start.format( 'L LT' ) );
             },
         });
     },
@@ -1023,7 +1050,6 @@ app.Views.Front.RegTime = Backbone.View.extend({
             var times  = this.model.get( 'times' );
         }
         var rateId = this.model.get( 'rate_id' );
-        console.log(rateId);
         if ( !rateId ) {
             // console.log( 'No rate id!' );
             // console.log( sTime );