From 482d5835749c3de7a6da3d30e088475819dd912f Mon Sep 17 00:00:00 2001 From: Steve Sutton Date: Tue, 12 Dec 2017 11:36:07 -0500 Subject: [PATCH] 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. --- js/frontRegApp.js | 10 ++++++++++ js/views/front/regClass.js | 10 ++++++++++ models/front/registrations/registration.php | 12 ++++++------ views/front/registrations/registration.html | 2 +- 4 files changed, 27 insertions(+), 7 deletions(-) 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 59aafd8..f9addb1 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, 'regRequestJSON' => $regRequestJSON, 'loginAccount' => $loginAccount, diff --git a/views/front/registrations/registration.html b/views/front/registrations/registration.html index b08e22e..ad31153 100644 --- a/views/front/registrations/registration.html +++ b/views/front/registrations/registration.html @@ -245,7 +245,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); -- 2.17.1