From 7cdfc180afe6c3c2e6eb61e81ea77f1f0357b2b6 Mon Sep 17 00:00:00 2001 From: jlamanskygitt Date: Thu, 22 Jan 2026 13:54:05 -0500 Subject: [PATCH 1/4] Removed unused Health Metrics js --- dt-groups/groups.js | 140 -------------------------------------------- 1 file changed, 140 deletions(-) diff --git a/dt-groups/groups.js b/dt-groups/groups.js index 33fb9e340f..b9dabb9893 100644 --- a/dt-groups/groups.js +++ b/dt-groups/groups.js @@ -3,146 +3,6 @@ jQuery(document).ready(function ($) { let post_id = window.detailsSettings.post_id; let post_type = window.detailsSettings.post_type; let post = window.detailsSettings.post_fields; - let field_settings = window.detailsSettings.post_settings.fields; - - /* Health Metrics */ - let health_keys = Object.keys(field_settings.health_metrics.default); - - function fillOutChurchHealthMetrics() { - let practiced_items = - window.detailsSettings.post_fields.health_metrics || []; - - /* Make church commitment circle green */ - if (practiced_items.indexOf('church_commitment') !== -1) { - $('#health-items-container').addClass('committed'); - $('#is-church-switch').prop('checked', true); - } - - /* Color church circle items that are being practiced */ - let items = $('div[id^="icon_"]'); - - items.each(function (k, v) { - if ( - practiced_items.indexOf(v.id.replace('icon_', ''), practiced_items) !== - -1 - ) { - $(this).children('img').attr('class', 'practiced-item'); - } - }); - - /* Color group progress buttons */ - let icons = $('.group-progress-button'); - icons.each(function (k, v) { - if (practiced_items.indexOf(v.id, practiced_items) !== -1) { - $(this).addClass('practiced-button'); - } - }); - } - - fillOutChurchHealthMetrics(); - distributeItems(); - - $('.health-item').on('click', function () { - let fieldId = $(this).attr('id').replace('icon_', ''); - let already_set = window.lodash - .get(post, 'health_metrics', []) - .includes(fieldId); - let update = { values: [{ value: fieldId }] }; - if (already_set) { - update.values[0].delete = true; - } - window.API.update_post(post_type, post_id, { health_metrics: update }) - .then((groupData) => { - post = groupData; - /* Update icon */ - if ($(this).attr('id') === 'church_commitment') { - $('#health-items-container').toggleClass('committed'); - $(this).toggleClass('practiced-button'); - return true; - } - /* Toggle church health circle item color */ - $(this).children('img').toggleClass('practiced-item'); - $(this).children('i').toggleClass('practiced-item'); - }) - .catch((err) => { - console.log(err); - }); - }); - - $('#is-church-switch').on('click', function () { - let fieldId = 'church_commitment'; - let already_set = window.lodash - .get(post, 'health_metrics', []) - .includes(fieldId); - let update = { values: [{ value: fieldId }] }; - if (already_set) { - update.values[0].delete = true; - } - window.API.update_post(post_type, post_id, { health_metrics: update }) - .then((groupData) => { - post = groupData; - /* Update commitment circle */ - $('#health-items-container').toggleClass('committed'); - }) - .catch((err) => { - console.log(err); - }); - }); - - /* Dynamically distribute items in Church Health Circle - according to amount of health metric elements */ - function distributeItems() { - let radius = 75; - let items = $('.health-item'), - container = $('#health-items-container'), - item_count = items.length, - fade_delay = 45, - width = container.width(), - height = container.height() + 66, - angle = 0, - step = (2 * Math.PI) / items.length, - y_offset = -35; - - if (item_count >= 5 && item_count < 7) { - radius = 90; - } - - if ((item_count >= 7) & (item_count < 11)) { - radius = 100; - } - - if (item_count >= 11) { - radius = 110; - } - - if (item_count == 3) { - angle = 22.5; - } - - items.each(function () { - let X = Math.round( - width / 2 + radius * Math.cos(angle) - $(this).width() / 2, - ); - let y = - Math.round( - height / 2 + radius * Math.sin(angle) - $(this).height() / 2, - ) + y_offset; - - if (item_count == 1) { - X = 112.5; - y = 68; - } - - $(this).css({ - left: X + 'px', - top: y + 'px', - }); - $(this).delay(fade_delay).fadeIn(1000, 'linear'); - angle += step; - fade_delay += 45; - }); - } - /* End Health Metrics*/ let { template_dir } = window.wpApiShare; From 6303cfd6ee7e1481c37bdd107f92026d5825f274 Mon Sep 17 00:00:00 2001 From: jlamanskygitt Date: Mon, 23 Feb 2026 10:41:44 -0500 Subject: [PATCH 2/4] Updated link to new multi-text-groups --- dt-core/global-functions.php | 141 +--------------------------- dt-core/utilities/dt-components.php | 10 ++ 2 files changed, 13 insertions(+), 138 deletions(-) diff --git a/dt-core/global-functions.php b/dt-core/global-functions.php index 18b05e79cb..ad74c374f0 100755 --- a/dt-core/global-functions.php +++ b/dt-core/global-functions.php @@ -654,6 +654,9 @@ function render_field_for_display( $field_key, $fields, $post, $show_extra_contr case 'user_select': DT_Components::render_user_select( $field_key, $fields, $post, $params ); break; + case 'link': + DT_Components::render_link( $field_key, $fields, $post, $params ); + break; default: $is_legacy = true; break; @@ -663,60 +666,6 @@ function render_field_for_display( $field_key, $fields, $post, $show_extra_contr $is_empty_post = !is_array( $post ) || count( array_keys( $post ) ) <= 1; // if this is a new post, it only has a post_type key $hide_label = isset( $params['hide_label'] ) && $params['hide_label'] === true; ?> - -
> - - - - "> - - - - - - - - - -
- " min="" max="" onwheel="return false;" /> - - - -
@@ -834,34 +727,6 @@ class="text-input" value="" - -
- - - > -
- -
-
- - + + value=""> + + + Date: Wed, 4 Mar 2026 15:40:38 -0500 Subject: [PATCH 3/4] Added passing groups to link component --- dt-core/utilities/dt-components.php | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/dt-core/utilities/dt-components.php b/dt-core/utilities/dt-components.php index 8c6ad3e91d..79ff954c01 100644 --- a/dt-core/utilities/dt-components.php +++ b/dt-core/utilities/dt-components.php @@ -324,8 +324,16 @@ public static function render_user_select( $field_key, $fields, $post, $params = public static function render_link( $field_key, $fields, $post, $params = [] ) { $shared_attributes = self::shared_attributes( $field_key, $fields, $post, $params ); + $default_options = $fields[$field_key]['default']; + $options_array = array_map(function ( $key, $value ) { + return [ + 'id' => (string) $key, + 'label' => $value['label'] ?? $key + ]; + }, array_keys( $default_options ), $default_options); ?> + groups='' value=""> From ade427acdba25e7e4bff8a20cde4a477a41a351b Mon Sep 17 00:00:00 2001 From: jlamanskygitt Date: Mon, 9 Mar 2026 12:43:43 -0400 Subject: [PATCH 4/4] Removed unused link-input code --- dt-assets/js/details.js | 47 -------- dt-assets/js/merge-post-details.js | 174 ----------------------------- dt-assets/js/new-bulk-record.js | 13 --- dt-assets/js/new-record.js | 13 --- 4 files changed, 247 deletions(-) diff --git a/dt-assets/js/details.js b/dt-assets/js/details.js index 748721cc74..6ca1e3cefa 100644 --- a/dt-assets/js/details.js +++ b/dt-assets/js/details.js @@ -79,53 +79,6 @@ jQuery(document).ready(function ($) { }; } - /* field type: link */ - $('input.link-input').change(function () { - const link_input = $(this); - const fieldKey = $(link_input).data('field-key'); - const type = $(link_input).data('type'); - const meta_id = $(link_input).data('meta-id'); - const value = $(link_input).val(); - - if ($(link_input).prop('required') && value === '') { - return; - } - - const fieldValues = { - values: [ - { - value, - type, - meta_id, - }, - ], - }; - $(`#${fieldKey}-spinner`).addClass('active'); - rest_api - .update_post(post_type, post_id, { [fieldKey]: fieldValues }) - .then((newPost) => { - $(`#${fieldKey}-spinner`).removeClass('active'); - post = newPost; - - // Make sure a key exists for the new link field. - if (post && post[fieldKey] && post[fieldKey].length > 0) { - let updated_values = post[fieldKey].filter((option) => { - return option['type'] === type && option['value'] === value; - }); - - // This ensures any immediate updates, are assigned to correct link input and not to a new/duplicated input field. - if ( - updated_values && - updated_values[0] && - updated_values[0]['meta_id'] - ) { - $(link_input).data('meta-id', updated_values[0]['meta_id']); - } - } - }) - .catch(window.handleAjaxError); - }); - /* field type: datetime */ $('.dt_date_time_group').each(function setTimePickers() { const timestamp = this.dataset.timestamp; diff --git a/dt-assets/js/merge-post-details.js b/dt-assets/js/merge-post-details.js index c53113519b..813c286c32 100644 --- a/dt-assets/js/merge-post-details.js +++ b/dt-assets/js/merge-post-details.js @@ -225,11 +225,6 @@ jQuery(function ($) { return typeahead && !window.lodash.isEmpty(typeahead.items); } - case 'link': - return !window.lodash.isEmpty( - $(td_field_input).find('input.link-input').not('[value=""]'), - ); - case 'communication_channel': case 'location_meta': return !window.lodash.isEmpty( @@ -296,48 +291,6 @@ jQuery(function ($) { .prop('disabled', read_only); break; - case 'link': { - // Disable/Display field accordingly, based on read-only flag - $(td).find('input.link-input').prop('disabled', read_only); - $(td).find('button.link-delete-button').prop('disabled', read_only); - - // Ensure add link functionality is suppressed. - $(td).find('div.add-link-dropdown').remove(); - - if (!read_only) { - $(td) - .find('input.link-input') - .each(function (idx, input) { - if (window.lodash.isEmpty($(input).val())) { - $(input).parent().hide(); - } - }); - - /** - * Remove - */ - - $(document).on('click', '.link-delete-button', (evt) => { - const delete_but = $(evt.currentTarget); - - // Keep a record of deleted meta_ids. - let meta_id = $(delete_but).data('meta-id'); - let deleted_items = $(field_meta).val() - ? JSON.parse($(field_meta).val()) - : []; - if (!window.lodash.includes(deleted_items, meta_id)) { - deleted_items.push(meta_id); - $(field_meta).val(JSON.stringify(deleted_items)); - } - - // Finally, remove from parent. - $(delete_but).parent().parent().remove(); - }); - } - - break; - } - case 'user_select': { let user_select_typeahead_field_input = '.js-typeahead-' + field_id; @@ -501,78 +454,6 @@ jQuery(function ($) { break; } - case 'link': { - // Determine selector source field link inputs to be processed. - let source_field_link_inputs = []; - let tr = $(selector).parent().parent(); - $(tr) - .find('.td-field-input input.link-input') - .each(function (idx, input) { - if ($(input).val()) { - source_field_link_inputs.push(input); - } - }); - - // Delete/Add updated post record, based on identified source field inputs. - let main_updated_fields_div = $('#main_updated_fields_div'); - let link_field_meta_input = $(main_updated_fields_div) - .find(`.link-list-${update_field_id}`) - .parent() - .parent() - .find('#field_meta'); - let deleted_items = $(link_field_meta_input).val() - ? JSON.parse($(link_field_meta_input).val()) - : []; - - // Locate by link field values. - $.each(source_field_link_inputs, function (idx, input) { - let link_list_section_div = $(main_updated_fields_div).find( - `.link-list-${update_field_id} .link-section--${$(input).data('type')}`, - ); - let matched_input = $(link_list_section_div).find( - `.input-group input[value="${$(input).val()}"].link-input`, - ); - - // Handle accordingly, based on incoming selected state. - if (is_selected) { - // Add new updated link fields. - if (matched_input.length === 0) { - $(link_list_section_div).append(` -
- -
- -
-
`); - - // Remove any previously deleted entries. - window.lodash.remove(deleted_items, function (meta_id) { - return meta_id === $(input).data('meta-id'); - }); - $(link_field_meta_input).val(JSON.stringify(deleted_items)); - } - } else { - // Remove new updated link fields. - if (matched_input.length > 0) { - $(matched_input).parent().remove(); - - // Keep a record of deleted meta_ids. - if ( - !window.lodash.includes( - deleted_items, - $(matched_input).data('meta-id'), - ) - ) { - deleted_items.push($(matched_input).data('meta-id')); - $(link_field_meta_input).val(JSON.stringify(deleted_items)); - } - } - } - }); - - break; - } - case 'communication_channel': { // Determine values to be updated const sourceValue = sourceField.val() || []; @@ -1207,61 +1088,6 @@ jQuery(function ($) { break; } - case 'link': { - // Determine values to be processed - let link_entries = []; - let link_deletions = field_meta.val() - ? JSON.parse(field_meta.val()) - : []; - - // Package values and any deletions - $(td) - .find('.input-group input.link-input') - .each(function (idx, input) { - let link_type = $(input).data('type'); - let link_meta_id = $(input).data('meta-id'); - let link_val = $(input).val(); - - let has_value = is_link_field_value_already_in_primary( - post_field_id, - link_type, - link_meta_id, - link_val, - true, - ); - let matched_meta_id = is_link_field_value_already_in_primary( - post_field_id, - link_type, - link_meta_id, - link_val, - false, - ); - - if (link_val && !has_value) { - link_entries.push({ - value: link_val, - type: link_type, - meta_id: matched_meta_id ? link_meta_id : '', - }); - } - }); - - $.each(link_deletions, function (idx, deleted_meta_id) { - link_entries.push({ - meta_id: deleted_meta_id, - delete: true, - }); - }); - - // If present, capture entries - if (link_entries) { - values[post_field_id] = { - values: link_entries, - }; - } - break; - } - case 'user_select': { let user_select_typeahead = window.Typeahead['.js-typeahead-' + field_id]; diff --git a/dt-assets/js/new-bulk-record.js b/dt-assets/js/new-bulk-record.js index 473e3b5ac6..179c4c5fc5 100644 --- a/dt-assets/js/new-bulk-record.js +++ b/dt-assets/js/new-bulk-record.js @@ -117,19 +117,6 @@ jQuery(function ($) { new_post[$(entry).attr('id')] = $(entry).val(); } }); - $('.link-input').each((index, entry) => { - let fieldKey = $(entry).data('field-key'); - let type = $(entry).data('type'); - if ($(entry).val()) { - if (!Object.prototype.hasOwnProperty.call(new_post, fieldKey)) { - new_post[fieldKey] = { values: [] }; - } - new_post[fieldKey].values.push({ - value: $(entry).val(), - type: type, - }); - } - }); $('.dt_textarea').each((index, entry) => { if ($(entry).val()) { new_post[$(entry).attr('id')] = $(entry).val(); diff --git a/dt-assets/js/new-record.js b/dt-assets/js/new-record.js index 15adf76d2d..6210e4346a 100644 --- a/dt-assets/js/new-record.js +++ b/dt-assets/js/new-record.js @@ -232,19 +232,6 @@ jQuery(function ($) { new_post[$(entry).attr('id')] = $(entry).val(); } }); - $('.link-input').each((index, entry) => { - let fieldKey = $(entry).data('field-key'); - let type = $(entry).data('type'); - if ($(entry).val()) { - if (!Object.prototype.hasOwnProperty.call(new_post, fieldKey)) { - new_post[fieldKey] = { values: [] }; - } - new_post[fieldKey].values.push({ - value: $(entry).val(), - type: type, - }); - } - }); // location_meta if (typeof window.selected_location_grid_meta !== 'undefined') {