From: Steve Sutton Date: Tue, 19 Dec 2017 19:01:23 +0000 (-0500) Subject: Fix issue with calls to RegRequestRegistrant in wrong view files. X-Git-Tag: v1.0.0^2~161 X-Git-Url: http://cvs2.gaslightmedia.com/gitweb/?a=commitdiff_plain;h=e53bfd172b93205f59c26ff8941c4a72ee73144d;p=WP-Plugins%2Fglm-member-db-registrations.git Fix issue with calls to RegRequestRegistrant in wrong view files. RegRequestRegistrant should only be called in the regTime or the regRequestRegistrant view files. --- diff --git a/js/frontRegApp.js b/js/frontRegApp.js index 8401f8c..908e606 100644 --- a/js/frontRegApp.js +++ b/js/frontRegApp.js @@ -516,25 +516,19 @@ app.Views.Front.RegClass = Backbone.View.extend({ // Add times into regTimes collection var classTimes = this.model.get('times'); - //var timeArs = []; 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}); - //timeArs.push( newTime ); this.model.regTimes.create( newTime ); } - //this.model.regTimes.reset( timeArs ); - - // console.log( classTimes ); - return this; }, // used for binding events to the view events: { - 'click .addRegistrant': 'newEntry', - 'click .fc-event-container': 'updateTimeSelection', - 'click .show-hide-address': 'toggleClass', + // 'click .addRegistrant': 'newEntry', + // 'click .fc-event-container': 'updateTimeSelection', + // 'click .show-hide-address': 'toggleClass', }, // togle the ereg-addr class for the registrant form @@ -660,59 +654,12 @@ app.Views.Front.RegClass = Backbone.View.extend({ }); }, - // used to add login account to the class - addAccount: function(){ - // Check to make sure the loginAccount is not empty - if ( loginAccount !== '' ) { - this.$('.glm-add-account').hide(); - var regRequest = cart.get( 'request' ); - var accountEmail = loginAccount.get( 'email' ); - var accountId = loginAccount.get( 'id' ); - if ( accountId && accountEmail ) { - // If the model is already there then don't add - var findById = this.model.registrants.where({account: accountId}); - if ( findById.length === 0 ) { - // create the regRequestRegistrant for the account - registrant = new app.Models.Front.RegRequestRegistrant({ - account: accountId, - reg_request: regRequest.id, - reg_event: this.model.get( 'reg_event' ), - reg_class: this.model.get( 'id' ), - reg_rate: this.model.get('reg_rate_id'), - email: accountEmail, - fname: loginAccount.get('fname'), - lname: loginAccount.get('lname') - }); - // this.newRegAccount = new app.Models.Front.RegRequestRegistrant(); - this.newRegAccountView = new app.Views.Front.RegistrantForm({model: registrant}); - this.$el.append( this.newRegAccountView.render().el ); - if ( app.timeSpecific ) { - // this.setCalendar(); - } - } - } - } - }, - // cancel add new cancelAddNew: function(){ this.$('.glm-add-new-account').show(); this.newRegAccountView.remove(); }, - // add new account - addNewAccount: function(){ - this.$('.glm-add-new-account').hide(); - // Create the new Registrant View - if ( app.timeSpecific ) { - this.newRegAccount = new app.Models.Front.RegRequestRegistrant({ reg_time: this.model.get( 'selectedTime' ) }); - } else { - this.newRegAccount = new app.Models.Front.RegRequestRegistrant(); - } - this.newRegAccountView = new app.Views.Front.RegistrantForm({model: this.newRegAccount}); - this.$el.append( this.newRegAccountView.render().el ); - }, - // For the new entry check the email from the server and see // if there's already an account setup. newEntry: function(){ @@ -806,6 +753,16 @@ app.Views.Front.RegRequestRegistrant = Backbone.View.extend({ // used to setup initial class initialize: function(){ this.listenTo( this.model, 'change', this.render ); + + // Call the custom fields ajax + // if ( this.model.id ) { + // this.customFieldFormData = app.setCustomFieldsForm( + // this.model.get('reg_event'), + // this.model.id, + // 'return' + // ); + // } + return this; }, @@ -815,6 +772,7 @@ app.Views.Front.RegRequestRegistrant = Backbone.View.extend({ 'click .glm-registrant-edit': 'editRegistrant', 'click .update-registrant-cancel': 'cancelEdit', 'click .update-registrant': 'update', + 'click .show-hide-address': 'toggleClass', }, // update the model @@ -872,6 +830,10 @@ app.Views.Front.RegRequestRegistrant = Backbone.View.extend({ app.regEventLock = false; }, + toggleClass: function(){ + this.$('.ereg-addr').toggle(); + }, + // cancel the edit of model cancelEdit: function(){ this.$('.reg-edit-form').hide(); @@ -900,6 +862,9 @@ app.Views.Front.RegRequestRegistrant = Backbone.View.extend({ this.$el.html( this.template( this.model.toJSON() ) ); this.$emailInput = this.$('.editEmail'); this.$('.reg-edit-form').hide(); + // if ( this.customFieldFormData ) { + // this.$('.attendee-cf-' + this.model.get('id')).html( this.customFieldFormData ); + // } return this; }, @@ -1092,7 +1057,8 @@ app.Views.Front.RegistrantForm = Backbone.View.extend({ // bind events to the view events: { - 'blur input.add_reg_email': 'verifyEmail' + 'blur input.add_reg_email': 'verifyEmail', + 'click .show-hide-address': 'toggleClass', }, // setup the view @@ -1108,6 +1074,10 @@ app.Views.Front.RegistrantForm = Backbone.View.extend({ return this; }, + toggleClass: function(){ + this.$('.ereg-addr').toggle(); + }, + // verify the email address verifyEmail: function(){ var email = this.$('.add_reg_email').val().trim(); diff --git a/js/views/front/regClass.js b/js/views/front/regClass.js index e85add5..e49eb59 100644 --- a/js/views/front/regClass.js +++ b/js/views/front/regClass.js @@ -15,25 +15,19 @@ app.Views.Front.RegClass = Backbone.View.extend({ // Add times into regTimes collection var classTimes = this.model.get('times'); - //var timeArs = []; 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}); - //timeArs.push( newTime ); this.model.regTimes.create( newTime ); } - //this.model.regTimes.reset( timeArs ); - - // console.log( classTimes ); - return this; }, // used for binding events to the view events: { - 'click .addRegistrant': 'newEntry', - 'click .fc-event-container': 'updateTimeSelection', - 'click .show-hide-address': 'toggleClass', + // 'click .addRegistrant': 'newEntry', + // 'click .fc-event-container': 'updateTimeSelection', + // 'click .show-hide-address': 'toggleClass', }, // togle the ereg-addr class for the registrant form @@ -159,59 +153,12 @@ app.Views.Front.RegClass = Backbone.View.extend({ }); }, - // used to add login account to the class - addAccount: function(){ - // Check to make sure the loginAccount is not empty - if ( loginAccount !== '' ) { - this.$('.glm-add-account').hide(); - var regRequest = cart.get( 'request' ); - var accountEmail = loginAccount.get( 'email' ); - var accountId = loginAccount.get( 'id' ); - if ( accountId && accountEmail ) { - // If the model is already there then don't add - var findById = this.model.registrants.where({account: accountId}); - if ( findById.length === 0 ) { - // create the regRequestRegistrant for the account - registrant = new app.Models.Front.RegRequestRegistrant({ - account: accountId, - reg_request: regRequest.id, - reg_event: this.model.get( 'reg_event' ), - reg_class: this.model.get( 'id' ), - reg_rate: this.model.get('reg_rate_id'), - email: accountEmail, - fname: loginAccount.get('fname'), - lname: loginAccount.get('lname') - }); - // this.newRegAccount = new app.Models.Front.RegRequestRegistrant(); - this.newRegAccountView = new app.Views.Front.RegistrantForm({model: registrant}); - this.$el.append( this.newRegAccountView.render().el ); - if ( app.timeSpecific ) { - // this.setCalendar(); - } - } - } - } - }, - // cancel add new cancelAddNew: function(){ this.$('.glm-add-new-account').show(); this.newRegAccountView.remove(); }, - // add new account - addNewAccount: function(){ - this.$('.glm-add-new-account').hide(); - // Create the new Registrant View - if ( app.timeSpecific ) { - this.newRegAccount = new app.Models.Front.RegRequestRegistrant({ reg_time: this.model.get( 'selectedTime' ) }); - } else { - this.newRegAccount = new app.Models.Front.RegRequestRegistrant(); - } - this.newRegAccountView = new app.Views.Front.RegistrantForm({model: this.newRegAccount}); - this.$el.append( this.newRegAccountView.render().el ); - }, - // For the new entry check the email from the server and see // if there's already an account setup. newEntry: function(){ diff --git a/js/views/front/regRequestRegistrant.js b/js/views/front/regRequestRegistrant.js index 0fc01ec..9ae077c 100644 --- a/js/views/front/regRequestRegistrant.js +++ b/js/views/front/regRequestRegistrant.js @@ -8,6 +8,16 @@ app.Views.Front.RegRequestRegistrant = Backbone.View.extend({ // used to setup initial class initialize: function(){ this.listenTo( this.model, 'change', this.render ); + + // Call the custom fields ajax + // if ( this.model.id ) { + // this.customFieldFormData = app.setCustomFieldsForm( + // this.model.get('reg_event'), + // this.model.id, + // 'return' + // ); + // } + return this; }, @@ -17,6 +27,7 @@ app.Views.Front.RegRequestRegistrant = Backbone.View.extend({ 'click .glm-registrant-edit': 'editRegistrant', 'click .update-registrant-cancel': 'cancelEdit', 'click .update-registrant': 'update', + 'click .show-hide-address': 'toggleClass', }, // update the model @@ -74,6 +85,10 @@ app.Views.Front.RegRequestRegistrant = Backbone.View.extend({ app.regEventLock = false; }, + toggleClass: function(){ + this.$('.ereg-addr').toggle(); + }, + // cancel the edit of model cancelEdit: function(){ this.$('.reg-edit-form').hide(); @@ -102,6 +117,9 @@ app.Views.Front.RegRequestRegistrant = Backbone.View.extend({ this.$el.html( this.template( this.model.toJSON() ) ); this.$emailInput = this.$('.editEmail'); this.$('.reg-edit-form').hide(); + // if ( this.customFieldFormData ) { + // this.$('.attendee-cf-' + this.model.get('id')).html( this.customFieldFormData ); + // } return this; }, diff --git a/js/views/front/registrantForm.js b/js/views/front/registrantForm.js index b0a5002..2b2e115 100644 --- a/js/views/front/registrantForm.js +++ b/js/views/front/registrantForm.js @@ -13,7 +13,8 @@ app.Views.Front.RegistrantForm = Backbone.View.extend({ // bind events to the view events: { - 'blur input.add_reg_email': 'verifyEmail' + 'blur input.add_reg_email': 'verifyEmail', + 'click .show-hide-address': 'toggleClass', }, // setup the view @@ -29,6 +30,10 @@ app.Views.Front.RegistrantForm = Backbone.View.extend({ return this; }, + toggleClass: function(){ + this.$('.ereg-addr').toggle(); + }, + // verify the email address verifyEmail: function(){ var email = this.$('.add_reg_email').val().trim(); diff --git a/views/front/registrations/registration.html b/views/front/registrations/registration.html index f5b28c8..ebdba5c 100644 --- a/views/front/registrations/registration.html +++ b/views/front/registrations/registration.html @@ -373,7 +373,12 @@ var app = { dataType: 'text' }) .done( function( formHtml ) { - $(target).html( formHtml ); + if ( target === 'return' ) { + console.log( formHtml ); + return formHtml; + } else { + $(target).html( formHtml ); + } }); } else { return false;