(selectEl, sources, activeId)
| 44 | } |
| 45 | |
| 46 | function populateFolderAccessSourceSelect(selectEl, sources, activeId) { |
| 47 | if (!selectEl) return; |
| 48 | selectEl.innerHTML = ''; |
| 49 | sources.forEach(src => { |
| 50 | if (!src || typeof src !== 'object') return; |
| 51 | const id = String(src.id || ''); |
| 52 | if (!id) return; |
| 53 | const name = String(src.name || id); |
| 54 | const type = String(src.type || ''); |
| 55 | const disabled = src.enabled === false; |
| 56 | const ro = src.readOnly ? ` (${tf('read_only', 'Read-only')})` : ''; |
| 57 | const dis = disabled ? ' (disabled)' : ''; |
| 58 | const label = type ? `${name} (${type})${ro}${dis}` : `${name}${ro}${dis}`; |
| 59 | const opt = document.createElement('option'); |
| 60 | opt.value = id; |
| 61 | opt.textContent = label; |
| 62 | selectEl.appendChild(opt); |
| 63 | }); |
| 64 | if (!selectEl.options.length) return; |
| 65 | const hasActive = Array.from(selectEl.options).some(opt => opt.value === activeId); |
| 66 | selectEl.value = hasActive ? activeId : selectEl.options[0].value; |
| 67 | } |
| 68 | |
| 69 | async function initFolderAccessSourceSelector(opts = {}) { |
| 70 | const rowId = opts.rowId || 'folderAccessSourceRow'; |
no test coverage detected