Logging in and logging out sets up the add me button now
authorSteve Sutton <steve@gaslightmedia.com>
Mon, 2 Oct 2017 15:50:47 +0000 (11:50 -0400)
committerSteve Sutton <steve@gaslightmedia.com>
Mon, 2 Oct 2017 15:50:47 +0000 (11:50 -0400)
Add me will now toggle correctly when logging in and out.

js/frontRegApp.js
js/views/front/app.js
js/views/front/register.js
models/front/registrations/registration.php
views/front/registrations/registration.html

index e264821..8e492bc 100644 (file)
@@ -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;
index 6cec340..3b1c86d 100644 (file)
@@ -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!' });
index 4097e4f..7126d98 100644 (file)
@@ -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;
index 3c521c6..0d64a17 100644 (file)
@@ -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',
             //unset( $_SESSION['LoginAccount'] );
         }
 
-        //echo '<pre>$_SESSION: ' . print_r( $_SESSION, true ) . '</pre>';
+        // echo '<pre>$_SESSION: ' . print_r( $_SESSION, true ) . '</pre>';
 
         // 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 '<pre>$cart: ' . print_r( $cart, true ) . '</pre>';
+        // echo '<pre>$cart: ' . print_r( $cart, true ) . '</pre>';
         $registrants = array();
         //echo '<pre>$cart[events]: ' . print_r( $cart['events'], true ) . '</pre>';
 
             }
         }
 
-        echo '<pre>$registrants: ' . print_r( $registrants, true ) . '</pre>';
+        // echo '<pre>$registrants: ' . print_r( $registrants, true ) . '</pre>';
 
         // Compile template data
         $templateData = array(
index 292ad81..3de4609 100644 (file)
@@ -28,7 +28,7 @@
     </div>
     <div>
         <input class="account_email" placeholder="*Email Address">
-        <% if ( emailError ) { %>
+        <% if ( emailError !== undefined && emailError !== '' ) { %>
             <span class="error"><%= emailError %></span>
         <% } %>
         <input class="account_password" placeholder="*Password">