()
| 15510 | }); |
| 15511 | |
| 15512 | // Add back the cancel button handler |
| 15513 | document.getElementById('cancel-parent-button')?.addEventListener('click', () => { |
| 15514 | const dialog = document.getElementById('new-parent-dialog'); |
| 15515 | const input = document.getElementById('new-parent-name'); |
| 15516 | input.value = ''; |
| 15517 | dialog.close(); |
| 15518 | }); |
| 15519 | |
| 15520 | |
| 15521 | |
| 15522 | // Add these new functions |
| 15523 | function debounce(func, wait) { |
| 15524 | let timeout; |
| 15525 | return function executedFunction(...args) { |
| 15526 | const context = this; // Store the context |
| 15527 | const later = () => { |
| 15528 | timeout = null; // Clear timeout identifier |
| 15529 | func.apply(context, args); // Call the original function with correct context and args |
| 15530 | }; |
| 15531 | clearTimeout(timeout); |
| 15532 | timeout = setTimeout(later, wait); |
| 15533 | }; |
| 15534 | } |
| 15535 | |
| 15536 | |
| 15537 | // Replace the existing tag handling functions with these |
| 15538 | async function initializeTags() { |
| 15539 | const tagSelect = document.getElementById('tag-select'); |
| 15540 | const multiTagSelect = document.getElementById('multi-tag-select'); |
| 15541 | |
| 15542 | // Handle selecting a tag from the single edit dropdown |
| 15543 | tagSelect.addEventListener('change', () => { |
| 15544 | const selectedTag = tagSelect.value; |
| 15545 | if (selectedTag) { |
| 15546 | addTagToModel(selectedTag, 'model-tags'); |
| 15547 | tagSelect.value = ''; // Reset selection |
| 15548 | } |
| 15549 | }); |
| 15550 | |
| 15551 | // Handle selecting a tag from the multi edit dropdown |
| 15552 | multiTagSelect.addEventListener('change', () => { |
| 15553 | const selectedTag = multiTagSelect.value; |
| 15554 | if (selectedTag) { |
| 15555 | addTagToModel(selectedTag, 'multi-tags'); |
| 15556 | multiTagSelect.value = ''; // Reset selection |
| 15557 | } |
| 15558 | }); |
| 15559 | |
| 15560 | // Initial population of tag dropdowns |
| 15561 | await populateTagSelect('tag-select', 'model-tags'); |
| 15562 | await populateTagSelect('multi-tag-select', 'multi-tags'); |
| 15563 | } |
| 15564 | |
| 15565 | async function populateTagSelect(selectId = 'tag-select', containerId = 'model-tags') { |
| 15566 | const tagSelect = document.getElementById(selectId); |
| 15567 | const currentTags = Array.from(document.querySelectorAll(`#${containerId} .tag`)) |
| 15568 | .map(tag => tag.getAttribute('data-tag-name')); |
| 15569 |
nothing calls this directly
no test coverage detected