@quillsql/react 2.12.26 → 2.12.27
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 +17 -2
- package/dist/cjs/Chart.d.ts.map +1 -1
- package/dist/cjs/Chart.js +110 -80
- package/dist/cjs/Context.d.ts +1 -0
- package/dist/cjs/Context.d.ts.map +1 -1
- package/dist/cjs/Context.js +17 -2
- package/dist/cjs/Table.d.ts +15 -1
- package/dist/cjs/Table.d.ts.map +1 -1
- package/dist/cjs/Table.js +134 -60
- package/dist/cjs/components/Dashboard/DashboardFilter.d.ts.map +1 -1
- package/dist/cjs/components/Dashboard/DashboardFilter.js +1 -1
- package/dist/cjs/utils/dashboard.d.ts +1 -0
- package/dist/cjs/utils/dashboard.d.ts.map +1 -1
- package/dist/cjs/utils/dashboard.js +20 -1
- package/dist/cjs/utils/filterProcessing.d.ts +2 -0
- package/dist/cjs/utils/filterProcessing.d.ts.map +1 -1
- package/dist/cjs/utils/filterProcessing.js +129 -1
- package/dist/esm/Chart.d.ts +17 -2
- package/dist/esm/Chart.d.ts.map +1 -1
- package/dist/esm/Chart.js +113 -83
- package/dist/esm/Context.d.ts +1 -0
- package/dist/esm/Context.d.ts.map +1 -1
- package/dist/esm/Context.js +16 -1
- package/dist/esm/Table.d.ts +15 -1
- package/dist/esm/Table.d.ts.map +1 -1
- package/dist/esm/Table.js +137 -63
- package/dist/esm/components/Dashboard/DashboardFilter.d.ts.map +1 -1
- package/dist/esm/components/Dashboard/DashboardFilter.js +1 -1
- package/dist/esm/utils/dashboard.d.ts +1 -0
- package/dist/esm/utils/dashboard.d.ts.map +1 -1
- package/dist/esm/utils/dashboard.js +18 -0
- package/dist/esm/utils/filterProcessing.d.ts +2 -0
- package/dist/esm/utils/filterProcessing.d.ts.map +1 -1
- package/dist/esm/utils/filterProcessing.js +126 -0
- package/package.json +1 -1
package/dist/esm/Chart.js
CHANGED
|
@@ -5,7 +5,7 @@ import { useExport } from './hooks/useExport';
|
|
|
5
5
|
import { differenceInHours } from 'date-fns';
|
|
6
6
|
import BarList from './components/Chart/BarList';
|
|
7
7
|
import PieChart from './components/Chart/PieChart';
|
|
8
|
-
import { ClientContext, CustomFieldContext, DashboardContext, DashboardFiltersContext, } from './Context';
|
|
8
|
+
import { ClientContext, CustomFieldContext, DashboardContext, DashboardFiltersContext, ReportFiltersContext, } from './Context';
|
|
9
9
|
import QuillTable from './components/QuillTable';
|
|
10
10
|
import { getData } from './utils/dataFetcher';
|
|
11
11
|
import { DATE_FORMAT_TYPES, valueFormatter } from './utils/valueFormatter';
|
|
@@ -14,12 +14,17 @@ import BarChart from './components/Chart/BarChart';
|
|
|
14
14
|
import { mergeComparisonRange } from './utils/merge';
|
|
15
15
|
import { QuillLoadingSkeleton } from './components/Chart/ChartSkeleton';
|
|
16
16
|
import ChartError from './components/Chart/ChartError';
|
|
17
|
-
import { COMPARISON_OPTIONS } from './DateRangePicker/dateRangePickerUtils';
|
|
17
|
+
import { COMPARISON_OPTIONS, } from './DateRangePicker/dateRangePickerUtils';
|
|
18
18
|
import { quillFormat } from './utils/valueFormatter';
|
|
19
19
|
import useTheme from './hooks/useTheme';
|
|
20
20
|
import { processFilterErrorList } from './utils/errorProcessing';
|
|
21
|
-
import { findAndProcessDateFilter } from './utils/filterProcessing';
|
|
21
|
+
import { findAndProcessDateFilter, processFilterFromBackend, updateFilter, } from './utils/filterProcessing';
|
|
22
22
|
import { cleanDashboardItem } from './utils/dashboard';
|
|
23
|
+
import { QuillFilterContainerComponent, } from './components/UiComponents';
|
|
24
|
+
import { DashboardFilter } from './components/Dashboard/DashboardFilter';
|
|
25
|
+
import { QuillSelectComponent } from './components/QuillSelect';
|
|
26
|
+
import { QuillMultiSelectComponent } from './components/QuillMultiSelect';
|
|
27
|
+
import { QuillDateRangePicker, } from './DateRangePicker/QuillDateRangePicker';
|
|
23
28
|
const MAX_ROWS_FOR_GENERIC_TABLE = 300;
|
|
24
29
|
// @ts-ignore
|
|
25
30
|
function sumByKey(arr, key) {
|
|
@@ -148,17 +153,11 @@ const Chart = (props) => {
|
|
|
148
153
|
? theme.chartColors
|
|
149
154
|
: ['#4E80EE', '#E14F62', '#55B5A6', '#E9A23B', '#6466E9', '#55B685'];
|
|
150
155
|
}, [data.colors]);
|
|
151
|
-
return (_jsx(ChartUpdater, { reportId: data.reportId, className: data.className, containerStyle: data.containerStyle, colors: chartColors, isAnimationActive: data.isAnimationActive, hideXAxis: data.hideXAxis, hideYAxis: data.hideYAxis, hideCartesianGrid: data.hideCartesianGrid, hideHorizontalCartesianGrid: data.hideHorizontalCartesianGrid, hideVerticalCartesianGrid: data.hideVerticalCartesianGrid, hideSubsequentXAxisTicks: data.hideSubsequentXAxisTicks, hideDateRangeFilter: data.hideDateRangeFilter, cartesianGridLineStyle: data.cartesianGridLineStyle, cartesianGridLineColor: data.cartesianGridLineColor, comparisonLineStyle: data.comparisonLineStyle, mapColorsToFields: data.mapColorsToFields ?? fallbackMapColorsToFields, LoadingComponent: data.LoadingComponent, filters: data.filters, onClickChartElement: props.onClickChartElement }));
|
|
156
|
+
return (_jsx(ChartUpdater, { reportId: data.reportId, className: data.className, containerStyle: data.containerStyle, colors: chartColors, isAnimationActive: data.isAnimationActive, hideXAxis: data.hideXAxis, hideYAxis: data.hideYAxis, hideCartesianGrid: data.hideCartesianGrid, hideHorizontalCartesianGrid: data.hideHorizontalCartesianGrid, hideVerticalCartesianGrid: data.hideVerticalCartesianGrid, hideSubsequentXAxisTicks: data.hideSubsequentXAxisTicks, hideDateRangeFilter: data.hideDateRangeFilter, cartesianGridLineStyle: data.cartesianGridLineStyle, cartesianGridLineColor: data.cartesianGridLineColor, comparisonLineStyle: data.comparisonLineStyle, mapColorsToFields: data.mapColorsToFields ?? fallbackMapColorsToFields, LoadingComponent: data.LoadingComponent, filters: data.filters, onClickChartElement: props.onClickChartElement, SelectComponent: data.SelectComponent, MultiSelectComponent: data.MultiSelectComponent, DateRangePickerComponent: data.DateRangePickerComponent, FilterContainerComponent: data.FilterContainerComponent, hideFilters: data.hideFilters }));
|
|
152
157
|
};
|
|
153
|
-
const ChartUpdater = ({ colors, reportId, className, containerStyle, isAnimationActive, hideXAxis, hideYAxis, hideCartesianGrid, hideHorizontalCartesianGrid = false, hideVerticalCartesianGrid = true, hideSubsequentXAxisTicks = false, cartesianGridLineStyle = 'solid', cartesianGridLineColor, comparisonLineStyle, hideDateRangeFilter = false, mapColorsToFields, LoadingComponent = QuillLoadingSkeleton, filters, onClickChartElement, }) => {
|
|
158
|
+
const ChartUpdater = ({ colors, reportId, className, containerStyle, isAnimationActive, hideXAxis, hideYAxis, hideCartesianGrid, hideHorizontalCartesianGrid = false, hideVerticalCartesianGrid = true, hideSubsequentXAxisTicks = false, cartesianGridLineStyle = 'solid', cartesianGridLineColor, comparisonLineStyle, hideDateRangeFilter = false, hideFilters = false, mapColorsToFields, LoadingComponent = QuillLoadingSkeleton, SelectComponent = QuillSelectComponent, MultiSelectComponent = QuillMultiSelectComponent, DateRangePickerComponent = QuillDateRangePicker, FilterContainerComponent = QuillFilterContainerComponent, filters, onClickChartElement, }) => {
|
|
154
159
|
const { dispatch, dashboard } = useContext(DashboardContext);
|
|
155
|
-
const {
|
|
156
|
-
const specificDashboardFilter = useMemo(() => {
|
|
157
|
-
return dashboardFilters.filter((f) => dashboard &&
|
|
158
|
-
dashboard[reportId] &&
|
|
159
|
-
f &&
|
|
160
|
-
f.dashboardName === dashboard[reportId].dashboardName);
|
|
161
|
-
}, [dashboardFilters, dashboard]);
|
|
160
|
+
const { reportFiltersDispatch, reportFilters } = useContext(ReportFiltersContext);
|
|
162
161
|
const [initialLoad, setInitialLoad] = useState(true);
|
|
163
162
|
const [loading, setLoading] = useState(true);
|
|
164
163
|
const [paginating, setPaginating] = useState(false);
|
|
@@ -171,7 +170,10 @@ const ChartUpdater = ({ colors, reportId, className, containerStyle, isAnimation
|
|
|
171
170
|
page: 0,
|
|
172
171
|
});
|
|
173
172
|
const [report, setReport] = useState(undefined);
|
|
173
|
+
const [dateFilter, setDateFilter] = useState(undefined);
|
|
174
|
+
const [chartFilters, setChartFilters] = useState([]);
|
|
174
175
|
const [previousPage, setPreviousPage] = useState(0);
|
|
176
|
+
const [filterUpdateIndex, setFilterUpdateIndex] = useState(-1);
|
|
175
177
|
const theme = useTheme();
|
|
176
178
|
const onPageChange = (page) => {
|
|
177
179
|
if ((previousPage < page.currentPage &&
|
|
@@ -188,10 +190,6 @@ const ChartUpdater = ({ colors, reportId, className, containerStyle, isAnimation
|
|
|
188
190
|
};
|
|
189
191
|
const getChartDataPaginate = async (processing) => {
|
|
190
192
|
setPaginating(true);
|
|
191
|
-
if (!didFiltersChange(dashboard[reportId], specificDashboardFilter)) {
|
|
192
|
-
setPaginating(false);
|
|
193
|
-
return;
|
|
194
|
-
}
|
|
195
193
|
try {
|
|
196
194
|
let updatedProcessing = { ...additionalProcessing, ...processing };
|
|
197
195
|
if (processing && processing.sort) {
|
|
@@ -202,8 +200,8 @@ const ChartUpdater = ({ colors, reportId, className, containerStyle, isAnimation
|
|
|
202
200
|
}
|
|
203
201
|
// Remove extra fields on each filter so we don't confuse the backend.
|
|
204
202
|
const allowDateRange = !hideDateRangeFilter;
|
|
205
|
-
const minimalFilters = Object.values(
|
|
206
|
-
? Object.values(
|
|
203
|
+
const minimalFilters = Object.values(dashboard.filters).length
|
|
204
|
+
? Object.values(chartFilters)
|
|
207
205
|
.filter((f) => allowDateRange || f.filterType !== 'date_range')
|
|
208
206
|
.map((filter) => {
|
|
209
207
|
const newFilter = { ...filter };
|
|
@@ -249,11 +247,6 @@ const ChartUpdater = ({ colors, reportId, className, containerStyle, isAnimation
|
|
|
249
247
|
};
|
|
250
248
|
const cleanedReport = await cleanDashboardItem(dashboardItem, filters);
|
|
251
249
|
setReport(cleanedReport);
|
|
252
|
-
dispatch({
|
|
253
|
-
type: 'UPDATE_DASHBOARD_ITEM',
|
|
254
|
-
id: reportId,
|
|
255
|
-
data: cleanedReport,
|
|
256
|
-
});
|
|
257
250
|
if (mapColorsToFields) {
|
|
258
251
|
setColorMap(mapColorsToFields(cleanedReport, theme));
|
|
259
252
|
}
|
|
@@ -271,85 +264,68 @@ const ChartUpdater = ({ colors, reportId, className, containerStyle, isAnimation
|
|
|
271
264
|
setPaginating(false);
|
|
272
265
|
}
|
|
273
266
|
};
|
|
274
|
-
const getChartData = async (
|
|
275
|
-
setLoading(true);
|
|
276
|
-
if (!didFiltersChange(dashboard[reportId], specificDashboardFilter)) {
|
|
277
|
-
setLoading(false);
|
|
278
|
-
return;
|
|
279
|
-
}
|
|
267
|
+
const getChartData = async (reportFilterInfo) => {
|
|
280
268
|
try {
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
if (!updatedProcessing.page) {
|
|
284
|
-
updatedProcessing.page = {};
|
|
285
|
-
}
|
|
286
|
-
updatedProcessing.page.currentPage = 0;
|
|
287
|
-
}
|
|
288
|
-
// Remove extra fields on each filter so we don't confuse the backend.
|
|
289
|
-
const allowDateRange = !hideDateRangeFilter;
|
|
290
|
-
const minimalFilters = Object.values(specificDashboardFilter).length
|
|
291
|
-
? Object.values(specificDashboardFilter)
|
|
292
|
-
.filter((f) => allowDateRange || f.filterType !== 'date_range')
|
|
293
|
-
.map((filter) => {
|
|
294
|
-
const newFilter = { ...filter };
|
|
295
|
-
if (newFilter.filterType === 'date_range') {
|
|
296
|
-
delete newFilter['field'];
|
|
297
|
-
delete newFilter['options'];
|
|
298
|
-
delete newFilter['selectedValue'];
|
|
299
|
-
}
|
|
300
|
-
return newFilter;
|
|
301
|
-
})
|
|
302
|
-
: [];
|
|
303
|
-
if (filters) {
|
|
304
|
-
minimalFilters.push(...filters);
|
|
269
|
+
if (filterUpdateIndex === reportFilterInfo.updateIndex) {
|
|
270
|
+
return;
|
|
305
271
|
}
|
|
272
|
+
const filters = reportFilterInfo.filters;
|
|
273
|
+
setLoading(true);
|
|
306
274
|
const hostedBody = {
|
|
307
275
|
metadata: {
|
|
308
276
|
dashboardItemId: reportId,
|
|
309
277
|
orgId: client.customerId || '*',
|
|
310
278
|
clientId: client.publicKey,
|
|
311
279
|
task: 'item',
|
|
312
|
-
|
|
313
|
-
|
|
280
|
+
getDefaultDashboardFilters: filters ? false : true,
|
|
281
|
+
databaseType: client?.databaseType,
|
|
314
282
|
customFields,
|
|
315
|
-
|
|
316
|
-
paginateTable: true,
|
|
283
|
+
filters,
|
|
317
284
|
},
|
|
318
285
|
};
|
|
319
286
|
const cloudBody = {
|
|
320
287
|
id: reportId,
|
|
321
|
-
filters: minimalFilters.filter((f) => f.dashboardName === dashboard[reportId].dashboardName),
|
|
322
288
|
};
|
|
323
|
-
|
|
324
|
-
const resp = await getData(client, 'itempost', 'omit', hostedBody, cloudBody);
|
|
289
|
+
const resp = await getData(client, 'itempost', 'same-origin', hostedBody, cloudBody);
|
|
325
290
|
processFilterErrorList(resp);
|
|
326
291
|
if (resp && resp.name !== 'error' && !resp.errorMessage) {
|
|
327
292
|
setIsComparison(!!resp.compareRows?.length);
|
|
328
293
|
if (resp.compareRows) {
|
|
329
294
|
mergeComparisonRange(resp);
|
|
330
295
|
}
|
|
331
|
-
const
|
|
332
|
-
...resp,
|
|
333
|
-
filtersApplied: minimalFilters.filter((f) => f.dashboardName === dashboard[reportId].dashboardName),
|
|
334
|
-
};
|
|
335
|
-
const cleanedReport = await cleanDashboardItem(dashboardItem, filters);
|
|
296
|
+
const cleanedReport = await cleanDashboardItem(resp, filters ? filters : resp.filters);
|
|
336
297
|
if (cleanedReport.chartType === 'table' && cleanedReport.pivot) {
|
|
337
298
|
cleanedReport.columns = cleanedReport.yAxisFields;
|
|
338
299
|
}
|
|
339
300
|
setReport(cleanedReport);
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
301
|
+
let filterArray = filters;
|
|
302
|
+
// THIS SHOULD ONLY BE UNDEFINED ON INITIAL LOAD
|
|
303
|
+
if (!filterArray) {
|
|
304
|
+
filterArray = resp.filters.map((filter) => {
|
|
305
|
+
return processFilterFromBackend(filter, resp.rows);
|
|
306
|
+
});
|
|
307
|
+
reportFiltersDispatch({
|
|
308
|
+
type: 'UPDATE_REPORT_FILTER',
|
|
309
|
+
id: reportId,
|
|
310
|
+
data: {
|
|
311
|
+
filters: filterArray,
|
|
312
|
+
updateIndex: reportFilterInfo.updateIndex,
|
|
313
|
+
},
|
|
314
|
+
});
|
|
315
|
+
}
|
|
316
|
+
const dateFilter = filterArray.find((filter) => {
|
|
317
|
+
return filter.filterType === 'date_range';
|
|
344
318
|
});
|
|
319
|
+
setFilterUpdateIndex(reportFilterInfo.updateIndex);
|
|
320
|
+
setDateFilter(dateFilter);
|
|
321
|
+
setChartFilters(filterArray);
|
|
345
322
|
if (mapColorsToFields) {
|
|
346
|
-
setColorMap(mapColorsToFields(
|
|
323
|
+
setColorMap(mapColorsToFields(resp, theme));
|
|
347
324
|
}
|
|
348
325
|
}
|
|
349
326
|
else {
|
|
350
327
|
setError(resp?.errorMessage);
|
|
351
328
|
}
|
|
352
|
-
setAdditionProcessing(updatedProcessing);
|
|
353
329
|
setLoading(false);
|
|
354
330
|
}
|
|
355
331
|
catch (e) {
|
|
@@ -358,12 +334,60 @@ const ChartUpdater = ({ colors, reportId, className, containerStyle, isAnimation
|
|
|
358
334
|
}
|
|
359
335
|
};
|
|
360
336
|
useEffect(() => {
|
|
337
|
+
// IF WE HAVE THE DATA IN DASHBOARD CONTEXT AND IT IS THE INITIAL LAOD DON'T FETCH DATA
|
|
338
|
+
if (initialLoad && dashboard[reportId]) {
|
|
339
|
+
setInitialLoad(false);
|
|
340
|
+
return;
|
|
341
|
+
}
|
|
342
|
+
setInitialLoad(false);
|
|
343
|
+
let parsedReportFilters = reportFilters[reportId]
|
|
344
|
+
? reportFilters[reportId]
|
|
345
|
+
: { updateIndex: 0 };
|
|
346
|
+
getChartData(parsedReportFilters);
|
|
347
|
+
}, [client.customerId, reportId, reportFilters[reportId]?.updateIndex]);
|
|
348
|
+
useEffect(() => {
|
|
349
|
+
if (!dashboard || !dashboard[reportId]) {
|
|
350
|
+
return;
|
|
351
|
+
}
|
|
361
352
|
setInitialLoad(false);
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
353
|
+
setLoading(false);
|
|
354
|
+
setReport(dashboard[reportId]);
|
|
355
|
+
setChartFilters(dashboard[reportId].filtersApplied);
|
|
356
|
+
const dateFilter = dashboard[reportId].filtersApplied.find((filter) => {
|
|
357
|
+
return filter.filterType === 'date_range';
|
|
358
|
+
});
|
|
359
|
+
setDateFilter(dateFilter);
|
|
360
|
+
}, []);
|
|
361
|
+
return (_jsxs("div", { children: [!hideFilters && (_jsx("div", { style: {
|
|
362
|
+
display: 'flex',
|
|
363
|
+
boxSizing: 'content-box',
|
|
364
|
+
flexDirection: 'row',
|
|
365
|
+
alignItems: 'center',
|
|
366
|
+
}, children: _jsx(FilterContainerComponent, { children: chartFilters.map((filter, index) => (_jsx(DashboardFilter, { filter: filter, onChangeFilter: (filter, value = null, comparison = null) => {
|
|
367
|
+
const updatedFilters = chartFilters.map((f) => {
|
|
368
|
+
if (f.field === filter.field ||
|
|
369
|
+
(f.filterType === 'date_range' &&
|
|
370
|
+
filter.filterType === 'date_range')) {
|
|
371
|
+
return updateFilter(f, value, comparison);
|
|
372
|
+
}
|
|
373
|
+
return f;
|
|
374
|
+
});
|
|
375
|
+
setChartFilters(updatedFilters);
|
|
376
|
+
getChartData({
|
|
377
|
+
filters: updatedFilters,
|
|
378
|
+
updateIndex: filterUpdateIndex + 1,
|
|
379
|
+
});
|
|
380
|
+
reportFiltersDispatch({
|
|
381
|
+
type: 'UPDATE_REPORT_FILTER',
|
|
382
|
+
id: reportId,
|
|
383
|
+
data: {
|
|
384
|
+
filters: updatedFilters,
|
|
385
|
+
updateIndex: filterUpdateIndex + 1,
|
|
386
|
+
},
|
|
387
|
+
});
|
|
388
|
+
}, theme: theme, SelectComponent: SelectComponent, MultiSelectComponent: MultiSelectComponent, DateRangePickerComponent: DateRangePickerComponent }, index))) }) })), _jsx(ChartDisplay, { config: report, reportId: reportId, colors: colors, className: className, containerStyle: containerStyle, hideXAxis: hideXAxis, hideYAxis: hideYAxis, hideCartesianGrid: hideCartesianGrid, hideHorizontalCartesianGrid: hideHorizontalCartesianGrid, hideVerticalCartesianGrid: hideVerticalCartesianGrid, hideSubsequentXAxisTicks: hideSubsequentXAxisTicks, cartesianGridLineStyle: cartesianGridLineStyle, cartesianGridLineColor: cartesianGridLineColor, hideDateRangeFilter: hideDateRangeFilter, comparisonLineStyle: comparisonLineStyle, isAnimationActive: isAnimationActive, isComparison: isComparison, loading: loading || initialLoad, paginating: paginating, error: error, colorMap: colorMap, LoadingComponent: LoadingComponent, onPageChange: onPageChange, onSortChange: onSortChange, onClickChartElement: onClickChartElement, initialDateFilter: dateFilter })] }));
|
|
365
389
|
};
|
|
366
|
-
export const ChartDisplay = ({ reportId, config, colors, className, containerStyle, hideXAxis, hideYAxis, hideCartesianGrid, hideDateRangeFilter = false, hideHorizontalCartesianGrid = false, hideVerticalCartesianGrid = true, hideSubsequentXAxisTicks = false, cartesianGridLineStyle = 'solid', cartesianGridLineColor, comparisonLineStyle, isAnimationActive, loading = false, paginating = false, error = undefined, isComparison = false, colorMap, LoadingComponent = QuillLoadingSkeleton, onPageChange, onSortChange, onClickChartElement, dateBucket, overrideTheme, }) => {
|
|
390
|
+
export const ChartDisplay = ({ reportId, config, colors, className, containerStyle, hideXAxis, hideYAxis, hideCartesianGrid, hideDateRangeFilter = false, hideHorizontalCartesianGrid = false, hideVerticalCartesianGrid = true, hideSubsequentXAxisTicks = false, cartesianGridLineStyle = 'solid', cartesianGridLineColor, comparisonLineStyle, isAnimationActive, loading = false, paginating = false, error = undefined, isComparison = false, colorMap, LoadingComponent = QuillLoadingSkeleton, onPageChange, onSortChange, onClickChartElement, dateBucket, overrideTheme, initialDateFilter, }) => {
|
|
367
391
|
const { dashboardFilters } = useContext(DashboardFiltersContext);
|
|
368
392
|
const specificDashboardFilter = useMemo(() => {
|
|
369
393
|
if (!dashboardFilters) {
|
|
@@ -381,9 +405,14 @@ export const ChartDisplay = ({ reportId, config, colors, className, containerSty
|
|
|
381
405
|
: ['#4E80EE', '#E14F62', '#55B5A6', '#E9A23B', '#6466E9', '#55B685'];
|
|
382
406
|
}, [colors]);
|
|
383
407
|
const rows = config?.pivotRows ?? config?.rows ?? [];
|
|
384
|
-
const
|
|
385
|
-
|
|
386
|
-
|
|
408
|
+
const getDateFilter = () => {
|
|
409
|
+
if (!hideDateRangeFilter) {
|
|
410
|
+
return findAndProcessDateFilter(Object.values(specificDashboardFilter));
|
|
411
|
+
}
|
|
412
|
+
return undefined;
|
|
413
|
+
};
|
|
414
|
+
const [dateFilter, setDateFilter] = useState(initialDateFilter ?? getDateFilter());
|
|
415
|
+
const getYAxisFields = (curDateFilter) => {
|
|
387
416
|
if (config && config.pivot && config.pivot.columnField) {
|
|
388
417
|
return (config?.pivotColumns
|
|
389
418
|
.slice(1)
|
|
@@ -403,8 +432,8 @@ export const ChartDisplay = ({ reportId, config, colors, className, containerSty
|
|
|
403
432
|
}) ?? []);
|
|
404
433
|
}
|
|
405
434
|
else {
|
|
406
|
-
if (
|
|
407
|
-
|
|
435
|
+
if (curDateFilter?.comparison &&
|
|
436
|
+
curDateFilter.comparisonRange.value !== 'NO_COMPARISON') {
|
|
408
437
|
const comparisonYAxisFields = config?.yAxisFields?.map((field) => {
|
|
409
438
|
return {
|
|
410
439
|
...field,
|
|
@@ -421,10 +450,11 @@ export const ChartDisplay = ({ reportId, config, colors, className, containerSty
|
|
|
421
450
|
return config?.pivotColumns ?? config?.yAxisFields ?? [];
|
|
422
451
|
}
|
|
423
452
|
};
|
|
424
|
-
const [yAxisFields, setYAxisFields] = useState(getYAxisFields());
|
|
453
|
+
const [yAxisFields, setYAxisFields] = useState(getYAxisFields(dateFilter ?? getDateFilter()));
|
|
425
454
|
useEffect(() => {
|
|
426
|
-
setYAxisFields(getYAxisFields());
|
|
427
|
-
|
|
455
|
+
setYAxisFields(getYAxisFields(initialDateFilter ?? getDateFilter()));
|
|
456
|
+
setDateFilter(initialDateFilter ?? getDateFilter());
|
|
457
|
+
}, [config, specificDashboardFilter, initialDateFilter]);
|
|
428
458
|
if (error) {
|
|
429
459
|
return _jsx(ChartError, { className: className, containerStyle: containerStyle });
|
|
430
460
|
}
|
package/dist/esm/Context.d.ts
CHANGED
|
@@ -19,6 +19,7 @@ export declare const ReportBuilderQueryContext: React.Context<any>;
|
|
|
19
19
|
export declare const SavedReportsQueryContext: React.Context<any>;
|
|
20
20
|
export declare const DashboardContext: React.Context<any>;
|
|
21
21
|
export declare const DashboardFiltersContext: React.Context<any>;
|
|
22
|
+
export declare const ReportFiltersContext: React.Context<any>;
|
|
22
23
|
export declare const ChartDateFiltersContext: React.Context<any>;
|
|
23
24
|
export declare const useChartDateFilters: () => {
|
|
24
25
|
getChartDateFilterById: (id: string) => any;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Context.d.ts","sourceRoot":"","sources":["../../src/Context.tsx"],"names":[],"mappings":"AAAA,OAAO,KAMN,MAAM,OAAO,CAAC;AAMf,eAAO,MAAM,iBAAiB,oBAAwC,CAAC;AACvE,eAAO,MAAM,aAAa,oBAAwC,CAAC;AACnE,eAAO,MAAM,kBAAkB,oBAAwC,CAAC;AACxE,eAAO,MAAM,cAAc,oBAA0C,CAAC;AACtE,eAAO,MAAM,WAAW,oBAA0C,CAAC;AACnE,eAAO,MAAM,2BAA2B,oBAAuC,CAAC;AAChF,eAAO,MAAM,cAAc,oBAAwC,CAAC;AACpE,eAAO,MAAM,mBAAmB,oBAAwC,CAAC;AACzE,eAAO,MAAM,2BAA2B,oBAGtC,CAAC;AACH,eAAO,MAAM,kBAAkB,oBAAwC,CAAC;AACxE,eAAO,MAAM,YAAY,oBAA0C,CAAC;AACpE,eAAO,MAAM,aAAa,oBAA0C,CAAC;AACrE,eAAO,MAAM,sCAAsC,oBAGjD,CAAC;AACH,eAAO,MAAM,0BAA0B,oBAGrC,C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AwC,CAAC;AACtE,eAAO,MAAM,uBAAuB,oBAAwC,CAAC;AAC7E,eAAO,MAAM,oBAAoB,oBAAwC,CAAC;AAC1E,eAAO,MAAM,uBAAuB,oBAAwC,CAAC;AAE7E,eAAO,MAAM,mBAAmB;iCAKM,MAAM;6BACV,MAAM,cAAc,GAAG;CAQxD,CAAC;AA6DF,eAAO,MAAM,eAAe,qIAWzB,GAAG,mDAkQL,CAAC"}
|
package/dist/esm/Context.js
CHANGED
|
@@ -37,6 +37,7 @@ export const ReportBuilderQueryContext = createContext(['', dummySetter]);
|
|
|
37
37
|
export const SavedReportsQueryContext = createContext(['', dummySetter]);
|
|
38
38
|
export const DashboardContext = createContext([{}, dummySetter]);
|
|
39
39
|
export const DashboardFiltersContext = createContext([[], dummySetter]);
|
|
40
|
+
export const ReportFiltersContext = createContext([{}, dummySetter]);
|
|
40
41
|
export const ChartDateFiltersContext = createContext([{}, dummySetter]);
|
|
41
42
|
export const useChartDateFilters = () => {
|
|
42
43
|
const { chartDateFilters, setChartDateFilters } = useContext(ChartDateFiltersContext);
|
|
@@ -70,6 +71,16 @@ const dashboardReducer = (state, action) => {
|
|
|
70
71
|
return state;
|
|
71
72
|
}
|
|
72
73
|
};
|
|
74
|
+
const reportFiltersReducer = (state, action) => {
|
|
75
|
+
switch (action.type) {
|
|
76
|
+
case 'UPDATE_REPORT_FILTER':
|
|
77
|
+
return { ...state, [action.id]: action.data };
|
|
78
|
+
case 'CLEAR_REPORT_FILTERS':
|
|
79
|
+
return {};
|
|
80
|
+
default:
|
|
81
|
+
return state;
|
|
82
|
+
}
|
|
83
|
+
};
|
|
73
84
|
const dashboardFiltersReducer = (state, action) => {
|
|
74
85
|
switch (action.type) {
|
|
75
86
|
case 'UPDATE_DASHBOARD_FILTER':
|
|
@@ -112,6 +123,7 @@ export const ContextProvider = ({ children, initialTheme, publicKey, environment
|
|
|
112
123
|
const [editVisualizationModalVisible, setEditVisualizationModalVisible] = useState(false);
|
|
113
124
|
const [dashboard, dispatch] = useReducer(dashboardReducer, {});
|
|
114
125
|
const [dashboardFilters, dashboardFiltersDispatch] = useReducer(dashboardFiltersReducer, []);
|
|
126
|
+
const [reportFilters, reportFiltersDispatch] = useReducer(reportFiltersReducer, {});
|
|
115
127
|
const customFieldHelper = async (client) => {
|
|
116
128
|
const customFields = await getCustomFieldInfo(client, 'context');
|
|
117
129
|
setCustomFields(customFields);
|
|
@@ -254,5 +266,8 @@ export const ContextProvider = ({ children, initialTheme, publicKey, environment
|
|
|
254
266
|
], children: _jsx(DashboardContext.Provider, { value: { dashboard, dispatch }, children: _jsx(DashboardFiltersContext.Provider, { value: {
|
|
255
267
|
dashboardFilters,
|
|
256
268
|
dashboardFiltersDispatch,
|
|
257
|
-
}, children:
|
|
269
|
+
}, children: _jsx(ReportFiltersContext.Provider, { value: {
|
|
270
|
+
reportFilters,
|
|
271
|
+
reportFiltersDispatch,
|
|
272
|
+
}, children: children }) }) }) }) }) }) }) }) }) }) }) }) }) }) }) }) }) }) }) }));
|
|
258
273
|
};
|
package/dist/esm/Table.d.ts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
import React from 'react';
|
|
1
|
+
import React, { ReactNode } from 'react';
|
|
2
|
+
import { MultiSelectComponentProps, SelectComponentProps } from './components/UiComponents';
|
|
3
|
+
import { DateRangePickerComponentProps } from './DateRangePicker/QuillDateRangePicker';
|
|
2
4
|
export interface TableColumn {
|
|
3
5
|
label: string;
|
|
4
6
|
field: string;
|
|
@@ -78,6 +80,8 @@ export interface TableProps {
|
|
|
78
80
|
* Whether to show the download csv button.
|
|
79
81
|
*/
|
|
80
82
|
hideCSVDownloadButton?: boolean;
|
|
83
|
+
/** Whether to hide the table filters component, deafulted to true */
|
|
84
|
+
hideFilters?: boolean;
|
|
81
85
|
/**
|
|
82
86
|
* Whether this table component is loading.
|
|
83
87
|
*/
|
|
@@ -90,6 +94,16 @@ export interface TableProps {
|
|
|
90
94
|
* A loading component to show when the table is loading.
|
|
91
95
|
*/
|
|
92
96
|
LoadingComponent?: () => JSX.Element;
|
|
97
|
+
/** A select component prop for the table filters */
|
|
98
|
+
SelectComponent?: (props: SelectComponentProps) => JSX.Element;
|
|
99
|
+
/** A multi select component prop for the table filters */
|
|
100
|
+
MultiSelectComponent?: (props: MultiSelectComponentProps) => JSX.Element;
|
|
101
|
+
/** A date range picker component prop for the table filters */
|
|
102
|
+
DateRangePickerComponent?: (props: DateRangePickerComponentProps) => JSX.Element;
|
|
103
|
+
/** A filter container component component prop for the table filters */
|
|
104
|
+
FilterContainerComponent?: ({ children, }: {
|
|
105
|
+
children: ReactNode;
|
|
106
|
+
}) => JSX.Element;
|
|
93
107
|
/**
|
|
94
108
|
* Styles the top-level container of the Table.
|
|
95
109
|
*
|
package/dist/esm/Table.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Table.d.ts","sourceRoot":"","sources":["../../src/Table.tsx"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"Table.d.ts","sourceRoot":"","sources":["../../src/Table.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EACZ,SAAS,EAKV,MAAM,OAAO,CAAC;AAuBf,OAAO,EACL,yBAAyB,EAEzB,oBAAoB,EACrB,MAAM,2BAA2B,CAAC;AAInC,OAAO,EACL,6BAA6B,EAE9B,MAAM,wCAAwC,CAAC;AAGhD,MAAM,WAAW,WAAW;IAC1B,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;CACf;AAoCD;;GAEG;AACH,MAAM,WAAW,UAAU;IACzB;;;;;;;;OAQG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAElB;;;;;;;;;;;;;;;;;;;;;;OAsBG;IACH,IAAI,CAAC,EAAE;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAA;KAAE,EAAE,CAAC;IAEhC;;;;;;;;;;;;;;;;;;;;;;OAsBG;IACH,OAAO,CAAC,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