Working on the event reg forms for adding attendees.
authorSteve Sutton <steve@gaslightmedia.com>
Thu, 12 Oct 2017 16:33:23 +0000 (12:33 -0400)
committerSteve Sutton <steve@gaslightmedia.com>
Thu, 12 Oct 2017 16:33:23 +0000 (12:33 -0400)
Fixing the add attendee forms. Changing the class used on the new form and the edit ones so they don't get confused in backbone.
Fixed: When adding attendee with the next attempt to add attendee wasn't working.

css/front.css
js/frontRegApp.js
js/views/front/app.js
js/views/front/regClass.js
js/views/front/regRequestRegistrant.js
js/views/front/registrantForm.js
models/front/registrations/registration.php
views/front/registrations/registration.html

index 213ce44..bad3cac 100644 (file)
@@ -204,19 +204,19 @@ div.glm-reg-register input.error {
 .new-reg-notime h2 {
     width: auto;
 }
-.new-reg-notime .reg_fname,
-.new-reg-notime .reg_lname,
-.new-reg-notime .reg_addr1,
-.new-reg-notime .reg_addr2,
-.new-reg-notime .reg_city,
-.new-reg-notime .reg_state,
-.new-reg-notime .reg_zip,
-.new-reg-notime .reg_country {
+.new-reg-notime .add_reg_fname,
+.new-reg-notime .add_reg_lname,
+.new-reg-notime .add_reg_addr1,
+.new-reg-notime .add_reg_addr2,
+.new-reg-notime .add_reg_city,
+.new-reg-notime .add_reg_state,
+.new-reg-notime .add_reg_zip,
+.new-reg-notime .add_reg_country {
     width: 46%;
     margin-right: 1rem;
     float: left;
 }
-.new-reg-notime .reg_email {
+.new-reg-notime .add_reg_email {
     width: 95%;
 }
 #reg-select-time {
index cf1f00b..f5338fb 100644 (file)
@@ -470,6 +470,7 @@ app.Views.Front.Account = Backbone.View.extend({
 // js/views/app.js
 Backbone.emulateJSON = true;
 Backbone.emulateHTTP = true;
+Backbone.history.start({ pushState: true, root: thisPageUrl });
 
 // Event Registrant List View
 app.Views.Front.App = Backbone.View.extend({
@@ -761,17 +762,17 @@ app.Views.Front.RegClass = Backbone.View.extend({
     },
     addNew: function(){
         var findByEmail = [];
-        var fname   = this.$('.reg_fname').val().trim();
-        var lname   = this.$('.reg_lname').val().trim();
-        var email   = this.$('.reg_email').val().trim();
-        var addr1   = this.$('.reg_addr1').val().trim();
-        var addr2   = this.$('.reg_addr2').val().trim();
-        var city    = this.$('.reg_city').val().trim();
-        var state   = this.$('.reg_state').val().trim();
-        var zip     = this.$('.reg_zip').val().trim();
-        var country = this.$('.reg_country').val().trim();
-        if ( this.$('#reg-select-time').length ) {
-            var rTime   = this.$('#reg-select-time').val().trim();
+        var fname   = this.$('.add_reg_fname').val().trim();
+        var lname   = this.$('.add_reg_lname').val().trim();
+        var email   = this.$('.add_reg_email').val().trim();
+        var addr1   = this.$('.add_reg_addr1').val().trim();
+        var addr2   = this.$('.add_reg_addr2').val().trim();
+        var city    = this.$('.add_reg_city').val().trim();
+        var state   = this.$('.add_reg_state').val().trim();
+        var zip     = this.$('.add_reg_zip').val().trim();
+        var country = this.$('.add_reg_country').val().trim();
+        if ( this.$('#add_reg-select-time').length ) {
+            var rTime   = this.$('#add_reg-select-time').val().trim();
         } else {
             var rTime = null;
         }
@@ -950,23 +951,43 @@ app.Views.Front.RegRequestRegistrant = Backbone.View.extend({
 
     update: function(){
         console.log( 'updating model' );
+        var fname   = this.$('.reg_fname').val().trim();
+        var lname   = this.$('.reg_lname').val().trim();
+        var email   = this.$('.reg_email').val().trim();
+        var addr1   = this.$('.reg_addr1').val().trim();
+        var addr2   = this.$('.reg_addr2').val().trim();
+        var city    = this.$('.reg_city').val().trim();
+        var state   = this.$('.reg_state').val().trim();
+        var zip     = this.$('.reg_zip').val().trim();
+        var country = this.$('.reg_country').val().trim();
+        if ( this.$('#reg-select-time').length ) {
+            var rTime   = this.$('#reg-select-time').val().trim();
+        } else {
+            var rTime = null;
+        }
+        if ( app.timeSpecific && !rTime ) {
+            alert( 'You must select a time!' );
+            return;
+        }
+        if ( fname === '' || lname === '' ) {
+            alert( 'First and Last name required!' );
+            return;
+        }
         // Validate the model
         // Have to require reg_time if app.timeSpecific is true
         // Get the form values and update the model.
         this.model.set({
             option: 'update',
-            fname: this.$('.reg_fname').val().trim(),
-            lname: this.$('.reg_lname').val().trim(),
-            addr1: this.$('.reg_addr1').val().trim(),
-            addr2: this.$('.reg_addr2').val().trim(),
-            city: this.$('.reg_city').val().trim(),
-            state: this.$('.reg_state').val().trim(),
-            zip: this.$('.reg_zip').val().trim(),
-            country: this.$('.reg_country').val().trim(),
-            reg_time: this.$('#reg-select-time').val().trim(),
+            fname: fname,
+            lname: lname,
+            addr1: addr1,
+            addr2: addr2,
+            city: city,
+            state: state,
+            zip: zip,
+            country: country,
+            reg_time: rTime
         });
-        console.log( 'model id' );
-        console.log( this.model.get( 'id' ) );
         this.model.save();
 
     },
@@ -1129,7 +1150,7 @@ app.Views.Front.RegistrantForm = Backbone.View.extend({
     template: _.template( jQuery('#eventReg-registrant-add').html() ),
 
     events: {
-        'focusout .reg_email': 'verifyEmail'
+        'focusout .add_reg_email': 'verifyEmail'
     },
 
     initialize: function(){
@@ -1142,7 +1163,7 @@ app.Views.Front.RegistrantForm = Backbone.View.extend({
     },
 
     verifyEmail: function(){
-        var email = this.$('.reg_email').val().trim();
+        var email = this.$('.add_reg_email').val().trim();
         if ( email == '' ) {
             return;
         }
@@ -1165,8 +1186,8 @@ app.Views.Front.RegistrantForm = Backbone.View.extend({
                     // This account already exists.
                     // They should not be able to edit the record.
                     console.log( 'Record exists not able to edit!' );
-                    this.$('.reg_fname').val(account.fname);
-                    this.$('.reg_lname').val(account.lname);
+                    this.$('.add_reg_fname').val(account.fname);
+                    this.$('.add_reg_lname').val(account.lname);
 
                     // lock the form
                     this.lockForm();
@@ -1182,25 +1203,25 @@ app.Views.Front.RegistrantForm = Backbone.View.extend({
     },
 
     lockForm: function(){
-        this.$('.reg_fname').prop('disabled', true);
-        this.$('.reg_lname').prop('disabled', true);
-        this.$('.reg_addr1').prop('disabled', true);
-        this.$('.reg_addr2').prop('disabled', true);
-        this.$('.reg_city').prop('disabled', true);
-        this.$('.reg_state').prop('disabled', true);
-        this.$('.reg_zip').prop('disabled', true);
-        this.$('.reg_country').prop('disabled', true);
+        this.$('.add_reg_fname').prop('disabled', true);
+        this.$('.add_reg_lname').prop('disabled', true);
+        this.$('.add_reg_addr1').prop('disabled', true);
+        this.$('.add_reg_addr2').prop('disabled', true);
+        this.$('.add_reg_city').prop('disabled', true);
+        this.$('.add_reg_state').prop('disabled', true);
+        this.$('.add_reg_zip').prop('disabled', true);
+        this.$('.add_reg_country').prop('disabled', true);
     },
 
     unLockForm: function(){
-        this.$('.reg_fname').prop('disabled', false);
-        this.$('.reg_lname').prop('disabled', false);
-        this.$('.reg_addr1').prop('disabled', false);
-        this.$('.reg_addr2').prop('disabled', false);
-        this.$('.reg_city').prop('disabled', false);
-        this.$('.reg_state').prop('disabled', false);
-        this.$('.reg_zip').prop('disabled', false);
-        this.$('.reg_country').prop('disabled', false);
+        this.$('.add_reg_fname').prop('disabled', false);
+        this.$('.add_reg_lname').prop('disabled', false);
+        this.$('.add_reg_addr1').prop('disabled', false);
+        this.$('.add_reg_addr2').prop('disabled', false);
+        this.$('.add_reg_city').prop('disabled', false);
+        this.$('.add_reg_state').prop('disabled', false);
+        this.$('.add_reg_zip').prop('disabled', false);
+        this.$('.add_reg_country').prop('disabled', false);
     },
 
 });
index 3b1c86d..b9358ad 100644 (file)
@@ -1,6 +1,7 @@
 // js/views/app.js
 Backbone.emulateJSON = true;
 Backbone.emulateHTTP = true;
+Backbone.history.start({ pushState: true, root: thisPageUrl });
 
 // Event Registrant List View
 app.Views.Front.App = Backbone.View.extend({
index 920f1f3..cba27ce 100644 (file)
@@ -73,17 +73,17 @@ app.Views.Front.RegClass = Backbone.View.extend({
     },
     addNew: function(){
         var findByEmail = [];
-        var fname   = this.$('.reg_fname').val().trim();
-        var lname   = this.$('.reg_lname').val().trim();
-        var email   = this.$('.reg_email').val().trim();
-        var addr1   = this.$('.reg_addr1').val().trim();
-        var addr2   = this.$('.reg_addr2').val().trim();
-        var city    = this.$('.reg_city').val().trim();
-        var state   = this.$('.reg_state').val().trim();
-        var zip     = this.$('.reg_zip').val().trim();
-        var country = this.$('.reg_country').val().trim();
-        if ( this.$('#reg-select-time').length ) {
-            var rTime   = this.$('#reg-select-time').val().trim();
+        var fname   = this.$('.add_reg_fname').val().trim();
+        var lname   = this.$('.add_reg_lname').val().trim();
+        var email   = this.$('.add_reg_email').val().trim();
+        var addr1   = this.$('.add_reg_addr1').val().trim();
+        var addr2   = this.$('.add_reg_addr2').val().trim();
+        var city    = this.$('.add_reg_city').val().trim();
+        var state   = this.$('.add_reg_state').val().trim();
+        var zip     = this.$('.add_reg_zip').val().trim();
+        var country = this.$('.add_reg_country').val().trim();
+        if ( this.$('#add_reg-select-time').length ) {
+            var rTime   = this.$('#add_reg-select-time').val().trim();
         } else {
             var rTime = null;
         }
index b0fa90e..b60b749 100644 (file)
@@ -19,23 +19,43 @@ app.Views.Front.RegRequestRegistrant = Backbone.View.extend({
 
     update: function(){
         console.log( 'updating model' );
+        var fname   = this.$('.reg_fname').val().trim();
+        var lname   = this.$('.reg_lname').val().trim();
+        var email   = this.$('.reg_email').val().trim();
+        var addr1   = this.$('.reg_addr1').val().trim();
+        var addr2   = this.$('.reg_addr2').val().trim();
+        var city    = this.$('.reg_city').val().trim();
+        var state   = this.$('.reg_state').val().trim();
+        var zip     = this.$('.reg_zip').val().trim();
+        var country = this.$('.reg_country').val().trim();
+        if ( this.$('#reg-select-time').length ) {
+            var rTime   = this.$('#reg-select-time').val().trim();
+        } else {
+            var rTime = null;
+        }
+        if ( app.timeSpecific && !rTime ) {
+            alert( 'You must select a time!' );
+            return;
+        }
+        if ( fname === '' || lname === '' ) {
+            alert( 'First and Last name required!' );
+            return;
+        }
         // Validate the model
         // Have to require reg_time if app.timeSpecific is true
         // Get the form values and update the model.
         this.model.set({
             option: 'update',
-            fname: this.$('.reg_fname').val().trim(),
-            lname: this.$('.reg_lname').val().trim(),
-            addr1: this.$('.reg_addr1').val().trim(),
-            addr2: this.$('.reg_addr2').val().trim(),
-            city: this.$('.reg_city').val().trim(),
-            state: this.$('.reg_state').val().trim(),
-            zip: this.$('.reg_zip').val().trim(),
-            country: this.$('.reg_country').val().trim(),
-            reg_time: this.$('#reg-select-time').val().trim(),
+            fname: fname,
+            lname: lname,
+            addr1: addr1,
+            addr2: addr2,
+            city: city,
+            state: state,
+            zip: zip,
+            country: country,
+            reg_time: rTime
         });
-        console.log( 'model id' );
-        console.log( this.model.get( 'id' ) );
         this.model.save();
 
     },
index 02f2316..5e9e4e1 100644 (file)
@@ -12,7 +12,7 @@ app.Views.Front.RegistrantForm = Backbone.View.extend({
     template: _.template( jQuery('#eventReg-registrant-add').html() ),
 
     events: {
-        'focusout .reg_email': 'verifyEmail'
+        'focusout .add_reg_email': 'verifyEmail'
     },
 
     initialize: function(){
@@ -25,7 +25,7 @@ app.Views.Front.RegistrantForm = Backbone.View.extend({
     },
 
     verifyEmail: function(){
-        var email = this.$('.reg_email').val().trim();
+        var email = this.$('.add_reg_email').val().trim();
         if ( email == '' ) {
             return;
         }
@@ -48,8 +48,8 @@ app.Views.Front.RegistrantForm = Backbone.View.extend({
                     // This account already exists.
                     // They should not be able to edit the record.
                     console.log( 'Record exists not able to edit!' );
-                    this.$('.reg_fname').val(account.fname);
-                    this.$('.reg_lname').val(account.lname);
+                    this.$('.add_reg_fname').val(account.fname);
+                    this.$('.add_reg_lname').val(account.lname);
 
                     // lock the form
                     this.lockForm();
@@ -65,25 +65,25 @@ app.Views.Front.RegistrantForm = Backbone.View.extend({
     },
 
     lockForm: function(){
-        this.$('.reg_fname').prop('disabled', true);
-        this.$('.reg_lname').prop('disabled', true);
-        this.$('.reg_addr1').prop('disabled', true);
-        this.$('.reg_addr2').prop('disabled', true);
-        this.$('.reg_city').prop('disabled', true);
-        this.$('.reg_state').prop('disabled', true);
-        this.$('.reg_zip').prop('disabled', true);
-        this.$('.reg_country').prop('disabled', true);
+        this.$('.add_reg_fname').prop('disabled', true);
+        this.$('.add_reg_lname').prop('disabled', true);
+        this.$('.add_reg_addr1').prop('disabled', true);
+        this.$('.add_reg_addr2').prop('disabled', true);
+        this.$('.add_reg_city').prop('disabled', true);
+        this.$('.add_reg_state').prop('disabled', true);
+        this.$('.add_reg_zip').prop('disabled', true);
+        this.$('.add_reg_country').prop('disabled', true);
     },
 
     unLockForm: function(){
-        this.$('.reg_fname').prop('disabled', false);
-        this.$('.reg_lname').prop('disabled', false);
-        this.$('.reg_addr1').prop('disabled', false);
-        this.$('.reg_addr2').prop('disabled', false);
-        this.$('.reg_city').prop('disabled', false);
-        this.$('.reg_state').prop('disabled', false);
-        this.$('.reg_zip').prop('disabled', false);
-        this.$('.reg_country').prop('disabled', false);
+        this.$('.add_reg_fname').prop('disabled', false);
+        this.$('.add_reg_lname').prop('disabled', false);
+        this.$('.add_reg_addr1').prop('disabled', false);
+        this.$('.add_reg_addr2').prop('disabled', false);
+        this.$('.add_reg_city').prop('disabled', false);
+        this.$('.add_reg_state').prop('disabled', false);
+        this.$('.add_reg_zip').prop('disabled', false);
+        this.$('.add_reg_country').prop('disabled', false);
     },
 
 });
index 821932a..83fd2e2 100644 (file)
@@ -38,6 +38,7 @@
     public function modelAction($actionData = false)
     {
 
+        nocache_headers();
         $loginAccount      = '';
         $cartId            = false;
         $haveCart          = false;
index c9dbcc8..89d6c60 100644 (file)
             {/literal}{$terms.reg_term_contact_information}{literal}
         </div>
         <div>
-            <input class="reg_fname" placeholder="First Name">
-            <input class="reg_lname" placeholder="Last Name">
+            <input class="add_reg_fname" placeholder="First Name">
+            <input class="add_reg_lname" placeholder="Last Name">
         </div>
         <div>
-            <input class="reg_email" placeholder="Email Address" value="<%- email %>">
+            <input class="add_reg_email" placeholder="Email Address" value="<%- email %>">
             (Email is optional)
         </div>
         <div>
-            <input class="reg_addr1" placeholder="Address 1">
-            <input class="reg_addr2" placeholder="Address 2">
+            <input class="add_reg_addr1" placeholder="Address 1">
+            <input class="add_reg_addr2" placeholder="Address 2">
         </div>
         <div>
-            <input class="reg_city" placeholder="City">
-            <input class="reg_state" placeholder="State">
+            <input class="add_reg_city" placeholder="City">
+            <input class="add_reg_state" placeholder="State">
         </div>
         <div>
-            <input class="reg_zip" placeholder="Zip/Postal Code">
-            <input class="reg_country" placeholder="Country">
+            <input class="add_reg_zip" placeholder="Zip/Postal Code">
+            <input class="add_reg_country" placeholder="Country">
         </div>
         {/literal}{if $regEvent.time_specific.value}
             <div>
-                Selected Time: <span id="reg-select-time-display"></span>
-                <input type="hidden" id="reg-select-time">
+                Selected Time: <span id="add_reg-select-time-display"></span>
+                <input type="hidden" id="add_reg-select-time">
             </div>
         {/if}{literal}
     </div>
                 <input class="reg_lname" placeholder="Last Name" value="<%- lname %>">
             </div>
             <div>
-                <input class="reg_email" placeholder="Email Address" value="<%- email %>">
+                <input class="reg_email" placeholder="Email Address" value="<%- email %>" disabled>
                 (Email is optional)
             </div>
             <div>
 var appLoginUrl = '{$ajaxUrl}?action=glm_members_admin_ajax&glm_action=login';
 var appAccountUrl = '{$ajaxUrl}?action=glm_members_admin_ajax&glm_action=account';
 var ajaxUrl = '{$ajaxUrl}?action=glm_members_admin_ajax';
+var thisPageUrl = '{$thisUrl}';
 var nextPageUrl = '{$thisUrl}?page=cart';
 var app = {
     Models: { Front: {}, Admin: {} },