(initial = false)
| 236 | try { json = picker.decode(result.content); } |
| 237 | catch (error) { throw new Error(t('analytics', 'The datasource did not return valid JSON.')); } |
| 238 | const browse = (initial = false) => { |
| 239 | rowPath = null; |
| 240 | selected = initial && !/[{}]/.test(extractionPath) ? extractionPath.split(',').filter(Boolean) : []; |
| 241 | tree.replaceChildren(); |
| 242 | back.hidden = true; |
| 243 | if (Array.isArray(json) && json.some(picker.isContainer)) { |
| 244 | tree.appendChild(action(t('analytics', 'Use all entries and choose the relevant fields'), () => showFields(json, []))); |
| 245 | } |
| 246 | children([json], [], tree); |
| 247 | if (!picker.isContainer(json) || Object.keys(json).length === 0) { |
| 248 | const hint = document.createElement('p'); |
| 249 | hint.className = 'userGuidance'; |
| 250 | hint.textContent = t('analytics', 'No selectable fields found. You can still enter the Object path manually.'); |
| 251 | tree.appendChild(hint); |
| 252 | } |
| 253 | }; |
| 254 | browse(true); |
| 255 | const savedArray = extractionPath.match(/^([^{}]*)\{([^{}]+)\}$/); |
| 256 | if (savedArray) { |
no test coverage detected