From bc691fa942029cd804507cd83b58d6e31d24be78 Mon Sep 17 00:00:00 2001 From: Claude Date: Sun, 17 May 2026 16:16:38 +0000 Subject: [PATCH 1/2] Revert: Remove invalid set_initial_rows() call set_initial_rows() is not a valid Carbon Fields 3.6.9 method and caused a fatal PHP error. Reverting to previous state. https://claude.ai/code/session_01JB1xUQM892bVZ4Yv3MZjvq --- includes/class-fields.php | 1 - 1 file changed, 1 deletion(-) diff --git a/includes/class-fields.php b/includes/class-fields.php index c8c989c..28c0d2a 100644 --- a/includes/class-fields.php +++ b/includes/class-fields.php @@ -120,7 +120,6 @@ private static function register_required_fields(): void { array( Field::make( 'complex', 'odw_distributions', __( 'Wo können die Daten heruntergeladen werden?', 'open-data-wizard' ) ) ->set_min( 1 ) - ->set_initial_rows( 1 ) ->set_collapsed( false ) ->add_fields( array( From 2a5885bcb1b66f59df8c4ac5b9a964a9401f8f7e Mon Sep 17 00:00:00 2001 From: Claude Date: Sun, 17 May 2026 16:18:41 +0000 Subject: [PATCH 2/2] Add: Auto-show distribution fields on page load When Tab 3 (Datenbereitstellung) loads and no distribution entries exist, automatically click 'Add Entry' to display the empty form with all fields: - access_url (download URL) - format (file format) - byte_size (file size) - license (licensing) - license_custom (custom license URI) - attribution_text (attribution text) This provides better UX by showing the form immediately without requiring a manual 'Add Entry' click. Implementation: autoShowDistributionFields() function that: 1. Finds the odw_distributions complex field container 2. Checks if any entries already exist 3. If empty, clicks the 'Add Entry' button programmatically 4. Runs with 500ms delay to ensure Carbon Fields is initialized https://claude.ai/code/session_01JB1xUQM892bVZ4Yv3MZjvq --- assets/js/odw-admin-fields.js | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/assets/js/odw-admin-fields.js b/assets/js/odw-admin-fields.js index bb68bcc..8809c36 100644 --- a/assets/js/odw-admin-fields.js +++ b/assets/js/odw-admin-fields.js @@ -219,6 +219,30 @@ observer.observe( document.body, { childList: true, subtree: true } ); } + // ------------------------------------------------------------------------- + // Auto-show distribution fields by clicking "Add Entry" on load + // ------------------------------------------------------------------------- + function autoShowDistributionFields() { + // Find the distributions complex field container + var distributionsContainer = document.querySelector( '[data-carbon-field="odw_distributions"]' ); + if ( ! distributionsContainer ) { + return; + } + + // Check if there are any existing entries (groups) + var existingGroups = distributionsContainer.querySelectorAll( '.cf-complex__group' ); + if ( existingGroups.length > 0 ) { + // Entries already exist, no need to auto-add + return; + } + + // No entries exist, click "Add Entry" to show empty form + var addButton = distributionsContainer.querySelector( '.cf-complex__actions button' ); + if ( addButton ) { + addButton.click(); + } + } + // ------------------------------------------------------------------------- // Boot on DOMContentLoaded // ------------------------------------------------------------------------- @@ -227,6 +251,9 @@ initCessdaAutosuggest(); initFileSizeWidgets(); observeNewGroups(); + + // Auto-show distribution fields if no entries exist + setTimeout( autoShowDistributionFields, 500 ); } ); } )();