* Sync JSON editor back to form fields
()
| 614 | * Sync JSON editor back to form fields |
| 615 | */ |
| 616 | function syncJsonToForm() { |
| 617 | try { |
| 618 | const jsonInput = document.getElementById('json-input'); |
| 619 | const data = JSON.parse(jsonInput.value || '{}'); |
| 620 | |
| 621 | // Update form fields with JSON data |
| 622 | Object.entries(data).forEach(([key, value]) => { |
| 623 | const input = document.querySelector(`input[name="${key}"], select[name="${key}"]`); |
| 624 | if (input) { |
| 625 | input.value = value; |
| 626 | if (input.classList.contains('text-input')) { |
| 627 | input.classList.toggle('filled', !!value); |
| 628 | } |
| 629 | } |
| 630 | |
| 631 | const toggle = document.querySelector(`.toggle-switch[data-name="${key}"]`); |
| 632 | if (toggle) { |
| 633 | if (value) { |
| 634 | toggle.classList.add('on'); |
| 635 | toggle.classList.remove('off'); |
| 636 | } else { |
| 637 | toggle.classList.add('off'); |
| 638 | toggle.classList.remove('on'); |
| 639 | } |
| 640 | const label = toggle.parentElement.querySelector('.toggle-label'); |
| 641 | if (label) label.textContent = value ? 'True' : 'False'; |
| 642 | } |
| 643 | }); |
| 644 | } catch (e) { |
| 645 | console.error('Failed to sync JSON to form:', e); |
| 646 | } |
| 647 | } |
| 648 | |
| 649 | /* ============================================================================ |
| 650 | Pipeline Execution |