@quillsql/react 2.11.16 → 2.11.17
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/Chart.d.ts +117 -42
- package/dist/cjs/Chart.d.ts.map +1 -1
- package/dist/cjs/Chart.js +44 -18
- package/dist/cjs/ChartBuilder.d.ts +194 -30
- package/dist/cjs/ChartBuilder.d.ts.map +1 -1
- package/dist/cjs/ChartBuilder.js +122 -62
- package/dist/cjs/ChartEditor.d.ts +114 -18
- package/dist/cjs/ChartEditor.d.ts.map +1 -1
- package/dist/cjs/ChartEditor.js +47 -15
- package/dist/cjs/Dashboard.d.ts +148 -91
- package/dist/cjs/Dashboard.d.ts.map +1 -1
- package/dist/cjs/Dashboard.js +46 -152
- package/dist/cjs/DateRangePicker/QuillDateRangePicker.d.ts +21 -1
- package/dist/cjs/DateRangePicker/QuillDateRangePicker.d.ts.map +1 -1
- package/dist/cjs/DateRangePicker/QuillDateRangePicker.js +5 -2
- package/dist/cjs/DateRangePicker/dateRangePickerUtils.js +1 -1
- package/dist/cjs/QuillProvider.d.ts +105 -2
- package/dist/cjs/QuillProvider.d.ts.map +1 -1
- package/dist/cjs/QuillProvider.js +59 -0
- package/dist/cjs/ReportBuilder.d.ts +188 -42
- package/dist/cjs/ReportBuilder.d.ts.map +1 -1
- package/dist/cjs/ReportBuilder.js +466 -394
- package/dist/cjs/SQLEditor.d.ts +158 -23
- package/dist/cjs/SQLEditor.d.ts.map +1 -1
- package/dist/cjs/SQLEditor.js +35 -30
- package/dist/cjs/Table.d.ts +119 -15
- package/dist/cjs/Table.d.ts.map +1 -1
- package/dist/cjs/Table.js +37 -6
- package/dist/cjs/TableChart.d.ts.map +1 -1
- package/dist/cjs/TableChart.js +0 -194
- package/dist/cjs/{BarList.d.ts → components/Chart/BarList.d.ts} +1 -1
- package/dist/cjs/components/Chart/BarList.d.ts.map +1 -0
- package/dist/cjs/{BarList.js → components/Chart/BarList.js} +1 -1
- package/dist/cjs/components/Chart/LineChart.d.ts +2 -3
- package/dist/cjs/components/Chart/LineChart.d.ts.map +1 -1
- package/dist/cjs/components/Chart/LineChart.js +3 -3
- package/dist/cjs/components/Chart/PieChart.d.ts.map +1 -0
- package/dist/cjs/{PieChart.js → components/Chart/PieChart.js} +1 -1
- package/dist/cjs/components/Dashboard/ChartComponent.d.ts +2 -1
- package/dist/cjs/components/Dashboard/ChartComponent.d.ts.map +1 -1
- package/dist/cjs/components/Dashboard/ChartComponent.js +6 -7
- package/dist/cjs/components/Dashboard/DashboardFilter.d.ts +22 -0
- package/dist/cjs/components/Dashboard/DashboardFilter.d.ts.map +1 -0
- package/dist/cjs/components/Dashboard/DashboardFilter.js +75 -0
- package/dist/cjs/components/Dashboard/DataLoader.d.ts +1 -1
- package/dist/cjs/components/Dashboard/DataLoader.d.ts.map +1 -1
- package/dist/cjs/components/Dashboard/DataLoader.js +1 -1
- package/dist/cjs/components/Dashboard/MetricComponent.d.ts +2 -12
- package/dist/cjs/components/Dashboard/MetricComponent.d.ts.map +1 -1
- package/dist/cjs/components/Dashboard/MetricComponent.js +39 -17
- package/dist/cjs/components/Dashboard/TableComponent.d.ts +2 -1
- package/dist/cjs/components/Dashboard/TableComponent.d.ts.map +1 -1
- package/dist/cjs/components/Dashboard/TableComponent.js +6 -9
- package/dist/cjs/components/QuillSelect.d.ts +4 -1
- package/dist/cjs/components/QuillSelect.d.ts.map +1 -1
- package/dist/cjs/components/QuillSelect.js +13 -8
- package/dist/cjs/components/QuillTable.d.ts +16 -2
- package/dist/cjs/components/QuillTable.d.ts.map +1 -1
- package/dist/cjs/components/QuillTable.js +4 -4
- package/dist/cjs/components/ReportBuilder/AddColumnPopover.d.ts +9 -3
- package/dist/cjs/components/ReportBuilder/AddColumnPopover.d.ts.map +1 -1
- package/dist/cjs/components/ReportBuilder/AddColumnPopover.js +8 -6
- package/dist/cjs/components/ReportBuilder/AddLimitPopover.d.ts +13 -1
- package/dist/cjs/components/ReportBuilder/AddLimitPopover.d.ts.map +1 -1
- package/dist/cjs/components/ReportBuilder/AddLimitPopover.js +4 -14
- package/dist/cjs/components/ReportBuilder/AddSortPopover.d.ts +21 -1
- package/dist/cjs/components/ReportBuilder/AddSortPopover.d.ts.map +1 -1
- package/dist/cjs/components/ReportBuilder/AddSortPopover.js +15 -17
- package/dist/cjs/components/ReportBuilder/bigDateMap.js +1 -1
- package/dist/cjs/components/ReportBuilder/convert.d.ts +2 -1
- package/dist/cjs/components/ReportBuilder/convert.d.ts.map +1 -1
- package/dist/cjs/components/ReportBuilder/convert.js +40 -20
- package/dist/cjs/components/ReportBuilder/pivot.d.ts +2 -1
- package/dist/cjs/components/ReportBuilder/pivot.d.ts.map +1 -1
- package/dist/cjs/components/ReportBuilder/ui.d.ts +83 -18
- package/dist/cjs/components/ReportBuilder/ui.d.ts.map +1 -1
- package/dist/cjs/components/ReportBuilder/ui.js +52 -100
- package/dist/cjs/components/ReportBuilder/util.d.ts +2 -1
- package/dist/cjs/components/ReportBuilder/util.d.ts.map +1 -1
- package/dist/cjs/components/ReportBuilder/util.js +16 -9
- package/dist/cjs/components/UiComponents.d.ts +86 -86
- package/dist/cjs/components/UiComponents.d.ts.map +1 -1
- package/dist/cjs/components/UiComponents.js +118 -103
- package/dist/cjs/hooks/index.d.ts +1 -0
- package/dist/cjs/hooks/index.d.ts.map +1 -1
- package/dist/cjs/hooks/index.js +3 -1
- package/dist/cjs/hooks/useTheme.d.ts +7 -0
- package/dist/cjs/hooks/useTheme.d.ts.map +1 -0
- package/dist/cjs/hooks/useTheme.js +12 -0
- package/dist/cjs/index.d.ts +10 -2
- package/dist/cjs/index.d.ts.map +1 -1
- package/dist/cjs/internals/ReportBuilder/PivotList.d.ts.map +1 -1
- package/dist/cjs/internals/ReportBuilder/PivotList.js +10 -10
- package/dist/cjs/internals/ReportBuilder/PivotModal.d.ts +29 -14
- package/dist/cjs/internals/ReportBuilder/PivotModal.d.ts.map +1 -1
- package/dist/cjs/internals/ReportBuilder/PivotModal.js +73 -49
- package/dist/cjs/utils/dataFetcher.d.ts.map +1 -1
- package/dist/cjs/utils/dataFetcher.js +2 -0
- package/dist/esm/Chart.d.ts +117 -42
- package/dist/esm/Chart.d.ts.map +1 -1
- package/dist/esm/Chart.js +45 -19
- package/dist/esm/ChartBuilder.d.ts +194 -30
- package/dist/esm/ChartBuilder.d.ts.map +1 -1
- package/dist/esm/ChartBuilder.js +122 -62
- package/dist/esm/ChartEditor.d.ts +114 -18
- package/dist/esm/ChartEditor.d.ts.map +1 -1
- package/dist/esm/ChartEditor.js +51 -19
- package/dist/esm/Dashboard.d.ts +148 -91
- package/dist/esm/Dashboard.d.ts.map +1 -1
- package/dist/esm/Dashboard.js +49 -153
- package/dist/esm/DateRangePicker/QuillDateRangePicker.d.ts +21 -1
- package/dist/esm/DateRangePicker/QuillDateRangePicker.d.ts.map +1 -1
- package/dist/esm/DateRangePicker/QuillDateRangePicker.js +6 -3
- package/dist/esm/DateRangePicker/dateRangePickerUtils.js +1 -1
- package/dist/esm/QuillProvider.d.ts +105 -2
- package/dist/esm/QuillProvider.d.ts.map +1 -1
- package/dist/esm/QuillProvider.js +59 -0
- package/dist/esm/ReportBuilder.d.ts +188 -42
- package/dist/esm/ReportBuilder.d.ts.map +1 -1
- package/dist/esm/ReportBuilder.js +468 -396
- package/dist/esm/SQLEditor.d.ts +158 -23
- package/dist/esm/SQLEditor.d.ts.map +1 -1
- package/dist/esm/SQLEditor.js +35 -30
- package/dist/esm/Table.d.ts +119 -15
- package/dist/esm/Table.d.ts.map +1 -1
- package/dist/esm/Table.js +38 -7
- package/dist/esm/TableChart.d.ts.map +1 -1
- package/dist/esm/TableChart.js +0 -194
- package/dist/esm/{BarList.d.ts → components/Chart/BarList.d.ts} +1 -1
- package/dist/esm/components/Chart/BarList.d.ts.map +1 -0
- package/dist/esm/{BarList.js → components/Chart/BarList.js} +1 -1
- package/dist/esm/components/Chart/LineChart.d.ts +2 -3
- package/dist/esm/components/Chart/LineChart.d.ts.map +1 -1
- package/dist/esm/components/Chart/LineChart.js +3 -3
- package/dist/esm/components/Chart/PieChart.d.ts.map +1 -0
- package/dist/esm/{PieChart.js → components/Chart/PieChart.js} +1 -1
- package/dist/esm/components/Dashboard/ChartComponent.d.ts +2 -1
- package/dist/esm/components/Dashboard/ChartComponent.d.ts.map +1 -1
- package/dist/esm/components/Dashboard/ChartComponent.js +5 -6
- package/dist/esm/components/Dashboard/DashboardFilter.d.ts +22 -0
- package/dist/esm/components/Dashboard/DashboardFilter.d.ts.map +1 -0
- package/dist/esm/components/Dashboard/DashboardFilter.js +71 -0
- package/dist/esm/components/Dashboard/DataLoader.d.ts +1 -1
- package/dist/esm/components/Dashboard/DataLoader.d.ts.map +1 -1
- package/dist/esm/components/Dashboard/DataLoader.js +1 -1
- package/dist/esm/components/Dashboard/MetricComponent.d.ts +2 -12
- package/dist/esm/components/Dashboard/MetricComponent.d.ts.map +1 -1
- package/dist/esm/components/Dashboard/MetricComponent.js +39 -17
- package/dist/esm/components/Dashboard/TableComponent.d.ts +2 -1
- package/dist/esm/components/Dashboard/TableComponent.d.ts.map +1 -1
- package/dist/esm/components/Dashboard/TableComponent.js +6 -9
- package/dist/esm/components/QuillSelect.d.ts +4 -1
- package/dist/esm/components/QuillSelect.d.ts.map +1 -1
- package/dist/esm/components/QuillSelect.js +14 -9
- package/dist/esm/components/QuillTable.d.ts +16 -2
- package/dist/esm/components/QuillTable.d.ts.map +1 -1
- package/dist/esm/components/QuillTable.js +4 -4
- package/dist/esm/components/ReportBuilder/AddColumnPopover.d.ts +9 -3
- package/dist/esm/components/ReportBuilder/AddColumnPopover.d.ts.map +1 -1
- package/dist/esm/components/ReportBuilder/AddColumnPopover.js +8 -6
- package/dist/esm/components/ReportBuilder/AddLimitPopover.d.ts +13 -1
- package/dist/esm/components/ReportBuilder/AddLimitPopover.d.ts.map +1 -1
- package/dist/esm/components/ReportBuilder/AddLimitPopover.js +4 -14
- package/dist/esm/components/ReportBuilder/AddSortPopover.d.ts +21 -1
- package/dist/esm/components/ReportBuilder/AddSortPopover.d.ts.map +1 -1
- package/dist/esm/components/ReportBuilder/AddSortPopover.js +17 -19
- package/dist/esm/components/ReportBuilder/bigDateMap.js +1 -1
- package/dist/esm/components/ReportBuilder/convert.d.ts +2 -1
- package/dist/esm/components/ReportBuilder/convert.d.ts.map +1 -1
- package/dist/esm/components/ReportBuilder/convert.js +33 -13
- package/dist/esm/components/ReportBuilder/pivot.d.ts +2 -1
- package/dist/esm/components/ReportBuilder/pivot.d.ts.map +1 -1
- package/dist/esm/components/ReportBuilder/ui.d.ts +83 -18
- package/dist/esm/components/ReportBuilder/ui.d.ts.map +1 -1
- package/dist/esm/components/ReportBuilder/ui.js +50 -98
- package/dist/esm/components/ReportBuilder/util.d.ts +2 -1
- package/dist/esm/components/ReportBuilder/util.d.ts.map +1 -1
- package/dist/esm/components/ReportBuilder/util.js +14 -8
- package/dist/esm/components/UiComponents.d.ts +86 -86
- package/dist/esm/components/UiComponents.d.ts.map +1 -1
- package/dist/esm/components/UiComponents.js +111 -101
- package/dist/esm/hooks/index.d.ts +1 -0
- package/dist/esm/hooks/index.d.ts.map +1 -1
- package/dist/esm/hooks/index.js +1 -0
- package/dist/esm/hooks/useTheme.d.ts +7 -0
- package/dist/esm/hooks/useTheme.d.ts.map +1 -0
- package/dist/esm/hooks/useTheme.js +10 -0
- package/dist/esm/index.d.ts +10 -2
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/internals/ReportBuilder/PivotList.d.ts.map +1 -1
- package/dist/esm/internals/ReportBuilder/PivotList.js +10 -10
- package/dist/esm/internals/ReportBuilder/PivotModal.d.ts +29 -14
- package/dist/esm/internals/ReportBuilder/PivotModal.d.ts.map +1 -1
- package/dist/esm/internals/ReportBuilder/PivotModal.js +73 -49
- package/dist/esm/utils/dataFetcher.d.ts.map +1 -1
- package/dist/esm/utils/dataFetcher.js +2 -0
- package/package.json +1 -1
- package/dist/cjs/BarList.d.ts.map +0 -1
- package/dist/cjs/PieChart.d.ts.map +0 -1
- package/dist/esm/BarList.d.ts.map +0 -1
- package/dist/esm/PieChart.d.ts.map +0 -1
- /package/dist/cjs/{PieChart.d.ts → components/Chart/PieChart.d.ts} +0 -0
- /package/dist/esm/{PieChart.d.ts → components/Chart/PieChart.d.ts} +0 -0
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
/* eslint-disable no-unused-vars */
|
|
2
3
|
import { useContext, useEffect, useRef, useState, } from 'react';
|
|
3
|
-
import { MemoizedButton, MemoizedCheckbox, MemoizedDeleteButton, MemoizedHeader, MemoizedLabel, MemoizedPopover,
|
|
4
|
+
import { DEFAULT_TAB_OPTIONS, MemoizedButton, MemoizedCheckbox, MemoizedDeleteButton, MemoizedHeader, MemoizedLabel, MemoizedSecondaryButton, MemoizedText, MemoizedPopover, QuillTableComponent, QuillTabs, MemoizedModal, } from './components/UiComponents';
|
|
4
5
|
import { DndContext, closestCenter, KeyboardSensor, PointerSensor, useSensor, useSensors, } from '@dnd-kit/core';
|
|
5
6
|
import { arrayMove, SortableContext, sortableKeyboardCoordinates, verticalListSortingStrategy, useSortable, } from '@dnd-kit/sortable';
|
|
6
7
|
import { CSS as DND_CSS } from '@dnd-kit/utilities';
|
|
@@ -9,7 +10,7 @@ import { ClientContext, ThemeContext } from './Context';
|
|
|
9
10
|
import { getTableAliases, getTableNames, isDateishColumnType, isNumericColumnType, isTextColumnType, } from './components/ReportBuilder/ast';
|
|
10
11
|
import { ChartBuilderWithModal } from './ChartBuilder';
|
|
11
12
|
import { QuillTextInput } from './components/UiComponents';
|
|
12
|
-
import {
|
|
13
|
+
import { QuillSidebar, CustomContainer, QuillSelectColumn, QuillDraggableColumn, QuillSidebarHeading, QuillFilterPopover, QuillSortPopover, TagWrapper, EditPopover, AddFilterPopover, QuillLimitPopover, } from './components/ReportBuilder/ui';
|
|
13
14
|
import { generateCurrentPeriodPostgres, generateEqualsPostgres, generateLastNPeriodsPostgres, generatePreviousPeriodPostgres, } from './components/ReportBuilder/postgres';
|
|
14
15
|
import { convertBigQuery, convertGroupBy, convertRemoveSimpleParentheses, convertStringComparison, convertWildcardColumns, } from './components/ReportBuilder/convert';
|
|
15
16
|
import { deepCopy, formatDateComparisonNode, getDateFilterInfo, getInTheCurrentIntervalSentence, getInTheLastIntervalSentence, getInThePreviousIntervalSentence, getPostgresBasicType, isColumnComparison, isDateTruncEquals, isInTheLastInterval, isNodeEmptyCollection, isTheCurrentInterval, isThePreviousInterval, isTopLevelBoolean, showNodeAsRow, tryConvertDateEquality, removeNonSelectedTableReferences, } from './components/ReportBuilder/util';
|
|
@@ -20,11 +21,10 @@ import AddColumnPopover from './components/ReportBuilder/AddColumnPopover';
|
|
|
20
21
|
import { AddSortPopover, SortSentence, } from './components/ReportBuilder/AddSortPopover';
|
|
21
22
|
import { PivotModal, generatePivotTable, } from './internals/ReportBuilder/PivotModal';
|
|
22
23
|
import { PivotCard } from './internals/ReportBuilder/PivotList';
|
|
23
|
-
import QuillTable from './components/QuillTable';
|
|
24
|
-
import { QuillSelectComponent } from './components/QuillSelect';
|
|
25
24
|
import { snakeCaseToTitleCase } from './utils/textProcessing';
|
|
26
25
|
import { AddLimitPopover, LimitSentence, } from './components/ReportBuilder/AddLimitPopover';
|
|
27
26
|
import { updateFirstChildWidth } from './utils/width';
|
|
27
|
+
import { QuillSelectComponent } from './components/QuillSelect';
|
|
28
28
|
/**
|
|
29
29
|
* Quill Report Builder
|
|
30
30
|
*
|
|
@@ -32,8 +32,31 @@ import { updateFirstChildWidth } from './utils/width';
|
|
|
32
32
|
* then edit them on the fly. Once users have constructed a query they like,
|
|
33
33
|
* they can click a button and add that report to their dashboard or export it
|
|
34
34
|
* as a CSV.
|
|
35
|
+
*
|
|
36
|
+
* @example
|
|
37
|
+
* ```js
|
|
38
|
+
* // Usage without custom components
|
|
39
|
+
* <ReportBuilder />
|
|
40
|
+
* ```
|
|
41
|
+
*
|
|
42
|
+
* @example
|
|
43
|
+
* ```js
|
|
44
|
+
* // You can also pass your own components
|
|
45
|
+
* <ReportBuilder
|
|
46
|
+
* initialTableName="transactions"
|
|
47
|
+
* TableComponent={MyTable}
|
|
48
|
+
* SelectComponent={MySelect}
|
|
49
|
+
* ButtonComponent={MyButton}
|
|
50
|
+
* PopoverComponent={MyPopover}
|
|
51
|
+
* TextInputComponent={MyTextInput}
|
|
52
|
+
* containerStyle={{ backgroundColor: 'white', padding: '10px' }}
|
|
53
|
+
* />
|
|
54
|
+
* ```
|
|
55
|
+
*
|
|
56
|
+
* ### Report Builder API
|
|
57
|
+
* @see https://docs.quillsql.com/components/report-builder
|
|
35
58
|
*/
|
|
36
|
-
export default function ReportBuilder({ initialTableName = '',
|
|
59
|
+
export default function ReportBuilder({ initialTableName = '', onSubmitChartBuilder = () => void null, destinationDashboard = undefined, organizationName = '', ButtonComponent = MemoizedButton, SecondaryButtonComponent = MemoizedSecondaryButton, DeleteButtonComponent = MemoizedDeleteButton, ModalComponent = MemoizedModal, TextInputComponent = QuillTextInput, SelectComponent = QuillSelectComponent, TableComponent = QuillTableComponent, PopoverComponent = MemoizedPopover, TabsComponent = QuillTabs, CheckboxComponent = MemoizedCheckbox, SidebarComponent = QuillSidebar, ContainerComponent = CustomContainer, SelectColumnComponent = QuillSelectColumn, DraggableColumnComponent = QuillDraggableColumn, SidebarHeadingComponent = QuillSidebarHeading, FilterPopoverComponent = QuillFilterPopover, SortPopoverComponent = QuillSortPopover, LimitPopoverComponent = QuillLimitPopover, LabelComponent = MemoizedLabel, HeaderComponent = MemoizedHeader, TextComponent = MemoizedText, isAdminEnabled = false, isAIEnabled = true, containerStyle, }) {
|
|
37
60
|
const [aiPrompt, setAiPrompt] = useState('');
|
|
38
61
|
const [errorMessage, setErrorMessage] = useState('');
|
|
39
62
|
const [baseAst, setBaseAst] = useState(null);
|
|
@@ -125,9 +148,9 @@ export default function ReportBuilder({ initialTableName = '', onAddToDashboardC
|
|
|
125
148
|
setAiPrompt('');
|
|
126
149
|
setBaseAst(null);
|
|
127
150
|
setFormData(null);
|
|
128
|
-
setOrderedColumnNames([]);
|
|
129
151
|
setSelectedColumns([]);
|
|
130
152
|
setSchemaTables([]);
|
|
153
|
+
setOrderedColumnNames([]);
|
|
131
154
|
setActiveQuery('');
|
|
132
155
|
setActiveEditItem(null);
|
|
133
156
|
setActivePath(null);
|
|
@@ -138,6 +161,7 @@ export default function ReportBuilder({ initialTableName = '', onAddToDashboardC
|
|
|
138
161
|
setFields([]);
|
|
139
162
|
setTopLevelBinaryOperator('AND');
|
|
140
163
|
setEditPopoverKey(null);
|
|
164
|
+
setErrorMessage('');
|
|
141
165
|
// setUniqueValues({});
|
|
142
166
|
setPivot(null);
|
|
143
167
|
setPivotData(null);
|
|
@@ -237,7 +261,9 @@ export default function ReportBuilder({ initialTableName = '', onAddToDashboardC
|
|
|
237
261
|
const result = [];
|
|
238
262
|
const table = tables[0];
|
|
239
263
|
const { valueField, rowField, columnField } = pivot;
|
|
240
|
-
if (columnField &&
|
|
264
|
+
if (columnField &&
|
|
265
|
+
uniqueValues[table] &&
|
|
266
|
+
uniqueValues[table][columnField]) {
|
|
241
267
|
result.push(...Object.keys(uniqueValues[table][columnField]));
|
|
242
268
|
}
|
|
243
269
|
result.push(valueField, rowField);
|
|
@@ -275,6 +301,26 @@ export default function ReportBuilder({ initialTableName = '', onAddToDashboardC
|
|
|
275
301
|
}
|
|
276
302
|
};
|
|
277
303
|
useEffect(() => {
|
|
304
|
+
const loadTable = async (tables) => {
|
|
305
|
+
if (!tables)
|
|
306
|
+
return;
|
|
307
|
+
setLoading(true);
|
|
308
|
+
await getDistinctValues(initialTableName, tables);
|
|
309
|
+
const columnsForTable = tables
|
|
310
|
+
.find((t) => t.name === initialTableName)
|
|
311
|
+
?.columns.map((c) => c.name)
|
|
312
|
+
.sort((a, b) => {
|
|
313
|
+
const aIsId = a.endsWith('.id') || a.endsWith('_id') || a.endsWith('Id');
|
|
314
|
+
const bIsId = b.endsWith('.id') || b.endsWith('_id') || b.endsWith('Id');
|
|
315
|
+
if (aIsId && !bIsId)
|
|
316
|
+
return 1;
|
|
317
|
+
if (bIsId && !aIsId)
|
|
318
|
+
return -1;
|
|
319
|
+
return 0;
|
|
320
|
+
});
|
|
321
|
+
await handleAsk(`get ${columnsForTable} from ${initialTableName}`);
|
|
322
|
+
setInitialLoad(false);
|
|
323
|
+
};
|
|
278
324
|
const fetchSchema = async () => {
|
|
279
325
|
try {
|
|
280
326
|
setLoadingSchema(true);
|
|
@@ -300,8 +346,8 @@ export default function ReportBuilder({ initialTableName = '', onAddToDashboardC
|
|
|
300
346
|
setOrderedColumnNames((tables ?? []).flatMap((table) => table.columns
|
|
301
347
|
.map((c) => `${table.name}.${c.name}`)
|
|
302
348
|
.sort((a, b) => {
|
|
303
|
-
const aIsId = a.endsWith('.id') || a.endsWith('_id');
|
|
304
|
-
const bIsId = b.endsWith('.id') || b.endsWith('_id');
|
|
349
|
+
const aIsId = a.endsWith('.id') || a.endsWith('_id') || a.endsWith('Id');
|
|
350
|
+
const bIsId = b.endsWith('.id') || b.endsWith('_id') || b.endsWith('Id');
|
|
305
351
|
if (aIsId && !bIsId)
|
|
306
352
|
return 1;
|
|
307
353
|
if (bIsId && !aIsId)
|
|
@@ -309,13 +355,7 @@ export default function ReportBuilder({ initialTableName = '', onAddToDashboardC
|
|
|
309
355
|
return 0;
|
|
310
356
|
})));
|
|
311
357
|
if (initialTableName && initialLoad) {
|
|
312
|
-
|
|
313
|
-
setLoading(true);
|
|
314
|
-
await getDistinctValues(initialTableName, tables);
|
|
315
|
-
const columnsForTable = tables
|
|
316
|
-
.find((t) => t.name === initialTableName)
|
|
317
|
-
?.columns.map((c) => c.name);
|
|
318
|
-
await handleAsk(`get ${columnsForTable} from ${initialTableName}`);
|
|
358
|
+
await loadTable(tables);
|
|
319
359
|
}
|
|
320
360
|
setLoadingSchema(false);
|
|
321
361
|
}
|
|
@@ -326,7 +366,10 @@ export default function ReportBuilder({ initialTableName = '', onAddToDashboardC
|
|
|
326
366
|
if (schemaTables.length === 0) {
|
|
327
367
|
fetchSchema();
|
|
328
368
|
}
|
|
329
|
-
|
|
369
|
+
else if (initialLoad && initialTableName) {
|
|
370
|
+
loadTable(schemaTables);
|
|
371
|
+
}
|
|
372
|
+
}, [schemaTables, initialTableName]);
|
|
330
373
|
const updateFormData = (updates, { isDeletion = false, isInsertion = false, isReplaceSubtree = false, isAddVariant = false, isDeleteVariant = false, topLevelBinOp = 'OR', isCondition = undefined, }) => {
|
|
331
374
|
// Function to immutably update or delete nodes based on their path
|
|
332
375
|
// TODO: fix the following horible code
|
|
@@ -733,7 +776,9 @@ export default function ReportBuilder({ initialTableName = '', onAddToDashboardC
|
|
|
733
776
|
// see onChange callback handleChange
|
|
734
777
|
// eslint-disable-next-line no-unused-vars
|
|
735
778
|
dateColumnPath, dateFilterType, intervalCount, intervalType, intervalPaths, } = getDateFilterInfo(node);
|
|
736
|
-
const isPlural = intervalCount !== 1
|
|
779
|
+
const isPlural = intervalCount !== 1 && dateFilterType !== 'in the current'
|
|
780
|
+
? 's'
|
|
781
|
+
: '';
|
|
737
782
|
// Pull off the string literal date for "equals" comparisons
|
|
738
783
|
const rawDateStringEquals = node.right?.value ??
|
|
739
784
|
node.right?.args?.value[1]?.column ??
|
|
@@ -743,50 +788,50 @@ export default function ReportBuilder({ initialTableName = '', onAddToDashboardC
|
|
|
743
788
|
'node.right.args.value.1.column') ??
|
|
744
789
|
(node.right?.args?.value[1]?.value &&
|
|
745
790
|
'node.right.args.value.1.value');
|
|
746
|
-
return (_jsxs("div", { style: { display: 'flex', gap: 20 }, children: [_jsx(
|
|
747
|
-
const columnType = getColumnTypeByName(value);
|
|
791
|
+
return (_jsxs("div", { style: { display: 'flex', gap: 20 }, children: [_jsx(SelectComponent, { value: dateColumn, onChange: (event) => {
|
|
792
|
+
const columnType = getColumnTypeByName(event.target.value);
|
|
748
793
|
if (isDateishColumnType(columnType)) {
|
|
749
794
|
// handleChange(value, keyPrefix + dateColumnPath, "text");
|
|
750
|
-
handleOperatorChange('IN_THE_LAST', node, keyPrefix, value);
|
|
795
|
+
handleOperatorChange('IN_THE_LAST', node, keyPrefix, event.target.value);
|
|
751
796
|
}
|
|
752
797
|
else if (isNumericColumnType(columnType)) {
|
|
753
798
|
const newSubtree = deepCopy(defaultNumericComparison);
|
|
754
|
-
newSubtree.left.column = value;
|
|
799
|
+
newSubtree.left.column = event.target.value;
|
|
755
800
|
handleReplaceSubtree(keyPrefix, newSubtree);
|
|
756
801
|
}
|
|
757
802
|
else {
|
|
758
803
|
const newSubtree = deepCopy(defaultEntry);
|
|
759
|
-
newSubtree.left.args.value[0].column = value;
|
|
804
|
+
newSubtree.left.args.value[0].column = event.target.value;
|
|
760
805
|
handleReplaceSubtree(keyPrefix, newSubtree);
|
|
761
806
|
}
|
|
762
807
|
}, options: getAllPossibleColumns().map((column) => ({
|
|
763
808
|
label: snakeCaseToTitleCase(column.displayName),
|
|
764
809
|
value: column.name,
|
|
765
|
-
})) }), _jsx(
|
|
766
|
-
if (value === dateFilterType)
|
|
810
|
+
})) }), _jsx(SelectComponent, { value: dateFilterType, onChange: (event) => {
|
|
811
|
+
if (event.target.value === dateFilterType)
|
|
767
812
|
return null;
|
|
768
813
|
let newSubtree = {};
|
|
769
814
|
// TODO: implement one for each database type (eg. pg, snowflake, etc.)
|
|
770
|
-
if (value === 'in the last') {
|
|
815
|
+
if (event.target.value === 'in the last') {
|
|
771
816
|
newSubtree = generateLastNPeriodsPostgres({
|
|
772
817
|
dateField: dateColumn,
|
|
773
818
|
intervalPeriod: `${intervalCount ?? 1} ${intervalType}`,
|
|
774
819
|
});
|
|
775
820
|
}
|
|
776
|
-
else if (value === 'in the previous') {
|
|
821
|
+
else if (event.target.value === 'in the previous') {
|
|
777
822
|
newSubtree = generatePreviousPeriodPostgres({
|
|
778
823
|
dateField: dateColumn,
|
|
779
824
|
intervalPeriod: `${intervalCount ?? 1} ${intervalType}`,
|
|
780
825
|
currentPeriod: intervalType,
|
|
781
826
|
});
|
|
782
827
|
}
|
|
783
|
-
else if (value === 'in the current') {
|
|
828
|
+
else if (event.target.value === 'in the current') {
|
|
784
829
|
newSubtree = generateCurrentPeriodPostgres({
|
|
785
830
|
dateField: dateColumn,
|
|
786
831
|
currentPeriod: intervalType,
|
|
787
832
|
});
|
|
788
833
|
}
|
|
789
|
-
else if (value === 'equals') {
|
|
834
|
+
else if (event.target.value === 'equals') {
|
|
790
835
|
newSubtree = generateEqualsPostgres({
|
|
791
836
|
dateField: dateColumn,
|
|
792
837
|
currentPeriod: intervalType,
|
|
@@ -800,7 +845,7 @@ export default function ReportBuilder({ initialTableName = '', onAddToDashboardC
|
|
|
800
845
|
{ label: 'in the previous', value: 'in the previous' },
|
|
801
846
|
{ label: 'in the current', value: 'in the current' },
|
|
802
847
|
{ label: 'equals', value: 'equals' },
|
|
803
|
-
] }), !['in the current', 'equals'].includes(dateFilterType) && (_jsx(
|
|
848
|
+
] }), !['in the current', 'equals'].includes(dateFilterType) && (_jsx(TextInputComponent, { id: "date_filter_interval_count", value: intervalCount?.toString() ?? '', width: 70, onChange: (e) => {
|
|
804
849
|
if (Number.isNaN(parseFloat(e.target.value || '0'))) {
|
|
805
850
|
alert('Please input a number.');
|
|
806
851
|
return;
|
|
@@ -812,13 +857,13 @@ export default function ReportBuilder({ initialTableName = '', onAddToDashboardC
|
|
|
812
857
|
path: keyPrefix + intervalPath,
|
|
813
858
|
},
|
|
814
859
|
]));
|
|
815
|
-
} })), _jsx(
|
|
860
|
+
} })), _jsx(SelectComponent, { value: intervalType, onChange: (event) => {
|
|
816
861
|
if (intervalPaths.length === 1) {
|
|
817
862
|
handleChangeText([
|
|
818
863
|
{
|
|
819
864
|
value: intervalCount !== null
|
|
820
|
-
? `${intervalCount} ${value}${isPlural}`
|
|
821
|
-
: value,
|
|
865
|
+
? `${intervalCount} ${event.target.value}${isPlural}`
|
|
866
|
+
: event.target.value,
|
|
822
867
|
path: keyPrefix + intervalPaths[0],
|
|
823
868
|
},
|
|
824
869
|
]);
|
|
@@ -828,14 +873,14 @@ export default function ReportBuilder({ initialTableName = '', onAddToDashboardC
|
|
|
828
873
|
if (dateFilterType === 'equals') {
|
|
829
874
|
newSubtree = generateEqualsPostgres({
|
|
830
875
|
dateField: dateColumn,
|
|
831
|
-
currentPeriod: value,
|
|
876
|
+
currentPeriod: event.target.value,
|
|
832
877
|
timestamp: rawDateStringEquals,
|
|
833
878
|
});
|
|
834
879
|
}
|
|
835
880
|
else {
|
|
836
881
|
newSubtree = generateCurrentPeriodPostgres({
|
|
837
882
|
dateField: dateColumn,
|
|
838
|
-
currentPeriod: value,
|
|
883
|
+
currentPeriod: event.target.value,
|
|
839
884
|
});
|
|
840
885
|
}
|
|
841
886
|
handleReplaceSubtree(keyPrefix, newSubtree);
|
|
@@ -846,7 +891,7 @@ export default function ReportBuilder({ initialTableName = '', onAddToDashboardC
|
|
|
846
891
|
{ label: `week${isPlural}`, value: 'week' },
|
|
847
892
|
{ label: `day${isPlural}`, value: 'day' },
|
|
848
893
|
{ label: `hour${isPlural}`, value: 'hour' },
|
|
849
|
-
] }), dateFilterType === 'equals' && (_jsx(
|
|
894
|
+
] }), dateFilterType === 'equals' && (_jsx(TextInputComponent, { id: "date_filter_equals_raw_date", value: rawDateStringEquals, width: 120, onChange: (e) => {
|
|
850
895
|
handleChangeText([
|
|
851
896
|
{
|
|
852
897
|
value: e.target.value,
|
|
@@ -867,24 +912,24 @@ export default function ReportBuilder({ initialTableName = '', onAddToDashboardC
|
|
|
867
912
|
flexDirection: 'row',
|
|
868
913
|
alignItems: 'center',
|
|
869
914
|
gap: 20,
|
|
870
|
-
}, children: [_jsx(
|
|
871
|
-
const columnType = getColumnTypeByName(value);
|
|
915
|
+
}, children: [_jsx(SelectComponent, { value: node.left.column, onChange: (event) => {
|
|
916
|
+
const columnType = getColumnTypeByName(event.target.value);
|
|
872
917
|
if (isDateishColumnType(columnType)) {
|
|
873
918
|
// handleChange(value, keyPrefix + dateColumnPath, "text");
|
|
874
|
-
handleOperatorChange('IN_THE_LAST', node, keyPrefix, value);
|
|
919
|
+
handleOperatorChange('IN_THE_LAST', node, keyPrefix, event.target.value);
|
|
875
920
|
}
|
|
876
921
|
else if (isNumericColumnType(columnType)) {
|
|
877
922
|
const newSubtree = deepCopy(defaultNumericComparison);
|
|
878
|
-
newSubtree.left.column = value;
|
|
923
|
+
newSubtree.left.column = event.target.value;
|
|
879
924
|
handleReplaceSubtree(keyPrefix, newSubtree);
|
|
880
925
|
}
|
|
881
926
|
else {
|
|
882
927
|
const newSubtree = deepCopy(defaultEntry);
|
|
883
|
-
newSubtree.left.args.value[0].column = value;
|
|
928
|
+
newSubtree.left.args.value[0].column = event.target.value;
|
|
884
929
|
handleReplaceSubtree(keyPrefix, newSubtree);
|
|
885
930
|
}
|
|
886
|
-
}, options: options }), _jsx(
|
|
887
|
-
handleOperatorChange(value, node, keyPrefix, dateColumn);
|
|
931
|
+
}, options: options }), _jsx(SelectComponent, { value: 'IN_THE_LAST', onChange: (event) => {
|
|
932
|
+
handleOperatorChange(event.target.value, node, keyPrefix, dateColumn);
|
|
888
933
|
}, options: [
|
|
889
934
|
{ label: 'in the last', value: 'IN_THE_LAST' },
|
|
890
935
|
{ label: 'in the previous', value: 'IN_THE_PREVIOUS' },
|
|
@@ -892,15 +937,18 @@ export default function ReportBuilder({ initialTableName = '', onAddToDashboardC
|
|
|
892
937
|
{ label: 'is not null', value: 'IS NOT' },
|
|
893
938
|
{ label: 'is null', value: 'IS' },
|
|
894
939
|
// { label: 'equals', value: 'equals' },
|
|
895
|
-
] }), _jsx(
|
|
940
|
+
] }), _jsx(TextInputComponent, { id: 'date_window_interval_count', value: node.right.args.value[1].expr.value, width: 120, onChange: (e) => {
|
|
896
941
|
handleChange([
|
|
897
942
|
{
|
|
898
943
|
value: e.target.value,
|
|
899
944
|
path: keyPrefix + 'right.args.value||1.expr.value',
|
|
900
945
|
},
|
|
901
946
|
]);
|
|
902
|
-
} }), _jsx("div", { children: _jsx(
|
|
903
|
-
{
|
|
947
|
+
} }), _jsx("div", { children: _jsx(SelectComponent, { value: node.right.args.value[1].unit, onChange: (event) => handleChange([
|
|
948
|
+
{
|
|
949
|
+
value: event.target.value,
|
|
950
|
+
path: keyPrefix + 'right.args.value||1.unit',
|
|
951
|
+
},
|
|
904
952
|
]), options: [
|
|
905
953
|
{ label: `year${plural}`, value: '* 365 DAY' },
|
|
906
954
|
{ label: `month${plural}`, value: '* 30 DAY' },
|
|
@@ -919,24 +967,24 @@ export default function ReportBuilder({ initialTableName = '', onAddToDashboardC
|
|
|
919
967
|
flexDirection: 'row',
|
|
920
968
|
alignItems: 'center',
|
|
921
969
|
gap: 20,
|
|
922
|
-
}, children: [_jsx(
|
|
923
|
-
const columnType = getColumnTypeByName(value);
|
|
970
|
+
}, children: [_jsx(SelectComponent, { value: node.left.column, onChange: (event) => {
|
|
971
|
+
const columnType = getColumnTypeByName(event.target.value);
|
|
924
972
|
if (isDateishColumnType(columnType)) {
|
|
925
973
|
// handleChange(value, keyPrefix + dateColumnPath, "text");
|
|
926
|
-
handleOperatorChange('IN_THE_LAST', node, keyPrefix, value);
|
|
974
|
+
handleOperatorChange('IN_THE_LAST', node, keyPrefix, event.target.value);
|
|
927
975
|
}
|
|
928
976
|
else if (isNumericColumnType(columnType)) {
|
|
929
977
|
const newSubtree = deepCopy(defaultNumericComparison);
|
|
930
|
-
newSubtree.left.column = value;
|
|
978
|
+
newSubtree.left.column = event.target.value;
|
|
931
979
|
handleReplaceSubtree(keyPrefix, newSubtree);
|
|
932
980
|
}
|
|
933
981
|
else {
|
|
934
982
|
const newSubtree = deepCopy(defaultEntry);
|
|
935
|
-
newSubtree.left.args.value[0].column = value;
|
|
983
|
+
newSubtree.left.args.value[0].column = event.target.value;
|
|
936
984
|
handleReplaceSubtree(keyPrefix, newSubtree);
|
|
937
985
|
}
|
|
938
|
-
}, options: options }), _jsx(
|
|
939
|
-
handleOperatorChange(value, node, keyPrefix, node.left.column);
|
|
986
|
+
}, options: options }), _jsx(SelectComponent, { value: 'IN_THE_CURRENT', onChange: (event) => {
|
|
987
|
+
handleOperatorChange(event.target.value, node, keyPrefix, node.left.column);
|
|
940
988
|
}, options: [
|
|
941
989
|
{ label: 'in the last', value: 'IN_THE_LAST' },
|
|
942
990
|
{ label: 'in the previous', value: 'IN_THE_PREVIOUS' },
|
|
@@ -944,10 +992,16 @@ export default function ReportBuilder({ initialTableName = '', onAddToDashboardC
|
|
|
944
992
|
{ label: 'is not null', value: 'IS NOT' },
|
|
945
993
|
{ label: 'is null', value: 'IS' },
|
|
946
994
|
// { label: 'equals', value: 'equals' },
|
|
947
|
-
] }), _jsx(
|
|
995
|
+
] }), _jsx(SelectComponent, { value: node.left.args.value[1].column, onChange: (event) => {
|
|
948
996
|
handleChange([
|
|
949
|
-
{
|
|
950
|
-
|
|
997
|
+
{
|
|
998
|
+
value: event.target.value,
|
|
999
|
+
path: 'right.args.value||1.column',
|
|
1000
|
+
},
|
|
1001
|
+
{
|
|
1002
|
+
value: event.target.value,
|
|
1003
|
+
path: 'left.args.value||1.column',
|
|
1004
|
+
},
|
|
951
1005
|
]);
|
|
952
1006
|
}, options: [
|
|
953
1007
|
{ label: `year`, value: 'YEAR' },
|
|
@@ -966,24 +1020,24 @@ export default function ReportBuilder({ initialTableName = '', onAddToDashboardC
|
|
|
966
1020
|
flexDirection: 'row',
|
|
967
1021
|
alignItems: 'center',
|
|
968
1022
|
gap: 20,
|
|
969
|
-
}, children: [_jsx(
|
|
970
|
-
const columnType = getColumnTypeByName(value);
|
|
1023
|
+
}, children: [_jsx(SelectComponent, { value: node.left.column, onChange: (event) => {
|
|
1024
|
+
const columnType = getColumnTypeByName(event.target.value);
|
|
971
1025
|
if (isDateishColumnType(columnType)) {
|
|
972
1026
|
// handleChange(value, keyPrefix + dateColumnPath, "text");
|
|
973
|
-
handleOperatorChange('IN_THE_LAST', node, keyPrefix, value);
|
|
1027
|
+
handleOperatorChange('IN_THE_LAST', node, keyPrefix, event.target.value);
|
|
974
1028
|
}
|
|
975
1029
|
else if (isNumericColumnType(columnType)) {
|
|
976
1030
|
const newSubtree = deepCopy(defaultNumericComparison);
|
|
977
|
-
newSubtree.left.column = value;
|
|
1031
|
+
newSubtree.left.column = event.target.value;
|
|
978
1032
|
handleReplaceSubtree(keyPrefix, newSubtree);
|
|
979
1033
|
}
|
|
980
1034
|
else {
|
|
981
1035
|
const newSubtree = deepCopy(defaultEntry);
|
|
982
|
-
newSubtree.left.args.value[0].column = value;
|
|
1036
|
+
newSubtree.left.args.value[0].column = event.target.value;
|
|
983
1037
|
handleReplaceSubtree(keyPrefix, newSubtree);
|
|
984
1038
|
}
|
|
985
|
-
}, options: options }), _jsx(
|
|
986
|
-
handleOperatorChange(value, node, keyPrefix, node.left.column);
|
|
1039
|
+
}, options: options }), _jsx(SelectComponent, { value: 'IN_THE_PREVIOUS', onChange: (event) => {
|
|
1040
|
+
handleOperatorChange(event.target.value, node, keyPrefix, node.left.column);
|
|
987
1041
|
}, options: [
|
|
988
1042
|
{ label: 'in the last', value: 'IN_THE_LAST' },
|
|
989
1043
|
{ label: 'in the previous', value: 'IN_THE_PREVIOUS' },
|
|
@@ -991,7 +1045,7 @@ export default function ReportBuilder({ initialTableName = '', onAddToDashboardC
|
|
|
991
1045
|
{ label: 'is not null', value: 'IS NOT' },
|
|
992
1046
|
{ label: 'is null', value: 'IS' },
|
|
993
1047
|
// { label: 'equals', value: 'equals' },
|
|
994
|
-
] }), _jsx(
|
|
1048
|
+
] }), _jsx(SelectComponent, { value: node.left.args.value[1].column, onChange: (event) => {
|
|
995
1049
|
const dayConversion = {
|
|
996
1050
|
YEAR: 365,
|
|
997
1051
|
QUARTER: 90,
|
|
@@ -1000,15 +1054,15 @@ export default function ReportBuilder({ initialTableName = '', onAddToDashboardC
|
|
|
1000
1054
|
};
|
|
1001
1055
|
handleChange([
|
|
1002
1056
|
{
|
|
1003
|
-
value,
|
|
1057
|
+
value: event.target.value,
|
|
1004
1058
|
path: 'left.args.value||1.column',
|
|
1005
1059
|
},
|
|
1006
1060
|
{
|
|
1007
|
-
value,
|
|
1061
|
+
value: event.target.value,
|
|
1008
1062
|
path: 'right.args.value||1.column',
|
|
1009
1063
|
},
|
|
1010
1064
|
{
|
|
1011
|
-
value: dayConversion[value] || 30,
|
|
1065
|
+
value: dayConversion[event.target.value] || 30,
|
|
1012
1066
|
path: 'right.args.value||0.args.value||1.expr.value',
|
|
1013
1067
|
},
|
|
1014
1068
|
]);
|
|
@@ -1048,10 +1102,10 @@ export default function ReportBuilder({ initialTableName = '', onAddToDashboardC
|
|
|
1048
1102
|
: []),
|
|
1049
1103
|
...(isTextColumnType(columnType)
|
|
1050
1104
|
? [
|
|
1051
|
-
{ label: 'is', value: 'LIKE' },
|
|
1052
|
-
{ label: 'is not', value: 'NOT LIKE' },
|
|
1053
|
-
{ label: 'is
|
|
1054
|
-
{ label: 'is not
|
|
1105
|
+
{ label: 'is exactly', value: 'LIKE' },
|
|
1106
|
+
{ label: 'is not exactly', value: 'NOT LIKE' },
|
|
1107
|
+
{ label: 'is', value: 'IN' },
|
|
1108
|
+
{ label: 'is not', value: 'NOT IN' },
|
|
1055
1109
|
{ label: 'is not null', value: 'IS NOT' },
|
|
1056
1110
|
{ label: 'is null', value: 'IS' },
|
|
1057
1111
|
]
|
|
@@ -1083,45 +1137,48 @@ export default function ReportBuilder({ initialTableName = '', onAddToDashboardC
|
|
|
1083
1137
|
}, children: [_jsxs("div", { style: {
|
|
1084
1138
|
display: 'flex',
|
|
1085
1139
|
gap: 20,
|
|
1086
|
-
// justifyContent: "space-between",
|
|
1087
1140
|
flexDirection: showNodeAsRow(node, formData)
|
|
1088
1141
|
? 'row'
|
|
1089
1142
|
: 'column',
|
|
1090
1143
|
width: '100%',
|
|
1091
|
-
}, children: [_jsx(
|
|
1092
|
-
const columnType = getColumnTypeByName(value);
|
|
1144
|
+
}, children: [_jsx(SelectComponent, { value: leftChildValue, onChange: (event) => {
|
|
1145
|
+
const columnType = getColumnTypeByName(event.target.value);
|
|
1093
1146
|
if (isDateishColumnType(columnType)) {
|
|
1094
|
-
handleOperatorChange('IN_THE_LAST', node, keyPrefix, value);
|
|
1147
|
+
handleOperatorChange('IN_THE_LAST', node, keyPrefix, event.target.value);
|
|
1095
1148
|
}
|
|
1096
1149
|
else if (isNumericColumnType(columnType)) {
|
|
1097
1150
|
const newSubtree = deepCopy(defaultNumericComparison);
|
|
1098
|
-
newSubtree.left.column = value;
|
|
1151
|
+
newSubtree.left.column = event.target.value;
|
|
1099
1152
|
handleReplaceSubtree(keyPrefix, newSubtree);
|
|
1100
1153
|
}
|
|
1101
1154
|
else {
|
|
1102
1155
|
const newSubtree = deepCopy(defaultEntry);
|
|
1103
|
-
newSubtree.left.args.value[0].column = value;
|
|
1156
|
+
newSubtree.left.args.value[0].column = event.target.value;
|
|
1104
1157
|
handleReplaceSubtree(keyPrefix, newSubtree);
|
|
1105
1158
|
}
|
|
1106
|
-
}, options: options }), operatorOptions.length > 0 && (_jsx(
|
|
1107
|
-
handleOperatorChange(value, node, keyPrefix, leftChildValue);
|
|
1108
|
-
},
|
|
1159
|
+
}, options: options }), operatorOptions.length > 0 && (_jsx(SelectComponent, { value: node.operator, onChange: (event) => {
|
|
1160
|
+
handleOperatorChange(event.target.value, node, keyPrefix, leftChildValue);
|
|
1161
|
+
}, options: operatorOptions })), node.right &&
|
|
1109
1162
|
node.right.type !== 'expr_list' &&
|
|
1110
1163
|
renderNode(node.right, keyPrefix + 'right.')] }, keyPrefix), node.right && node.right.type === 'expr_list' && (_jsx("div", { style: {
|
|
1111
1164
|
display: 'grid',
|
|
1112
1165
|
gridTemplateColumns: 'repeat(2, 1fr)',
|
|
1113
1166
|
gap: 12,
|
|
1114
|
-
}, children:
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1167
|
+
}, children: uniqueValues[table] &&
|
|
1168
|
+
Object.keys(uniqueValues[table][leftChildValue] ?? {}).map((key) => (_jsxs("label", { style: { display: 'flex', gap: 4 }, children: [_jsx(CheckboxComponent, { isChecked: uniqueValues[table][leftChildValue][key], onChange: (event) => {
|
|
1169
|
+
const newValues = deepCopy(uniqueValues);
|
|
1170
|
+
newValues[table][leftChildValue][key] = event.target.checked;
|
|
1171
|
+
setUniqueValues(newValues);
|
|
1172
|
+
if (event.target.checked) {
|
|
1173
|
+
handleInsertVariant(keyPrefix + 'right.' + 'value', key);
|
|
1174
|
+
}
|
|
1175
|
+
else {
|
|
1176
|
+
handleDeleteVariant(keyPrefix + 'right.' + 'value', key);
|
|
1177
|
+
}
|
|
1178
|
+
} }), _jsx("span", { style: {
|
|
1179
|
+
fontFamily: theme.fontFamily,
|
|
1180
|
+
margin: 'auto 0',
|
|
1181
|
+
}, children: key })] }, key))) }, keyPrefix + 'right.'))] }));
|
|
1125
1182
|
}
|
|
1126
1183
|
else {
|
|
1127
1184
|
const columnName = node.left.column;
|
|
@@ -1133,9 +1190,9 @@ export default function ReportBuilder({ initialTableName = '', onAddToDashboardC
|
|
|
1133
1190
|
justifyContent: 'space-between',
|
|
1134
1191
|
flexDirection: showNodeAsRow(node, formData) ? 'row' : 'column',
|
|
1135
1192
|
width: '100%',
|
|
1136
|
-
}, children: [node.left && renderNode(node.left, keyPrefix + 'left.'), _jsx(
|
|
1137
|
-
handleOperatorChange(value, node, keyPrefix);
|
|
1138
|
-
},
|
|
1193
|
+
}, children: [node.left && renderNode(node.left, keyPrefix + 'left.'), _jsx(SelectComponent, { value: node.operator, onChange: (event) => {
|
|
1194
|
+
handleOperatorChange(event.target.value, node, keyPrefix);
|
|
1195
|
+
}, options: [
|
|
1139
1196
|
// { label: `and`, value: "AND" },
|
|
1140
1197
|
// { label: `or`, value: "OR" },
|
|
1141
1198
|
...(isNumericColumnType(columnType)
|
|
@@ -1152,10 +1209,10 @@ export default function ReportBuilder({ initialTableName = '', onAddToDashboardC
|
|
|
1152
1209
|
: []),
|
|
1153
1210
|
...(isTextColumnType(columnType)
|
|
1154
1211
|
? [
|
|
1155
|
-
{ label: 'is', value: 'LIKE' },
|
|
1156
|
-
{ label: 'is not', value: 'NOT LIKE' },
|
|
1157
|
-
{ label: 'is
|
|
1158
|
-
{ label: 'is not
|
|
1212
|
+
{ label: 'is exactly', value: 'LIKE' },
|
|
1213
|
+
{ label: 'is not exactly', value: 'NOT LIKE' },
|
|
1214
|
+
{ label: 'is', value: 'IN' },
|
|
1215
|
+
{ label: 'is not', value: 'NOT IN' },
|
|
1159
1216
|
{ label: 'is not null', value: 'IS NOT' },
|
|
1160
1217
|
{ label: 'is null', value: 'IS' },
|
|
1161
1218
|
]
|
|
@@ -1178,15 +1235,17 @@ export default function ReportBuilder({ initialTableName = '', onAddToDashboardC
|
|
|
1178
1235
|
label: snakeCaseToTitleCase(column.displayName),
|
|
1179
1236
|
value: column.name,
|
|
1180
1237
|
}));
|
|
1181
|
-
return (_jsx(
|
|
1182
|
-
handleChange([
|
|
1238
|
+
return (_jsx(SelectComponent, { value: node.column ?? options[0]?.value, onChange: (event) => {
|
|
1239
|
+
handleChange([
|
|
1240
|
+
{ value: event.target.value, path: keyPrefix + 'column' },
|
|
1241
|
+
]);
|
|
1183
1242
|
}, options: options }));
|
|
1184
1243
|
}
|
|
1185
1244
|
case 'expr_list': {
|
|
1186
1245
|
const len = node.value.length;
|
|
1187
1246
|
return (_jsxs("div", { style: { display: 'flex', flexDirection: 'row', gap: 12 }, children: [node.value.map((elem, index) => {
|
|
1188
1247
|
if (elem.value) {
|
|
1189
|
-
return (_jsx(
|
|
1248
|
+
return (_jsx(TextInputComponent, { id: `expr_list_${index}`, width: 200, value: elem.value, onChange: (e) => handleChange([
|
|
1190
1249
|
{
|
|
1191
1250
|
value: e.target.value,
|
|
1192
1251
|
path: keyPrefix + `value.${index}.`,
|
|
@@ -1194,11 +1253,11 @@ export default function ReportBuilder({ initialTableName = '', onAddToDashboardC
|
|
|
1194
1253
|
]) }, `input_${index}`));
|
|
1195
1254
|
}
|
|
1196
1255
|
return renderNode(elem, keyPrefix + `value.${index}.`);
|
|
1197
|
-
}), len > 1 && (_jsx(
|
|
1256
|
+
}), len > 1 && (_jsx(SecondaryButtonComponent, { label: '-', onClick: () => handleDeleteVariant(keyPrefix + 'value') })), _jsx(SecondaryButtonComponent, { onClick: () => handleInsertVariant(keyPrefix + 'value'), label: '+' })] }, keyPrefix));
|
|
1198
1257
|
}
|
|
1199
1258
|
case 'double_quote_string':
|
|
1200
1259
|
case 'single_quote_string':
|
|
1201
|
-
return (_jsx(
|
|
1260
|
+
return (_jsx(TextInputComponent, { id: 'quoted_string', value: node.value.replaceAll('%', ''), width: 120, onChange: (e) => handleChange([
|
|
1202
1261
|
{
|
|
1203
1262
|
value: e.target.value,
|
|
1204
1263
|
path: keyPrefix + 'value',
|
|
@@ -1207,7 +1266,7 @@ export default function ReportBuilder({ initialTableName = '', onAddToDashboardC
|
|
|
1207
1266
|
case 'null':
|
|
1208
1267
|
return _jsx("div", {});
|
|
1209
1268
|
case 'number':
|
|
1210
|
-
return (_jsx(
|
|
1269
|
+
return (_jsx(TextInputComponent, { id: "quill_number_input", value: node.value, width: 120, onChange: (e) => {
|
|
1211
1270
|
handleChange([
|
|
1212
1271
|
{
|
|
1213
1272
|
value: e.target.value,
|
|
@@ -1280,13 +1339,13 @@ export default function ReportBuilder({ initialTableName = '', onAddToDashboardC
|
|
|
1280
1339
|
const OPS = {
|
|
1281
1340
|
AND: 'and',
|
|
1282
1341
|
OR: 'or',
|
|
1283
|
-
LIKE: 'is',
|
|
1342
|
+
LIKE: 'is exactly',
|
|
1284
1343
|
BETWEEN: 'is between',
|
|
1285
|
-
IN: 'is
|
|
1286
|
-
'NOT IN': 'is not
|
|
1287
|
-
'NOT LIKE': 'is not',
|
|
1288
|
-
'!=': 'is not',
|
|
1289
|
-
'=': 'is',
|
|
1344
|
+
IN: 'is',
|
|
1345
|
+
'NOT IN': 'is not',
|
|
1346
|
+
'NOT LIKE': 'is not exactly',
|
|
1347
|
+
'!=': 'is not exactly',
|
|
1348
|
+
'=': 'is exactly',
|
|
1290
1349
|
'<': 'is less than',
|
|
1291
1350
|
'>': 'is greater than',
|
|
1292
1351
|
'<=': 'is less than or equal to',
|
|
@@ -1294,25 +1353,16 @@ export default function ReportBuilder({ initialTableName = '', onAddToDashboardC
|
|
|
1294
1353
|
'<>': 'is not',
|
|
1295
1354
|
'-': 'minus',
|
|
1296
1355
|
'IS NOT': 'is not',
|
|
1297
|
-
IS: 'is
|
|
1356
|
+
IS: 'is',
|
|
1298
1357
|
};
|
|
1299
1358
|
switch (node.type) {
|
|
1300
1359
|
case 'binary_expr':
|
|
1301
|
-
return (_jsx(TagWrapper, { keyPrefix: keyPrefix, formData: formData, activeEditItem: activeEditItem, setEditPopoverKey: setEditPopoverKey, setActiveEditItem: setActiveEditItem, setCheckboxes: setCheckboxes, handleReplaceSubtree: handleReplaceSubtree, FilterPopover:
|
|
1302
|
-
display: 'flex',
|
|
1303
|
-
gap: 3,
|
|
1304
|
-
flexDirection: isRow ? 'row' : 'column',
|
|
1305
|
-
padding: '1px',
|
|
1306
|
-
border: isCard ? '1px solid black' : 'none',
|
|
1307
|
-
whiteSpace: 'nowrap',
|
|
1308
|
-
overflow: 'hidden',
|
|
1309
|
-
textOverflow: 'ellipsis',
|
|
1310
|
-
}, children: dateComparisonPartialMatch ??
|
|
1360
|
+
return (_jsx(TagWrapper, { keyPrefix: keyPrefix, formData: formData, activeEditItem: activeEditItem, setEditPopoverKey: setEditPopoverKey, setActiveEditItem: setActiveEditItem, setCheckboxes: setCheckboxes, handleReplaceSubtree: handleReplaceSubtree, FilterPopover: FilterPopoverComponent, setActivePath: setActivePath, setOpenPopover: setOpenPopover, setIsPending: setIsPending, clearCheckboxes: clearCheckboxes, fetchSqlQuery: fetchSqlQuery, handleDelete: handleDelete, editPopoverKey: editPopoverKey, isCard: isCard, isRow: isRow, getByKey: getByKey, EditPopover: EditPopover, Button: ButtonComponent, renderNode: renderNode, children: dateComparisonPartialMatch ??
|
|
1311
1361
|
dateEqualityPartialMatch ??
|
|
1312
1362
|
isInTheCurrentIntervalSentence ??
|
|
1313
1363
|
isInTheLastIntervalSentence ??
|
|
1314
1364
|
isInThePreviousIntervalSentence ?? (_jsxs(_Fragment, { children: [node.left &&
|
|
1315
|
-
renderSentence(formData, node.left, keyPrefix + 'left.', false, false, isRow), isRow ? (' ' + OPS[node.operator] + ' ') : isTopLevel || topLevelBinaryOperator === 'OR' ? (_jsx(TopLevelBooleanSwitch, { node: node, keyPrefix: keyPrefix, handleOperatorChange: handleOperatorChange, Select:
|
|
1365
|
+
renderSentence(formData, node.left, keyPrefix + 'left.', false, false, isRow), isRow ? (' ' + OPS[node.operator] + ' ') : isTopLevel || topLevelBinaryOperator === 'OR' ? (_jsx(TopLevelBooleanSwitch, { node: node, keyPrefix: keyPrefix, handleOperatorChange: handleOperatorChange, Select: SelectComponent })) : null, node.right &&
|
|
1316
1366
|
renderSentence(formData, node.right, keyPrefix + 'right.', false, false, isRow)] })) }));
|
|
1317
1367
|
case 'column_ref':
|
|
1318
1368
|
return snakeCaseToTitleCase(node.column);
|
|
@@ -1347,6 +1397,9 @@ export default function ReportBuilder({ initialTableName = '', onAddToDashboardC
|
|
|
1347
1397
|
if (node.args.value.length < 1)
|
|
1348
1398
|
return null;
|
|
1349
1399
|
if (node.args.value[0].value) {
|
|
1400
|
+
if (node.args.value[0].type === 'single_quote_string') {
|
|
1401
|
+
return node.args.value[0].value.replaceAll('%', '');
|
|
1402
|
+
}
|
|
1350
1403
|
return snakeCaseToTitleCase(node.args.value[0].value.replaceAll('%', ''));
|
|
1351
1404
|
}
|
|
1352
1405
|
if (node.args.value[0].column)
|
|
@@ -1394,9 +1447,11 @@ export default function ReportBuilder({ initialTableName = '', onAddToDashboardC
|
|
|
1394
1447
|
}))
|
|
1395
1448
|
.sort((a, b) => {
|
|
1396
1449
|
const aIsId = a.name.toLowerCase() === 'id' ||
|
|
1397
|
-
a.name.toLowerCase().endsWith('_id')
|
|
1450
|
+
a.name.toLowerCase().endsWith('_id') ||
|
|
1451
|
+
a.name.endsWith('Id');
|
|
1398
1452
|
const bIsId = b.name.toLowerCase() === 'id' ||
|
|
1399
|
-
b.name.toLowerCase().endsWith('_id')
|
|
1453
|
+
b.name.toLowerCase().endsWith('_id') ||
|
|
1454
|
+
b.name.endsWith('Id');
|
|
1400
1455
|
if (aIsId && !bIsId)
|
|
1401
1456
|
return 1;
|
|
1402
1457
|
if (bIsId && !aIsId)
|
|
@@ -1413,7 +1468,8 @@ export default function ReportBuilder({ initialTableName = '', onAddToDashboardC
|
|
|
1413
1468
|
return false;
|
|
1414
1469
|
const allColumns = orderedColumnNames.filter((row) => {
|
|
1415
1470
|
const [table, _] = row.split('.');
|
|
1416
|
-
|
|
1471
|
+
const selectedTable = selectedColumns[0].split('.')[0];
|
|
1472
|
+
return selectedTable === table;
|
|
1417
1473
|
});
|
|
1418
1474
|
return selectedColumns.length === allColumns.length;
|
|
1419
1475
|
};
|
|
@@ -1432,12 +1488,12 @@ export default function ReportBuilder({ initialTableName = '', onAddToDashboardC
|
|
|
1432
1488
|
fontSize: 18,
|
|
1433
1489
|
margin: 0,
|
|
1434
1490
|
textAlign: 'left',
|
|
1435
|
-
}, children: "Add condition" }), _jsx(
|
|
1491
|
+
}, children: "Add condition" }), _jsx(TabsComponent, { value: topLevelBinaryOperator, options: DEFAULT_TAB_OPTIONS, onChange: (event) => setTopLevelBinaryOperator(event.target.value) }), activeEditItem && renderNode(activeEditItem), _jsx("div", { style: {
|
|
1436
1492
|
display: 'flex',
|
|
1437
1493
|
flexDirection: 'row',
|
|
1438
1494
|
gap: 8,
|
|
1439
1495
|
justifyContent: 'end',
|
|
1440
|
-
}, children: _jsx(
|
|
1496
|
+
}, children: _jsx(ButtonComponent, { onClick: onSave, label: 'Add condition' }) })] }));
|
|
1441
1497
|
};
|
|
1442
1498
|
const fetchUponChange = async (baseAst, newFormData) => {
|
|
1443
1499
|
// if newFormData is null still use it
|
|
@@ -1698,9 +1754,8 @@ export default function ReportBuilder({ initialTableName = '', onAddToDashboardC
|
|
|
1698
1754
|
newAst = convertRemoveSimpleParentheses(newAst);
|
|
1699
1755
|
const table = getTableNames(newAst)[0] ?? initialTableName;
|
|
1700
1756
|
const tableAlias = getTableAliases(newAst)[0] ?? initialTableName;
|
|
1701
|
-
newAst = removeNonSelectedTableReferences(newAst, tableAlias ?? table);
|
|
1757
|
+
newAst = removeNonSelectedTableReferences(newAst, tableAlias ?? table, getAllPossibleColumns().map((col) => col.name));
|
|
1702
1758
|
// newAst = convertDateComparison(newAst); // TODO
|
|
1703
|
-
ast = newAst; // so we fetch data for newAst later.
|
|
1704
1759
|
if (table !== currentTable) {
|
|
1705
1760
|
await getDistinctValues(table);
|
|
1706
1761
|
setCurrentTable(table);
|
|
@@ -1720,6 +1775,7 @@ export default function ReportBuilder({ initialTableName = '', onAddToDashboardC
|
|
|
1720
1775
|
}));
|
|
1721
1776
|
if (groupByPivot) {
|
|
1722
1777
|
setBaseAst(deepCopy({ ...newAst, orderby: null, limit: null }));
|
|
1778
|
+
newAst = deepCopy({ ...newAst, orderby: null, limit: null });
|
|
1723
1779
|
}
|
|
1724
1780
|
else {
|
|
1725
1781
|
setBaseAst(deepCopy({ ...newAst }));
|
|
@@ -1729,6 +1785,7 @@ export default function ReportBuilder({ initialTableName = '', onAddToDashboardC
|
|
|
1729
1785
|
// @ts-ignore
|
|
1730
1786
|
newAst?.where ? newAst?.where?.operator : 'AND');
|
|
1731
1787
|
}
|
|
1788
|
+
ast = newAst; // so we fetch data for newAst later.
|
|
1732
1789
|
const res2 = await fetch('https://quill-344421.uc.r.appspot.com/patterns', {
|
|
1733
1790
|
method: 'POST',
|
|
1734
1791
|
headers: {
|
|
@@ -1809,11 +1866,11 @@ export default function ReportBuilder({ initialTableName = '', onAddToDashboardC
|
|
|
1809
1866
|
fetchSqlQuery(newAst);
|
|
1810
1867
|
};
|
|
1811
1868
|
function TopLevelBooleanSwitch({ node, keyPrefix, handleOperatorChange, }) {
|
|
1812
|
-
return (_jsx("div", { style: { width: 'fit-content' }, children: _jsx(
|
|
1869
|
+
return (_jsx("div", { style: { width: 'fit-content' }, children: _jsx(TabsComponent, { value: node.operator, options: DEFAULT_TAB_OPTIONS, onChange: (event) => {
|
|
1813
1870
|
if (loading) {
|
|
1814
1871
|
return;
|
|
1815
1872
|
}
|
|
1816
|
-
handleOperatorChange(value, node, keyPrefix);
|
|
1873
|
+
handleOperatorChange(event.target.value, node, keyPrefix);
|
|
1817
1874
|
} }) }));
|
|
1818
1875
|
}
|
|
1819
1876
|
const DraggableItem = ({ id, label, onDelete }) => {
|
|
@@ -1822,9 +1879,9 @@ export default function ReportBuilder({ initialTableName = '', onAddToDashboardC
|
|
|
1822
1879
|
transform: DND_CSS.Transform.toString(transform),
|
|
1823
1880
|
transition,
|
|
1824
1881
|
};
|
|
1825
|
-
return (_jsx("div", { style: { ...style }, ref: setNodeRef, children: _jsx(
|
|
1882
|
+
return (_jsx("div", { style: { ...style }, ref: setNodeRef, children: _jsx(DraggableColumnComponent, { label: snakeCaseToTitleCase(label), onDelete: onDelete, DragHandle: (props) => (_jsx("div", { style: {
|
|
1826
1883
|
cursor: 'grab',
|
|
1827
|
-
}, ...attributes, ...listeners, children: _jsx(
|
|
1884
|
+
}, ...attributes, ...listeners, children: _jsx(props.dragIcon, {}) })) }) }));
|
|
1828
1885
|
};
|
|
1829
1886
|
function DraggableColumns() {
|
|
1830
1887
|
const sensors = useSensors(useSensor(PointerSensor), useSensor(KeyboardSensor, {
|
|
@@ -1834,8 +1891,8 @@ export default function ReportBuilder({ initialTableName = '', onAddToDashboardC
|
|
|
1834
1891
|
function handleDragEnd(event) {
|
|
1835
1892
|
const { active, over } = event;
|
|
1836
1893
|
if (active.id !== over.id) {
|
|
1837
|
-
const oldIndex = orderedColumnNames.findIndex((c) => c.endsWith(active.id));
|
|
1838
|
-
const newIndex = orderedColumnNames.findIndex((c) => c.endsWith(over.id));
|
|
1894
|
+
const oldIndex = orderedColumnNames.findIndex((c) => c.endsWith(`${currentTable}.${active.id}`));
|
|
1895
|
+
const newIndex = orderedColumnNames.findIndex((c) => c.endsWith(`${currentTable}.${over.id}`));
|
|
1839
1896
|
const newOrder = arrayMove(orderedColumnNames, oldIndex, newIndex);
|
|
1840
1897
|
setOrderedColumnNames(newOrder);
|
|
1841
1898
|
const orderedSelectedColumns = [];
|
|
@@ -1890,25 +1947,27 @@ export default function ReportBuilder({ initialTableName = '', onAddToDashboardC
|
|
|
1890
1947
|
flexDirection: 'row',
|
|
1891
1948
|
height: '100%',
|
|
1892
1949
|
...containerStyle,
|
|
1893
|
-
}, ref: parentRef, children: [_jsxs(
|
|
1894
|
-
|
|
1895
|
-
|
|
1896
|
-
|
|
1897
|
-
|
|
1898
|
-
|
|
1899
|
-
|
|
1900
|
-
|
|
1901
|
-
|
|
1902
|
-
|
|
1903
|
-
|
|
1904
|
-
|
|
1950
|
+
}, ref: parentRef, children: [_jsxs(SidebarComponent, { children: [_jsx(SidebarHeadingComponent, { label: "Columns" }), _jsx("div", { style: { height: 4, width: '100%' } }), _jsx(DraggableColumns, {}), _jsx(SecondaryButtonComponent, { onClick: () => {
|
|
1951
|
+
if (loadingSchema)
|
|
1952
|
+
return;
|
|
1953
|
+
if (!openPopover) {
|
|
1954
|
+
setOpenPopover('AddColumnPopover');
|
|
1955
|
+
}
|
|
1956
|
+
}, label: 'Select columns' }), _jsx(PopoverComponent, { isOpen: openPopover === 'AddColumnPopover', setIsOpen: (isOpen) => {
|
|
1957
|
+
if (!isOpen) {
|
|
1958
|
+
setIsPending(false);
|
|
1959
|
+
setActiveEditItem(null);
|
|
1960
|
+
setActivePath(null);
|
|
1961
|
+
setOpenPopover(null);
|
|
1962
|
+
}
|
|
1963
|
+
}, popoverTitle: "Select columns", popoverChildren: _jsx(AddColumnPopover, { onSave: () => {
|
|
1905
1964
|
setActiveEditItem(null);
|
|
1906
1965
|
setActivePath(null);
|
|
1907
1966
|
setOpenPopover(null);
|
|
1908
1967
|
}, orderedColumnNames: orderedColumnNames, setOrderedColumnNames: setOrderedColumnNames, selectedColumns: selectedColumns, setSelectedColumns: setSelectedColumns, isSelectedAllColumns: isSelectedAllColumns, clearAllState: clearAllState, nameToColumn: nameToColumn, baseAst: baseAst, setBaseAst: (newAst) => {
|
|
1909
1968
|
setBaseAst(newAst);
|
|
1910
1969
|
fetchSqlQuery(newAst);
|
|
1911
|
-
}, pivot: pivot, initialTableName: initialTableName, defaultAST: defaultAST, defaultTable: defaultTable, setPivot: setPivot, TextInput:
|
|
1970
|
+
}, pivot: pivot, initialTableName: initialTableName, defaultAST: defaultAST, defaultTable: defaultTable, setPivot: setPivot, TextInput: TextInputComponent, SelectColumn: SelectColumnComponent, SecondaryButton: SecondaryButtonComponent, Button: ButtonComponent }) }), _jsx("div", { style: { height: 28, width: '100%' } }), _jsx(SidebarHeadingComponent, { label: "Filters" }), _jsx("div", { style: { height: 4, width: '100%' } }), formData && (_jsx("div", { style: {
|
|
1912
1971
|
display: 'flex',
|
|
1913
1972
|
flexDirection: 'column',
|
|
1914
1973
|
gap: 8,
|
|
@@ -1918,39 +1977,41 @@ export default function ReportBuilder({ initialTableName = '', onAddToDashboardC
|
|
|
1918
1977
|
flexDirection: 'column',
|
|
1919
1978
|
gap: 2.5,
|
|
1920
1979
|
alignItems: 'flex-start',
|
|
1921
|
-
}, children: [_jsx(
|
|
1922
|
-
|
|
1923
|
-
|
|
1924
|
-
|
|
1925
|
-
|
|
1980
|
+
}, children: [_jsx(SecondaryButtonComponent, { onClick: () => {
|
|
1981
|
+
if (!selectedColumns ||
|
|
1982
|
+
selectedColumns.length === 0 ||
|
|
1983
|
+
loading) {
|
|
1984
|
+
return;
|
|
1985
|
+
}
|
|
1986
|
+
if (!openPopover) {
|
|
1987
|
+
const value = orderedColumnNames[0];
|
|
1988
|
+
const [_table, column] = value.split('.');
|
|
1989
|
+
const columnType = getColumnTypeByName(column);
|
|
1990
|
+
if (isNumericColumnType(columnType)) {
|
|
1991
|
+
const newSubtree = deepCopy(defaultNumericComparison);
|
|
1992
|
+
newSubtree.left.column = column;
|
|
1993
|
+
setActiveEditItem(newSubtree);
|
|
1926
1994
|
}
|
|
1927
|
-
|
|
1928
|
-
const
|
|
1929
|
-
|
|
1930
|
-
|
|
1931
|
-
if (isNumericColumnType(columnType)) {
|
|
1932
|
-
const newSubtree = deepCopy(defaultNumericComparison);
|
|
1933
|
-
newSubtree.left.column = column;
|
|
1934
|
-
setActiveEditItem(newSubtree);
|
|
1935
|
-
}
|
|
1936
|
-
else {
|
|
1937
|
-
const newSubtree = deepCopy(defaultEntry);
|
|
1938
|
-
newSubtree.left.args.value[0].column = column;
|
|
1939
|
-
setActiveEditItem(newSubtree);
|
|
1940
|
-
}
|
|
1941
|
-
setOpenPopover('AddFilterPopover');
|
|
1942
|
-
setActivePath('');
|
|
1943
|
-
setIsPending(true);
|
|
1995
|
+
else {
|
|
1996
|
+
const newSubtree = deepCopy(defaultEntry);
|
|
1997
|
+
newSubtree.left.args.value[0].column = column;
|
|
1998
|
+
setActiveEditItem(newSubtree);
|
|
1944
1999
|
}
|
|
1945
|
-
|
|
1946
|
-
|
|
1947
|
-
|
|
1948
|
-
|
|
1949
|
-
|
|
1950
|
-
|
|
1951
|
-
|
|
1952
|
-
|
|
1953
|
-
|
|
2000
|
+
setOpenPopover('AddFilterPopover');
|
|
2001
|
+
setActivePath('');
|
|
2002
|
+
setIsPending(true);
|
|
2003
|
+
}
|
|
2004
|
+
}, label: 'Add filter' }), _jsx(PopoverComponent, { isOpen: openPopover === 'AddFilterPopover', setIsOpen: (isOpen) => {
|
|
2005
|
+
if (!isOpen) {
|
|
2006
|
+
setIsPending(false);
|
|
2007
|
+
setActivePath(null);
|
|
2008
|
+
setOpenPopover(null);
|
|
2009
|
+
clearCheckboxes();
|
|
2010
|
+
setTimeout(() => {
|
|
2011
|
+
setActiveEditItem(null);
|
|
2012
|
+
}, 300);
|
|
2013
|
+
}
|
|
2014
|
+
}, popoverTitle: 'Add filter', popoverChildren: _jsx(AddFilterPopover, { onSave: () => {
|
|
1954
2015
|
if (isNodeEmptyCollection(activeEditItem)) {
|
|
1955
2016
|
setIsPending(false);
|
|
1956
2017
|
setActivePath(null);
|
|
@@ -1970,44 +2031,46 @@ export default function ReportBuilder({ initialTableName = '', onAddToDashboardC
|
|
|
1970
2031
|
setActiveEditItem(null);
|
|
1971
2032
|
}, 300);
|
|
1972
2033
|
}
|
|
1973
|
-
}, Button:
|
|
2034
|
+
}, Button: ButtonComponent, renderNode: renderNode, activeEditItem: activeEditItem }) }), baseAst?.where &&
|
|
1974
2035
|
false && ( // temp removed the AddConditionPopover
|
|
1975
|
-
|
|
1976
|
-
|
|
1977
|
-
|
|
1978
|
-
|
|
1979
|
-
|
|
1980
|
-
|
|
1981
|
-
|
|
1982
|
-
|
|
1983
|
-
|
|
1984
|
-
|
|
1985
|
-
|
|
1986
|
-
|
|
1987
|
-
|
|
1988
|
-
|
|
1989
|
-
|
|
1990
|
-
|
|
1991
|
-
|
|
1992
|
-
|
|
1993
|
-
|
|
1994
|
-
|
|
1995
|
-
|
|
1996
|
-
|
|
1997
|
-
|
|
1998
|
-
|
|
1999
|
-
|
|
2000
|
-
|
|
2001
|
-
|
|
2002
|
-
|
|
2003
|
-
|
|
2004
|
-
|
|
2005
|
-
|
|
2006
|
-
|
|
2007
|
-
|
|
2008
|
-
|
|
2009
|
-
|
|
2010
|
-
|
|
2036
|
+
_jsxs(_Fragment, { children: [_jsx(SecondaryButtonComponent, { onClick: () => {
|
|
2037
|
+
if (!openPopover) {
|
|
2038
|
+
setActiveEditItem(deepCopy(defaultEntry));
|
|
2039
|
+
setOpenPopover('AddConditionPopover');
|
|
2040
|
+
setActivePath('');
|
|
2041
|
+
setIsPending(true);
|
|
2042
|
+
}
|
|
2043
|
+
}, label: "Add condition" }), _jsx(PopoverComponent, { isOpen: openPopover === 'AddConditionPopover', setIsOpen: (isOpen) => {
|
|
2044
|
+
if (!isOpen) {
|
|
2045
|
+
setIsPending(false);
|
|
2046
|
+
setTimeout(() => {
|
|
2047
|
+
setActiveEditItem(null);
|
|
2048
|
+
}, 300);
|
|
2049
|
+
setActivePath(null);
|
|
2050
|
+
setOpenPopover(null);
|
|
2051
|
+
clearCheckboxes();
|
|
2052
|
+
}
|
|
2053
|
+
}, popoverTitle: "Add condition", popoverChildren: _jsx(AddConditionPopover, { onSave: () => {
|
|
2054
|
+
if (isNodeEmptyCollection(activeEditItem)) {
|
|
2055
|
+
setIsPending(false);
|
|
2056
|
+
setTimeout(() => {
|
|
2057
|
+
setActiveEditItem(null);
|
|
2058
|
+
}, 300);
|
|
2059
|
+
setActivePath(null);
|
|
2060
|
+
setOpenPopover(null);
|
|
2061
|
+
clearCheckboxes();
|
|
2062
|
+
}
|
|
2063
|
+
else {
|
|
2064
|
+
setIsPending(false);
|
|
2065
|
+
handleInsertion(activeEditItem, topLevelBinaryOperator, true);
|
|
2066
|
+
setTimeout(() => {
|
|
2067
|
+
setActiveEditItem(null);
|
|
2068
|
+
}, 300);
|
|
2069
|
+
setActivePath(null);
|
|
2070
|
+
setOpenPopover(null);
|
|
2071
|
+
clearCheckboxes();
|
|
2072
|
+
}
|
|
2073
|
+
} }) })] }))] }), _jsx("div", { style: { height: 28, width: '100%' } }), _jsx(SidebarHeadingComponent, { label: "Pivot" }), _jsx("div", { style: { height: 4, width: '100%' } }), _jsx(PivotModal, { pivotRowField: pivotRowField, setPivotRowField: setPivotRowField, pivotColumnField: pivotColumnField, setPivotColumnField: setPivotColumnField, pivotValueField: pivotValueField, setPivotValueField: setPivotValueField, pivotAggregation: pivotAggregation, setPivotAggregation: setPivotAggregation, createdPivots: createdPivots, setCreatedPivots: setCreatedPivots, recommendedPivots: recommendedPivots, setRecommendedPivots: setRecommendedPivots, popUpTitle: pivotPopUpTitle, setPopUpTitle: setPivotPopUpTitle, selectedTable: initialTableName, SelectComponent: SelectComponent, ButtonComponent: ButtonComponent, PopoverComponent: PopoverComponent, TextComponent: TextComponent, isOpen: showPivotPopover, setIsOpen: setShowPivotPopover, showUpdatePivot: isEdittingPivot, setShowUpdatePivot: setIsEdittingPivot, parentRef: parentRef, data: rows, columns: processColumnsForChartBuilder(Object.keys(rows[0] ?? {})), triggerButtonText: 'Add pivot', selectedPivotIndex: selectedPivotIndex, setSelectedPivotIndex: setSelectedPivotIndex, removePivot: () => {
|
|
2011
2074
|
setPivot(null);
|
|
2012
2075
|
setPivotData(null);
|
|
2013
2076
|
},
|
|
@@ -2021,7 +2084,7 @@ export default function ReportBuilder({ initialTableName = '', onAddToDashboardC
|
|
|
2021
2084
|
setPivot(pivot);
|
|
2022
2085
|
const pivotedData = generatePivotTable(pivot, rows, [null, null, null], false);
|
|
2023
2086
|
setPivotData(pivotedData || []);
|
|
2024
|
-
}, selectPivotOnEdit: true, showTrigger: !pivot, theme: theme, LabelComponent:
|
|
2087
|
+
}, selectPivotOnEdit: true, showTrigger: !pivot, theme: theme, LabelComponent: LabelComponent, HeaderComponent: HeaderComponent, dateRange: [null, null, null], recommendPivotCount: 3, SecondaryButtonComponent: SecondaryButtonComponent }), pivot && (_jsx(PivotCard, { pivotTable: {
|
|
2025
2088
|
pivot: pivot,
|
|
2026
2089
|
rows: pivotData?.rows || [],
|
|
2027
2090
|
columns: pivotData?.columns || [],
|
|
@@ -2033,11 +2096,11 @@ export default function ReportBuilder({ initialTableName = '', onAddToDashboardC
|
|
|
2033
2096
|
setPivotValueField(pivot?.valueField);
|
|
2034
2097
|
setPivotAggregation(pivot?.aggregationType);
|
|
2035
2098
|
setPivotPopUpTitle('Edit Pivot');
|
|
2036
|
-
}, selectedPivotIndex: -1, onEditPivot: () => { }, ButtonComponent:
|
|
2099
|
+
}, selectedPivotIndex: -1, onEditPivot: () => { }, ButtonComponent: ButtonComponent, HeaderComponent: HeaderComponent, showEdit: false, onClose: () => {
|
|
2037
2100
|
setPivot(null);
|
|
2038
2101
|
setPivotData(null);
|
|
2039
2102
|
setBaseAst(deepCopy(baseAst)); // trigger refetch
|
|
2040
|
-
}, minHeight: 180, LabelComponent:
|
|
2103
|
+
}, minHeight: 180, LabelComponent: LabelComponent, TextComponent: TextComponent })), _jsx("div", { style: { height: 28, width: '100%' } }), _jsx(SidebarHeadingComponent, { label: "Sort" }), _jsx("div", { style: { height: 4, width: '100%' } }), pivot && pivot.sort && (_jsx("div", { style: {
|
|
2041
2104
|
display: 'flex',
|
|
2042
2105
|
flexDirection: 'column',
|
|
2043
2106
|
gap: 8,
|
|
@@ -2045,7 +2108,7 @@ export default function ReportBuilder({ initialTableName = '', onAddToDashboardC
|
|
|
2045
2108
|
}, children: _jsx(SortSentence, { sortData: {
|
|
2046
2109
|
type: pivot.sortDirection,
|
|
2047
2110
|
expr: { type: 'column_ref', column: pivot.rowField },
|
|
2048
|
-
}, columns: selectedColumns, setIsPending: setIsPending, setEditPopoverKey: setEditPopoverKey, setActiveEditItem: setActiveEditItem, setOpenPopover: setOpenPopover, SortPopover:
|
|
2111
|
+
}, columns: selectedColumns, setIsPending: setIsPending, setEditPopoverKey: setEditPopoverKey, setActiveEditItem: setActiveEditItem, setActivePath: setActivePath, setOpenPopover: setOpenPopover, SortPopover: SortPopoverComponent, EditPopover: AddSortPopover, handleDelete: () => {
|
|
2049
2112
|
setPivot({ ...pivot, sort: false });
|
|
2050
2113
|
setBaseAst(deepCopy(baseAst));
|
|
2051
2114
|
if (!pivot) {
|
|
@@ -2058,7 +2121,7 @@ export default function ReportBuilder({ initialTableName = '', onAddToDashboardC
|
|
|
2058
2121
|
if (!pivot) {
|
|
2059
2122
|
fetchSqlQuery(baseAst);
|
|
2060
2123
|
}
|
|
2061
|
-
}, Select:
|
|
2124
|
+
}, Select: SelectComponent, Button: ButtonComponent, SecondaryButton: SecondaryButtonComponent }, `sort-sentence-pivot`) })), baseAst && baseAst.orderby && (_jsx("div", { style: {
|
|
2062
2125
|
display: 'flex',
|
|
2063
2126
|
flexDirection: 'column',
|
|
2064
2127
|
gap: 8,
|
|
@@ -2085,31 +2148,33 @@ export default function ReportBuilder({ initialTableName = '', onAddToDashboardC
|
|
|
2085
2148
|
if (!pivot) {
|
|
2086
2149
|
fetchSqlQuery(newAst);
|
|
2087
2150
|
}
|
|
2088
|
-
}, setIsPending: setIsPending, setEditPopoverKey: setEditPopoverKey, setActiveEditItem: setActiveEditItem, setOpenPopover: setOpenPopover, SortPopover:
|
|
2151
|
+
}, setIsPending: setIsPending, setEditPopoverKey: setEditPopoverKey, setActiveEditItem: setActiveEditItem, setActivePath: setActivePath, setOpenPopover: setOpenPopover, SortPopover: SortPopoverComponent, EditPopover: AddSortPopover, handleDelete: () => {
|
|
2089
2152
|
const newAst = { ...baseAst };
|
|
2090
2153
|
newAst.orderby.splice(id, 1);
|
|
2091
2154
|
setBaseAst(deepCopy(newAst));
|
|
2092
2155
|
if (!pivot) {
|
|
2093
2156
|
fetchSqlQuery(newAst);
|
|
2094
2157
|
}
|
|
2095
|
-
}, Select:
|
|
2096
|
-
|
|
2097
|
-
|
|
2098
|
-
|
|
2099
|
-
|
|
2100
|
-
|
|
2101
|
-
|
|
2102
|
-
|
|
2103
|
-
|
|
2104
|
-
|
|
2105
|
-
|
|
2106
|
-
|
|
2107
|
-
|
|
2158
|
+
}, Select: SelectComponent, Button: ButtonComponent, SecondaryButton: SecondaryButtonComponent }, `sort-sentence-${id}`))) })), _jsx(SecondaryButtonComponent, { onClick: () => {
|
|
2159
|
+
if (!selectedColumns || selectedColumns.length === 0) {
|
|
2160
|
+
return;
|
|
2161
|
+
}
|
|
2162
|
+
if (!openPopover) {
|
|
2163
|
+
setOpenPopover('AddSortPopover');
|
|
2164
|
+
}
|
|
2165
|
+
}, label: "Add sort" }), _jsx(PopoverComponent, { isOpen: openPopover === 'AddSortPopover', setIsOpen: (isOpen) => {
|
|
2166
|
+
if (!isOpen) {
|
|
2167
|
+
setIsPending(false);
|
|
2168
|
+
setActiveEditItem(null);
|
|
2169
|
+
setActivePath(null);
|
|
2170
|
+
setOpenPopover(null);
|
|
2171
|
+
}
|
|
2172
|
+
}, popoverTitle: "Sort by", popoverChildren: _jsx(AddSortPopover, { columns: selectedColumns, Select: SelectComponent, Button: ButtonComponent, onSave: () => { } }) }), _jsx("div", { style: { height: 28, width: '100%' } }), _jsx(SidebarHeadingComponent, { label: "Limit" }), _jsx("div", { style: { height: 4, width: '100%' } }), baseAst && baseAst.limit ? (_jsx("div", { style: {
|
|
2108
2173
|
display: 'flex',
|
|
2109
2174
|
flexDirection: 'column',
|
|
2110
2175
|
gap: 8,
|
|
2111
2176
|
marginBottom: 12,
|
|
2112
|
-
}, children: _jsx(LimitSentence, { limit: baseAst.limit, setOpenPopover: setOpenPopover, LimitPopover:
|
|
2177
|
+
}, children: _jsx(LimitSentence, { limit: baseAst.limit, setOpenPopover: setOpenPopover, LimitPopover: LimitPopoverComponent, EditPopover: AddLimitPopover, handleDelete: () => {
|
|
2113
2178
|
const newAst = { ...baseAst };
|
|
2114
2179
|
newAst.limit = null;
|
|
2115
2180
|
setBaseAst(deepCopy(newAst));
|
|
@@ -2128,27 +2193,29 @@ export default function ReportBuilder({ initialTableName = '', onAddToDashboardC
|
|
|
2128
2193
|
setOpenPopover(null);
|
|
2129
2194
|
setBaseAst(deepCopy(newAst));
|
|
2130
2195
|
fetchSqlQuery(newAst);
|
|
2131
|
-
}, TextInput:
|
|
2132
|
-
|
|
2133
|
-
|
|
2134
|
-
|
|
2135
|
-
|
|
2136
|
-
|
|
2137
|
-
|
|
2138
|
-
|
|
2139
|
-
|
|
2140
|
-
|
|
2196
|
+
}, TextInput: TextInputComponent, Button: ButtonComponent, SecondaryButton: SecondaryButtonComponent }) })) : (_jsxs(_Fragment, { children: [_jsx(SecondaryButtonComponent, { onClick: () => {
|
|
2197
|
+
if (!openPopover) {
|
|
2198
|
+
setOpenPopover('AddLimitPopover');
|
|
2199
|
+
}
|
|
2200
|
+
}, label: 'Add limit' }), _jsx(PopoverComponent, { isOpen: openPopover === 'AddLimitPopover', setIsOpen: (isOpen) => {
|
|
2201
|
+
if (!isOpen) {
|
|
2202
|
+
setIsPending(false);
|
|
2203
|
+
setActiveEditItem(null);
|
|
2204
|
+
setActivePath(null);
|
|
2205
|
+
setOpenPopover(null);
|
|
2206
|
+
}
|
|
2207
|
+
}, popoverTitle: "Limit", popoverChildren: _jsx(TextInputComponent, { id: "loading_input_limit", value: '0', width: 120, onChange: () => { } }) })] }))] }), _jsxs(ContainerComponent, { children: [isAIEnabled && (_jsxs("form", { ref: askAILoadingContainerRef, onSubmit: (event) => {
|
|
2141
2208
|
event.preventDefault();
|
|
2142
2209
|
}, style: {
|
|
2143
2210
|
display: 'flex',
|
|
2144
2211
|
flexDirection: 'row',
|
|
2145
2212
|
gap: 12,
|
|
2146
2213
|
padding: 1,
|
|
2147
|
-
}, children: [_jsx(
|
|
2214
|
+
}, children: [_jsx(TextInputComponent, { id: "ask_ai_loading_bar", placeholder: baseAst ? 'Ask a follow-up question...' : 'Ask a question...', width: askAILoadingContainerWidth, value: aiPrompt, onChange: () => { } }), _jsx(ButtonComponent, { onClick: () => { }, label: "Ask AI" }), baseAst && (_jsx(SecondaryButtonComponent, { onClick: clearAllState, label: "New report" }))] })), _jsxs(_Fragment, { children: [_jsx(TableComponent, { isLoading: true, rows: [], columns: [] }), _jsxs("div", { style: {
|
|
2148
2215
|
display: 'flex',
|
|
2149
2216
|
flexDirection: 'row',
|
|
2150
2217
|
gap: '12px',
|
|
2151
|
-
}, children: [_jsx("div", { style: { width: '100%' } }), _jsx(
|
|
2218
|
+
}, children: [_jsx("div", { style: { width: '100%' } }), _jsx(SecondaryButtonComponent, { onClick: () => copyToClipboard(activeQuery), label: isCopying ? '✅ Copied' : 'Copy SQL' }), _jsx(ButtonComponent, { label: 'Add to dashboard', onClick: () => { } })] })] })] }), _jsx("style", { children: `body{margin:0;}` })] }));
|
|
2152
2219
|
}
|
|
2153
2220
|
return (_jsxs("div", { ref: parentRef, style: {
|
|
2154
2221
|
display: 'flex',
|
|
@@ -2157,26 +2224,28 @@ export default function ReportBuilder({ initialTableName = '', onAddToDashboardC
|
|
|
2157
2224
|
overflowY: 'auto',
|
|
2158
2225
|
boxSizing: 'border-box',
|
|
2159
2226
|
...containerStyle,
|
|
2160
|
-
}, children: [_jsxs(
|
|
2161
|
-
|
|
2162
|
-
|
|
2163
|
-
|
|
2164
|
-
|
|
2165
|
-
|
|
2166
|
-
|
|
2167
|
-
|
|
2168
|
-
|
|
2169
|
-
|
|
2170
|
-
|
|
2171
|
-
|
|
2172
|
-
|
|
2227
|
+
}, children: [_jsxs(SidebarComponent, { children: [_jsx(SidebarHeadingComponent, { label: "Columns" }), _jsx("div", { style: { height: 4, width: '100%' } }), _jsx(DraggableColumns, {}), _jsx(SecondaryButtonComponent, { onClick: () => {
|
|
2228
|
+
if (!openPopover) {
|
|
2229
|
+
setOpenPopover('AddColumnPopover');
|
|
2230
|
+
}
|
|
2231
|
+
}, label: "Select columns" }), _jsx(PopoverComponent, { isOpen: openPopover === 'AddColumnPopover', setIsOpen: (isOpen) => {
|
|
2232
|
+
if (!isOpen) {
|
|
2233
|
+
// delay onClose callback so onClick no-ops
|
|
2234
|
+
setTimeout(() => {
|
|
2235
|
+
setIsPending(false);
|
|
2236
|
+
setActiveEditItem(null);
|
|
2237
|
+
setActivePath(null);
|
|
2238
|
+
setOpenPopover(null);
|
|
2239
|
+
}, 100);
|
|
2240
|
+
}
|
|
2241
|
+
}, popoverTitle: "Select columns", popoverChildren: _jsx(AddColumnPopover, { onSave: () => {
|
|
2173
2242
|
setActiveEditItem(null);
|
|
2174
2243
|
setActivePath(null);
|
|
2175
2244
|
setOpenPopover(null);
|
|
2176
2245
|
}, orderedColumnNames: orderedColumnNames, setOrderedColumnNames: setOrderedColumnNames, selectedColumns: selectedColumns, setSelectedColumns: setSelectedColumns, isSelectedAllColumns: isSelectedAllColumns, clearAllState: clearAllState, nameToColumn: nameToColumn, baseAst: baseAst, setBaseAst: (ast) => {
|
|
2177
2246
|
setBaseAst(ast);
|
|
2178
2247
|
fetchSqlQuery(ast);
|
|
2179
|
-
}, pivot: pivot, initialTableName: initialTableName, defaultAST: defaultAST, defaultTable: defaultTable, setPivot: setPivot, TextInput:
|
|
2248
|
+
}, pivot: pivot, initialTableName: initialTableName, defaultAST: defaultAST, defaultTable: defaultTable, setPivot: setPivot, TextInput: TextInputComponent, SelectColumn: SelectColumnComponent, SecondaryButton: SecondaryButtonComponent, Button: ButtonComponent }) }), _jsx("div", { style: { height: 28, width: '100%' } }), _jsx(SidebarHeadingComponent, { label: "Filters" }), _jsx("div", { style: { height: 4, width: '100%' } }), formData && (_jsx("div", { style: {
|
|
2180
2249
|
display: 'flex',
|
|
2181
2250
|
flexDirection: 'column',
|
|
2182
2251
|
gap: 8,
|
|
@@ -2186,52 +2255,42 @@ export default function ReportBuilder({ initialTableName = '', onAddToDashboardC
|
|
|
2186
2255
|
flexDirection: 'column',
|
|
2187
2256
|
gap: 2.5,
|
|
2188
2257
|
alignItems: 'flex-start',
|
|
2189
|
-
}, children: [_jsx(
|
|
2190
|
-
|
|
2191
|
-
|
|
2192
|
-
|
|
2193
|
-
|
|
2258
|
+
}, children: [_jsx(SecondaryButtonComponent, { onClick: () => {
|
|
2259
|
+
if (!selectedColumns || selectedColumns.length === 0 || loading) {
|
|
2260
|
+
return;
|
|
2261
|
+
}
|
|
2262
|
+
if (!openPopover) {
|
|
2263
|
+
const value = orderedColumnNames[0];
|
|
2264
|
+
const [_table, column] = value.split('.');
|
|
2265
|
+
const columnType = getColumnTypeByName(column);
|
|
2266
|
+
if (isNumericColumnType(columnType)) {
|
|
2267
|
+
const newSubtree = deepCopy(defaultNumericComparison);
|
|
2268
|
+
newSubtree.left.column = column;
|
|
2269
|
+
setActiveEditItem(newSubtree);
|
|
2194
2270
|
}
|
|
2195
|
-
|
|
2196
|
-
const
|
|
2197
|
-
|
|
2198
|
-
|
|
2199
|
-
if (isNumericColumnType(columnType)) {
|
|
2200
|
-
const newSubtree = deepCopy(defaultNumericComparison);
|
|
2201
|
-
newSubtree.left.column = column;
|
|
2202
|
-
setActiveEditItem(newSubtree);
|
|
2203
|
-
}
|
|
2204
|
-
else {
|
|
2205
|
-
const newSubtree = deepCopy(defaultEntry);
|
|
2206
|
-
newSubtree.left.args.value[0].column = column;
|
|
2207
|
-
setActiveEditItem(newSubtree);
|
|
2208
|
-
}
|
|
2209
|
-
setOpenPopover('AddFilterPopover');
|
|
2210
|
-
setActivePath('');
|
|
2211
|
-
setIsPending(true);
|
|
2271
|
+
else {
|
|
2272
|
+
const newSubtree = deepCopy(defaultEntry);
|
|
2273
|
+
newSubtree.left.args.value[0].column = column;
|
|
2274
|
+
setActiveEditItem(newSubtree);
|
|
2212
2275
|
}
|
|
2213
|
-
|
|
2214
|
-
|
|
2215
|
-
|
|
2216
|
-
|
|
2217
|
-
|
|
2218
|
-
|
|
2219
|
-
|
|
2220
|
-
|
|
2221
|
-
}, 200);
|
|
2222
|
-
}, children: _jsx(AddFilterPopover, { onSave: () => {
|
|
2223
|
-
if (isNodeEmptyCollection(activeEditItem)) {
|
|
2276
|
+
setOpenPopover('AddFilterPopover');
|
|
2277
|
+
setActivePath('');
|
|
2278
|
+
setIsPending(true);
|
|
2279
|
+
}
|
|
2280
|
+
}, label: 'Add filter' }), _jsx(PopoverComponent, { isOpen: openPopover === 'AddFilterPopover', setIsOpen: (isOpen) => {
|
|
2281
|
+
if (!isOpen) {
|
|
2282
|
+
// delay onClose callback so onClick no-ops
|
|
2283
|
+
setTimeout(() => {
|
|
2224
2284
|
setIsPending(false);
|
|
2225
2285
|
setActivePath(null);
|
|
2226
2286
|
setOpenPopover(null);
|
|
2227
2287
|
clearCheckboxes();
|
|
2228
|
-
|
|
2229
|
-
|
|
2230
|
-
|
|
2231
|
-
|
|
2232
|
-
|
|
2288
|
+
setActiveEditItem(null);
|
|
2289
|
+
}, 200);
|
|
2290
|
+
}
|
|
2291
|
+
}, popoverTitle: "Add filter", popoverChildren: _jsx(AddFilterPopover, { onSave: () => {
|
|
2292
|
+
if (isNodeEmptyCollection(activeEditItem)) {
|
|
2233
2293
|
setIsPending(false);
|
|
2234
|
-
handleInsertion(activeEditItem, 'AND', false);
|
|
2235
2294
|
setActivePath(null);
|
|
2236
2295
|
setOpenPopover(null);
|
|
2237
2296
|
clearCheckboxes();
|
|
@@ -2239,45 +2298,57 @@ export default function ReportBuilder({ initialTableName = '', onAddToDashboardC
|
|
|
2239
2298
|
setActiveEditItem(null);
|
|
2240
2299
|
}, 300);
|
|
2241
2300
|
}
|
|
2242
|
-
|
|
2243
|
-
false && ( // temp removed the AddConditionPopover
|
|
2244
|
-
_jsx(Popover, { isOpen: openPopover === 'AddConditionPopover', trigger: _jsx(SecondaryButton, { onClick: () => {
|
|
2245
|
-
if (!openPopover) {
|
|
2246
|
-
setActiveEditItem(deepCopy(defaultEntry));
|
|
2247
|
-
setOpenPopover('AddConditionPopover');
|
|
2248
|
-
setActivePath('');
|
|
2249
|
-
setIsPending(true);
|
|
2250
|
-
}
|
|
2251
|
-
}, label: 'Add condition' }), onClose: () => {
|
|
2252
|
-
// delay onClose callback so onClick no-ops
|
|
2253
|
-
setTimeout(() => {
|
|
2254
|
-
setIsPending(false);
|
|
2255
|
-
setActiveEditItem(null);
|
|
2256
|
-
setActivePath(null);
|
|
2257
|
-
setOpenPopover(null);
|
|
2258
|
-
clearCheckboxes();
|
|
2259
|
-
}, 200);
|
|
2260
|
-
}, children: _jsx(AddConditionPopover, { onSave: () => {
|
|
2261
|
-
if (isNodeEmptyCollection(activeEditItem)) {
|
|
2301
|
+
else {
|
|
2262
2302
|
setIsPending(false);
|
|
2263
|
-
|
|
2264
|
-
setActiveEditItem(null);
|
|
2265
|
-
}, 300);
|
|
2303
|
+
handleInsertion(activeEditItem, 'AND', false);
|
|
2266
2304
|
setActivePath(null);
|
|
2267
2305
|
setOpenPopover(null);
|
|
2268
2306
|
clearCheckboxes();
|
|
2269
|
-
}
|
|
2270
|
-
else {
|
|
2271
|
-
setIsPending(false);
|
|
2272
|
-
handleInsertion(activeEditItem, topLevelBinaryOperator, true);
|
|
2273
2307
|
setTimeout(() => {
|
|
2274
2308
|
setActiveEditItem(null);
|
|
2275
2309
|
}, 300);
|
|
2276
|
-
setActivePath(null);
|
|
2277
|
-
setOpenPopover(null);
|
|
2278
|
-
clearCheckboxes();
|
|
2279
2310
|
}
|
|
2280
|
-
}
|
|
2311
|
+
}, Button: ButtonComponent, renderNode: renderNode, activeEditItem: activeEditItem }) }), baseAst?.where &&
|
|
2312
|
+
false && ( // temp removed the AddConditionPopover
|
|
2313
|
+
_jsxs(_Fragment, { children: [_jsx(SecondaryButtonComponent, { onClick: () => {
|
|
2314
|
+
if (!openPopover) {
|
|
2315
|
+
setActiveEditItem(deepCopy(defaultEntry));
|
|
2316
|
+
setOpenPopover('AddConditionPopover');
|
|
2317
|
+
setActivePath('');
|
|
2318
|
+
setIsPending(true);
|
|
2319
|
+
}
|
|
2320
|
+
}, label: 'Add condition' }), _jsx(PopoverComponent, { isOpen: openPopover === 'AddConditionPopover', setIsOpen: (isOpen) => {
|
|
2321
|
+
if (!isOpen) {
|
|
2322
|
+
// delay onClose callback so onClick no-ops
|
|
2323
|
+
setTimeout(() => {
|
|
2324
|
+
setIsPending(false);
|
|
2325
|
+
setActiveEditItem(null);
|
|
2326
|
+
setActivePath(null);
|
|
2327
|
+
setOpenPopover(null);
|
|
2328
|
+
clearCheckboxes();
|
|
2329
|
+
}, 200);
|
|
2330
|
+
}
|
|
2331
|
+
}, popoverChildren: _jsx(AddConditionPopover, { onSave: () => {
|
|
2332
|
+
if (isNodeEmptyCollection(activeEditItem)) {
|
|
2333
|
+
setIsPending(false);
|
|
2334
|
+
setTimeout(() => {
|
|
2335
|
+
setActiveEditItem(null);
|
|
2336
|
+
}, 300);
|
|
2337
|
+
setActivePath(null);
|
|
2338
|
+
setOpenPopover(null);
|
|
2339
|
+
clearCheckboxes();
|
|
2340
|
+
}
|
|
2341
|
+
else {
|
|
2342
|
+
setIsPending(false);
|
|
2343
|
+
handleInsertion(activeEditItem, topLevelBinaryOperator, true);
|
|
2344
|
+
setTimeout(() => {
|
|
2345
|
+
setActiveEditItem(null);
|
|
2346
|
+
}, 300);
|
|
2347
|
+
setActivePath(null);
|
|
2348
|
+
setOpenPopover(null);
|
|
2349
|
+
clearCheckboxes();
|
|
2350
|
+
}
|
|
2351
|
+
} }) })] }))] }), _jsx("div", { style: { height: 28, width: '100%' } }), _jsx(SidebarHeadingComponent, { label: "Pivot" }), _jsx("div", { style: { height: 4, width: '100%' } }), _jsx(PivotModal, { pivotRowField: pivotRowField, setPivotRowField: setPivotRowField, pivotColumnField: pivotColumnField, setPivotColumnField: setPivotColumnField, pivotValueField: pivotValueField, setPivotValueField: setPivotValueField, pivotAggregation: pivotAggregation, setPivotAggregation: setPivotAggregation, createdPivots: createdPivots, setCreatedPivots: setCreatedPivots, recommendedPivots: recommendedPivots, setRecommendedPivots: setRecommendedPivots, popUpTitle: pivotPopUpTitle, setPopUpTitle: setPivotPopUpTitle, selectedTable: initialTableName, SelectComponent: SelectComponent, ButtonComponent: ButtonComponent, SecondaryButtonComponent: SecondaryButtonComponent, PopoverComponent: PopoverComponent, TextComponent: TextComponent, isOpen: showPivotPopover, setIsOpen: setShowPivotPopover, showUpdatePivot: isEdittingPivot, setShowUpdatePivot: setIsEdittingPivot, parentRef: parentRef, data: rows, columns: processColumnsForChartBuilder(Object.keys(rows[0] ?? {})), triggerButtonText: 'Add pivot', selectedPivotIndex: selectedPivotIndex, setSelectedPivotIndex: setSelectedPivotIndex, removePivot: () => {
|
|
2281
2352
|
setPivot(null);
|
|
2282
2353
|
setPivotData(null);
|
|
2283
2354
|
}, selectPivot: (pivot) => {
|
|
@@ -2293,7 +2364,7 @@ export default function ReportBuilder({ initialTableName = '', onAddToDashboardC
|
|
|
2293
2364
|
setPivot(pivot);
|
|
2294
2365
|
const pivotedData = generatePivotTable(pivot, rows, [null, null, null], false);
|
|
2295
2366
|
setPivotData(pivotedData || []);
|
|
2296
|
-
}, selectPivotOnEdit: true, showTrigger: !pivot, theme: theme, LabelComponent:
|
|
2367
|
+
}, selectPivotOnEdit: true, showTrigger: !pivot, theme: theme, LabelComponent: LabelComponent, HeaderComponent: HeaderComponent, dateRange: [null, null, null], recommendPivotCount: 3 }), pivot && (_jsx(PivotCard, { pivotTable: {
|
|
2297
2368
|
pivot: pivot,
|
|
2298
2369
|
rows: pivotData?.rows || [],
|
|
2299
2370
|
columns: pivotData?.columns || [],
|
|
@@ -2305,11 +2376,11 @@ export default function ReportBuilder({ initialTableName = '', onAddToDashboardC
|
|
|
2305
2376
|
setPivotValueField(pivot?.valueField);
|
|
2306
2377
|
setPivotAggregation(pivot?.aggregationType);
|
|
2307
2378
|
setPivotPopUpTitle('Edit Pivot');
|
|
2308
|
-
}, selectedPivotIndex: -1, onEditPivot: () => { }, ButtonComponent:
|
|
2379
|
+
}, selectedPivotIndex: -1, onEditPivot: () => { }, ButtonComponent: ButtonComponent, HeaderComponent: HeaderComponent, showEdit: false, onClose: () => {
|
|
2309
2380
|
setPivot(null);
|
|
2310
2381
|
setPivotData(null);
|
|
2311
2382
|
setBaseAst(deepCopy(baseAst));
|
|
2312
|
-
}, minHeight: 180, LabelComponent:
|
|
2383
|
+
}, minHeight: 180, LabelComponent: LabelComponent, TextComponent: TextComponent })), _jsx("div", { style: { height: 28, width: '100%' } }), _jsx(SidebarHeadingComponent, { label: "Sort" }), _jsx("div", { style: { height: 4, width: '100%' } }), pivot && pivot.sort && (_jsx("div", { style: {
|
|
2313
2384
|
display: 'flex',
|
|
2314
2385
|
flexDirection: 'column',
|
|
2315
2386
|
gap: 8,
|
|
@@ -2317,7 +2388,7 @@ export default function ReportBuilder({ initialTableName = '', onAddToDashboardC
|
|
|
2317
2388
|
}, children: _jsx(SortSentence, { sortData: {
|
|
2318
2389
|
type: pivot.sortDirection,
|
|
2319
2390
|
expr: { type: 'column_ref', column: pivot.rowField },
|
|
2320
|
-
}, columns: pivot ? [`.${pivot.rowField}`] : selectedColumns, setIsPending: setIsPending, setEditPopoverKey: setEditPopoverKey, setActiveEditItem: setActiveEditItem, setOpenPopover: setOpenPopover, SortPopover:
|
|
2391
|
+
}, columns: pivot ? [`.${pivot.rowField}`] : selectedColumns, setIsPending: setIsPending, setEditPopoverKey: setEditPopoverKey, setActiveEditItem: setActiveEditItem, setActivePath: setActivePath, setOpenPopover: setOpenPopover, SortPopover: SortPopoverComponent, EditPopover: AddSortPopover, handleDelete: () => {
|
|
2321
2392
|
if (pivot) {
|
|
2322
2393
|
setPivot({ ...pivot, sort: false });
|
|
2323
2394
|
const pivotedData = generatePivotTable({ ...pivot, sort: false }, rows, [null, null, null], false);
|
|
@@ -2336,12 +2407,12 @@ export default function ReportBuilder({ initialTableName = '', onAddToDashboardC
|
|
|
2336
2407
|
setOpenPopover(null);
|
|
2337
2408
|
setBaseAst(deepCopy(baseAst));
|
|
2338
2409
|
fetchSqlQuery(deepCopy(baseAst));
|
|
2339
|
-
}, Select:
|
|
2410
|
+
}, Select: SelectComponent, Button: ButtonComponent, SecondaryButton: SecondaryButtonComponent }, `sort-sentence-pivot`) })), baseAst && baseAst.orderby && (_jsx("div", { style: {
|
|
2340
2411
|
display: 'flex',
|
|
2341
2412
|
flexDirection: 'column',
|
|
2342
2413
|
gap: 8,
|
|
2343
2414
|
marginBottom: 12,
|
|
2344
|
-
}, children: baseAst.orderby.map((sortData, id) => (_jsx(SortSentence, { sortData: sortData, columns: selectedColumns, setIsPending: setIsPending, setEditPopoverKey: setEditPopoverKey, setActiveEditItem: setActiveEditItem, setOpenPopover: setOpenPopover, SortPopover:
|
|
2415
|
+
}, children: baseAst.orderby.map((sortData, id) => (_jsx(SortSentence, { sortData: sortData, columns: selectedColumns, setIsPending: setIsPending, setEditPopoverKey: setEditPopoverKey, setActiveEditItem: setActiveEditItem, setActivePath: setActivePath, setOpenPopover: setOpenPopover, SortPopover: SortPopoverComponent, EditPopover: AddSortPopover, handleDelete: () => {
|
|
2345
2416
|
if (pivot) {
|
|
2346
2417
|
setPivot({ ...pivot, sort: false });
|
|
2347
2418
|
return;
|
|
@@ -2378,19 +2449,21 @@ export default function ReportBuilder({ initialTableName = '', onAddToDashboardC
|
|
|
2378
2449
|
setOpenPopover(null);
|
|
2379
2450
|
setBaseAst(deepCopy(newAst));
|
|
2380
2451
|
fetchSqlQuery(deepCopy(newAst));
|
|
2381
|
-
}, Select:
|
|
2382
|
-
|
|
2383
|
-
|
|
2384
|
-
|
|
2385
|
-
|
|
2386
|
-
|
|
2387
|
-
|
|
2388
|
-
|
|
2389
|
-
|
|
2390
|
-
|
|
2391
|
-
|
|
2392
|
-
|
|
2393
|
-
|
|
2452
|
+
}, Select: SelectComponent, Button: ButtonComponent, SecondaryButton: SecondaryButtonComponent }, `sort-sentence-${id}`))) })), _jsx(SecondaryButtonComponent, { onClick: () => {
|
|
2453
|
+
if (!selectedColumns || selectedColumns.length === 0) {
|
|
2454
|
+
return;
|
|
2455
|
+
}
|
|
2456
|
+
if (!openPopover) {
|
|
2457
|
+
setOpenPopover('AddSortPopover');
|
|
2458
|
+
}
|
|
2459
|
+
}, label: 'Add sort' }), _jsx(PopoverComponent, { isOpen: openPopover === 'AddSortPopover', setIsOpen: (isOpen) => {
|
|
2460
|
+
if (!isOpen) {
|
|
2461
|
+
setIsPending(false);
|
|
2462
|
+
setActiveEditItem(null);
|
|
2463
|
+
setActivePath(null);
|
|
2464
|
+
setOpenPopover(null);
|
|
2465
|
+
}
|
|
2466
|
+
}, popoverTitle: "Sort by", popoverChildren: _jsx(AddSortPopover, { columns: pivot ? [`.${pivot.rowField}`] : selectedColumns, Select: SelectComponent, Button: ButtonComponent, SecondaryButton: SecondaryButtonComponent, onSave: (column, direction) => {
|
|
2394
2467
|
if (column === '')
|
|
2395
2468
|
return;
|
|
2396
2469
|
if (pivot) {
|
|
@@ -2414,12 +2487,12 @@ export default function ReportBuilder({ initialTableName = '', onAddToDashboardC
|
|
|
2414
2487
|
setOpenPopover(null);
|
|
2415
2488
|
setBaseAst(deepCopy(newAst));
|
|
2416
2489
|
fetchSqlQuery(deepCopy(newAst));
|
|
2417
|
-
} }) }), _jsx("div", { style: { height: 28, width: '100%' } }), _jsx(
|
|
2490
|
+
} }) }), _jsx("div", { style: { height: 28, width: '100%' } }), _jsx(SidebarHeadingComponent, { label: "Limit" }), _jsx("div", { style: { height: 4, width: '100%' } }), baseAst && baseAst.limit ? (_jsx("div", { style: {
|
|
2418
2491
|
display: 'flex',
|
|
2419
2492
|
flexDirection: 'column',
|
|
2420
2493
|
gap: 8,
|
|
2421
2494
|
marginBottom: 12,
|
|
2422
|
-
}, children: _jsx(LimitSentence, { limit: baseAst.limit, setOpenPopover: setOpenPopover, LimitPopover:
|
|
2495
|
+
}, children: _jsx(LimitSentence, { limit: baseAst.limit, setOpenPopover: setOpenPopover, LimitPopover: LimitPopoverComponent, EditPopover: AddLimitPopover, handleDelete: () => {
|
|
2423
2496
|
const newAst = { ...baseAst };
|
|
2424
2497
|
newAst.limit = null;
|
|
2425
2498
|
setBaseAst(deepCopy(newAst));
|
|
@@ -2438,36 +2511,38 @@ export default function ReportBuilder({ initialTableName = '', onAddToDashboardC
|
|
|
2438
2511
|
setOpenPopover(null);
|
|
2439
2512
|
setBaseAst(deepCopy(newAst));
|
|
2440
2513
|
fetchSqlQuery(deepCopy(newAst));
|
|
2441
|
-
}, TextInput:
|
|
2442
|
-
|
|
2443
|
-
|
|
2444
|
-
|
|
2445
|
-
|
|
2446
|
-
|
|
2447
|
-
|
|
2448
|
-
|
|
2449
|
-
|
|
2450
|
-
|
|
2451
|
-
|
|
2452
|
-
|
|
2453
|
-
|
|
2454
|
-
|
|
2455
|
-
|
|
2456
|
-
|
|
2457
|
-
|
|
2458
|
-
|
|
2459
|
-
|
|
2460
|
-
|
|
2461
|
-
|
|
2462
|
-
|
|
2463
|
-
|
|
2464
|
-
|
|
2465
|
-
|
|
2466
|
-
|
|
2467
|
-
|
|
2468
|
-
|
|
2469
|
-
|
|
2470
|
-
|
|
2514
|
+
}, TextInput: TextInputComponent, Button: ButtonComponent, SecondaryButton: SecondaryButtonComponent }) })) : (_jsxs(_Fragment, { children: [_jsx(SecondaryButtonComponent, { onClick: () => {
|
|
2515
|
+
if (!selectedColumns || selectedColumns.length === 0) {
|
|
2516
|
+
return;
|
|
2517
|
+
}
|
|
2518
|
+
if (!baseAst) {
|
|
2519
|
+
return;
|
|
2520
|
+
}
|
|
2521
|
+
if (!openPopover) {
|
|
2522
|
+
setOpenPopover('AddLimitPopover');
|
|
2523
|
+
}
|
|
2524
|
+
}, label: 'Add limit' }), _jsx(PopoverComponent, { isOpen: openPopover === 'AddLimitPopover', setIsOpen: (isOpen) => {
|
|
2525
|
+
if (!isOpen) {
|
|
2526
|
+
setIsPending(false);
|
|
2527
|
+
setActiveEditItem(null);
|
|
2528
|
+
setActivePath(null);
|
|
2529
|
+
setOpenPopover(null);
|
|
2530
|
+
}
|
|
2531
|
+
}, popoverTitle: "Limit", popoverChildren: _jsx(AddLimitPopover, { TextInput: TextInputComponent, Button: ButtonComponent, SecondaryButton: SecondaryButtonComponent, onSave: (limit) => {
|
|
2532
|
+
const newAst = { ...baseAst };
|
|
2533
|
+
newAst.limit = {
|
|
2534
|
+
seperator: '',
|
|
2535
|
+
value: [
|
|
2536
|
+
{
|
|
2537
|
+
type: 'number',
|
|
2538
|
+
value: Number(limit),
|
|
2539
|
+
},
|
|
2540
|
+
],
|
|
2541
|
+
};
|
|
2542
|
+
setOpenPopover(null);
|
|
2543
|
+
setBaseAst(deepCopy(newAst));
|
|
2544
|
+
fetchSqlQuery(deepCopy(newAst));
|
|
2545
|
+
} }) })] }))] }), _jsxs(ContainerComponent, { children: [isAIEnabled && (_jsxs("form", { ref: askAIContainerRef, onSubmit: (event) => {
|
|
2471
2546
|
event.preventDefault();
|
|
2472
2547
|
handleAsk();
|
|
2473
2548
|
}, style: {
|
|
@@ -2475,14 +2550,14 @@ export default function ReportBuilder({ initialTableName = '', onAddToDashboardC
|
|
|
2475
2550
|
flexDirection: 'row',
|
|
2476
2551
|
gap: 12,
|
|
2477
2552
|
padding: 1,
|
|
2478
|
-
}, children: [_jsx(
|
|
2479
|
-
|
|
2480
|
-
|
|
2481
|
-
|
|
2482
|
-
|
|
2483
|
-
|
|
2484
|
-
|
|
2485
|
-
|
|
2553
|
+
}, children: [_jsx(TextInputComponent, { id: "ask_ai_input_bar", value: aiPrompt, width: askAIInputWidth, onChange: (e) => setAiPrompt(e.target.value), placeholder: baseAst ? 'Ask a follow-up question...' : 'Ask a question...' }), _jsx(ButtonComponent, { onClick: handleAsk, label: 'Ask AI' }), baseAst && (_jsx(SecondaryButtonComponent, { label: 'New report', onClick: clearAllState }))] })), baseAst && (_jsx(TableComponent, { isLoading: loading && errorMessage.length === 0, rows: applyFormatting({
|
|
2554
|
+
rows: pivotData?.rows || rows,
|
|
2555
|
+
fields: pivotData?.fields || fields,
|
|
2556
|
+
}, baseAst?.columns ?? []), columns: pivot
|
|
2557
|
+
? pivotData?.columns || emptyPivotColumns()
|
|
2558
|
+
: enforceOrderOnColumns(Object.keys(rows[0] ?? {})).map((c) => {
|
|
2559
|
+
return { label: snakeCaseToTitleCase(c), field: c };
|
|
2560
|
+
}) })), _jsxs("div", { style: {
|
|
2486
2561
|
display: 'flex',
|
|
2487
2562
|
flexDirection: 'row',
|
|
2488
2563
|
gap: '12px',
|
|
@@ -2491,10 +2566,7 @@ export default function ReportBuilder({ initialTableName = '', onAddToDashboardC
|
|
|
2491
2566
|
fontSize: 14,
|
|
2492
2567
|
padding: '12px',
|
|
2493
2568
|
whiteSpace: 'nowrap',
|
|
2494
|
-
}, children: errorMessage })), _jsx("div", { style: { width: '100%' } }), baseAst && (_jsxs(_Fragment, { children: [_jsx(
|
|
2569
|
+
}, children: errorMessage })), _jsx("div", { style: { width: '100%' } }), baseAst && (_jsxs(_Fragment, { children: [_jsx(SecondaryButtonComponent, { label: isCopying ? '✅ Copied' : 'Copy SQL', onClick: () => copyToClipboard(activeQuery) }), _jsx(ButtonComponent, { onClick: () => {
|
|
2495
2570
|
setIsChartBuilderOpen(true);
|
|
2496
|
-
}, label: 'Add to dashboard' })] }))] })] }), _jsx("style", { children: `body{margin:0;}` }), _jsx(ChartBuilderWithModal, { rows:
|
|
2497
|
-
// TODO: Modal={Modal}
|
|
2498
|
-
// TODO: Popover={Popover}
|
|
2499
|
-
DeleteButton: DeleteButton })] }));
|
|
2571
|
+
}, label: 'Add to dashboard' })] }))] })] }), _jsx("style", { children: `body{margin:0;}` }), _jsx(ChartBuilderWithModal, { rows: rows, columns: processColumnsForChartBuilder(Object.keys(rows[0] ?? {})), fields: fields, pivot: pivot, query: activeQuery, showTableFormatOptions: isAdminEnabled, showDateFieldOptions: isAdminEnabled, showAccessControlOptions: isAdminEnabled, title: "Add to dashboard", isOpen: isChartBuilderOpen, setIsOpen: setIsChartBuilderOpen, onAddToDashboardComplete: onSubmitChartBuilder, destinationDashboard: destinationDashboard, organizationName: organizationName, pivotData: pivotData, SelectComponent: SelectComponent, TextInputComponent: TextInputComponent, ButtonComponent: ButtonComponent, SecondaryButtonComponent: SecondaryButtonComponent, HeaderComponent: HeaderComponent, LabelComponent: LabelComponent, TextComponent: TextComponent, ModalComponent: ModalComponent, PopoverComponent: PopoverComponent, DeleteButtonComponent: DeleteButtonComponent })] }));
|
|
2500
2572
|
}
|