(selectEl, sources, activeId)
| 201 | } |
| 202 | |
| 203 | function populateSourceSelect(selectEl, sources, activeId) { |
| 204 | if (!selectEl) return; |
| 205 | selectEl.innerHTML = ''; |
| 206 | sources.forEach(src => { |
| 207 | if (!src || typeof src !== 'object') return; |
| 208 | const id = String(src.id || ''); |
| 209 | if (!id) return; |
| 210 | const name = String(src.name || id); |
| 211 | const type = String(src.type || ''); |
| 212 | const ro = src.readOnly ? ` \uD83D\uDD12 ${t('read_only')}` : ''; |
| 213 | const label = type ? `${name} (${type})${ro}` : `${name}${ro}`; |
| 214 | const opt = document.createElement('option'); |
| 215 | opt.value = id; |
| 216 | opt.textContent = label; |
| 217 | if (src.readOnly) opt.disabled = true; |
| 218 | selectEl.appendChild(opt); |
| 219 | }); |
| 220 | if (!selectEl.options.length) return; |
| 221 | const hasActive = Array.from(selectEl.options).some(opt => opt.value === activeId && !opt.disabled); |
| 222 | selectEl.value = hasActive ? activeId : selectEl.options[0].value; |
| 223 | } |
| 224 | |
| 225 | async function initCopyMoveSourceSelect(kind, preferredFolder = '', preferredSourceId = '') { |
| 226 | const rowId = kind === 'move' ? 'moveFilesSourceRow' : 'copyFilesSourceRow'; |
no test coverage detected