Skip to content

Commit 839b686

Browse files
committed
Refactor bulk edit field selection to utilize dt-multi-select component. Updated the archive template to replace the dropdown with a multi-select interface, enhancing user experience for field selection. Adjusted related JavaScript and CSS for improved functionality and styling consistency.
1 parent 677553f commit 839b686

4 files changed

Lines changed: 528 additions & 640 deletions

File tree

archive-template.php

Lines changed: 9 additions & 104 deletions
Original file line numberDiff line numberDiff line change
@@ -765,113 +765,18 @@ class="second-bar show-for-small-only center list-actions-bar"><!-- /* MOBILE V
765765
<?php esc_html_e( 'Add Fields to Update', 'disciple_tools' ); ?>
766766
</div>
767767

768-
<!-- Field Selection Dropdown -->
768+
<!-- Field Selection with dt-multi-select -->
769769
<div class="bulk-edit-field-select-wrapper" style="margin-bottom: 15px;">
770-
<label for="bulk_edit_field_select_trigger" class="field-search-label">
770+
<label for="bulk_edit_field_selector" class="field-search-label">
771771
<?php esc_html_e( 'Search and add fields:', 'disciple_tools' ); ?>
772772
</label>
773-
<button type="button"
774-
id="bulk_edit_field_select_trigger"
775-
class="bulk-edit-field-select-trigger"
776-
aria-haspopup="listbox"
777-
aria-expanded="false">
778-
<span class="bulk-edit-field-select-text">
779-
<span class="bulk-edit-field-select-placeholder">
780-
<?php esc_html_e( 'Select a field to add...', 'disciple_tools' ); ?>
781-
</span>
782-
<span class="bulk-edit-field-select-selected" style="display:none;">
783-
<span class="bulk-edit-field-icon"></span>
784-
<span></span>
785-
</span>
786-
</span>
787-
<span class="bulk-edit-field-select-count" style="display:none;"></span>
788-
<span class="bulk-edit-field-select-arrow">▼</span>
789-
</button>
790-
791-
<div id="bulk_edit_field_search_dropdown"
792-
class="bulk-edit-field-search-dropdown"
793-
role="listbox"
794-
style="display:none;">
795-
<!-- Sticky search input at top -->
796-
<div class="bulk-edit-field-dropdown-search">
797-
<input type="text"
798-
id="bulk_edit_field_search_input"
799-
class="bulk-edit-field-dropdown-search-input"
800-
placeholder="<?php esc_html_e( 'Search fields...', 'disciple_tools' ); ?>"
801-
autocomplete="off"
802-
role="searchbox"
803-
aria-label="<?php esc_html_e( 'Search fields', 'disciple_tools' ); ?>">
804-
</div>
805-
806-
<!-- Loading state -->
807-
<div class="bulk-edit-field-dropdown-loading" style="display:none;">
808-
<div class="loading-spinner active" style="margin: 20px auto;"></div>
809-
<p style="text-align: center; color: #999; margin-top: 10px;">
810-
<?php esc_html_e( 'Loading fields...', 'disciple_tools' ); ?>
811-
</p>
812-
</div>
813-
814-
<!-- Scrollable options container -->
815-
<div class="bulk-edit-field-dropdown-options" role="listbox">
816-
<?php
817-
// Build list of available fields (excluding already visible ones)
818-
$already_visible = [ 'assigned_to', 'subassigned', 'overall_status', 'coaches', 'share', 'requires_update', 'follow', 'comments' ];
819-
if ( $post_type == 'contacts' ) {
820-
$already_visible[] = 'reason_paused';
821-
}
822-
823-
// Sort fields alphabetically by name
824-
uasort( $field_options, function ( $a, $b ) {
825-
return strnatcmp( $a['name'] ?? 'z', $b['name'] ?? 'z' );
826-
});
827-
828-
$allowed_types = [ 'user_select', 'multi_select', 'key_select', 'date', 'datetime', 'location', 'location_meta', 'connection', 'tags', 'text', 'textarea', 'number' ];
829-
830-
$available_fields_count = 0;
831-
foreach ( $field_options as $field_key => $field_values ):
832-
if ( in_array( $field_key, $already_visible ) ) {
833-
continue;
834-
}
835-
if ( empty( $field_values['hidden'] )
836-
&& isset( $field_values['type'] )
837-
&& in_array( $field_values['type'], $allowed_types )
838-
&& $field_values['type'] != 'communication_channel' ) :
839-
$available_fields_count++;
840-
$has_icon = !empty( $field_values['icon'] ) || !empty( $field_values['font-icon'] );
841-
$option_classes = 'bulk-edit-field-search-option' . ( $has_icon ? '' : ' no-icon' );
842-
?>
843-
<div class="<?php echo esc_attr( $option_classes ); ?>"
844-
role="option"
845-
tabindex="-1"
846-
data-field-key="<?php echo esc_attr( $field_key ); ?>"
847-
data-field-type="<?php echo esc_attr( $field_values['type'] ); ?>"
848-
data-field-name="<?php echo esc_attr( strtolower( $field_values['name'] ) ); ?>">
849-
<?php dt_render_field_icon( $field_values ); ?>
850-
<span><?php echo esc_html( $field_values['name'] ); ?></span>
851-
</div>
852-
<?php endif;
853-
endforeach; ?>
854-
</div>
855-
856-
<!-- Field count display -->
857-
<div class="bulk-edit-field-dropdown-footer">
858-
<span class="bulk-edit-field-count-text">
859-
<?php
860-
echo sprintf(
861-
esc_html( _n( '%d field available', '%d fields available', $available_fields_count, 'disciple_tools' ) ),
862-
esc_html( $available_fields_count )
863-
);
864-
?>
865-
</span>
866-
</div>
867-
868-
<!-- No results message (hidden by default) -->
869-
<div class="bulk-edit-field-dropdown-no-results" style="display:none;">
870-
<p style="padding: 12px; text-align: center; color: #999; font-style: italic; margin: 0;">
871-
<?php esc_html_e( 'No matching fields found', 'disciple_tools' ); ?>
872-
</p>
873-
</div>
874-
</div>
773+
<dt-multi-select
774+
id="bulk_edit_field_selector"
775+
name="bulk_edit_field_selector"
776+
placeholder="<?php esc_attr_e( 'Search and add fields...', 'disciple_tools' ); ?>"
777+
options='[]'
778+
value='[]'>
779+
</dt-multi-select>
875780
</div>
876781

877782
<!-- Selected Fields Container -->

dt-assets/build/css/style.min.css

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)