Fix node status sync error (WIP)

TODO: Use Map object to optimize node lookup
This commit is contained in:
2026-05-18 12:40:25 +02:00
parent 6777037d3d
commit 9ae4b0bb8f
2 changed files with 14 additions and 4 deletions

View File

@@ -28,6 +28,9 @@ export default class extends Controller {
* @param {Event} event * @param {Event} event
*/ */
toggleNode(event) { toggleNode(event) {
console.debug(AppState.treeNodes);
/** /**
* The node's id * The node's id
* @type {string} * @type {string}
@@ -60,15 +63,21 @@ export default class extends Controller {
*/ */
#toggleGroup(groupNode, status) { #toggleGroup(groupNode, status) {
for (const child of groupNode.children) { for (const child of groupNode.children) {
child.active = status;
if (child.model) { if (child.model) {
ATON.getSceneNode(child.id).toggle(status); ATON.getSceneNode(child.id).toggle(status);
child.active = status;
} }
if (child.children.length > 0) { if (child.children.length > 0) {
this.#toggleGroup(child, status); this.#toggleGroup(child, status);
} }
} }
} }
/**
* Toggles checkboxes in a group based on status
* @param {Object} groupNode
* @param {Boolean} status
* @param {HTMLElement} container
*/
#syncGroupCheckboxes(groupNode, status, container) { #syncGroupCheckboxes(groupNode, status, container) {
for (const child of groupNode.children) { for (const child of groupNode.children) {
const checkbox = container.querySelector( const checkbox = container.querySelector(

View File

@@ -8,9 +8,10 @@ initStimulus();
AppState.currentScene = 'ssgp'; AppState.currentScene = 'ssgp';
const marker = config.markers.find(m => m.id === 'ssgp'); const marker = config.markers.find(m => m.id === 'ssgp');
AppState.normalizedNodes = normalizeNodes(marker.nodes).flat; const {flat, tree} = normalizeNodes(marker.nodes);
AppState.treeNodes = normalizeNodes(marker.nodes).tree; AppState.normalizedNodes = flat;
AppState.treeNodes = tree;
//console.debug(AppState.treeNodes); // TODO: add Map object for lookup optimization
openScene(marker, AppState.normalizedNodes); openScene(marker, AppState.normalizedNodes);