(field, value, filePath)
| 16922 | bulkEditButton.textContent = 'Edit Selected Models'; |
| 16923 | document.querySelector('.main-content').appendChild(bulkEditButton); |
| 16924 | |
| 16925 | // Add bulk edit functionality |
| 16926 | bulkEditButton.addEventListener('click', () => { |
| 16927 | const dialog = document.getElementById('bulk-edit-dialog'); |
| 16928 | |
| 16929 | // Populate dropdowns |
| 16930 | populateModelDesignerDropdown(); |
| 16931 | populateParentModelDropdown(); |
| 16932 | |
| 16933 | dialog.showModal(); |
| 16934 | }); |
| 16935 | |
| 16936 | // Handle bulk edit save |
| 16937 | document.getElementById('bulk-edit-dialog').addEventListener('submit', async (event) => { |
| 16938 | event.preventDefault(); |
| 16939 | |
| 16940 | const updates = { |
| 16941 | designer: document.getElementById('bulk-designer').value, |
| 16942 | parentModel: document.getElementById('bulk-parent').value, |
| 16943 | source: document.getElementById('bulk-source').value, |
| 16944 | printed: document.getElementById('bulk-printed').value |
| 16945 | }; |
| 16946 | |
| 16947 | try { |
| 16948 | for (const filePath of selectedModels) { |
| 16949 | const model = await window.electron.getModel(filePath); |
| 16950 | const updatedModel = { |
| 16951 | ...model, |
| 16952 | designer: updates.designer || model.designer, |
| 16953 | parentModel: updates.parentModel === 'none' ? '' : (updates.parentModel || model.parentModel), |
| 16954 | source: updates.source || model.source, |
| 16955 | printStatus: updates.printed || undefined |
| 16956 | }; |
| 16957 | await window.electron.saveModel(updatedModel); |
| 16958 | } |
| 16959 | |
| 16960 | // Refresh the view |
| 16961 | const models = await window.electron.getAllModels(); |
| 16962 | await renderFiles(models); |
| 16963 | |
| 16964 | // Clear selection |
| 16965 | selectedModels.clear(); |
| 16966 | document.getElementById('bulk-edit-button').classList.remove('visible'); |
| 16967 | |
| 16968 | await window.electron.showMessage('Success', 'Changes saved successfully!'); |
| 16969 | } catch (error) { |
no test coverage detected