Updated Dataset Builder UI for nesting of Datapoints.

This commit is contained in:
Jeremy Rangel
2025-01-16 00:11:34 -08:00
parent 06b8c30fa3
commit 436af3dd29
3 changed files with 16 additions and 3 deletions

View File

@ -1 +1 @@
<?php return array('dependencies' => array('react', 'react-jsx-runtime', 'wp-block-editor', 'wp-blocks', 'wp-components', 'wp-element', 'wp-i18n'), 'version' => 'c6994dab2419d48d7900');
<?php return array('dependencies' => array('react', 'react-jsx-runtime', 'wp-block-editor', 'wp-blocks', 'wp-components', 'wp-element', 'wp-i18n'), 'version' => 'a7190cef9649b69f1e40');

File diff suppressed because one or more lines are too long

View File

@ -63,8 +63,21 @@ const DatasetItem = ({ item, datasetKey, moveItem, updateItem, items }) => {
// Get child items
const childItems = items.filter(i => i.parent === item.id);
// Calculate the nesting level
const getItemDepth = (itemId) => {
let depth = 0;
let currentItem = items.find(i => i.id === itemId);
while (currentItem && currentItem.parent) {
depth++;
currentItem = items.find(i => i.id === currentItem.parent);
}
return depth;
};
const depth = getItemDepth(item.id);
const style = {
marginLeft: item.parent ? '20px' : '0',
marginLeft: `${depth * 20}px`, // 20px indentation per level
opacity: isDragging ? 0.5 : 1,
cursor: 'move',
background: isOver ? '#f0f0f0' : 'white',