From f53e159fa5a7645f6ca82666dbdb1c35913bb8c9 Mon Sep 17 00:00:00 2001 From: Steve Sutton Date: Wed, 3 Jan 2018 16:05:06 -0500 Subject: [PATCH] Front end deal with state and country selects Had to fix some things with the state and country selects. --- js/frontRegApp.js | 40 +++++++-------------- js/views/front/regRequestRegistrant.js | 4 +-- js/views/front/regTime.js | 36 ++++++------------- views/front/registrations/registration.html | 1 + 4 files changed, 25 insertions(+), 56 deletions(-) diff --git a/js/frontRegApp.js b/js/frontRegApp.js index 2cb20e3..df631d5 100644 --- a/js/frontRegApp.js +++ b/js/frontRegApp.js @@ -782,9 +782,9 @@ app.Views.Front.RegRequestRegistrant = Backbone.View.extend({ 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 state = ( this.$('.reg_state').val() ) ? this.$('.reg_state').val().trim() : ''; var zip = this.$('.reg_zip').val().trim(); - var country = this.$('.reg_country').val().trim(); + var country = ( this.$('.reg_country').val() ) ? this.$('.reg_country').val().trim(): ''; if ( this.$('#reg-time-' + modelId).length ) { var rTime = this.$('#reg-time-' + modelId).val().trim(); } else { @@ -917,7 +917,6 @@ app.Views.Front.RegTime = Backbone.View.extend({ // render the view render: function(){ - // console.log('render called from Views.Front.RegTime'); this.model.set({ reg_count: this.model.registrants.length }); this.$el.html( this.template( this.model.toJSON() ) ); // Need to see if this has attendees and render them @@ -927,6 +926,14 @@ app.Views.Front.RegTime = Backbone.View.extend({ var accountContainer = this.$('.reg-class-accounts'); accountContainer.append(view); app.regEventLock = false; + // console.log( 'attendees_available', this.model.get('attendees_available') ); + // this.model.set({attendees_available: this.model.get('attendees_available') - this.model.registrants.length }); + // var available = this.model.get( 'attendees_available' ); + // if ( available === 0 ) { + // // hide add button + // this.$('.glm-add-new-account').hide(); + // this.$('.glm-time-full').show(); + // } return this; }, @@ -961,9 +968,9 @@ app.Views.Front.RegTime = Backbone.View.extend({ 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 state = ( this.$('.add_reg_state').val() ) ? this.$('.add_reg_state').val().trim() : ''; var zip = this.$('.add_reg_zip').val().trim(); - var country = this.$('.add_reg_country').val().trim(); + var country = ( this.$('.add_reg_country').val() ) ? this.$('.add_reg_country').val().trim(): ''; var sTime = this.model.get( 'rate_id' ); if ( this.$('#add_reg-select-time').length ) { var times = this.model.get( 'times' ); @@ -997,29 +1004,6 @@ app.Views.Front.RegTime = Backbone.View.extend({ // to the collection. var customFieldData = this.$( 'form.attendee-cf-form-new' ).serialize(); - // var newRegistrant = new app.Models.Front.RegRequestRegistrant({ - // option: 'add', - // reg_request: regRequest.id, - // reg_time: this.model.get( 'id' ), - // reg_event: this.model.get( 'reg_event' ), // Todo: use correct reg_event - // reg_class: this.model.get( 'parent' ).id, // Todo: use correct reg_class - // reg_rate: rateId, - // email: email, - // fname: fname, - // lname: lname, - // addr1: addr1, - // addr2: addr2, - // city: city, - // state: state, - // zip: zip, - // country: country, - // customFields: customFieldData - // } ); - // newRegistrant.save({error: function( model, response, options ){ - // console.log( 'Error run for adding model' ); - // console.log( response ); - // }}); - // this.model.collection.add( newRegistrant ); var newRegistrant = this.model.registrants.create({ option: 'add', reg_request: regRequest.id, diff --git a/js/views/front/regRequestRegistrant.js b/js/views/front/regRequestRegistrant.js index f3c6bfb..3c14624 100644 --- a/js/views/front/regRequestRegistrant.js +++ b/js/views/front/regRequestRegistrant.js @@ -36,9 +36,9 @@ app.Views.Front.RegRequestRegistrant = Backbone.View.extend({ 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 state = ( this.$('.reg_state').val() ) ? this.$('.reg_state').val().trim() : ''; var zip = this.$('.reg_zip').val().trim(); - var country = this.$('.reg_country').val().trim(); + var country = ( this.$('.reg_country').val() ) ? this.$('.reg_country').val().trim(): ''; if ( this.$('#reg-time-' + modelId).length ) { var rTime = this.$('#reg-time-' + modelId).val().trim(); } else { diff --git a/js/views/front/regTime.js b/js/views/front/regTime.js index 69ee51a..675441e 100644 --- a/js/views/front/regTime.js +++ b/js/views/front/regTime.js @@ -27,7 +27,6 @@ app.Views.Front.RegTime = Backbone.View.extend({ // render the view render: function(){ - // console.log('render called from Views.Front.RegTime'); this.model.set({ reg_count: this.model.registrants.length }); this.$el.html( this.template( this.model.toJSON() ) ); // Need to see if this has attendees and render them @@ -37,6 +36,14 @@ app.Views.Front.RegTime = Backbone.View.extend({ var accountContainer = this.$('.reg-class-accounts'); accountContainer.append(view); app.regEventLock = false; + // console.log( 'attendees_available', this.model.get('attendees_available') ); + // this.model.set({attendees_available: this.model.get('attendees_available') - this.model.registrants.length }); + // var available = this.model.get( 'attendees_available' ); + // if ( available === 0 ) { + // // hide add button + // this.$('.glm-add-new-account').hide(); + // this.$('.glm-time-full').show(); + // } return this; }, @@ -71,9 +78,9 @@ app.Views.Front.RegTime = Backbone.View.extend({ 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 state = ( this.$('.add_reg_state').val() ) ? this.$('.add_reg_state').val().trim() : ''; var zip = this.$('.add_reg_zip').val().trim(); - var country = this.$('.add_reg_country').val().trim(); + var country = ( this.$('.add_reg_country').val() ) ? this.$('.add_reg_country').val().trim(): ''; var sTime = this.model.get( 'rate_id' ); if ( this.$('#add_reg-select-time').length ) { var times = this.model.get( 'times' ); @@ -107,29 +114,6 @@ app.Views.Front.RegTime = Backbone.View.extend({ // to the collection. var customFieldData = this.$( 'form.attendee-cf-form-new' ).serialize(); - // var newRegistrant = new app.Models.Front.RegRequestRegistrant({ - // option: 'add', - // reg_request: regRequest.id, - // reg_time: this.model.get( 'id' ), - // reg_event: this.model.get( 'reg_event' ), // Todo: use correct reg_event - // reg_class: this.model.get( 'parent' ).id, // Todo: use correct reg_class - // reg_rate: rateId, - // email: email, - // fname: fname, - // lname: lname, - // addr1: addr1, - // addr2: addr2, - // city: city, - // state: state, - // zip: zip, - // country: country, - // customFields: customFieldData - // } ); - // newRegistrant.save({error: function( model, response, options ){ - // console.log( 'Error run for adding model' ); - // console.log( response ); - // }}); - // this.model.collection.add( newRegistrant ); var newRegistrant = this.model.registrants.create({ option: 'add', reg_request: regRequest.id, diff --git a/views/front/registrations/registration.html b/views/front/registrations/registration.html index 81b85fc..5bb9700 100644 --- a/views/front/registrations/registration.html +++ b/views/front/registrations/registration.html @@ -200,6 +200,7 @@ <%= start_datetime.datetime %> <% } %> +
List of {/literal}{$terms.reg_term_attendee_plur}{literal}
-- 2.17.1