Make the regClass add all times to it's collection
authorSteve Sutton <steve@gaslightmedia.com>
Tue, 12 Dec 2017 16:36:07 +0000 (11:36 -0500)
committerAnthony Talarico <talarico@gaslightmedia.com>
Tue, 12 Dec 2017 16:42:44 +0000 (11:42 -0500)
Adding all regClass times to the regTimes collections without having to
click each in the calender.

js/frontRegApp.js
js/views/front/regClass.js
models/front/registrations/registration.php
views/front/registrations/registration.html

index 68b2d01..55083e0 100644 (file)
@@ -494,6 +494,16 @@ app.Views.Front.RegClass = Backbone.View.extend({
         this.listenTo( this.model, 'change', this.render );
         this.listenTo( this.model.regTimes, 'add', this.render );
 
+        // Add times into regTimes collection
+        var classTimes = this.model.get('times');
+        for ( var key in classTimes ) {
+            var newTime = new app.Models.Front.RegTime( classTimes[key] );
+            newTime.set({reg_event: this.model.get('reg_event'), parent: this.model});
+            this.model.regTimes.create( newTime );
+        }
+
+        console.log( classTimes );
+
         return this;
     },
 
index 36079d2..f7b9097 100644 (file)
@@ -13,6 +13,16 @@ app.Views.Front.RegClass = Backbone.View.extend({
         this.listenTo( this.model, 'change', this.render );
         this.listenTo( this.model.regTimes, 'add', this.render );
 
+        // Add times into regTimes collection
+        var classTimes = this.model.get('times');
+        for ( var key in classTimes ) {
+            var newTime = new app.Models.Front.RegTime( classTimes[key] );
+            newTime.set({reg_event: this.model.get('reg_event'), parent: this.model});
+            this.model.regTimes.create( newTime );
+        }
+
+        console.log( classTimes );
+
         return this;
     },
 
index 017aed8..fcf1db8 100644 (file)
         $jsonClasses = array();
         $regClasses  = array();
 
-        $regTimes = array();
+        // $regTimes = array();
 
         if ( isset( $regEvent['reg_class'] ) && is_array( $regEvent['reg_class'] ) ) {
 
                         if ( $regEvent['time_specific'] ) {
                             $rClass['selectedTime'] = $time['id'];
                         }
-                        if ( empty( $regtimes[$time['id']] ) ) {
-                            $regTimes[$time['id']] = json_encode( $time, JSON_NUMERIC_CHECK );
-                        }
+                        // if ( empty( $regtimes[$time['id']] ) ) {
+                        //     $regTimes[$time['id']] = json_encode( $time, JSON_NUMERIC_CHECK );
+                        // }
                     }
                     $rClass['startingTime'] = $classStartingTime['start_datetime']['datetime'];
                     $jsonClasses[] = json_encode( $rClass, JSON_NUMERIC_CHECK );
         // Build the regClass JSON for the template.
         $regClassJSON = '[' . implode( ',', $jsonClasses ) . ']';
         $regCartJSON  = json_encode( $cart );
-        $regTimesJSON = '[' . implode( ',', $regTimes ) . ']';
+        // $regTimesJSON = '[' . implode( ',', $regTimes ) . ']';
 
         // Get terms into JSON
         $termsJSON = json_encode( $this->config['terms'] );
             'thisJsUrl'         => GLM_MEMBERS_REGISTRATIONS_PLUGIN_URL . '/js',
             'regEventJSON'      => json_encode( $event, JSON_NUMERIC_CHECK ),
             'regClassesJSON'    => $regClassJSON,
-            'regTimesJSON'      => $regTimesJSON,
+            // 'regTimesJSON'      => $regTimesJSON,
             'regCartJSON'       => $regCartJSON,
             'imgBaseUrl'        => GLM_MEMBERS_PLUGIN_MEDIA_URL ."/images/",
             'regRequestJSON'    => $regRequestJSON,
index cd9931e..b9b17dd 100644 (file)
@@ -301,7 +301,7 @@ var app = {
     Models: { Front: {}, Admin: {} },
     Collections: { Front: {}, Admin: {} },
     Views: { Front: {}, Admin: {} },
-    Times: {$regTimesJSON},
+    //Times: {$regTimesJSON},
     isValidEmail: function( email ){
         var regex = {literal}/^([a-zA-Z0-9_.+-])+\@(([a-zA-Z0-9-])+\.)+([a-zA-Z0-9]{2,4})+$/;{/literal}
         return regex.test(email);