MCPcopy Create free account
hub / github.com/TechJeeper/Printventory / autoSaveModel

Function autoSaveModel

renderer.js:16924–16966  ·  view source on GitHub ↗
(field, value, filePath)

Source from the content-addressed store, hash-verified

16922 li.style.color = '#ff4444';
16923 li.style.cursor = 'default';
16924 itemsList.appendChild(li);
16925 return;
16926 }
16927
16928 // Handle item selection
16929 const handleItemClick = (itemValue) => {
16930 dialog.close();
16931
16932 const targetSelect = document.getElementById(targetSelectId);
16933 if (!targetSelect) {
16934 console.error('Target select element not found:', targetSelectId);
16935 return;
16936 }
16937
16938 // Set the value in the dropdown
16939 targetSelect.value = itemValue;
16940
16941 // For remove tags, trigger the remove handler
16942 if (isRemove && targetSelectId === 'multi-tag-remove-select') {
16943 // Trigger the change event which will call handleRemoveTagSelect
16944 targetSelect.dispatchEvent(new Event('change', { bubbles: true }));
16945 } else if (fieldType === 'tag' && mode !== 'filter' && containerId) {
16946 // For tags in edit mode, use addTagToModel
16947 addTagToModel(itemValue, containerId);
16948 } else if (mode === 'edit' || mode === 'multi') {
16949 // For edit/multi mode, trigger auto-save
16950 const fieldMap = {
16951 designer: 'designer',
16952 parent: 'parentModel',
16953 license: 'license'
16954 };
16955
16956 if (fieldMap[fieldType]) {
16957 const filePath = mode === 'edit' ? getCurrentModelFilePath() : null;
16958 if (mode === 'multi') {
16959 autoSaveMultipleModels(fieldMap[fieldType], itemValue);
16960 } else if (filePath) {
16961 autoSaveModel(fieldMap[fieldType], itemValue, filePath);
16962 }
16963 }
16964
16965 // Trigger change event after setting value
16966 targetSelect.dispatchEvent(new Event('change', { bubbles: true }));
16967 } else if (mode === 'filter') {
16968 // For filter mode, trigger filter update
16969 targetSelect.dispatchEvent(new Event('change', { bubbles: true }));

Callers 7

updateModelElementFunction · 0.85
handlerFunction · 0.85
renderer.jsFile · 0.85
addTagToModelFunction · 0.85
handleItemClickFunction · 0.85
createModelItemFunction · 0.85

Calls 2

updateModelElementFunction · 0.85
getCurrentModelFilePathFunction · 0.85

Tested by

no test coverage detected