Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 31 additions & 16 deletions assets/js/odw-admin-fields.js
Original file line number Diff line number Diff line change
Expand Up @@ -220,27 +220,42 @@
}

// -------------------------------------------------------------------------
// Auto-show distribution fields by clicking "Add Entry" on load
// Auto-show distribution fields when Tab 3 is activated
// -------------------------------------------------------------------------
function autoShowDistributionFields() {
// Find the distributions complex field container
var distributionsContainer = document.querySelector( '[data-carbon-field="odw_distributions"]' );
if ( ! distributionsContainer ) {
return;
}
// Only run once per page load
var ran = false;

// 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;
}
function tryClickAddEntry() {
if ( ran ) {
return;
}

// The placeholder is only visible when there are no entries yet
var placeholder = document.querySelector( '.cf-complex__placeholder' );
if ( ! placeholder ) {
return;
}

// No entries exist, click "Add Entry" to show empty form
var addButton = distributionsContainer.querySelector( '.cf-complex__actions button' );
if ( addButton ) {
addButton.click();
// Find the "Add Entry" inserter button next to or after the placeholder
var inserterButton = document.querySelector( '.cf-complex__inserter-button' );
if ( ! inserterButton ) {
return;
}

ran = true;
inserterButton.click();
}

// Watch for Carbon Fields rendering the placeholder (lazy tab render)
var observer = new MutationObserver( function () {
tryClickAddEntry();
} );

observer.observe( document.body, { childList: true, subtree: true } );

// Also try immediately in case tab is already active
tryClickAddEntry();
}

// -------------------------------------------------------------------------
Expand Down
4 changes: 2 additions & 2 deletions open-data-wizard.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Plugin Name: Open Data Wizard
* Plugin URI: https://github.com/daimpad/OpenDataWizard
* Description: DCAT-AP 3.0 konforme Open Data Metadatenverwaltung für WordPress. Bereitstellung als maschinenlesbarer JSON-LD-Endpoint für offene Daten.
* Version: 2.1.1
* Version: 2.1.2
* Requires at least: 6.4
* Requires PHP: 8.1
* Author: nozilla
Expand All @@ -25,7 +25,7 @@
exit;
}

define( 'ODW_VERSION', '2.1.1' );
define( 'ODW_VERSION', '2.1.2' );
define( 'ODW_PLUGIN_DIR', plugin_dir_path( __FILE__ ) );
define( 'ODW_PLUGIN_URL', plugin_dir_url( __FILE__ ) );
define( 'ODW_PLUGIN_FILE', __FILE__ );
Expand Down
Loading