(saved)
| 14646 | } catch (error) { |
| 14647 | console.error('Error loading model tags:', error); |
| 14648 | } |
| 14649 | } |
| 14650 | |
| 14651 | /** Set tag filter dropdown and refresh the grid (same path as Filter menu; works with getModelsFiltered in Electron and server bridge). */ |
| 14652 | async function applyTagFilterFromModelClick(tagName) { |
| 14653 | const trimmed = (tagName && String(tagName).trim()) || ''; |
| 14654 | if (!trimmed) return; |
| 14655 | if (window.dateAddedFilter) { |
| 14656 | window.dateAddedFilter = null; |
| 14657 | window._lastDateAddedFilter = null; |
| 14658 | } |
| 14659 | window.viewingEntireLibrary = false; |
| 14660 | if (typeof window.resetFilterSelectionAndDetails === 'function') { |
| 14661 | window.resetFilterSelectionAndDetails(); |
| 14662 | } |
| 14663 | const tagSelect = document.getElementById('tag-filter'); |
| 14664 | if (!tagSelect) return; |
| 14665 | const hasOption = Array.from(tagSelect.options).some((o) => o.value === trimmed); |
| 14666 | if (!hasOption) { |
| 14667 | const opt = document.createElement('option'); |
| 14668 | opt.value = trimmed; |
| 14669 | opt.textContent = trimmed; |
| 14670 | tagSelect.appendChild(opt); |
no test coverage detected