MCPcopy Create free account
hub / github.com/Rello/analytics / create

Function create

js/app.js:1885–1926  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

1883 const currentId = button.dataset.id;
1884
1885 const create = () => {
1886 let requestUrl = OC.generateUrl('apps/analytics/threshold');
1887 const selectedColumn = document.getElementById('thresholdDimension').value;
1888 const isFlexible = OCA.Analytics.Flexible.isFlexible(OCA.Analytics.currentReportData);
1889 const selectedIndex = parseInt(selectedColumn, 10);
1890 const isCalculatedColumn = selectedIndex >= OCA.Analytics.Visualization.thresholdCalculatedColumnOffset;
1891 let sourceColumnRef = isFlexible ? selectedColumn : null;
1892 if (isFlexible && isCalculatedColumn) {
1893 const calculationIndex = selectedIndex - OCA.Analytics.Visualization.thresholdCalculatedColumnOffset;
1894 const calculation = OCA.Analytics.Visualization.getCalculatedColumns(
1895 OCA.Analytics.currentReportData.options.tableoptions || {}
1896 )[calculationIndex];
1897 sourceColumnRef = (calculation?.columns || [])
1898 .map(reference => String(reference).match(/^source-ref\|(c_[1-9][0-9]*)$/)?.[1])
1899 .find(Boolean) || OCA.Analytics.currentReportData.columnRefs?.[0];
1900 }
1901 fetch(requestUrl, {
1902 method: 'POST',
1903 headers: OCA.Analytics.headers(),
1904 body: JSON.stringify({
1905 reportId: reportId,
1906 dimension: isFlexible && !isCalculatedColumn
1907 ? OCA.Analytics.Flexible.indexForReference(OCA.Analytics.currentReportData, selectedColumn)
1908 : selectedColumn,
1909 sourceColumnRef: sourceColumnRef,
1910 option: document.getElementById('thresholdOption').value,
1911 value: document.getElementById('thresholdValue').value,
1912 severity: document.getElementById('thresholdSeverity').value,
1913 coloring: document.getElementById('thresholdColoring').value,
1914 })
1915 })
1916 .then(response => response.json())
1917 .then(data => {
1918 delete button.dataset.id;
1919 OCA.Analytics.Threshold.getThreholdList(reportId);
1920 OCA.Analytics.Threshold.resetThresholdInputs();
1921 if (!OCA.Analytics.isDataset) {
1922 OCA.Analytics.Report.resetContentArea();
1923 OCA.Analytics.Report.Backend.getData();
1924 }
1925 });
1926 };
1927
1928 if (currentId) {
1929 let delUrl = OC.generateUrl('apps/analytics/threshold/') + currentId;

Callers 2

app.jsFile · 0.85
NewFunction · 0.85

Calls 3

findMethod · 0.80
mapMethod · 0.80
getDataMethod · 0.45

Tested by

no test coverage detected