From: Steve Sutton Date: Tue, 12 Dec 2017 16:36:07 +0000 (-0500) Subject: Make the regClass add all times to it's collection X-Git-Tag: v1.0.0^2~223^2~3 X-Git-Url: http://cvs2.gaslightmedia.com/gitweb/?a=commitdiff_plain;h=d181da93d0472051aeaeaf358a7b8fcd92561bdc;p=WP-Plugins%2Fglm-member-db-registrations.git Make the regClass add all times to it's collection Adding all regClass times to the regTimes collections without having to click each in the calender. --- diff --git a/js/frontRegApp.js b/js/frontRegApp.js index 68b2d01..55083e0 100644 --- a/js/frontRegApp.js +++ b/js/frontRegApp.js @@ -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; }, diff --git a/js/views/front/regClass.js b/js/views/front/regClass.js index 36079d2..f7b9097 100644 --- a/js/views/front/regClass.js +++ b/js/views/front/regClass.js @@ -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; }, diff --git a/models/front/registrations/registration.php b/models/front/registrations/registration.php index 017aed8..fcf1db8 100644 --- a/models/front/registrations/registration.php +++ b/models/front/registrations/registration.php @@ -187,7 +187,7 @@ $jsonClasses = array(); $regClasses = array(); - $regTimes = array(); + // $regTimes = array(); if ( isset( $regEvent['reg_class'] ) && is_array( $regEvent['reg_class'] ) ) { @@ -220,9 +220,9 @@ 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 ); @@ -239,7 +239,7 @@ // 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'] ); @@ -354,7 +354,7 @@ '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, diff --git a/views/front/registrations/registration.html b/views/front/registrations/registration.html index cd9931e..b9b17dd 100644 --- a/views/front/registrations/registration.html +++ b/views/front/registrations/registration.html @@ -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);