Tree fixes
This commit is contained in:
@@ -115,6 +115,11 @@ function createTreeNode(name, value, path) {
|
||||
childrenContainer.appendChild(childNode);
|
||||
});
|
||||
|
||||
if (shouldStartCollapsed(name, value)) {
|
||||
childrenContainer.classList.add('collapsed');
|
||||
toggle.textContent = '▶';
|
||||
}
|
||||
|
||||
toggle.addEventListener('click', event => {
|
||||
event.stopPropagation();
|
||||
childrenContainer.classList.toggle('collapsed');
|
||||
@@ -138,6 +143,24 @@ function createTreeNode(name, value, path) {
|
||||
return container;
|
||||
}
|
||||
|
||||
function shouldStartCollapsed(name, value) {
|
||||
if (!value || typeof value !== 'object') {
|
||||
return false;
|
||||
}
|
||||
|
||||
const childKeys = Object.keys(value);
|
||||
if (childKeys.length === 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const hotfixChildren = childKeys.filter(key => {
|
||||
const match = key.match(/^(.*)-h\d+$/i);
|
||||
return match && match[1] === name;
|
||||
});
|
||||
|
||||
return hotfixChildren.length > 0;
|
||||
}
|
||||
|
||||
function createCheckbox(path, value) {
|
||||
const checkbox = document.createElement('input');
|
||||
checkbox.type = 'checkbox';
|
||||
|
||||
Reference in New Issue
Block a user