From 98930c26101f9bf7ae14ae00bf24b15906f6e3f6 Mon Sep 17 00:00:00 2001 From: Steve Sutton Date: Fri, 5 Jan 2018 11:44:36 -0500 Subject: [PATCH] Update to add attendee forms. Separate out the email lookup part to form within the add attendee form that allows someone to lookup account by email. If it finds the account it hides that part and fills in the other form. If it doesn't find the account it fills in the email address. --- js/frontRegApp.js | 38 +++++++++++++++------ js/views/front/regTime.js | 10 ++++-- js/views/front/registrantForm.js | 28 ++++++++++----- views/front/registrations/registration.html | 11 ++++++ 4 files changed, 65 insertions(+), 22 deletions(-) diff --git a/js/frontRegApp.js b/js/frontRegApp.js index 48b384e..fa30f42 100644 --- a/js/frontRegApp.js +++ b/js/frontRegApp.js @@ -958,6 +958,7 @@ app.Views.Front.RegTime = Backbone.View.extend({ // insert new registrant insertNew: function(){ + this.$('#loading-' + this.model.get('id') ).show(); var findByEmail = []; var fname = this.$('.add_reg_fname').val().trim(); var lname = this.$('.add_reg_lname').val().trim(); @@ -989,6 +990,10 @@ app.Views.Front.RegTime = Backbone.View.extend({ } } else { findByEmail = this.model.registrants.where({email: email, fname: fname, lname: lname}); + console.log( findByEmail.length ); + if ( findByEmail.length > 0 ) { + this.$('#loading-' + this.model.get('id') ).hide(); + } } var regRequest = cart.get( 'request' ); var parent = this.model.get('parent'); @@ -1001,7 +1006,6 @@ app.Views.Front.RegTime = Backbone.View.extend({ // to the collection. var customFieldData = this.$( 'form.attendee-cf-form-new' ).serialize(); - this.$('#loading-' + this.model.get('id') ).show(); var newRegistrant = this.model.registrants.create({ option: 'add', reg_request: regRequest.id, @@ -1032,8 +1036,8 @@ app.Views.Front.RegTime = Backbone.View.extend({ }, errorCallback: function( collection, response ){ - // console.log( 'errorCallback Called' ); - // console.log( response ); + console.log( 'errorCallback Called' ); + console.log( response ); }, // cancel add new registrant @@ -1075,7 +1079,8 @@ app.Views.Front.RegistrantForm = Backbone.View.extend({ // bind events to the view events: { 'blur input.add_reg_email': 'verifyEmail', - 'click .show-hide-address': 'toggleClass', + // 'click .show-hide-address': 'toggleClass', + 'click .lookup-attendee': 'lookupEmail' }, // setup the view @@ -1095,16 +1100,26 @@ app.Views.Front.RegistrantForm = Backbone.View.extend({ this.$('.ereg-addr').toggle(); }, - // verify the email address verifyEmail: function(){ var email = this.$('.add_reg_email').val().trim(); + var isValidEmail = app.isValidEmail( email ); + if ( !isValidEmail ) { + alert( 'Email must be valid' ); + this.$('.add_reg_email').val(''); + return; + } + }, + + // verify the email address + lookupEmail: function(){ + var email = this.$('.lookup_email').val().trim(); if ( email == '' ) { return; } var isValidEmail = app.isValidEmail( email ); if ( !isValidEmail ) { alert( 'Email must be valid' ); - this.$('.add_reg_email').val(''); + this.$('.lookup_email').val(''); return; } else { // Check to see if this is a valid email. @@ -1119,6 +1134,7 @@ app.Views.Front.RegistrantForm = Backbone.View.extend({ if ( account.id ) { // This account already exists. // They should not be able to edit the record. + this.$('.add_reg_email').val(account.email); this.$('.add_reg_fname').val(account.fname); this.$('.add_reg_lname').val(account.lname); this.$('.add_reg_addr1').val(account.addr1); @@ -1127,12 +1143,12 @@ app.Views.Front.RegistrantForm = Backbone.View.extend({ this.$('.add_reg_state').val(account.state); this.$('.add_reg_zip').val(account.zip); this.$('.add_reg_country').val(account.country); - - // lock the form - // this.lockForm(); + // alert( 'Account Found' ); + this.$('.account-lookup').hide(); } else { - // They should be able to edit the form - this.unLockForm(); + // Notify them nothing found + alert( 'Could not find account' ); + this.$('.add_reg_email').val(email); } }) .fail(function(msg){ diff --git a/js/views/front/regTime.js b/js/views/front/regTime.js index 1177352..2ff5167 100644 --- a/js/views/front/regTime.js +++ b/js/views/front/regTime.js @@ -68,6 +68,7 @@ app.Views.Front.RegTime = Backbone.View.extend({ // insert new registrant insertNew: function(){ + this.$('#loading-' + this.model.get('id') ).show(); var findByEmail = []; var fname = this.$('.add_reg_fname').val().trim(); var lname = this.$('.add_reg_lname').val().trim(); @@ -99,6 +100,10 @@ app.Views.Front.RegTime = Backbone.View.extend({ } } else { findByEmail = this.model.registrants.where({email: email, fname: fname, lname: lname}); + console.log( findByEmail.length ); + if ( findByEmail.length > 0 ) { + this.$('#loading-' + this.model.get('id') ).hide(); + } } var regRequest = cart.get( 'request' ); var parent = this.model.get('parent'); @@ -111,7 +116,6 @@ app.Views.Front.RegTime = Backbone.View.extend({ // to the collection. var customFieldData = this.$( 'form.attendee-cf-form-new' ).serialize(); - this.$('#loading-' + this.model.get('id') ).show(); var newRegistrant = this.model.registrants.create({ option: 'add', reg_request: regRequest.id, @@ -142,8 +146,8 @@ app.Views.Front.RegTime = Backbone.View.extend({ }, errorCallback: function( collection, response ){ - // console.log( 'errorCallback Called' ); - // console.log( response ); + console.log( 'errorCallback Called' ); + console.log( response ); }, // cancel add new registrant diff --git a/js/views/front/registrantForm.js b/js/views/front/registrantForm.js index 85c9fb7..d1f8ee2 100644 --- a/js/views/front/registrantForm.js +++ b/js/views/front/registrantForm.js @@ -14,7 +14,8 @@ app.Views.Front.RegistrantForm = Backbone.View.extend({ // bind events to the view events: { 'blur input.add_reg_email': 'verifyEmail', - 'click .show-hide-address': 'toggleClass', + // 'click .show-hide-address': 'toggleClass', + 'click .lookup-attendee': 'lookupEmail' }, // setup the view @@ -34,16 +35,26 @@ app.Views.Front.RegistrantForm = Backbone.View.extend({ this.$('.ereg-addr').toggle(); }, - // verify the email address verifyEmail: function(){ var email = this.$('.add_reg_email').val().trim(); + var isValidEmail = app.isValidEmail( email ); + if ( !isValidEmail ) { + alert( 'Email must be valid' ); + this.$('.add_reg_email').val(''); + return; + } + }, + + // verify the email address + lookupEmail: function(){ + var email = this.$('.lookup_email').val().trim(); if ( email == '' ) { return; } var isValidEmail = app.isValidEmail( email ); if ( !isValidEmail ) { alert( 'Email must be valid' ); - this.$('.add_reg_email').val(''); + this.$('.lookup_email').val(''); return; } else { // Check to see if this is a valid email. @@ -58,6 +69,7 @@ app.Views.Front.RegistrantForm = Backbone.View.extend({ if ( account.id ) { // This account already exists. // They should not be able to edit the record. + this.$('.add_reg_email').val(account.email); this.$('.add_reg_fname').val(account.fname); this.$('.add_reg_lname').val(account.lname); this.$('.add_reg_addr1').val(account.addr1); @@ -66,12 +78,12 @@ app.Views.Front.RegistrantForm = Backbone.View.extend({ this.$('.add_reg_state').val(account.state); this.$('.add_reg_zip').val(account.zip); this.$('.add_reg_country').val(account.country); - - // lock the form - // this.lockForm(); + // alert( 'Account Found' ); + this.$('.account-lookup').hide(); } else { - // They should be able to edit the form - this.unLockForm(); + // Notify them nothing found + alert( 'Could not find account' ); + this.$('.add_reg_email').val(email); } }) .fail(function(msg){ diff --git a/views/front/registrations/registration.html b/views/front/registrations/registration.html index ab92871..96da2a7 100644 --- a/views/front/registrations/registration.html +++ b/views/front/registrations/registration.html @@ -218,6 +218,17 @@ {/if}{literal}
+ +

{/literal}{$terms.reg_term_attendee_cap} Info{literal}

-- 2.17.1