(row, dimension = '', option = '', value = '')
| 793 | const addButton = container.getElementById('addFilterRowButton'); |
| 794 | |
| 795 | const initRow = function (row, dimension = '', option = '', value = '') { |
| 796 | const rowIndex = Array.from(table.querySelectorAll('.filterRow')).indexOf(row); |
| 797 | const dimSelect = row.querySelector('.filterDialogDimension'); |
| 798 | dimSelect.id = rowIndex === 0 ? 'filterDialogDimension' : `filterDialogDimension${rowIndex}`; |
| 799 | dimSelect.innerHTML = ''; |
| 800 | Object.keys(availableDimensions).forEach(key => { |
| 801 | dimSelect.options.add(new Option(availableDimensions[key], key)); |
| 802 | }); |
| 803 | if (dimension) { |
| 804 | dimSelect.value = dimension; |
| 805 | } |
| 806 | dimSelect.addEventListener('change', function (evt) { |
| 807 | row.querySelector('.filterDialogValue').dataset.dropdownlistindex = evt.target.selectedIndex; |
| 808 | if (context) { |
| 809 | optSelect.value = context.defaultOperators[dimSelect.value] || 'EQ'; |
| 810 | updateDescription(); |
| 811 | } |
| 812 | }); |
| 813 | |
| 814 | const optSelect = row.querySelector('.filterDialogOption'); |
| 815 | optSelect.id = rowIndex === 0 ? 'filterDialogOption' : `filterDialogOption${rowIndex}`; |
| 816 | optSelect.innerHTML = ''; |
| 817 | Object.keys(optionTexts).forEach(key => { |
| 818 | optSelect.options.add(new Option(optionTexts[key], key)); |
| 819 | }); |
| 820 | optSelect.value = option || context?.defaultOperators[dimSelect.value] || 'EQ'; |
| 821 | const updateDescription = () => { |
| 822 | if (!context) return; |
| 823 | let description = row.querySelector('.filterReportNames'); |
| 824 | if (!description) { |
| 825 | description = document.createElement('div'); |
| 826 | description.className = 'filterReportNames'; |
| 827 | dimSelect.parentElement.append(description); |
| 828 | } |
| 829 | const reportNames = context.descriptions[dimSelect.value] || []; |
| 830 | const names = Array.isArray(reportNames) ? reportNames : [reportNames]; |
| 831 | description.replaceChildren(...names.map(name => { |
| 832 | const report = document.createElement('div'); |
| 833 | report.textContent = name; |
| 834 | return report; |
| 835 | })); |
| 836 | }; |
| 837 | updateDescription(); |
| 838 | |
| 839 | const valueInput = row.querySelector('.filterDialogValue'); |
| 840 | valueInput.id = rowIndex === 0 ? 'filterDialogValue' : `filterDialogValue${rowIndex}`; |
| 841 | valueInput.value = value; |
| 842 | valueInput.addEventListener('click', context |
| 843 | ? event => OCA.Analytics.Report.showDropDownList(event, context.valuesFor(dimSelect.value)) |
| 844 | : OCA.Analytics.Report.showDropDownList); |
| 845 | valueInput.addEventListener('keydown', function (event) { |
| 846 | if (event.key === 'Enter') { |
| 847 | apply(); |
| 848 | } |
| 849 | }); |
| 850 | valueInput.dataset.dropdownlistindex = dimSelect.selectedIndex; |
| 851 | |
| 852 | const removeIcon = row.querySelector('.icon-analytics-filterRow-remove'); |
no test coverage detected