@quillsql/react 2.12.53 → 2.13.0

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.
Files changed (139) hide show
  1. package/dist/cjs/Chart.d.ts.map +1 -1
  2. package/dist/cjs/Chart.js +4 -2
  3. package/dist/cjs/ChartBuilder.d.ts +4 -1
  4. package/dist/cjs/ChartBuilder.d.ts.map +1 -1
  5. package/dist/cjs/ChartBuilder.js +9 -9
  6. package/dist/cjs/ChartEditor.d.ts.map +1 -1
  7. package/dist/cjs/ChartEditor.js +47 -24
  8. package/dist/cjs/Context.d.ts +14 -2
  9. package/dist/cjs/Context.d.ts.map +1 -1
  10. package/dist/cjs/Context.js +118 -41
  11. package/dist/cjs/Dashboard.d.ts +4 -1
  12. package/dist/cjs/Dashboard.d.ts.map +1 -1
  13. package/dist/cjs/Dashboard.js +138 -354
  14. package/dist/cjs/DateRangePicker/QuillDateRangePicker.d.ts.map +1 -1
  15. package/dist/cjs/DateRangePicker/QuillDateRangePicker.js +14 -6
  16. package/dist/cjs/ReportBuilder.d.ts.map +1 -1
  17. package/dist/cjs/ReportBuilder.js +13 -7
  18. package/dist/cjs/SQLEditor.d.ts.map +1 -1
  19. package/dist/cjs/SQLEditor.js +6 -5
  20. package/dist/cjs/Table.d.ts.map +1 -1
  21. package/dist/cjs/Table.js +5 -2
  22. package/dist/cjs/components/Dashboard/DashboardFilter.d.ts +2 -1
  23. package/dist/cjs/components/Dashboard/DashboardFilter.d.ts.map +1 -1
  24. package/dist/cjs/components/Dashboard/DashboardFilter.js +7 -7
  25. package/dist/cjs/components/Dashboard/DataLoader.d.ts +6 -4
  26. package/dist/cjs/components/Dashboard/DataLoader.d.ts.map +1 -1
  27. package/dist/cjs/components/Dashboard/DataLoader.js +81 -41
  28. package/dist/cjs/components/Dashboard/TableComponent.d.ts.map +1 -1
  29. package/dist/cjs/components/Dashboard/TableComponent.js +8 -1
  30. package/dist/cjs/components/QuillMultiSelect.js +1 -1
  31. package/dist/cjs/components/QuillMultiSelectWithCombo.js +1 -1
  32. package/dist/cjs/components/QuillSelect.d.ts +1 -1
  33. package/dist/cjs/components/QuillSelect.d.ts.map +1 -1
  34. package/dist/cjs/components/QuillSelect.js +3 -3
  35. package/dist/cjs/components/QuillSelectWithCombo.d.ts +1 -1
  36. package/dist/cjs/components/QuillSelectWithCombo.d.ts.map +1 -1
  37. package/dist/cjs/components/QuillSelectWithCombo.js +3 -3
  38. package/dist/cjs/components/QuillTable.d.ts +1 -1
  39. package/dist/cjs/components/QuillTable.d.ts.map +1 -1
  40. package/dist/cjs/components/QuillTable.js +26 -16
  41. package/dist/cjs/components/ReportBuilder/ui.d.ts +0 -1
  42. package/dist/cjs/components/ReportBuilder/ui.d.ts.map +1 -1
  43. package/dist/cjs/components/ReportBuilder/ui.js +1 -13
  44. package/dist/cjs/components/UiComponents.d.ts +2 -1
  45. package/dist/cjs/components/UiComponents.d.ts.map +1 -1
  46. package/dist/cjs/components/UiComponents.js +3 -3
  47. package/dist/cjs/hooks/useDashboard.d.ts +4 -1
  48. package/dist/cjs/hooks/useDashboard.d.ts.map +1 -1
  49. package/dist/cjs/hooks/useDashboard.js +129 -64
  50. package/dist/cjs/hooks/useExport.d.ts.map +1 -1
  51. package/dist/cjs/hooks/useExport.js +8 -2
  52. package/dist/cjs/hooks/useQuill.d.ts.map +1 -1
  53. package/dist/cjs/hooks/useQuill.js +14 -14
  54. package/dist/cjs/models/Client.d.ts +6 -0
  55. package/dist/cjs/models/Client.d.ts.map +1 -1
  56. package/dist/cjs/models/Dashboard.d.ts +1 -1
  57. package/dist/cjs/models/Dashboard.d.ts.map +1 -1
  58. package/dist/cjs/models/Filter.d.ts +4 -3
  59. package/dist/cjs/models/Filter.d.ts.map +1 -1
  60. package/dist/cjs/models/Filter.js +38 -1
  61. package/dist/cjs/utils/dashboard.d.ts.map +1 -1
  62. package/dist/cjs/utils/dashboard.js +3 -2
  63. package/dist/cjs/utils/paginationProcessing.js +1 -1
  64. package/dist/cjs/utils/report.d.ts +2 -2
  65. package/dist/cjs/utils/report.d.ts.map +1 -1
  66. package/dist/cjs/utils/report.js +6 -5
  67. package/dist/cjs/utils/tableProcessing.d.ts +4 -4
  68. package/dist/cjs/utils/tableProcessing.d.ts.map +1 -1
  69. package/dist/cjs/utils/tableProcessing.js +3 -1
  70. package/dist/esm/Chart.d.ts.map +1 -1
  71. package/dist/esm/Chart.js +4 -2
  72. package/dist/esm/ChartBuilder.d.ts +4 -1
  73. package/dist/esm/ChartBuilder.d.ts.map +1 -1
  74. package/dist/esm/ChartBuilder.js +9 -9
  75. package/dist/esm/ChartEditor.d.ts.map +1 -1
  76. package/dist/esm/ChartEditor.js +48 -25
  77. package/dist/esm/Context.d.ts +14 -2
  78. package/dist/esm/Context.d.ts.map +1 -1
  79. package/dist/esm/Context.js +118 -41
  80. package/dist/esm/Dashboard.d.ts +4 -1
  81. package/dist/esm/Dashboard.d.ts.map +1 -1
  82. package/dist/esm/Dashboard.js +138 -354
  83. package/dist/esm/DateRangePicker/QuillDateRangePicker.d.ts.map +1 -1
  84. package/dist/esm/DateRangePicker/QuillDateRangePicker.js +15 -7
  85. package/dist/esm/ReportBuilder.d.ts.map +1 -1
  86. package/dist/esm/ReportBuilder.js +14 -8
  87. package/dist/esm/SQLEditor.d.ts.map +1 -1
  88. package/dist/esm/SQLEditor.js +6 -5
  89. package/dist/esm/Table.d.ts.map +1 -1
  90. package/dist/esm/Table.js +5 -2
  91. package/dist/esm/components/Dashboard/DashboardFilter.d.ts +2 -1
  92. package/dist/esm/components/Dashboard/DashboardFilter.d.ts.map +1 -1
  93. package/dist/esm/components/Dashboard/DashboardFilter.js +7 -7
  94. package/dist/esm/components/Dashboard/DataLoader.d.ts +6 -4
  95. package/dist/esm/components/Dashboard/DataLoader.d.ts.map +1 -1
  96. package/dist/esm/components/Dashboard/DataLoader.js +83 -43
  97. package/dist/esm/components/Dashboard/TableComponent.d.ts.map +1 -1
  98. package/dist/esm/components/Dashboard/TableComponent.js +8 -1
  99. package/dist/esm/components/QuillMultiSelect.js +1 -1
  100. package/dist/esm/components/QuillMultiSelectWithCombo.js +1 -1
  101. package/dist/esm/components/QuillSelect.d.ts +1 -1
  102. package/dist/esm/components/QuillSelect.d.ts.map +1 -1
  103. package/dist/esm/components/QuillSelect.js +3 -3
  104. package/dist/esm/components/QuillSelectWithCombo.d.ts +1 -1
  105. package/dist/esm/components/QuillSelectWithCombo.d.ts.map +1 -1
  106. package/dist/esm/components/QuillSelectWithCombo.js +3 -3
  107. package/dist/esm/components/QuillTable.d.ts +1 -1
  108. package/dist/esm/components/QuillTable.d.ts.map +1 -1
  109. package/dist/esm/components/QuillTable.js +26 -16
  110. package/dist/esm/components/ReportBuilder/ui.d.ts +0 -1
  111. package/dist/esm/components/ReportBuilder/ui.d.ts.map +1 -1
  112. package/dist/esm/components/ReportBuilder/ui.js +0 -8
  113. package/dist/esm/components/UiComponents.d.ts +2 -1
  114. package/dist/esm/components/UiComponents.d.ts.map +1 -1
  115. package/dist/esm/components/UiComponents.js +3 -3
  116. package/dist/esm/hooks/useDashboard.d.ts +4 -1
  117. package/dist/esm/hooks/useDashboard.d.ts.map +1 -1
  118. package/dist/esm/hooks/useDashboard.js +128 -66
  119. package/dist/esm/hooks/useExport.d.ts.map +1 -1
  120. package/dist/esm/hooks/useExport.js +9 -3
  121. package/dist/esm/hooks/useQuill.d.ts.map +1 -1
  122. package/dist/esm/hooks/useQuill.js +15 -15
  123. package/dist/esm/models/Client.d.ts +6 -0
  124. package/dist/esm/models/Client.d.ts.map +1 -1
  125. package/dist/esm/models/Dashboard.d.ts +1 -1
  126. package/dist/esm/models/Dashboard.d.ts.map +1 -1
  127. package/dist/esm/models/Filter.d.ts +4 -3
  128. package/dist/esm/models/Filter.d.ts.map +1 -1
  129. package/dist/esm/models/Filter.js +36 -0
  130. package/dist/esm/utils/dashboard.d.ts.map +1 -1
  131. package/dist/esm/utils/dashboard.js +3 -2
  132. package/dist/esm/utils/paginationProcessing.js +1 -1
  133. package/dist/esm/utils/report.d.ts +2 -2
  134. package/dist/esm/utils/report.d.ts.map +1 -1
  135. package/dist/esm/utils/report.js +6 -5
  136. package/dist/esm/utils/tableProcessing.d.ts +4 -4
  137. package/dist/esm/utils/tableProcessing.d.ts.map +1 -1
  138. package/dist/esm/utils/tableProcessing.js +3 -1
  139. package/package.json +1 -1
@@ -55,7 +55,7 @@ const TemplateMetricComponent_1 = __importDefault(require("./components/Dashboar
55
55
  const TemplateTableComponent_1 = __importDefault(require("./components/Dashboard/TemplateTableComponent"));
56
56
  const DashboardTemplate_1 = __importDefault(require("./components/Dashboard/DashboardTemplate"));
57
57
  const Filter_2 = require("./models/Filter");
58
- const fast_deep_equal_1 = __importDefault(require("fast-deep-equal"));
58
+ const paginationProcessing_1 = require("./utils/paginationProcessing");
59
59
  const defaultChartContainerStyles = {
60
60
  display: 'flex',
61
61
  width: '100%',
@@ -71,6 +71,15 @@ const charts = (sections, section, sortByOrdering) => sections[section]
71
71
  const tables = (sections, section, sortByOrdering) => sections[section]
72
72
  .filter(({ chartType }) => chartType === 'table')
73
73
  .sort(sortByOrdering);
74
+ const sortByOrdering = (a, b) => {
75
+ if (a.order === undefined && b.order === undefined)
76
+ return 0;
77
+ if (a.order === undefined)
78
+ return 1;
79
+ if (b.order === undefined)
80
+ return -1;
81
+ return a.order - b.order;
82
+ };
74
83
  /**
75
84
  * ### Quill Dashboard
76
85
  *
@@ -102,37 +111,52 @@ const tables = (sections, section, sortByOrdering) => sections[section]
102
111
  * ### API Reference
103
112
  * @see https://docs.quillsql.com/components/dashboard
104
113
  */
105
- function Dashboard({ name, hidden = false, SelectComponent = QuillSelectWithCombo_1.QuillSelectComponentWithCombo, MultiSelectComponent = QuillMultiSelectWithCombo_1.QuillMultiSelectComponentWithCombo, ModalComponent = UiComponents_1.QuillModalComponent, ButtonComponent = UiComponents_1.MemoizedButton, SecondaryButtonComponent = UiComponents_1.MemoizedSecondaryButton, FilterTagComponent = ui_1.QuillFilterPopover, PopoverComponent = UiComponents_1.MemoizedPopover, TextInputComponent = UiComponents_1.QuillTextInput, EmptyDashboardComponent = UiComponents_1.QuillEmptyDashboardComponent, DateRangePickerComponent = QuillDateRangePicker_1.QuillDateRangePicker, MetricComponent = MetricComponent_1.default, ChartComponent = ChartComponent_1.default, TableComponent = TableComponent_1.default, TemplateMetricComponent = TemplateMetricComponent_1.default, TemplateChartComponent = TemplateChartComponent_1.default, TemplateTableComponent = TemplateTableComponent_1.default, DashboardSectionComponent = DashboardSection_1.default, DashboardSectionContainerComponent = DashboardSectionContainer_1.default, FilterContainerComponent = UiComponents_1.QuillFilterContainerComponent, DashboardLoadingComponent = UiComponents_1.QuillLoadingDashboardComponent, ErrorComponent = ChartError_1.QuillChartErrorWithAction, onClickReport, hoverActions, onChangeLoading, hideFilters, hideXAxis = false, hideYAxis = false, hideCartesianGrid = false, comparisonLineStyle = 'solid', containerStyle, className, chartContainerStyle = defaultChartContainerStyles, filters, onClickChartElement, dateBucket, additionalProcessing, hideAdminErrors = true, templateDashboardName, }) {
106
- const { isLoading, data, isDashboardFiltersLoading, dashboardFilters: populatedDashboardFilters, reload, } = (0, useDashboard_1.useDashboard)(name);
107
- const [presetFilters, setPresetFilters] = (0, react_1.useState)(null);
114
+ function Dashboard({ name, hidden = false, SelectComponent = QuillSelectWithCombo_1.QuillSelectComponentWithCombo, MultiSelectComponent = QuillMultiSelectWithCombo_1.QuillMultiSelectComponentWithCombo, ModalComponent = UiComponents_1.QuillModalComponent, ButtonComponent = UiComponents_1.MemoizedButton, SecondaryButtonComponent = UiComponents_1.MemoizedSecondaryButton, FilterTagComponent = ui_1.QuillFilterPopover, PopoverComponent = UiComponents_1.MemoizedPopover, TextInputComponent = UiComponents_1.QuillTextInput, EmptyDashboardComponent = UiComponents_1.QuillEmptyDashboardComponent, DateRangePickerComponent = QuillDateRangePicker_1.QuillDateRangePicker, MetricComponent = MetricComponent_1.default, ChartComponent = ChartComponent_1.default, TableComponent = TableComponent_1.default, TemplateMetricComponent = TemplateMetricComponent_1.default, TemplateChartComponent = TemplateChartComponent_1.default, TemplateTableComponent = TemplateTableComponent_1.default, DashboardSectionComponent = DashboardSection_1.default, DashboardSectionContainerComponent = DashboardSectionContainer_1.default, FilterContainerComponent = UiComponents_1.QuillFilterContainerComponent, DashboardLoadingComponent = UiComponents_1.QuillLoadingDashboardComponent, ErrorComponent = ChartError_1.QuillChartErrorWithAction, onClickReport, hoverActions, onChangeLoading, hideFilters, hideXAxis = false, hideYAxis = false, hideCartesianGrid = false, comparisonLineStyle = 'solid', containerStyle, className, chartContainerStyle = defaultChartContainerStyles,
115
+ // TODO: do something with these custom filters
116
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
117
+ filters, onClickChartElement, dateBucket, additionalProcessing, hideAdminErrors = true, templateDashboardName, pagination = { rowsPerPage: 10, rowsPerRequest: 50 }, }) {
118
+ const { isLoading, data, isDashboardFilterLoading, dashboardFilters: populatedDashboardFilters, reload, } = (0, useDashboard_1.useDashboard)(name);
108
119
  const [client, isClientLoading] = (0, react_1.useContext)(Context_1.ClientContext);
109
120
  const [theme] = (0, react_1.useContext)(Context_1.ThemeContext);
110
- const [initialLoad, setInitialLoad] = (0, react_1.useState)(true);
111
- const [appliedFilters, setAppliedFilters] = (0, react_1.useState)(null);
112
- const { dashboardFilters, dashboardFiltersDispatch } = (0, react_1.useContext)(Context_1.DashboardFiltersContext);
121
+ const { dispatch: dashboardFiltersDispatch } = (0, react_1.useContext)(Context_1.DashboardFiltersContext);
113
122
  const [schemaData] = (0, react_1.useContext)(Context_1.SchemaDataContext);
114
- const [filterSchemaIsLoaded, setFilterSchemaIsLoaded] = (0, react_1.useState)(false);
115
- const [filterSchema, setFilterSchema] = (0, react_1.useState)({ columns: [] }); // Schema to be passed into FilterModal
116
123
  const [fieldValuesMap, setFieldValuesMap] = (0, react_1.useState)({}); // Mapping of unique values per field, used in string filter 'in' and 'not in'
117
124
  const [referencedTables, setReferencedTables] = (0, react_1.useState)([]); // Intersection of tables referenced in the dashboard
118
125
  const [fieldValuesIsLoaded, setFieldValuesIsLoaded] = (0, react_1.useState)(false);
119
126
  const [addFilterPopoverIsOpen, setAddFilterPopoverIsOpen] = (0, react_1.useState)(false);
120
127
  const [filterListIsOpen, setFilterListIsOpen] = (0, react_1.useState)(false);
121
128
  const [filterListAddFilterPopoverIsOpen, setFilterListAddFilterPopoverIsOpen,] = (0, react_1.useState)(false);
122
- const [uniqueCounter, setUniqueCounter] = (0, react_1.useState)(0);
123
- const userFilters = (0, react_1.useMemo)(() => {
124
- return (appliedFilters
125
- ?.map((filter, index) => {
126
- return { filter, index };
127
- })
128
- .filter((filter) => filter.filter.isUserFilter) ?? []);
129
- }, [appliedFilters]);
130
- const adminFilters = (0, react_1.useMemo)(() => {
131
- return appliedFilters?.filter((filter) => !filter.isUserFilter) ?? [];
132
- }, [appliedFilters]);
129
+ const presetOptions = (0, react_1.useMemo)(() => {
130
+ return populatedDashboardFilters?.[0]?.filterType === 'date_range'
131
+ ? populatedDashboardFilters[0].presetRanges?.map((elem) => {
132
+ if (!elem.isStatic) {
133
+ return {
134
+ label: elem.label,
135
+ value: elem.value,
136
+ startDate: dateRangePickerUtils_1.PRIMARY_RANGE[elem.value].start,
137
+ endDate: dateRangePickerUtils_1.PRIMARY_RANGE[elem.value].end,
138
+ };
139
+ }
140
+ return {
141
+ label: elem.label,
142
+ value: elem.value,
143
+ startDate: new Date(elem.startDate),
144
+ endDate: new Date(elem.endDate),
145
+ };
146
+ }) ?? dateRangePickerUtils_1.defaultOptionsV2
147
+ : dateRangePickerUtils_1.defaultOptionsV2;
148
+ }, [populatedDashboardFilters]);
149
+ const [userFilters, setUserFilters] = (0, react_1.useState)({});
150
+ // A filter value can either be a string, an array of strings for a multiselect, or a date range (that could have a comparison range)
151
+ const [filterValues, setFilterValues] = (0, react_1.useState)({});
133
152
  (0, react_1.useEffect)(() => {
153
+ setFilterValues({});
134
154
  reload(name, true);
135
- }, [name, client?.organizationId]);
155
+ }, [client?.organizationId]);
156
+ (0, react_1.useEffect)(() => {
157
+ setFilterValues({});
158
+ reload(name, false);
159
+ }, [name]);
136
160
  const customOperatorOptions = {
137
161
  [Filter_1.FieldTypes.Number]: [
138
162
  Filter_1.NumberOperator.EqualTo,
@@ -160,28 +184,6 @@ function Dashboard({ name, hidden = false, SelectComponent = QuillSelectWithComb
160
184
  Filter_1.NullOperator.IsNull,
161
185
  ],
162
186
  };
163
- (0, react_1.useEffect)(() => {
164
- if (!data)
165
- return;
166
- onDashboardDataChange(data, schemaData.schema);
167
- }, [data, filters, schemaData.schema]);
168
- (0, react_1.useEffect)(() => {
169
- if (isDashboardFiltersLoading)
170
- return;
171
- if (populatedDashboardFilters) {
172
- const newApplied = appliedFilters?.map((filter) => {
173
- if ((filter.options && filter.options.length) ||
174
- filter.isUserFilter) {
175
- return filter;
176
- }
177
- const equivalent = populatedDashboardFilters.find((populatedFilter) => populatedFilter._id === filter._id);
178
- return { ...filter, options: equivalent?.options ?? filter.options };
179
- }) ?? populatedDashboardFilters;
180
- if (!(0, fast_deep_equal_1.default)(appliedFilters, newApplied)) {
181
- setAppliedFilters(newApplied);
182
- }
183
- }
184
- }, [isDashboardFiltersLoading, populatedDashboardFilters]);
185
187
  // Go through all columns in the referenced tables and get the unique values to use in fieldValuesMap
186
188
  (0, react_1.useEffect)(() => {
187
189
  const fetchData = async () => {
@@ -202,24 +204,22 @@ function Dashboard({ name, hidden = false, SelectComponent = QuillSelectWithComb
202
204
  setFieldValuesMap(newFieldValues);
203
205
  setFieldValuesIsLoaded(true);
204
206
  };
205
- fetchData();
207
+ if (data?.customFiltersEnabled) {
208
+ fetchData();
209
+ }
206
210
  }, [referencedTables]);
207
- // Get the relevant information from the dashboard and schema to pass to FilterModal
208
- const updateFilterSchema = (sections, schema) => {
209
- if (!sections || !schema || schema.length === 0) {
210
- return;
211
+ const filterSchema = (0, react_1.useMemo)(() => {
212
+ if (!data?.sections ||
213
+ !schemaData.schema ||
214
+ schemaData.schema.length === 0) {
215
+ return { columns: [] };
211
216
  }
212
- setFilterSchemaIsLoaded(false);
217
+ const sections = data?.sections;
218
+ const schema = schemaData.schema;
213
219
  // find intersection of all referenced tables
214
- const tables = Object.keys(sections)
215
- .map((section) => {
216
- return sections[section].map((chart) => {
217
- return chart.referencedTables;
218
- });
219
- })
220
- .reduce((accumulator, currentArray) => {
221
- return accumulator.concat(currentArray);
222
- }, []);
220
+ const tables = Object.values(sections)
221
+ .flatMap((section) => section.map((chart) => chart.referencedTables))
222
+ .flat();
223
223
  if (tables && tables.length > 0) {
224
224
  let intersection = new Set(tables[0]);
225
225
  for (let i = 1; i < tables.length; ++i) {
@@ -243,292 +243,94 @@ function Dashboard({ name, hidden = false, SelectComponent = QuillSelectWithComb
243
243
  .reduce((accumulator, currentArray) => {
244
244
  return accumulator.concat(currentArray);
245
245
  }, []);
246
- setFilterSchema({ columns });
247
- }
248
- else {
249
- setFilterSchema({ columns: [] });
250
- }
251
- setFilterSchemaIsLoaded(true);
252
- };
253
- const onDashboardDataChange = (resp, schema) => {
254
- // setDashboardSections(resp.sections ?? {});
255
- updateFilterSchema(resp.sections, schema);
256
- const filterArray = [];
257
- if (resp.dateFilter && Object.keys(resp.dateFilter).length) {
258
- let presetsOptions = dateRangePickerUtils_1.defaultOptionsV2;
259
- if (resp.dateFilter.presetRanges) {
260
- presetsOptions = resp.dateFilter.presetRanges.map((elem) => {
261
- if (!elem.isStatic) {
262
- return {
263
- label: elem.label,
264
- value: elem.value,
265
- startDate: dateRangePickerUtils_1.PRIMARY_RANGE[elem.value].start,
266
- endDate: dateRangePickerUtils_1.PRIMARY_RANGE[elem.value].end,
267
- };
268
- }
269
- return {
270
- label: elem.label,
271
- value: elem.value,
272
- startDate: new Date(elem.startDate),
273
- endDate: new Date(elem.endDate),
274
- };
275
- });
276
- }
277
- setPresetFilters(presetsOptions);
278
- // Attempt to find a date filter in the current applied filters
279
- const currentDateFilter = appliedFilters?.find((filter) => filter.filterType === 'date_range');
280
- const key = currentDateFilter?.preset?.value ||
281
- resp.dateFilter?.primaryRange?.value ||
282
- 'LAST_6_MONTHS';
283
- const primaryPreset = presetsOptions.find((option) => {
284
- return option.value === key;
285
- });
286
- const filter = {
287
- startDate: primaryPreset.startDate,
288
- endDate: primaryPreset.endDate,
289
- filterType: 'date_range',
290
- options: presetsOptions.map((elem) => {
291
- return {
292
- label: elem.label,
293
- value: elem.value,
294
- };
295
- }),
296
- field: 'date_range',
297
- label: resp.dateFilter.label,
298
- preset: {
299
- label: primaryPreset.label,
300
- value: primaryPreset.value,
301
- },
302
- dashboardName: name,
303
- };
304
- if (resp.dateFilter.comparison) {
305
- filter.comparison = true;
306
- const compKey = resp.dateFilter.defaultComparisonRange ?? 'PREV_PERIOD';
307
- const range = { start: filter.startDate, end: filter.endDate };
308
- filter.comparisonRange = {
309
- startDate: dateRangePickerUtils_1.COMPARISON_RANGE[compKey](range)?.start,
310
- endDate: dateRangePickerUtils_1.COMPARISON_RANGE[compKey](range)?.end,
311
- value: compKey,
312
- };
313
- }
314
- else {
315
- filter.comparison = false;
316
- }
317
- filterArray.push(filter);
318
- }
319
- // Add string filters to filterArray
320
- if (resp.filters && resp.filters.length) {
321
- Object.values(resp.filters)
322
- .filter((filter) => filter.filterType !== 'date_range')
323
- .forEach((filter) => {
324
- let processedFilter = processFilter(filter);
325
- if (populatedDashboardFilters) {
326
- const equivalent = populatedDashboardFilters.find((populatedFilter) => populatedFilter._id === filter._id);
327
- processedFilter = {
328
- ...processedFilter,
329
- options: equivalent?.options ?? filter.options,
330
- };
331
- }
332
- filterArray.push(processedFilter);
333
- });
334
- }
335
- // Add custom filter to filterArray
336
- if (filters) {
337
- filters.forEach((filter) => {
338
- filterArray.push({
339
- ...filter,
340
- dashboardName: name,
341
- isUserFilter: true,
342
- });
343
- });
344
- }
345
- // remove all that are already present in dashboardSpecificFilters
346
- const dashboardSpecificFilters = dashboardFilters.filter((f) => f.dashboardName === name);
347
- if (!(0, fast_deep_equal_1.default)(dashboardSpecificFilters, filterArray)) {
348
- dashboardFiltersDispatch({
349
- type: 'CLEAR_AND_ADD_DASHBOARD_FILTERS',
350
- data: filterArray,
351
- dashboardName: name,
352
- });
353
- }
354
- if (!(0, fast_deep_equal_1.default)(appliedFilters, filterArray)) {
355
- setAppliedFilters(filterArray);
356
- }
357
- setInitialLoad(false);
358
- };
359
- const handleOnClickDashboardItem = (elem) => {
360
- if (onClickReport) {
361
- onClickReport({ ...elem, _id: elem.id });
362
- }
363
- };
364
- function removeQuotes(str) {
365
- if (str.startsWith('"') && str.endsWith('"')) {
366
- return str.slice(1, -1);
246
+ return { columns };
367
247
  }
368
248
  else {
369
- return str;
370
- }
371
- }
372
- const processFilter = (filter, value = null) => {
373
- //for dateObjects only, since values are arrays for dateObjects
374
- const { ...filterWithoutSelectedValue } = filter; // _ is a throwaway variable
375
- let selectedValue;
376
- let selectedElem;
377
- if (filter.filterType === 'string') {
378
- if (filter.options) {
379
- selectedElem = filter.options.find((elem) => elem[removeQuotes(filter.field)] === value);
380
- }
381
- if (selectedElem) {
382
- selectedValue = selectedElem[removeQuotes(filter.field)];
383
- }
384
- return {
385
- ...filterWithoutSelectedValue,
386
- ...(selectedValue ? { selectedValue } : {}),
387
- dashboardName: name,
388
- };
389
- }
390
- if (filter.filterType === 'date' || filter.filterType === 'date_range') {
391
- return {
392
- startDate: value ? value[0] : filter.startDate,
393
- endDate: value ? value[1] : filter.endDate,
394
- filterType: 'date_range',
395
- label: 'Date',
396
- field: 'date_range',
397
- options: filter.options,
398
- dashboardName: name,
399
- };
249
+ return { columns: [] };
400
250
  }
401
- };
251
+ }, [data?.sections, schemaData.schema]);
252
+ const handleOnClickDashboardItem = (elem) => onClickReport && onClickReport({ ...elem, _id: elem.id });
402
253
  const updateFilter = (filter, value = null, comparison = null) => {
403
- if (!appliedFilters) {
254
+ if (!populatedDashboardFilters)
404
255
  return;
405
- }
406
- //for dateObjects only, since values are arrays for dateObjects
407
- const { ...filterWithoutSelectedValue } = filter; // _ is a throwaway variable
256
+ let filterValue = {};
408
257
  if (filter.filterType === 'string') {
409
- let selectedValue = {};
410
258
  if (filter.stringFilterType === 'multiselect') {
411
259
  if ((value?.length ?? 0) === 0) {
412
- selectedValue = { values: [] };
260
+ filterValue = { values: undefined, operator: undefined };
413
261
  }
414
262
  else {
415
- selectedValue = { values: value, operator: 'IN' };
263
+ filterValue = { values: value, operator: 'IN' };
416
264
  }
417
265
  }
418
266
  else {
419
- selectedValue = { selectedValue: value };
420
- }
421
- const newFilter = {
422
- ...filterWithoutSelectedValue,
423
- ...selectedValue,
424
- dashboardName: name,
425
- stringFilterType: filter.stringFilterType,
426
- table: filter.table,
427
- labelField: filter.labelField,
428
- label: filter.label,
429
- field: filter.field,
430
- filterType: Filter_2.DashboardFilterType.String,
431
- };
432
- dashboardFiltersDispatch({
433
- type: 'UPDATE_DASHBOARD_FILTER',
434
- id: filter.field,
435
- data: newFilter,
436
- });
437
- const index = appliedFilters.findIndex((filter) => filter.field === newFilter.field &&
438
- filter.dashboardName === newFilter.dashboardName);
439
- if (index !== -1) {
440
- setAppliedFilters([
441
- ...appliedFilters.slice(0, index),
442
- newFilter,
443
- ...appliedFilters.slice(index + 1),
444
- ]);
267
+ filterValue = { selectedValue: value };
445
268
  }
446
- return;
269
+ setFilterValues((filterValues) => ({
270
+ ...filterValues,
271
+ [filter.label]: filterValue,
272
+ }));
447
273
  }
448
- if (filter.filterType === Filter_2.DashboardFilterType.Date) {
274
+ else if (filter.filterType === Filter_2.DashboardFilterType.Date) {
449
275
  if (comparison ||
450
- (filter.comparison && filter.comparisonRange.value !== 'NO_COMPARISON')) {
276
+ (filter.comparison &&
277
+ (filter.comparisonRange?.value ?? 'NO_COMPARISON') !==
278
+ 'NO_COMPARISON')) {
451
279
  let preset = '';
452
280
  if (comparison) {
453
- preset = filter.preset.label;
281
+ preset = filter.preset.value;
454
282
  }
455
- const key = comparison?.value || filter.comparisonRange.value;
283
+ const key = comparison?.value ||
284
+ (filter.comparisonRange?.value ?? 'NO_COMPARISON');
456
285
  let primaryRange = {
457
286
  start: value ? value.startDate : filter.startDate,
458
287
  end: value ? value.endDate : filter.endDate,
459
288
  };
460
289
  if (value && value.preset) {
461
290
  preset = value.preset;
462
- primaryRange = (0, dateRangePickerUtils_1.getRangeFromPresetOptions)(value.preset, presetFilters);
291
+ primaryRange = (0, dateRangePickerUtils_1.getRangeFromPresetOptions)(value.preset, presetOptions);
463
292
  }
464
- const newFilter = {
293
+ filterValue = {
465
294
  startDate: primaryRange.start,
466
295
  endDate: primaryRange.end,
467
- filterType: Filter_2.DashboardFilterType.Date,
468
- label: filter.label,
469
- field: 'date_range',
470
- preset: { label: preset, value: preset },
471
- options: filter.options,
472
- comparison: true,
296
+ preset: {
297
+ label: presetOptions.find((o) => o.value === preset)?.label ?? preset,
298
+ value: preset,
299
+ },
473
300
  comparisonRange: {
474
301
  startDate: dateRangePickerUtils_1.COMPARISON_RANGE[key](primaryRange)?.start,
475
302
  endDate: dateRangePickerUtils_1.COMPARISON_RANGE[key](primaryRange)?.end,
476
303
  value: key,
477
304
  },
478
- defaultComparisonRange: filter.defaultComparisonRange,
479
- primaryRange: filter.primaryRange,
480
- dashboardName: name,
481
305
  };
482
- dashboardFiltersDispatch({
483
- type: 'UPDATE_DASHBOARD_FILTER',
484
- id: 'date_range',
485
- data: newFilter,
486
- });
487
- const index = appliedFilters.findIndex((filter) => filter.field === newFilter.field &&
488
- filter.dashboardName === newFilter.dashboardName);
489
- if (index !== -1) {
490
- setAppliedFilters([
491
- ...appliedFilters.slice(0, index),
492
- newFilter,
493
- ...appliedFilters.slice(index + 1),
494
- ]);
495
- }
306
+ setFilterValues((filterValues) => ({
307
+ ...filterValues,
308
+ [filter.label]: filterValue,
309
+ }));
496
310
  }
497
311
  else {
498
312
  const primaryRange = value && value.preset
499
- ? (0, dateRangePickerUtils_1.getRangeFromPresetOptions)(value.preset, presetFilters)
313
+ ? (0, dateRangePickerUtils_1.getRangeFromPresetOptions)(value.preset, presetOptions)
500
314
  : {
501
315
  start: value?.startDate || filter.startDate,
502
316
  end: value?.endDate || filter.endDate,
503
317
  };
504
318
  const preset = value?.preset ? value.preset : '';
505
- const newFilter = {
506
- ...filter,
507
- preset: { label: preset, value: preset },
319
+ filterValue = {
508
320
  startDate: primaryRange.start,
509
321
  endDate: primaryRange.end,
510
- filterType: Filter_2.DashboardFilterType.Date,
511
- field: 'date_range',
512
- options: filter.options,
513
- label: filter.label,
514
- dashboardName: name,
322
+ preset: { label: preset, value: preset },
515
323
  };
516
- dashboardFiltersDispatch({
517
- type: 'UPDATE_DASHBOARD_FILTER',
518
- id: 'date_range',
519
- data: newFilter,
520
- });
521
- const index = appliedFilters.findIndex((filter) => filter.field === newFilter.field &&
522
- filter.dashboardName === newFilter.dashboardName);
523
- if (index !== -1) {
524
- setAppliedFilters([
525
- ...appliedFilters.slice(0, index),
526
- newFilter,
527
- ...appliedFilters.slice(index + 1),
528
- ]);
529
- }
324
+ setFilterValues((filterValues) => ({
325
+ ...filterValues,
326
+ [filter.label]: filterValue,
327
+ }));
530
328
  }
531
329
  }
330
+ reload(name, false, undefined, {
331
+ filters: populatedDashboardFilters.map((f) => filter.label === f.label ? { ...f, ...filterValue } : f),
332
+ editedFilterLabel: filter.label,
333
+ });
532
334
  };
533
335
  // generate the correct filter structure
534
336
  const getUserFilter = (filter, id, existingFilter) => {
@@ -553,34 +355,20 @@ function Dashboard({ name, hidden = false, SelectComponent = QuillSelectWithComb
553
355
  return userFilter;
554
356
  };
555
357
  // new update filter function for user added filters
556
- const updateUserFilter = (filter, id) => {
557
- if (!appliedFilters) {
558
- return;
559
- }
560
- const newFilter = getUserFilter(filter, id);
561
- dashboardFiltersDispatch({
562
- type: 'ADD_DASHBOARD_FILTER',
563
- data: newFilter,
564
- });
565
- setAppliedFilters([...appliedFilters, newFilter]);
358
+ const updateUserFilter = (filter) => {
359
+ setUserFilters((userFilters) => ({
360
+ ...userFilters,
361
+ [filter.field]: filter,
362
+ }));
566
363
  };
567
364
  (0, react_1.useEffect)(() => {
568
- if (onChangeLoading) {
569
- onChangeLoading(isLoading || initialLoad);
365
+ if (onChangeLoading && isLoading) {
366
+ onChangeLoading(isLoading);
570
367
  }
571
- }, [isLoading, initialLoad, onChangeLoading]);
572
- const sortByOrdering = (a, b) => {
573
- if (a.order === undefined && b.order === undefined)
574
- return 0;
575
- if (a.order === undefined)
576
- return 1;
577
- if (b.order === undefined)
578
- return -1;
579
- return a.order - b.order;
580
- };
368
+ }, [isLoading, onChangeLoading]);
581
369
  if (!isLoading &&
582
370
  (Object.keys(data?.sections ?? {}).length === 0 ||
583
- data?.sections?.['']?.length === 0)) {
371
+ Object.values(data?.sections ?? {})[0]?.length === 0)) {
584
372
  return (0, jsx_runtime_1.jsx)(EmptyDashboardComponent, {});
585
373
  }
586
374
  if (hidden || isLoading || isClientLoading || !data?.sections) {
@@ -588,13 +376,18 @@ function Dashboard({ name, hidden = false, SelectComponent = QuillSelectWithComb
588
376
  }
589
377
  return ((0, jsx_runtime_1.jsxs)("div", { className: className, ...(0, styles_1.styleToProps)(containerStyle), children: [data &&
590
378
  data.customFiltersEnabled &&
591
- filterSchemaIsLoaded &&
592
379
  !hideAdminErrors &&
593
380
  !hideFilters &&
594
381
  data &&
595
382
  data.customFiltersEnabled &&
596
383
  filterSchema &&
597
- filterSchema.columns.length === 0 && ((0, jsx_runtime_1.jsx)("div", { style: { marginBottom: 10 }, children: (0, jsx_runtime_1.jsx)(UiComponents_1.QuillErrorMessageComponent, { errorMessage: "Warning: No custom filter options because there are no common views among the charts in the dashboard" }) })), (0, jsx_runtime_1.jsxs)("div", { style: { display: 'flex', flexDirection: 'row', alignItems: 'center' }, children: [!hideFilters && ((0, jsx_runtime_1.jsxs)(FilterContainerComponent, { children: [adminFilters.map((filter, index) => ((0, jsx_runtime_1.jsx)(DashboardFilter_1.DashboardFilter, { filter: filter, onChangeFilter: updateFilter, theme: theme, SelectComponent: SelectComponent, MultiSelectComponent: MultiSelectComponent, DateRangePickerComponent: DateRangePickerComponent, isLoading: isDashboardFiltersLoading }, filter._id ?? index))), (0, jsx_runtime_1.jsxs)("div", { style: {
384
+ filterSchema.columns.length === 0 && ((0, jsx_runtime_1.jsx)("div", { style: { marginBottom: 10 }, children: (0, jsx_runtime_1.jsx)(UiComponents_1.QuillErrorMessageComponent, { errorMessage: "Warning: No custom filter options because there are no common views among the charts in the dashboard" }) })), (0, jsx_runtime_1.jsxs)("div", { style: { display: 'flex', flexDirection: 'row', alignItems: 'center' }, children: [!hideFilters && ((0, jsx_runtime_1.jsxs)(FilterContainerComponent, { children: [(populatedDashboardFilters ?? []).map((filter) => ((0, jsx_runtime_1.jsx)(DashboardFilter_1.DashboardFilter, { filter: {
385
+ ...filter,
386
+ ...(filter.filterType === 'date_range' && {
387
+ options: presetOptions,
388
+ }),
389
+ ...filterValues[filter.label],
390
+ }, onChangeFilter: updateFilter, theme: theme, SelectComponent: SelectComponent, MultiSelectComponent: MultiSelectComponent, DateRangePickerComponent: DateRangePickerComponent, isLoading: isDashboardFilterLoading(filter.label) }, filter.label + name))), (0, jsx_runtime_1.jsxs)("div", { style: {
598
391
  display: 'flex',
599
392
  flexDirection: 'column',
600
393
  }, children: [data && data.customFiltersEnabled && ((0, jsx_runtime_1.jsx)(SecondaryButtonComponent, { onClick: () => {
@@ -604,14 +397,12 @@ function Dashboard({ name, hidden = false, SelectComponent = QuillSelectWithComb
604
397
  }
605
398
  }, label: `Add Filter` })), (0, jsx_runtime_1.jsx)(PopoverComponent, { isOpen: addFilterPopoverIsOpen, setIsOpen: setAddFilterPopoverIsOpen, popoverTitle: "Add Filter", popoverChildren: (0, jsx_runtime_1.jsx)(FilterModal_1.default, { schema: filterSchema, fieldValuesMap: fieldValuesMap, onSubmitFilter: (filter) => {
606
399
  setAddFilterPopoverIsOpen(false);
607
- if (appliedFilters) {
608
- updateUserFilter(filter, appliedFilters.length);
609
- }
610
- }, onDeleteFilter: () => { }, ButtonComponent: ButtonComponent, SelectComponent: SelectComponent, MultiSelectComponent: MultiSelectComponent, TextInputComponent: TextInputComponent }), containerStyle: { position: 'relative', top: 10 } })] }), userFilters.length > 0 && ((0, jsx_runtime_1.jsx)(ModalComponent, { triggerLabel: `Filters${userFilters.length > 0 ? ` (${userFilters.length})` : ''}`, isOpen: filterListIsOpen, setIsOpen: setFilterListIsOpen, title: "Filters", children: (0, jsx_runtime_1.jsxs)("div", { style: {
400
+ updateUserFilter(filter);
401
+ }, onDeleteFilter: () => { }, ButtonComponent: ButtonComponent, SelectComponent: SelectComponent, MultiSelectComponent: MultiSelectComponent, TextInputComponent: TextInputComponent }), containerStyle: { position: 'relative', top: 10 } })] }), Object.values(userFilters).length > 0 && ((0, jsx_runtime_1.jsx)(ModalComponent, { triggerLabel: `Filters${Object.values(userFilters).length > 0 ? ` (${Object.values(userFilters).length})` : ''}`, isOpen: filterListIsOpen, setIsOpen: setFilterListIsOpen, title: "Filters", children: (0, jsx_runtime_1.jsxs)("div", { style: {
611
402
  display: 'flex',
612
403
  flexDirection: 'column',
613
404
  alignItems: 'start',
614
- }, children: [userFilters.map(({ filter, index }) => ((0, jsx_runtime_1.jsx)(ui_1.FilterPopoverWrapper, { schema: filterSchema, filter: {
405
+ }, children: [Object.values(userFilters).map((filter, index) => ((0, jsx_runtime_1.jsx)(ui_1.FilterPopoverWrapper, { schema: filterSchema, filter: {
615
406
  filterType: filter.filterType,
616
407
  fieldType: filter.fieldType,
617
408
  field: filter.field,
@@ -619,31 +410,17 @@ function Dashboard({ name, hidden = false, SelectComponent = QuillSelectWithComb
619
410
  value: filter.value,
620
411
  }, filterLabel: filter ? (0, filterProcessing_1.filterSentence)(filter) : '', index: index, fieldValuesMap: fieldValuesMap, customOperatorOptions: customOperatorOptions, FilterTagComponent: FilterTagComponent, FilterModal: FilterModal_1.default, ButtonComponent: ButtonComponent, SecondaryButtonComponent: SecondaryButtonComponent, SelectComponent: SelectComponent, TextInputComponent: TextInputComponent, MultiSelectComponent: MultiSelectComponent, handleFilterSave: (newFilter) => {
621
412
  const updatedFilter = getUserFilter(newFilter, filter._id, filter);
622
- if (!appliedFilters) {
623
- return;
624
- }
625
413
  dashboardFiltersDispatch({
626
414
  type: 'UPDATE_DASHBOARD_FILTER',
627
415
  id: updatedFilter._id,
628
416
  data: updateFilter,
629
417
  });
630
- setAppliedFilters([
631
- ...appliedFilters.slice(0, index),
632
- updatedFilter,
633
- ...appliedFilters.slice(index + 1),
634
- ]);
635
418
  }, handleFilterDelete: () => {
636
- if (!appliedFilters) {
637
- return;
638
- }
639
- dashboardFiltersDispatch({
640
- type: 'DELETE_DASHBOARD_FILTER',
641
- id: appliedFilters[index]._id,
419
+ setUserFilters((userFilters) => {
420
+ const updatedFilters = { ...userFilters };
421
+ delete updatedFilters[filter.field];
422
+ return updatedFilters;
642
423
  });
643
- setAppliedFilters([
644
- ...appliedFilters.slice(0, index),
645
- ...appliedFilters.slice(index + 1),
646
- ]);
647
424
  }, containerStyle: { width: 300, marginBottom: 10 } }, `userFilter_${index}_${filter ? (0, filterProcessing_1.filterSentence)(filter) : ''}`))), (0, jsx_runtime_1.jsxs)("div", { style: {
648
425
  display: 'flex',
649
426
  flexDirection: 'column',
@@ -654,10 +431,8 @@ function Dashboard({ name, hidden = false, SelectComponent = QuillSelectWithComb
654
431
  }, label: `Add Filter` }), (0, jsx_runtime_1.jsx)(PopoverComponent, { isOpen: filterListAddFilterPopoverIsOpen, setIsOpen: setFilterListAddFilterPopoverIsOpen, popoverTitle: "Add Filter", popoverChildren: (0, jsx_runtime_1.jsx)(FilterModal_1.default, { schema: filterSchema, fieldValuesMap: fieldValuesMap, onSubmitFilter: (filter) => {
655
432
  setFilterListAddFilterPopoverIsOpen(false);
656
433
  setFilterListIsOpen(false);
657
- const id = uniqueCounter;
658
- setUniqueCounter(uniqueCounter + 1);
659
- updateUserFilter(filter, id);
660
- }, onDeleteFilter: () => { }, ButtonComponent: ButtonComponent, SelectComponent: SelectComponent, MultiSelectComponent: MultiSelectComponent, TextInputComponent: TextInputComponent }), containerStyle: { position: 'relative', top: 10 } })] })] }) }))] })), templateDashboardName && ((0, jsx_runtime_1.jsx)(DashboardTemplate_1.default, { name: templateDashboardName, originDashboard: name, client: client, appliedFilters: appliedFilters, ModalComponent: ModalComponent, TemplateChartComponent: TemplateChartComponent, TemplateMetricComponent: TemplateMetricComponent, TemplateTableComponent: TemplateTableComponent, ButtonComponent: SecondaryButtonComponent }))] }), Object.keys(data.sections)
434
+ updateUserFilter(filter);
435
+ }, onDeleteFilter: () => { }, ButtonComponent: ButtonComponent, SelectComponent: SelectComponent, MultiSelectComponent: MultiSelectComponent, TextInputComponent: TextInputComponent }), containerStyle: { position: 'relative', top: 10 } })] })] }) }))] })), templateDashboardName && ((0, jsx_runtime_1.jsx)(DashboardTemplate_1.default, { name: templateDashboardName, originDashboard: name, client: client, appliedFilters: populatedDashboardFilters, ModalComponent: ModalComponent, TemplateChartComponent: TemplateChartComponent, TemplateMetricComponent: TemplateMetricComponent, TemplateTableComponent: TemplateTableComponent, ButtonComponent: SecondaryButtonComponent }))] }), Object.keys(data.sections)
661
436
  .sort(function (a, b) {
662
437
  return a.length - b.length;
663
438
  })
@@ -671,13 +446,19 @@ function Dashboard({ name, hidden = false, SelectComponent = QuillSelectWithComb
671
446
  textAlign: 'left',
672
447
  marginTop: 12,
673
448
  }, children: section })] })), metrics(data.sections, section, sortByOrdering).length > 0 && ((0, jsx_runtime_1.jsx)(DashboardSectionComponent, { section: "metrics", children: metrics(data.sections, section, sortByOrdering).map((item, index) => {
674
- return ((0, jsx_runtime_1.jsx)(DataLoader_1.default, { item: item, filters: appliedFilters, children: ({ isLoading, error, data, }) => ((0, jsx_runtime_1.jsx)(MetricComponent, { error: error, isLoading: isLoading, report: data, onClick: !isLoading && onClickReport
449
+ return ((0, jsx_runtime_1.jsx)(DataLoader_1.default, { item: item, filters: populatedDashboardFilters, additionalProcessing: {
450
+ page: paginationProcessing_1.DEFAULT_PAGINATION,
451
+ last: additionalProcessing?.last,
452
+ }, children: ({ isLoading, error, data, }) => ((0, jsx_runtime_1.jsx)(MetricComponent, { error: error, isLoading: isLoading, report: data, onClick: !isLoading && onClickReport
675
453
  ? () => handleOnClickDashboardItem({
676
454
  ...item,
677
455
  ...data,
678
456
  })
679
- : () => { }, hoverActions: hoverActions }, item.name + '' + index)) }, `${item._id}${index}`));
680
- }) })), charts(data.sections, section, sortByOrdering).length > 0 && ((0, jsx_runtime_1.jsx)(DashboardSectionComponent, { section: "charts", children: charts(data.sections, section, sortByOrdering).map((item, index) => ((0, jsx_runtime_1.jsx)(DataLoader_1.ChartDataLoader, { item: item, dateBucket: dateBucket, additionalProcessing: additionalProcessing, filters: appliedFilters, children: ({ isLoading, data, error, dateBucket, }) => ((0, jsx_runtime_1.jsx)(ChartComponent, { report: data, error: error, onClick: () => {
457
+ : () => { }, hoverActions: hoverActions }, item.name + '' + index)) }, `metric${index}`));
458
+ }) })), charts(data.sections, section, sortByOrdering).length > 0 && ((0, jsx_runtime_1.jsx)(DashboardSectionComponent, { section: "charts", children: charts(data.sections, section, sortByOrdering).map((item, index) => ((0, jsx_runtime_1.jsx)(DataLoader_1.ChartDataLoader, { item: item, dateBucket: dateBucket, additionalProcessing: {
459
+ page: pagination,
460
+ last: additionalProcessing?.last,
461
+ }, filters: populatedDashboardFilters, children: ({ isLoading, data, error, dateBucket, }) => ((0, jsx_runtime_1.jsx)(ChartComponent, { report: data, error: error, onClick: () => {
681
462
  if (!isLoading && onClickReport) {
682
463
  handleOnClickDashboardItem({
683
464
  ...item,
@@ -689,7 +470,10 @@ function Dashboard({ name, hidden = false, SelectComponent = QuillSelectWithComb
689
470
  height: 300,
690
471
  } })) : ((0, jsx_runtime_1.jsx)(Chart_1.ChartDisplay, { reportId: data.id, config: data, loading: isLoading, containerStyle: chartContainerStyle, colors: theme.chartColors?.length
691
472
  ? theme.chartColors
692
- : undefined, scrollable: false, hideXAxis: hideXAxis, hideYAxis: hideYAxis, hideCartesianGrid: hideCartesianGrid, comparisonLineStyle: comparisonLineStyle, onClickChartElement: onClickChartElement })) }, item.name + '' + index)) }, `${item._id}${index}`))) })), tables(data.sections, section, sortByOrdering).length > 0 && ((0, jsx_runtime_1.jsx)(DashboardSectionComponent, { section: "tables", children: tables(data.sections, section, sortByOrdering).map((item, index) => ((0, jsx_runtime_1.jsx)(DataLoader_1.default, { item: item, filters: appliedFilters, children: ({ isLoading, error, onPageChange, onSortChange, data, rowCount, rowCountIsLoading, }) => ((0, jsx_runtime_1.jsx)(TableComponent, { report: data, isLoading: isLoading, error: error, onClick: !isLoading && onClickReport
473
+ : undefined, scrollable: false, hideXAxis: hideXAxis, hideYAxis: hideYAxis, hideCartesianGrid: hideCartesianGrid, comparisonLineStyle: comparisonLineStyle, onClickChartElement: onClickChartElement })) }, item.name + '' + index)) }, `chart${index}`))) })), tables(data.sections, section, sortByOrdering).length > 0 && ((0, jsx_runtime_1.jsx)(DashboardSectionComponent, { section: "tables", children: tables(data.sections, section, sortByOrdering).map((item, index) => ((0, jsx_runtime_1.jsx)(DataLoader_1.default, { item: item, filters: populatedDashboardFilters, additionalProcessing: {
474
+ page: pagination,
475
+ last: additionalProcessing?.last,
476
+ }, children: ({ isLoading, error, onPageChange, onSortChange, data, rowCount, rowCountIsLoading, }) => ((0, jsx_runtime_1.jsx)(TableComponent, { report: data, isLoading: isLoading, error: error, onClick: !isLoading && onClickReport
693
477
  ? () => handleOnClickDashboardItem({
694
478
  ...item,
695
479
  ...data,
@@ -697,7 +481,7 @@ function Dashboard({ name, hidden = false, SelectComponent = QuillSelectWithComb
697
481
  : undefined, hoverActions: hoverActions, rowCount: rowCount ??
698
482
  data?.rowCount ??
699
483
  data?.rows?.length ??
700
- 0, rowCountIsLoading: rowCountIsLoading, onPageChange: (page) => onPageChange(page), onSortChange: (sort) => onSortChange(sort) })) }, `${item._id}${index}`))) }))] }, section + '' + sectionIndex));
484
+ 0, rowCountIsLoading: rowCountIsLoading, onPageChange: (page) => onPageChange(page), onSortChange: (sort) => onSortChange(sort) })) }, `${name}${index}`))) }))] }, section + '' + sectionIndex));
701
485
  })] }));
702
486
  }
703
487
  exports.default = Dashboard;