From: Steve Sutton Date: Tue, 17 Apr 2018 10:49:16 +0000 (-0400) Subject: WIP Working on the level custom fields X-Git-Tag: v1.0.0^2~27 X-Git-Url: http://cvs2.gaslightmedia.com/gitweb/?a=commitdiff_plain;h=26dd0d2b1ac592622da0d7366a186289f285af86;p=WP-Plugins%2Fglm-member-db-registrations.git WIP Working on the level custom fields I'm getting the custom field form elements now on add. Not working is maybe saving the data and the edit level custom fields. --- diff --git a/js/frontRegApp.js b/js/frontRegApp.js index eec6a21..b6d889e 100644 --- a/js/frontRegApp.js +++ b/js/frontRegApp.js @@ -830,6 +830,7 @@ app.Views.Front.RegRequestRegistrant = Backbone.View.extend({ resetCustomFields: function() { // Call the custom fields ajax app.setCustomFieldsForm(this.model.get('reg_event'), this.model.id, '.attendee-cf-' + this.model.id); + app.setCustomFieldsForLevelForm(this.model.get('reg_event'), this.model.get('class_id'), this.model.id, '.attendee-cf-level-' + this.model.id); this.$('.reg-edit-form').hide(); }, @@ -868,6 +869,7 @@ app.Views.Front.RegRequestRegistrant = Backbone.View.extend({ // Call the custom fields ajax app.setCustomFieldsForm(this.model.get('reg_event'), this.model.id, '.attendee-cf-' + this.model.id); + app.setCustomFieldsForLevelForm(this.model.get('reg_event'), this.model.get('class_id'), this.model.id, '.attendee-cf-level-' + this.model.id); return this; }, @@ -1101,8 +1103,8 @@ app.Views.Front.RegistrantForm = Backbone.View.extend({ // render the view render: function(){ this.$el.html( this.template( this.model.toJSON() ) ); - // console.log( this.model.get('reg_event') ); - // app.setCustomFieldsForm(this.model.get('reg_event'), '', '.attendee-cf-new'); + var regClass = this.model.get('reg_class'); + app.setCustomFieldsForLevelForm( this.model.get('reg_event'), regClass.get('id'), this.model.id, '.attendee-cf-level-' + this.model.id); return this; }, diff --git a/js/views/front/regRequestRegistrant.js b/js/views/front/regRequestRegistrant.js index 3c14624..6e4e15b 100644 --- a/js/views/front/regRequestRegistrant.js +++ b/js/views/front/regRequestRegistrant.js @@ -84,6 +84,7 @@ app.Views.Front.RegRequestRegistrant = Backbone.View.extend({ resetCustomFields: function() { // Call the custom fields ajax app.setCustomFieldsForm(this.model.get('reg_event'), this.model.id, '.attendee-cf-' + this.model.id); + app.setCustomFieldsForLevelForm(this.model.get('reg_event'), this.model.get('class_id'), this.model.id, '.attendee-cf-level-' + this.model.id); this.$('.reg-edit-form').hide(); }, @@ -122,6 +123,7 @@ app.Views.Front.RegRequestRegistrant = Backbone.View.extend({ // Call the custom fields ajax app.setCustomFieldsForm(this.model.get('reg_event'), this.model.id, '.attendee-cf-' + this.model.id); + app.setCustomFieldsForLevelForm(this.model.get('reg_event'), this.model.get('class_id'), this.model.id, '.attendee-cf-level-' + this.model.id); return this; }, diff --git a/js/views/front/registrantForm.js b/js/views/front/registrantForm.js index 0681f07..15af930 100644 --- a/js/views/front/registrantForm.js +++ b/js/views/front/registrantForm.js @@ -26,8 +26,8 @@ app.Views.Front.RegistrantForm = Backbone.View.extend({ // render the view render: function(){ this.$el.html( this.template( this.model.toJSON() ) ); - // console.log( this.model.get('reg_event') ); - // app.setCustomFieldsForm(this.model.get('reg_event'), '', '.attendee-cf-new'); + var regClass = this.model.get('reg_class'); + app.setCustomFieldsForLevelForm( this.model.get('reg_event'), regClass.get('id'), this.model.id, '.attendee-cf-level-' + this.model.id); return this; }, diff --git a/views/front/registrations/registration.html b/views/front/registrations/registration.html index 3629622..db13409 100644 --- a/views/front/registrations/registration.html +++ b/views/front/registrations/registration.html @@ -323,6 +323,9 @@ glm_reg_customfields_reg_event_{$regEventId}_level_{literal}<%- reg_class.id %>{ {literal} +
+
+
{/literal}{/if}{literal} {/literal}{if $regEvent.time_specific.value} @@ -417,6 +420,7 @@ glm_reg_customfields_reg_event_{$regEventId}_level_{literal}<%- reg_class.id %>{

Additional Info Needed

{/literal}{/if}{literal}
+
{/literal}{/if}{literal} {/literal}{if $regEvent.time_specific.value} @@ -489,6 +493,38 @@ var app = { return false; } }, + setCustomFieldsForLevelForm: function( reg_event_id, reg_level_id, record_id, target ){ + console.log('record_id: ', record_id); + if ( customFieldActive ) { + var formData = { + 'action': 'glm_members_admin_ajax', + 'glm_action': 'customFieldsFront', + 'option': 'displayForm', + 'fid': 'glm_reg_customfields_reg_event_' + reg_event_id + '_level_' + reg_level_id, + 'recordId': record_id, + 'parentFormId': '', + 'formData': false + }; + jQuery.ajax({ + cache: false, + type: 'POST', + url: ajaxUrl, + data: formData, + encode: true, + dataType: 'text' + }) + .done( function( formHtml ) { + if ( target === 'return' ) { + console.log( formHtml ); + return formHtml; + } else { + jQuery(target).html( formHtml ); + } + }); + } else { + return false; + } + }, setCustomFieldsForm: function( reg_event_id, record_id, target ){ if ( customFieldActive ) { var formData = {