MCPcopy Index your code
hub / github.com/TechJeeper/Printventory / handler

Function handler

renderer.js:2668–2687  ·  view source on GitHub ↗
(e)

Source from the content-addressed store, hash-verified

2666 if (!element) return;
2667
2668 const handler = async (e) => {
2669 // Verify that we still have a valid model selected before saving
2670 // Check both the path tree container and the current model details path
2671 const pathTreeContainer = document.getElementById('path-tree-container');
2672 const pathFromContainer = pathTreeContainer?.getAttribute('data-file-path') || '';
2673 const currentPath = pathFromContainer || getCurrentModelFilePath() || currentModelDetailsPath;
2674
2675 // If no path exists or it doesn't match the original filePath, don't save
2676 if (!currentPath || currentPath !== filePath || !pathFromContainer) {
2677 console.log('No valid model selected, ignoring checkbox change');
2678 // Revert the checkbox to its previous state
2679 if (config.type === 'checkbox') {
2680 e.target.checked = !e.target.checked;
2681 }
2682 return;
2683 }
2684
2685 const value = config.type === 'checkbox' ? e.target.checked : e.target.value;
2686 await autoSaveModel(config.field, value, filePath);
2687 };
2688
2689 if (config.useChange) {
2690 element.addEventListener('change', handler);

Callers 2

startHttpServerFunction · 0.85
main.jsFile · 0.85

Calls 3

getCurrentModelFilePathFunction · 0.85
autoSaveModelFunction · 0.85
showHtmlContextMenuFunction · 0.85

Tested by

no test coverage detected