@qrvey/utils 1.4.0-1 → 1.4.0-2
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/README.md +1 -1
- package/dist/charts/helpers/isSimpleTableChart.js +2 -1
- package/dist/cjs/charts/helpers/isSimpleTableChart.js +2 -1
- package/dist/cjs/column_format/helpers/defineTableChartFormat.js +7 -13
- package/dist/cjs/column_format/helpers/defineXYChartFormat.js +7 -11
- package/dist/cjs/columns/constants/COLUMN_INFO.js +23 -49
- package/dist/cjs/columns/constants/COLUMN_LABEL.js +1 -29
- package/dist/cjs/columns/constants/COLUMN_PROPERTY_INFO.js +3 -8
- package/dist/cjs/columns/constants/COLUMN_PROPERTY_LABEL.js +1 -11
- package/dist/cjs/columns/helpers/getDatasetColumn.js +1 -1
- package/dist/cjs/dates/relative/RelativeStatementAdapter.js +6 -24
- package/dist/cjs/filters/adapters/FDToFlatUI.js +8 -18
- package/dist/cjs/filters/adapters/FDToLogic.js +1 -1
- package/dist/cjs/filters/adapters/FDToUI.js +12 -24
- package/dist/cjs/filters/adapters/UIToFlatUI.js +4 -14
- package/dist/cjs/filters/adapters/UIToOldLogic.js +2 -1
- package/dist/cjs/filters/adapters/adaptFilterValues.js +1 -6
- package/dist/cjs/filters/adapters/flatUIToFD.js +3 -14
- package/dist/cjs/filters/adapters/flatUIToOldLogic.js +15 -49
- package/dist/cjs/filters/adapters/flatUIToUI.js +3 -14
- package/dist/cjs/filters/adapters/logicToFlatUI.js +20 -32
- package/dist/cjs/filters/adapters/transformFilters.js +4 -19
- package/dist/cjs/filters/classes/FilterInputErrorHandler.js +0 -8
- package/dist/cjs/filters/helpers/applyHierarchyForAggFilters.js +2 -11
- package/dist/cjs/filters/helpers/backend/buildExpression.js +2 -1
- package/dist/cjs/filters/helpers/backend/buildFilters.js +2 -1
- package/dist/cjs/filters/helpers/backend/getAggFiltersBySummaryIndex.js +1 -4
- package/dist/cjs/filters/helpers/backend/getLogicByDatasets.js +5 -7
- package/dist/cjs/filters/helpers/backend/getLogicByDatasetsColumns.js +6 -8
- package/dist/cjs/filters/helpers/common/areFiltersEquals.js +3 -2
- package/dist/cjs/filters/helpers/common/excludeFiltersByParams.js +17 -22
- package/dist/cjs/filters/helpers/common/getFilterid.js +9 -8
- package/dist/cjs/filters/helpers/common/getFiltersByDatasetsColumns.js +7 -16
- package/dist/cjs/filters/helpers/common/getFiltersByParams.js +12 -18
- package/dist/cjs/filters/helpers/common/getMergeFiltersSettings.js +4 -3
- package/dist/cjs/filters/helpers/common/getMergeValuesSettings.js +2 -1
- package/dist/cjs/filters/helpers/common/getParamsToGetFilterSettings.js +10 -9
- package/dist/cjs/filters/helpers/common/mergeFilters.js +7 -30
- package/dist/cjs/filters/helpers/common/mergeValues.js +9 -6
- package/dist/cjs/filters/helpers/common/resolveFilterConditions.js +9 -8
- package/dist/cjs/filters/helpers/getAggFiltersFromFilterData.js +1 -1
- package/dist/cjs/filters/helpers/ui/getUIValues.js +14 -12
- package/dist/cjs/filters/helpers/ui/getUpdatedUIFilters.js +1 -1
- package/dist/cjs/filters/helpers/ui/resolveUIFlatFilterByParams.js +5 -4
- package/dist/cjs/filters/helpers/ui/transformFilterValues.js +3 -14
- package/dist/cjs/filters/interfaces/builder/IFilterBuilderSettings.d.ts +2 -0
- package/dist/cjs/filters/services/Filters.api.js +44 -45
- package/dist/cjs/filters/services/UChartApi.js +246 -257
- package/dist/cjs/filters/services/UChartPaginationApi.js +289 -301
- package/dist/cjs/format/duration/durationFormatter.js +7 -12
- package/dist/cjs/format/format.js +8 -7
- package/dist/cjs/format/localization.d.ts +2 -1
- package/dist/cjs/format/localization.js +8 -7
- package/dist/cjs/general/array/addPropertyToArrayOfObjects.js +1 -1
- package/dist/cjs/general/object/getAttribute.js +2 -6
- package/dist/cjs/general/object/mergeDeep.js +3 -2
- package/dist/cjs/globalization/labels/chart_builder/I18N_CHART_BUILDER.js +6 -21
- package/dist/cjs/globalization/service/i18nextBuilder.js +31 -19
- package/dist/cjs/globalization/service/initI18n.js +13 -2
- package/dist/cjs/qrvey/helpers/getCategorizableExpression.js +2 -1
- package/dist/cjs/qrvey/helpers/getDataAnswersByColumn.js +1 -4
- package/dist/cjs/qrvey/helpers/getDropdownAnswers.js +1 -1
- package/dist/cjs/qrvey/helpers/getImageAnswers.js +1 -1
- package/dist/cjs/qrvey/helpers/getImageUploadHasAnalysis.js +1 -1
- package/dist/cjs/qrvey/helpers/getLookupAnswers.js +4 -4
- package/dist/cjs/qrvey/helpers/getLookupDisplays.js +1 -1
- package/dist/cjs/qrvey/helpers/getSlidebarAnswers.js +2 -1
- package/dist/cjs/qrvey/helpers/getYesNoAnswers.js +1 -5
- package/dist/cjs/qrvey/helpers/transformValue.js +2 -1
- package/dist/cjs/services/api/Charts.api.js +3 -9
- package/dist/cjs/services/api/getAllDatasets.api.js +1 -1
- package/dist/cjs/services/api/getAllQrveys.api.js +1 -1
- package/dist/cjs/services/api/getDatasetColumns.api.js +1 -1
- package/dist/cjs/services/api/getDatasetsByIds.api.js +2 -2
- package/dist/cjs/services/api/getModel.api.js +1 -4
- package/dist/cjs/services/helpers/Request.js +16 -5
- package/dist/column_format/helpers/defineTableChartFormat.js +7 -13
- package/dist/column_format/helpers/defineXYChartFormat.js +7 -11
- package/dist/columns/constants/COLUMN_INFO.js +23 -49
- package/dist/columns/constants/COLUMN_LABEL.js +1 -29
- package/dist/columns/constants/COLUMN_PROPERTY_INFO.js +3 -8
- package/dist/columns/constants/COLUMN_PROPERTY_LABEL.js +1 -11
- package/dist/columns/helpers/getDatasetColumn.js +1 -1
- package/dist/dates/relative/RelativeStatementAdapter.js +6 -24
- package/dist/filters/adapters/FDToFlatUI.js +8 -18
- package/dist/filters/adapters/FDToLogic.js +1 -1
- package/dist/filters/adapters/FDToUI.js +12 -24
- package/dist/filters/adapters/UIToFlatUI.js +4 -14
- package/dist/filters/adapters/UIToOldLogic.js +2 -1
- package/dist/filters/adapters/adaptFilterValues.js +1 -6
- package/dist/filters/adapters/flatUIToFD.js +3 -14
- package/dist/filters/adapters/flatUIToOldLogic.js +15 -49
- package/dist/filters/adapters/flatUIToUI.js +3 -14
- package/dist/filters/adapters/logicToFlatUI.js +20 -32
- package/dist/filters/adapters/transformFilters.js +4 -19
- package/dist/filters/classes/FilterInputErrorHandler.js +0 -8
- package/dist/filters/helpers/applyHierarchyForAggFilters.js +2 -11
- package/dist/filters/helpers/backend/buildExpression.js +2 -1
- package/dist/filters/helpers/backend/buildFilters.js +2 -1
- package/dist/filters/helpers/backend/getAggFiltersBySummaryIndex.js +1 -4
- package/dist/filters/helpers/backend/getLogicByDatasets.js +5 -7
- package/dist/filters/helpers/backend/getLogicByDatasetsColumns.js +6 -8
- package/dist/filters/helpers/common/areFiltersEquals.js +3 -2
- package/dist/filters/helpers/common/excludeFiltersByParams.js +17 -22
- package/dist/filters/helpers/common/getFilterid.js +9 -8
- package/dist/filters/helpers/common/getFiltersByDatasetsColumns.js +7 -16
- package/dist/filters/helpers/common/getFiltersByParams.js +12 -18
- package/dist/filters/helpers/common/getMergeFiltersSettings.js +4 -3
- package/dist/filters/helpers/common/getMergeValuesSettings.js +2 -1
- package/dist/filters/helpers/common/getParamsToGetFilterSettings.js +10 -9
- package/dist/filters/helpers/common/mergeFilters.js +7 -30
- package/dist/filters/helpers/common/mergeValues.js +9 -6
- package/dist/filters/helpers/common/resolveFilterConditions.js +9 -8
- package/dist/filters/helpers/getAggFiltersFromFilterData.js +1 -1
- package/dist/filters/helpers/ui/getUIValues.js +14 -12
- package/dist/filters/helpers/ui/getUpdatedUIFilters.js +1 -1
- package/dist/filters/helpers/ui/resolveUIFlatFilterByParams.js +5 -4
- package/dist/filters/helpers/ui/transformFilterValues.js +3 -14
- package/dist/filters/interfaces/builder/IFilterBuilderSettings.d.ts +2 -0
- package/dist/filters/services/Filters.api.js +44 -45
- package/dist/filters/services/UChartApi.js +246 -257
- package/dist/filters/services/UChartPaginationApi.js +289 -301
- package/dist/format/duration/durationFormatter.js +7 -12
- package/dist/format/format.js +8 -7
- package/dist/format/localization.d.ts +2 -1
- package/dist/format/localization.js +7 -6
- package/dist/general/array/addPropertyToArrayOfObjects.js +1 -1
- package/dist/general/object/getAttribute.js +2 -6
- package/dist/general/object/mergeDeep.js +3 -2
- package/dist/globalization/labels/chart_builder/I18N_CHART_BUILDER.js +6 -21
- package/dist/globalization/service/i18nextBuilder.js +31 -19
- package/dist/globalization/service/initI18n.js +13 -2
- package/dist/qrvey/helpers/getCategorizableExpression.js +2 -1
- package/dist/qrvey/helpers/getDataAnswersByColumn.js +1 -4
- package/dist/qrvey/helpers/getDropdownAnswers.js +1 -1
- package/dist/qrvey/helpers/getImageAnswers.js +1 -1
- package/dist/qrvey/helpers/getImageUploadHasAnalysis.js +1 -1
- package/dist/qrvey/helpers/getLookupAnswers.js +4 -4
- package/dist/qrvey/helpers/getLookupDisplays.js +1 -1
- package/dist/qrvey/helpers/getSlidebarAnswers.js +2 -1
- package/dist/qrvey/helpers/getYesNoAnswers.js +1 -5
- package/dist/qrvey/helpers/transformValue.js +2 -1
- package/dist/services/api/Charts.api.js +3 -9
- package/dist/services/api/getAllDatasets.api.js +1 -1
- package/dist/services/api/getAllQrveys.api.js +1 -1
- package/dist/services/api/getDatasetColumns.api.js +1 -1
- package/dist/services/api/getDatasetsByIds.api.js +2 -2
- package/dist/services/api/getModel.api.js +1 -4
- package/dist/services/helpers/Request.js +16 -5
- package/package.json +3 -3
|
@@ -13,313 +13,301 @@ import { cloneDeep } from "../../general/object/cloneDeep";
|
|
|
13
13
|
import { FILTER_VALIDATOR } from "../constants/common/FILTER_VALIDATOR";
|
|
14
14
|
import { flatUIToOldLogic } from "../adapters/flatUIToOldLogic";
|
|
15
15
|
export default class UChartPaginationApi {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
return customChartApi
|
|
44
|
-
.getResultsPagination(requestBody, false)
|
|
45
|
-
.then((response) => {
|
|
46
|
-
return this._getDataFromResponse(response, uFilter);
|
|
47
|
-
})
|
|
48
|
-
.catch((_) => {
|
|
49
|
-
return { data: [], total: 0 };
|
|
50
|
-
});
|
|
51
|
-
};
|
|
52
|
-
/**
|
|
53
|
-
* Gets request body structure
|
|
54
|
-
* @param uFilter The filter Builder filter
|
|
55
|
-
* @param filterLogic Additional filter logic to apply in the preview
|
|
56
|
-
* @param chartSettings The settings of the chart. For Aggregate Columns.
|
|
57
|
-
* @returns the request body structure
|
|
58
|
-
*/
|
|
59
|
-
_getPreviewRequestBody = (uFilter, filterLogic = [], chartSettings, afterKey) => {
|
|
60
|
-
const { column, validator } = uFilter;
|
|
61
|
-
const haveAggFilters = (chartSettings?.aggregateColumns || []).length &&
|
|
62
|
-
(chartSettings?.chart || []).length;
|
|
63
|
-
let searchLogic;
|
|
64
|
-
if (!isEmpty(uFilter.values)) {
|
|
65
|
-
searchLogic = flatUIToOldLogic([
|
|
66
|
-
{
|
|
67
|
-
...uFilter,
|
|
68
|
-
validator: this._getValidationType(column, validator),
|
|
69
|
-
column: { ...uFilter.column, linkid: undefined },
|
|
70
|
-
},
|
|
71
|
-
]);
|
|
72
|
-
}
|
|
73
|
-
let filterCharts = [];
|
|
74
|
-
if (haveAggFilters) {
|
|
75
|
-
filterCharts = chartSettings?.chart
|
|
76
|
-
.map((chart) => {
|
|
77
|
-
const summaryIndex = (chart.summaries || []).findIndex((s) => s.questionid === uFilter.column.id &&
|
|
78
|
-
s.aggregate === uFilter.column.aggregate);
|
|
79
|
-
const summary = summaryIndex !== -1 && chart.summaries[summaryIndex];
|
|
80
|
-
const chartAggFilters = getAggFiltersBySummaryIndex(chart.aggFilters, summaryIndex);
|
|
81
|
-
const searchAggFilters = getAggFilters(searchLogic?.logic || [], summary ? [summary] : []);
|
|
82
|
-
return {
|
|
83
|
-
...chart,
|
|
84
|
-
aggFilters: searchAggFilters || chartAggFilters,
|
|
85
|
-
summaries: summary ? [summary] : [],
|
|
86
|
-
};
|
|
16
|
+
constructor() {
|
|
17
|
+
/**
|
|
18
|
+
* Gets afterKey object
|
|
19
|
+
* @returns the afterKey object
|
|
20
|
+
*/
|
|
21
|
+
this.getAfterKey = () => {
|
|
22
|
+
return this.afterKey;
|
|
23
|
+
};
|
|
24
|
+
/**
|
|
25
|
+
* Gets a promise with a resulting data
|
|
26
|
+
* @param config the config
|
|
27
|
+
* @param uFilter The filter Builder filter
|
|
28
|
+
* @param filterLogic Additional filter logic to apply in the preview
|
|
29
|
+
* @param chartSettings The settings of the chart. For Aggregate Columns.
|
|
30
|
+
* @returns a promise with a resulting data
|
|
31
|
+
*/
|
|
32
|
+
this.getChartResult = (config, uFilter, filterLogic = [], chartSettings, resetApi = false) => {
|
|
33
|
+
this.refineAfterkey(uFilter, resetApi);
|
|
34
|
+
this.setProps(uFilter);
|
|
35
|
+
const requestBody = this._getPreviewRequestBody(uFilter, filterLogic, chartSettings, this.afterKey);
|
|
36
|
+
const customChartApi = new ChartsApi(Object.assign(Object.assign({}, config), { qrvey_id: isEmpty(uFilter.column.aggregate)
|
|
37
|
+
? uFilter.column.qrveyid
|
|
38
|
+
: chartSettings === null || chartSettings === void 0 ? void 0 : chartSettings.qrveyid }));
|
|
39
|
+
return customChartApi
|
|
40
|
+
.getResultsPagination(requestBody, false)
|
|
41
|
+
.then((response) => {
|
|
42
|
+
return this._getDataFromResponse(response, uFilter);
|
|
87
43
|
})
|
|
88
|
-
.
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
? this._getDimensionsBody(uFilter)
|
|
92
|
-
: this._getDimensionsBodyAdapter(filterCharts[0].dimensions);
|
|
93
|
-
const summaries = !filterCharts[0]
|
|
94
|
-
? this._getSummariesBody(uFilter)
|
|
95
|
-
: filterCharts[0].summaries;
|
|
96
|
-
const maxDataPoints = this._getMaxDataPoints(column, chartSettings);
|
|
97
|
-
const filters = [
|
|
98
|
-
...filterLogic,
|
|
99
|
-
...(!filterCharts[0] ? searchLogic?.logic || [] : []),
|
|
100
|
-
];
|
|
101
|
-
return { dimensions, summaries, maxDataPoints, afterKey, logic: filters };
|
|
102
|
-
};
|
|
103
|
-
/**
|
|
104
|
-
* Gets dimension body structure
|
|
105
|
-
* @param uFilter The filter Builder filter
|
|
106
|
-
* @returns the dimension body structure
|
|
107
|
-
*/
|
|
108
|
-
_getDimensionsBody = (uFilter) => {
|
|
109
|
-
const { column, validator } = uFilter;
|
|
110
|
-
let dimensions;
|
|
111
|
-
if (!isRangeValidator(validator)) {
|
|
112
|
-
dimensions = [
|
|
113
|
-
{
|
|
114
|
-
questionid: column.id,
|
|
115
|
-
type: column.type,
|
|
116
|
-
formulaType: column.type === COLUMN.FORMULA ? column.formulaType : undefined,
|
|
117
|
-
sort: this._getSortOption(column),
|
|
118
|
-
},
|
|
119
|
-
];
|
|
120
|
-
dimensions = this._refineBodies([...dimensions], uFilter);
|
|
121
|
-
}
|
|
122
|
-
return dimensions;
|
|
123
|
-
};
|
|
124
|
-
/**
|
|
125
|
-
* Get a dimension body structure foor pagination endpoint
|
|
126
|
-
* @param dimensions
|
|
127
|
-
* @returns the dimension body structure
|
|
128
|
-
*/
|
|
129
|
-
_getDimensionsBodyAdapter = (dimensions = []) => {
|
|
130
|
-
return dimensions.map((dimension) => ({
|
|
131
|
-
questionid: dimension.questionid,
|
|
132
|
-
type: dimension.type,
|
|
133
|
-
formulaType: dimension.type === COLUMN.FORMULA ? dimension.formulaType : undefined,
|
|
134
|
-
groupType: dimension.groupType,
|
|
135
|
-
groupValue: dimension.groupValue,
|
|
136
|
-
sort: {
|
|
137
|
-
by: _get(dimension, "sortOption.sortBy", "VALUE"),
|
|
138
|
-
direction: _get(dimension, "sortOption.sortDirection", "DESC"),
|
|
139
|
-
},
|
|
140
|
-
}));
|
|
141
|
-
};
|
|
142
|
-
/**
|
|
143
|
-
* Gets max data point number
|
|
144
|
-
* @param column The column to filter
|
|
145
|
-
* @param chartSettings The settings of the chart. For Aggregate Columns.
|
|
146
|
-
* @returns max data point number
|
|
147
|
-
*/
|
|
148
|
-
_getMaxDataPoints = (column, chartSettings) => {
|
|
149
|
-
return !isDateColumn(column) && !isEmpty(column.aggregate)
|
|
150
|
-
? _get(chartSettings, "maxDataPoints.option", 1000)
|
|
151
|
-
: 1000;
|
|
152
|
-
};
|
|
153
|
-
/**
|
|
154
|
-
* Gets sort option structure
|
|
155
|
-
* @param column The column to filter
|
|
156
|
-
* @returns sort option structure
|
|
157
|
-
*/
|
|
158
|
-
_getSortOption = (column) => {
|
|
159
|
-
let by = "CATEGORY";
|
|
160
|
-
let direction = isNumericalColumn(column) ? "DESC" : "ASC";
|
|
161
|
-
if (!isEmpty(column.sorting)) {
|
|
162
|
-
by = _get(column.sorting, "sortBy");
|
|
163
|
-
direction = _get(column.sorting, "order");
|
|
164
|
-
if (by == null)
|
|
165
|
-
by = "VALUE";
|
|
166
|
-
if (direction == null)
|
|
167
|
-
direction = "DESC";
|
|
168
|
-
}
|
|
169
|
-
return { by, direction };
|
|
170
|
-
};
|
|
171
|
-
/**
|
|
172
|
-
* Gets summaries body structure
|
|
173
|
-
* @param uFilter The filter Builder filter
|
|
174
|
-
* @returns summaries body structure
|
|
175
|
-
*/
|
|
176
|
-
_getSummariesBody = (uFilter) => {
|
|
177
|
-
const { column, validator } = uFilter;
|
|
178
|
-
const summary = {
|
|
179
|
-
aggregate: _get(column, "aggregate.label", AGGREGATE.COUNT),
|
|
180
|
-
questionid: column.id,
|
|
181
|
-
property: !isDateColumn(uFilter.column) ? uFilter.property : undefined,
|
|
182
|
-
type: column.type,
|
|
44
|
+
.catch((_) => {
|
|
45
|
+
return { data: [], total: 0 };
|
|
46
|
+
});
|
|
183
47
|
};
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
48
|
+
/**
|
|
49
|
+
* Gets request body structure
|
|
50
|
+
* @param uFilter The filter Builder filter
|
|
51
|
+
* @param filterLogic Additional filter logic to apply in the preview
|
|
52
|
+
* @param chartSettings The settings of the chart. For Aggregate Columns.
|
|
53
|
+
* @returns the request body structure
|
|
54
|
+
*/
|
|
55
|
+
this._getPreviewRequestBody = (uFilter, filterLogic = [], chartSettings, afterKey) => {
|
|
56
|
+
const { column, validator } = uFilter;
|
|
57
|
+
const haveAggFilters = ((chartSettings === null || chartSettings === void 0 ? void 0 : chartSettings.aggregateColumns) || []).length &&
|
|
58
|
+
((chartSettings === null || chartSettings === void 0 ? void 0 : chartSettings.chart) || []).length;
|
|
59
|
+
let searchLogic;
|
|
60
|
+
if (!isEmpty(uFilter.values)) {
|
|
61
|
+
searchLogic = flatUIToOldLogic([
|
|
62
|
+
Object.assign(Object.assign({}, uFilter), { validator: this._getValidationType(column, validator), column: Object.assign(Object.assign({}, uFilter.column), { linkid: undefined }) }),
|
|
63
|
+
]);
|
|
64
|
+
}
|
|
65
|
+
let filterCharts = [];
|
|
66
|
+
if (haveAggFilters) {
|
|
67
|
+
filterCharts = chartSettings === null || chartSettings === void 0 ? void 0 : chartSettings.chart.map((chart) => {
|
|
68
|
+
const summaryIndex = (chart.summaries || []).findIndex((s) => s.questionid === uFilter.column.id &&
|
|
69
|
+
s.aggregate === uFilter.column.aggregate);
|
|
70
|
+
const summary = summaryIndex !== -1 && chart.summaries[summaryIndex];
|
|
71
|
+
const chartAggFilters = getAggFiltersBySummaryIndex(chart.aggFilters, summaryIndex);
|
|
72
|
+
const searchAggFilters = getAggFilters((searchLogic === null || searchLogic === void 0 ? void 0 : searchLogic.logic) || [], summary ? [summary] : []);
|
|
73
|
+
return Object.assign(Object.assign({}, chart), { aggFilters: searchAggFilters || chartAggFilters, summaries: summary ? [summary] : [] });
|
|
74
|
+
}).filter((chart) => chart.summaries.length);
|
|
75
|
+
}
|
|
76
|
+
const dimensions = !filterCharts[0]
|
|
77
|
+
? this._getDimensionsBody(uFilter)
|
|
78
|
+
: this._getDimensionsBodyAdapter(filterCharts[0].dimensions);
|
|
79
|
+
const summaries = !filterCharts[0]
|
|
80
|
+
? this._getSummariesBody(uFilter)
|
|
81
|
+
: filterCharts[0].summaries;
|
|
82
|
+
const maxDataPoints = this._getMaxDataPoints(column, chartSettings);
|
|
83
|
+
const filters = [
|
|
84
|
+
...filterLogic,
|
|
85
|
+
...(!filterCharts[0] ? (searchLogic === null || searchLogic === void 0 ? void 0 : searchLogic.logic) || [] : []),
|
|
189
86
|
];
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
}
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
87
|
+
return { dimensions, summaries, maxDataPoints, afterKey, logic: filters };
|
|
88
|
+
};
|
|
89
|
+
/**
|
|
90
|
+
* Gets dimension body structure
|
|
91
|
+
* @param uFilter The filter Builder filter
|
|
92
|
+
* @returns the dimension body structure
|
|
93
|
+
*/
|
|
94
|
+
this._getDimensionsBody = (uFilter) => {
|
|
95
|
+
const { column, validator } = uFilter;
|
|
96
|
+
let dimensions;
|
|
97
|
+
if (!isRangeValidator(validator)) {
|
|
98
|
+
dimensions = [
|
|
99
|
+
{
|
|
100
|
+
questionid: column.id,
|
|
101
|
+
type: column.type,
|
|
102
|
+
formulaType: column.type === COLUMN.FORMULA ? column.formulaType : undefined,
|
|
103
|
+
sort: this._getSortOption(column),
|
|
104
|
+
},
|
|
105
|
+
];
|
|
106
|
+
dimensions = this._refineBodies([...dimensions], uFilter);
|
|
107
|
+
}
|
|
108
|
+
return dimensions;
|
|
109
|
+
};
|
|
110
|
+
/**
|
|
111
|
+
* Get a dimension body structure foor pagination endpoint
|
|
112
|
+
* @param dimensions
|
|
113
|
+
* @returns the dimension body structure
|
|
114
|
+
*/
|
|
115
|
+
this._getDimensionsBodyAdapter = (dimensions = []) => {
|
|
116
|
+
return dimensions.map((dimension) => ({
|
|
117
|
+
questionid: dimension.questionid,
|
|
118
|
+
type: dimension.type,
|
|
119
|
+
formulaType: dimension.type === COLUMN.FORMULA ? dimension.formulaType : undefined,
|
|
120
|
+
groupType: dimension.groupType,
|
|
121
|
+
groupValue: dimension.groupValue,
|
|
122
|
+
sort: {
|
|
123
|
+
by: _get(dimension, "sortOption.sortBy", "VALUE"),
|
|
124
|
+
direction: _get(dimension, "sortOption.sortDirection", "DESC"),
|
|
125
|
+
},
|
|
126
|
+
}));
|
|
127
|
+
};
|
|
128
|
+
/**
|
|
129
|
+
* Gets max data point number
|
|
130
|
+
* @param column The column to filter
|
|
131
|
+
* @param chartSettings The settings of the chart. For Aggregate Columns.
|
|
132
|
+
* @returns max data point number
|
|
133
|
+
*/
|
|
134
|
+
this._getMaxDataPoints = (column, chartSettings) => {
|
|
135
|
+
return !isDateColumn(column) && !isEmpty(column.aggregate)
|
|
136
|
+
? _get(chartSettings, "maxDataPoints.option", 1000)
|
|
137
|
+
: 1000;
|
|
138
|
+
};
|
|
139
|
+
/**
|
|
140
|
+
* Gets sort option structure
|
|
141
|
+
* @param column The column to filter
|
|
142
|
+
* @returns sort option structure
|
|
143
|
+
*/
|
|
144
|
+
this._getSortOption = (column) => {
|
|
145
|
+
let by = "CATEGORY";
|
|
146
|
+
let direction = isNumericalColumn(column) ? "DESC" : "ASC";
|
|
147
|
+
if (!isEmpty(column.sorting)) {
|
|
148
|
+
by = _get(column.sorting, "sortBy");
|
|
149
|
+
direction = _get(column.sorting, "order");
|
|
150
|
+
if (by == null)
|
|
151
|
+
by = "VALUE";
|
|
152
|
+
if (direction == null)
|
|
153
|
+
direction = "DESC";
|
|
154
|
+
}
|
|
155
|
+
return { by, direction };
|
|
156
|
+
};
|
|
157
|
+
/**
|
|
158
|
+
* Gets summaries body structure
|
|
159
|
+
* @param uFilter The filter Builder filter
|
|
160
|
+
* @returns summaries body structure
|
|
161
|
+
*/
|
|
162
|
+
this._getSummariesBody = (uFilter) => {
|
|
163
|
+
const { column, validator } = uFilter;
|
|
164
|
+
const summary = {
|
|
165
|
+
aggregate: _get(column, "aggregate.label", AGGREGATE.COUNT),
|
|
166
|
+
questionid: column.id,
|
|
167
|
+
property: !isDateColumn(uFilter.column) ? uFilter.property : undefined,
|
|
168
|
+
type: column.type,
|
|
169
|
+
};
|
|
170
|
+
let summaries = [summary];
|
|
171
|
+
if (isNumericalColumn(column) || isRangeValidator(validator)) {
|
|
172
|
+
summaries = [
|
|
173
|
+
Object.assign(Object.assign({}, summary), { aggregate: AGGREGATE.MIN }),
|
|
174
|
+
Object.assign(Object.assign({}, summary), { aggregate: AGGREGATE.MAX }),
|
|
175
|
+
];
|
|
233
176
|
}
|
|
234
|
-
|
|
235
|
-
|
|
177
|
+
return summaries;
|
|
178
|
+
};
|
|
179
|
+
/**
|
|
180
|
+
* Refines the body structure
|
|
181
|
+
* @param bodies The body structure
|
|
182
|
+
* @param uFilter The filter Builder filter
|
|
183
|
+
* @returns the body structure
|
|
184
|
+
*/
|
|
185
|
+
this._refineBodies = (bodies, uFilter) => {
|
|
186
|
+
const _bodies = cloneDeep(bodies);
|
|
187
|
+
if (uFilter.property != null) {
|
|
188
|
+
_bodies.forEach((body) => {
|
|
189
|
+
if (isDateColumn(uFilter.column)) {
|
|
190
|
+
body["groupType"] = "DATE";
|
|
191
|
+
body["groupValue"] = uFilter.property.toUpperCase();
|
|
192
|
+
}
|
|
193
|
+
else {
|
|
194
|
+
body["property"] = uFilter.property;
|
|
195
|
+
}
|
|
196
|
+
});
|
|
236
197
|
}
|
|
237
|
-
|
|
238
|
-
|
|
198
|
+
return _bodies;
|
|
199
|
+
};
|
|
200
|
+
/**
|
|
201
|
+
* Gets the validation type for the preview request
|
|
202
|
+
* @param column The column to filter
|
|
203
|
+
* @param vaildator Validator Type
|
|
204
|
+
* @returns the validator type for the preview request
|
|
205
|
+
*/
|
|
206
|
+
this._getValidationType = (column, validator) => {
|
|
207
|
+
if (isDateColumn(column) ||
|
|
208
|
+
column.type === COLUMN.BUCKET ||
|
|
209
|
+
isNumericalColumn(column)) {
|
|
210
|
+
return FILTER_VALIDATOR.EQUALS;
|
|
239
211
|
}
|
|
240
212
|
else {
|
|
241
|
-
|
|
213
|
+
if ([
|
|
214
|
+
FILTER_VALIDATOR.NOT_CONTAIN,
|
|
215
|
+
FILTER_VALIDATOR.EQUALS,
|
|
216
|
+
FILTER_VALIDATOR.NOT_EQUAL,
|
|
217
|
+
].includes(validator)) {
|
|
218
|
+
return FILTER_VALIDATOR.CONTAINS;
|
|
219
|
+
}
|
|
220
|
+
else if (validator === FILTER_VALIDATOR.NOT_END_WITH) {
|
|
221
|
+
return FILTER_VALIDATOR.ENDS_WITH;
|
|
222
|
+
}
|
|
223
|
+
else if (validator === FILTER_VALIDATOR.NOT_START_WITH) {
|
|
224
|
+
return FILTER_VALIDATOR.STARTS_WITH;
|
|
225
|
+
}
|
|
226
|
+
else {
|
|
227
|
+
return validator;
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
};
|
|
231
|
+
/**
|
|
232
|
+
* Gets the Data from preview Response
|
|
233
|
+
* @param response The preview presponse
|
|
234
|
+
* @param uFilter The filter Builder filter
|
|
235
|
+
* @returns The resulting data
|
|
236
|
+
*/
|
|
237
|
+
this._getDataFromResponse = (response, uFilter) => {
|
|
238
|
+
var _a;
|
|
239
|
+
const data = { data: [], total: 0 };
|
|
240
|
+
if (!this.isResultPaginationEmpty(response)) {
|
|
241
|
+
const records = _get(response, "data");
|
|
242
|
+
data.data = isEmpty(uFilter.column.aggregate)
|
|
243
|
+
? records.map((record) => ({
|
|
244
|
+
value: record.key.toString(),
|
|
245
|
+
}))
|
|
246
|
+
: this._getResponseSummaries(records);
|
|
247
|
+
data.data = getUniqueArray(data.data, "value");
|
|
248
|
+
data.total = (_a = _get(response, "totalGroups", 0)) !== null && _a !== void 0 ? _a : 0;
|
|
249
|
+
this.setAfterKey(_get(response, "afterKey"));
|
|
242
250
|
}
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
this.uFilter = cloneDeep(uFilter);
|
|
306
|
-
};
|
|
307
|
-
/**
|
|
308
|
-
* Checks if two filter columns are the same.
|
|
309
|
-
* @param column1
|
|
310
|
-
* @param column2
|
|
311
|
-
* @returns True: Columns are equal; False: Columns are not equal
|
|
312
|
-
*/
|
|
313
|
-
areColumnsEquals = (column1, column2) => {
|
|
314
|
-
if (isEmpty(column1) || isEmpty(column2))
|
|
315
|
-
return false;
|
|
316
|
-
return (column1.id === column2.id &&
|
|
317
|
-
column1.qrveyid === column2.qrveyid &&
|
|
318
|
-
column1.property === column2.property &&
|
|
319
|
-
column1.aggregate === column2.aggregate);
|
|
320
|
-
};
|
|
321
|
-
isResultPaginationEmpty = (resultObject) => {
|
|
322
|
-
const result = _get(resultObject, "data");
|
|
323
|
-
return isEmpty(result);
|
|
324
|
-
};
|
|
251
|
+
return data;
|
|
252
|
+
};
|
|
253
|
+
/**
|
|
254
|
+
* Gets summaries from preview response
|
|
255
|
+
* @param records The data from preview response
|
|
256
|
+
* @param values The values from the preview response
|
|
257
|
+
* @returns the sumaries
|
|
258
|
+
*/
|
|
259
|
+
this._getResponseSummaries = (records, values = []) => {
|
|
260
|
+
records.forEach((record) => {
|
|
261
|
+
const value = record.summaries[0].toString();
|
|
262
|
+
value && values.push({ value });
|
|
263
|
+
});
|
|
264
|
+
return values;
|
|
265
|
+
};
|
|
266
|
+
/**
|
|
267
|
+
* Refines the afterKey object
|
|
268
|
+
* @param props
|
|
269
|
+
*/
|
|
270
|
+
this.refineAfterkey = (uFilter, forceSet = false) => {
|
|
271
|
+
if (forceSet ||
|
|
272
|
+
_get(uFilter, "values[0].value", "") !==
|
|
273
|
+
_get(this.uFilter, "values[0].value", "") ||
|
|
274
|
+
!this.areColumnsEquals(uFilter.column, _get(this.uFilter, "column")) ||
|
|
275
|
+
uFilter.validator !== this.uFilter.validator ||
|
|
276
|
+
uFilter.property !== this.uFilter.property ||
|
|
277
|
+
uFilter.extras.scope !== this.uFilter.extras.scope)
|
|
278
|
+
this.setAfterKey(undefined);
|
|
279
|
+
};
|
|
280
|
+
/**
|
|
281
|
+
* Sets the afterKey object
|
|
282
|
+
* @param afterKey the afterKey object
|
|
283
|
+
*/
|
|
284
|
+
this.setAfterKey = (afterKey) => {
|
|
285
|
+
this.afterKey = afterKey;
|
|
286
|
+
};
|
|
287
|
+
/**
|
|
288
|
+
* Sets the Filter Builder Filter
|
|
289
|
+
* @param uFilter
|
|
290
|
+
*/
|
|
291
|
+
this.setProps = (uFilter) => {
|
|
292
|
+
this.uFilter = cloneDeep(uFilter);
|
|
293
|
+
};
|
|
294
|
+
/**
|
|
295
|
+
* Checks if two filter columns are the same.
|
|
296
|
+
* @param column1
|
|
297
|
+
* @param column2
|
|
298
|
+
* @returns True: Columns are equal; False: Columns are not equal
|
|
299
|
+
*/
|
|
300
|
+
this.areColumnsEquals = (column1, column2) => {
|
|
301
|
+
if (isEmpty(column1) || isEmpty(column2))
|
|
302
|
+
return false;
|
|
303
|
+
return (column1.id === column2.id &&
|
|
304
|
+
column1.qrveyid === column2.qrveyid &&
|
|
305
|
+
column1.property === column2.property &&
|
|
306
|
+
column1.aggregate === column2.aggregate);
|
|
307
|
+
};
|
|
308
|
+
this.isResultPaginationEmpty = (resultObject) => {
|
|
309
|
+
const result = _get(resultObject, "data");
|
|
310
|
+
return isEmpty(result);
|
|
311
|
+
};
|
|
312
|
+
}
|
|
325
313
|
}
|
|
@@ -13,15 +13,6 @@ this class is based on moment format:
|
|
|
13
13
|
ms: S
|
|
14
14
|
*/
|
|
15
15
|
export class DurationFormatter {
|
|
16
|
-
options;
|
|
17
|
-
parts;
|
|
18
|
-
valueFormatter;
|
|
19
|
-
numberFactor;
|
|
20
|
-
template;
|
|
21
|
-
numberFormatOptions = {
|
|
22
|
-
minimumFractionDigits: DEFAULT_OPTIONS.fractionDigits,
|
|
23
|
-
maximumFractionDigits: DEFAULT_OPTIONS.fractionDigits,
|
|
24
|
-
};
|
|
25
16
|
/**
|
|
26
17
|
* The constructor function takes in a template string and an options object. It then sets the
|
|
27
18
|
* options object to the default options object if no options object is passed in. It then parses
|
|
@@ -34,13 +25,17 @@ export class DurationFormatter {
|
|
|
34
25
|
* @param options - This is an object that contains the following properties: unit, locale and fractionDigits
|
|
35
26
|
*/
|
|
36
27
|
constructor(options) {
|
|
28
|
+
this.numberFormatOptions = {
|
|
29
|
+
minimumFractionDigits: DEFAULT_OPTIONS.fractionDigits,
|
|
30
|
+
maximumFractionDigits: DEFAULT_OPTIONS.fractionDigits,
|
|
31
|
+
};
|
|
37
32
|
this.setOptions(options.options);
|
|
38
33
|
this.setParts(options.template);
|
|
39
34
|
this.setLocaleFormatter(options.intlNumberFormat);
|
|
40
35
|
this.setNumberFactor();
|
|
41
36
|
}
|
|
42
37
|
setOptions(options) {
|
|
43
|
-
this.options = {
|
|
38
|
+
this.options = Object.assign(Object.assign({}, DEFAULT_OPTIONS), options);
|
|
44
39
|
}
|
|
45
40
|
/**
|
|
46
41
|
* It sets the locale formatter for the number.
|
|
@@ -94,9 +89,9 @@ export class DurationFormatter {
|
|
|
94
89
|
* It sets the numberFactor to the value of the duration part that matches the unit.
|
|
95
90
|
*/
|
|
96
91
|
setNumberFactor() {
|
|
92
|
+
var _a;
|
|
97
93
|
this.numberFactor =
|
|
98
|
-
Object.values(DURATION_PARTS).find((d) => d.name === this.options.unit)
|
|
99
|
-
?.ms || 1;
|
|
94
|
+
((_a = Object.values(DURATION_PARTS).find((d) => d.name === this.options.unit)) === null || _a === void 0 ? void 0 : _a.ms) || 1;
|
|
100
95
|
}
|
|
101
96
|
/**
|
|
102
97
|
* It takes a string, splits it into an array of strings, then maps each string to a config object,
|