From c97686680ca4e8e214d9123e748de528d87679c1 Mon Sep 17 00:00:00 2001 From: Ashima-Arora <117061227+Ashima-Arora@users.noreply.github.com> Date: Thu, 18 Apr 2024 17:07:36 +0530 Subject: [PATCH 1/8] initial code changes for dt-componenets integration in new contact form --- dt-assets/js/new-record.js | 42 ++++++++++++-------- dt-core/global-functions.php | 77 +++++------------------------------- template-new-post.php | 4 +- 3 files changed, 36 insertions(+), 87 deletions(-) diff --git a/dt-assets/js/new-record.js b/dt-assets/js/new-record.js index df6b5956ea..401d2f5333 100644 --- a/dt-assets/js/new-record.js +++ b/dt-assets/js/new-record.js @@ -91,21 +91,23 @@ jQuery(function($) { }) /* breadcrumb: new-field-type Add the new link type data to the new_post array */ - $(".js-create-post").on("submit", function() { + $(".js-create-post").on("submit", function(e) { $(".js-create-post-button") .attr("disabled", true) .addClass("loading"); - new_post.title = $(".js-create-post input[name=title]").val() - $('.select-field').each((index, entry)=>{ - if ( $(entry).val() ){ - new_post[$(entry).attr('id')] = $(entry).val() - } + e.preventDefault(); + new_post.title = $(".js-create-post [name= name]").val() + + $('dt-single-select').each((entry) => { + new_post[$(entry).attr('id')] = $(entry).attr('value') }) - $('.text-input').each((index, entry)=>{ + + $('dt-text').each((entry)=>{ if ( $(entry).val() ){ new_post[$(entry).attr('id')] = $(entry).val() } }) + $('.link-input').each((index, entry) => { let fieldKey = $(entry).data('field-key') let type = $(entry).data('type') @@ -119,23 +121,28 @@ jQuery(function($) { } ) } }) + $('.dt_textarea').each((index, entry)=>{ if ( $(entry).val() ){ new_post[$(entry).attr('id')] = $(entry).val() } }); - $('.dt-communication-channel').each((index, entry)=>{ - let val = $(entry).val() - if ( val.length > 0 ){ - let channel = $(entry).data('field') - if ( !new_post[channel]){ - new_post[channel] =[] - } - new_post[channel].push({ - value: $(entry).val() - }) + + $('dt-comm-channel').each((index, entry)=>{ + let channel = $(entry).attr('id'); + console.log('id', channel) + const commChannelComponentValue = JSON.parse($(entry).attr('value')) + if (typeof new_post[channel] === 'undefined') { + new_post[channel] = []; } + console.log('value---',typeof(commChannelComponentValue)) + commChannelComponentValue.map(currentItem => { + console.log('currentItem', currentItem.value) + new_post[channel].push({value: currentItem.value}); + }) + console.log('new_post', new_post) }) + $('.selected-select-button').each((index, entry)=>{ let optionKey = $(entry).attr('id') let fieldKey = $(entry).data("field-key") @@ -1103,6 +1110,7 @@ jQuery(function($) { }); $(record).find('.multi_select .typeahead__query input').each((index, entry) => { + console.log('here-----multi-select') if ($(entry).is(':visible')) { fields.push($(entry).data('field')); } diff --git a/dt-core/global-functions.php b/dt-core/global-functions.php index 972951304c..58bb4a85a4 100755 --- a/dt-core/global-functions.php +++ b/dt-core/global-functions.php @@ -638,73 +638,19 @@ function render_field_for_display( $field_key, $fields, $post, $show_extra_contr ' . esc_html( $disabled ) . ' ' . ( $is_private ? 'private privateLabel=' . esc_attr( _x( "Private Field: Only I can see it\'s content", 'disciple_tools' ) ) : null ) . ' '; - $supported_web_components = [ 'text', 'key_select', 'date', 'tags', 'connection', 'multi_select' ]; + $supported_web_components = [ 'text', 'key_select', 'date', 'tags', 'connection', 'multi_select']; ?> - -
-
-
+
+
+
-
-