()
| 1028 | input.setAttribute('role', 'button'); |
| 1029 | input.setAttribute('aria-haspopup', 'dialog'); |
| 1030 | const open = () => { |
| 1031 | if (input.disabled) return; |
| 1032 | const content = document.importNode(document.getElementById('templateTablePicker').content, true); |
| 1033 | const tree = content.querySelector('[data-role="tree"]'); |
| 1034 | let selected = input.value; |
| 1035 | OCA.Analytics.Notification.htmlDialogInitiate(t('analytics', 'Select table or view'), () => { |
| 1036 | input.value = selected; |
| 1037 | input.dispatchEvent(new Event('input', {bubbles: true})); |
| 1038 | input.dispatchEvent(new Event('change', {bubbles: true})); |
| 1039 | OCA.Analytics.Notification.dialogClose(); |
| 1040 | }); |
| 1041 | for (const group of input.querySelectorAll('optgroup')) { |
| 1042 | const section = document.createElement('details'); |
| 1043 | const summary = document.createElement('summary'); |
| 1044 | summary.textContent = group.label; |
| 1045 | section.appendChild(summary); |
| 1046 | for (const option of group.querySelectorAll('option')) { |
| 1047 | if (option.dataset.tableDisplayOption === 'true') continue; |
| 1048 | const row = document.createElement('label'); |
| 1049 | row.className = 'jsonPickerValue'; |
| 1050 | const radio = document.createElement('input'); |
| 1051 | radio.type = 'radio'; |
| 1052 | radio.name = 'analyticsTableSelection'; |
| 1053 | radio.value = option.value; |
| 1054 | radio.checked = option.value === selected; |
| 1055 | radio.addEventListener('change', () => { selected = radio.value; }); |
| 1056 | const text = document.createElement('span'); |
| 1057 | text.textContent = option.textContent; |
| 1058 | row.append(radio, text); |
| 1059 | section.appendChild(row); |
| 1060 | } |
| 1061 | tree.appendChild(section); |
| 1062 | } |
| 1063 | OCA.Analytics.Notification.htmlDialogUpdate(content, ''); |
| 1064 | }; |
| 1065 | input.addEventListener('pointerdown', event => { |
| 1066 | event.preventDefault(); |
| 1067 | input.focus(); |
no test coverage detected