From 7ebccf3c4af5f2298c4b128c0507ef5a4a61b9d0 Mon Sep 17 00:00:00 2001 From: Steve Sutton Date: Mon, 2 Oct 2017 11:50:47 -0400 Subject: [PATCH] Logging in and logging out sets up the add me button now Add me will now toggle correctly when logging in and out. --- js/frontRegApp.js | 10 +++++++--- js/views/front/app.js | 9 ++++++--- js/views/front/register.js | 1 + models/front/registrations/registration.php | 8 ++++---- views/front/registrations/registration.html | 2 +- 5 files changed, 19 insertions(+), 11 deletions(-) diff --git a/js/frontRegApp.js b/js/frontRegApp.js index e264821..8e492bc 100644 --- a/js/frontRegApp.js +++ b/js/frontRegApp.js @@ -518,6 +518,9 @@ app.Views.Front.App = Backbone.View.extend({ loginAccount = ''; this.accountView.remove(); this.render(); + this.event.model.classes.map(function(item){ + item.set({ loggedIn: false }); + }); jQuery('#appLogin').show(); }) .fail(function(msg){ @@ -550,9 +553,9 @@ app.Views.Front.App = Backbone.View.extend({ this.loginModel.destroy(); this.loginView.remove(); this.render(); - // this.event.model.classes.map(function(item){ - // item.trigger( 'change' ); - // }); + this.event.model.classes.map(function(item){ + item.set({ loggedIn: true }); + }); } else { console.log( 'Login failed' ); this.loginModel.set({ message: 'Failed login!' }); @@ -1001,6 +1004,7 @@ app.Views.Front.Register = Backbone.View.extend({ checkEmail: function(){ console.log( 'focusout for email' ); this.$('.account_email').removeClass('error'); + this.model.set({ emailError: '' }); // if they entered email then test for existing email if ( this.model.get( 'validEmail' ) === true ){ return; diff --git a/js/views/front/app.js b/js/views/front/app.js index 6cec340..3b1c86d 100644 --- a/js/views/front/app.js +++ b/js/views/front/app.js @@ -58,6 +58,9 @@ app.Views.Front.App = Backbone.View.extend({ loginAccount = ''; this.accountView.remove(); this.render(); + this.event.model.classes.map(function(item){ + item.set({ loggedIn: false }); + }); jQuery('#appLogin').show(); }) .fail(function(msg){ @@ -90,9 +93,9 @@ app.Views.Front.App = Backbone.View.extend({ this.loginModel.destroy(); this.loginView.remove(); this.render(); - // this.event.model.classes.map(function(item){ - // item.trigger( 'change' ); - // }); + this.event.model.classes.map(function(item){ + item.set({ loggedIn: true }); + }); } else { console.log( 'Login failed' ); this.loginModel.set({ message: 'Failed login!' }); diff --git a/js/views/front/register.js b/js/views/front/register.js index 4097e4f..7126d98 100644 --- a/js/views/front/register.js +++ b/js/views/front/register.js @@ -36,6 +36,7 @@ app.Views.Front.Register = Backbone.View.extend({ checkEmail: function(){ console.log( 'focusout for email' ); this.$('.account_email').removeClass('error'); + this.model.set({ emailError: '' }); // if they entered email then test for existing email if ( this.model.get( 'validEmail' ) === true ){ return; diff --git a/models/front/registrations/registration.php b/models/front/registrations/registration.php index 3c521c6..0d64a17 100644 --- a/models/front/registrations/registration.php +++ b/models/front/registrations/registration.php @@ -41,7 +41,7 @@ $loginAccount = ''; $cartId = false; - var_dump( $_SESSION ); + // var_dump( $_SESSION ); // Have Backbone.js loaded $scripts = array( //'backbone-local' => 'js/lib/backbone.localStorage.min.js', @@ -194,13 +194,13 @@ //unset( $_SESSION['LoginAccount'] ); } - //echo '
$_SESSION: ' . print_r( $_SESSION, true ) . '
'; + // echo '
$_SESSION: ' . print_r( $_SESSION, true ) . '
'; // If there's a cart then pull any registrants for it // If there classes in the cart with rates and registrants they'll need // be setup. - //echo '
$cart: ' . print_r( $cart, true ) . '
'; + // echo '
$cart: ' . print_r( $cart, true ) . '
'; $registrants = array(); //echo '
$cart[events]: ' . print_r( $cart['events'], true ) . '
'; @@ -242,7 +242,7 @@ } } - echo '
$registrants: ' . print_r( $registrants, true ) . '
'; + // echo '
$registrants: ' . print_r( $registrants, true ) . '
'; // Compile template data $templateData = array( diff --git a/views/front/registrations/registration.html b/views/front/registrations/registration.html index 292ad81..3de4609 100644 --- a/views/front/registrations/registration.html +++ b/views/front/registrations/registration.html @@ -28,7 +28,7 @@
- <% if ( emailError ) { %> + <% if ( emailError !== undefined && emailError !== '' ) { %> <%= emailError %> <% } %> -- 2.17.1