@qrvey/utils 1.18.9 → 1.18.11

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 CHANGED
@@ -1,4 +1,4 @@
1
- # [@qrvey/utils](https://bitbucket.org/qrvey/qrvey_utils/wiki/Home) *1.18.9*
1
+ # [@qrvey/utils](https://bitbucket.org/qrvey/qrvey_utils/wiki/Home) *1.18.11*
2
2
 
3
3
  > Helper, Utils for all Qrvey Projects
4
4
 
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.COUNT_SUPPORTED_FORMATS = void 0;
4
+ exports.COUNT_SUPPORTED_FORMATS = [
5
+ "Abbreviated",
6
+ "Scientific",
7
+ ];
@@ -2,6 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const tslib_1 = require("tslib");
4
4
  tslib_1.__exportStar(require("./CHART_GROUP"), exports);
5
+ tslib_1.__exportStar(require("./COUNT_SUPPORTED_FORMATS"), exports);
5
6
  tslib_1.__exportStar(require("./DATEGROUP_UNSUPPORT_FORMAT"), exports);
6
7
  tslib_1.__exportStar(require("./DATEGROUP_WITHOUT_FORMAT"), exports);
7
8
  tslib_1.__exportStar(require("./SHELF_TYPE"), exports);
@@ -5,6 +5,7 @@ const AGGREGATE_1 = require("../../charts/constants/AGGREGATE");
5
5
  const COLUMN_1 = require("../../columns/constants/COLUMN");
6
6
  const isEmpty_1 = require("../../general/mix/isEmpty");
7
7
  const CHART_GROUP_1 = require("../constants/CHART_GROUP");
8
+ const COUNT_SUPPORTED_FORMATS_1 = require("../constants/COUNT_SUPPORTED_FORMATS");
8
9
  const STRING_FORMAT_1 = require("../constants/STRING_FORMAT");
9
10
  const TABLE_TYPE_1 = require("../constants/TABLE_TYPE");
10
11
  const columnTypeByChart_1 = require("./columnTypeByChart");
@@ -85,11 +86,16 @@ const defineTableChartFormat = (column, settings) => {
85
86
  return defaultPercentage;
86
87
  if (selectedFormat && selectedFormat.format !== defaultText)
87
88
  return selectedFormat;
89
+ const isCountAggregate = aggregate?.label === AGGREGATE_1.AGGREGATE.COUNT ||
90
+ aggregate?.label === AGGREGATE_1.AGGREGATE.DISTINCTCOUNT;
88
91
  let output;
89
- if (isGroupedTable &&
90
- (aggregate?.label === AGGREGATE_1.AGGREGATE.COUNT ||
91
- aggregate?.label === AGGREGATE_1.AGGREGATE.DISTINCTCOUNT)) {
92
- output = defaultNumeric;
92
+ if (isGroupedTable && isCountAggregate) {
93
+ output = COUNT_SUPPORTED_FORMATS_1.COUNT_SUPPORTED_FORMATS.includes(outputFormat?.format)
94
+ ? { ...outputFormat }
95
+ : defaultNumeric;
96
+ }
97
+ else if (definition_1.STANDARD_NUMERIC_FORMATS.includes(outputFormat?.format)) {
98
+ output = { ...outputFormat };
93
99
  }
94
100
  else {
95
101
  output = defaultFormat || defaultNumeric;
@@ -8,6 +8,7 @@ const isEmpty_1 = require("../../general/mix/isEmpty");
8
8
  const CALCULATION_LABEL_1 = require("../../qrvey/constants/CALCULATION_LABEL");
9
9
  const constants_1 = require("../constants");
10
10
  const CHART_GROUP_1 = require("../constants/CHART_GROUP");
11
+ const COUNT_SUPPORTED_FORMATS_1 = require("../constants/COUNT_SUPPORTED_FORMATS");
11
12
  const DATEGROUP_UNSUPPORT_FORMAT_1 = require("../constants/DATEGROUP_UNSUPPORT_FORMAT");
12
13
  const STRING_FORMAT_1 = require("../constants/STRING_FORMAT");
13
14
  const columnTypeByChart_1 = require("./columnTypeByChart");
@@ -78,8 +79,11 @@ const defineXYChartFormat = (column, settings) => {
78
79
  return defaultPercentage;
79
80
  if ((aggregate?.label === AGGREGATE_1.AGGREGATE.COUNT ||
80
81
  aggregate?.label === AGGREGATE_1.AGGREGATE.DISTINCTCOUNT) &&
81
- hasDefaultFormat)
82
+ hasDefaultFormat) {
83
+ if (COUNT_SUPPORTED_FORMATS_1.COUNT_SUPPORTED_FORMATS.includes(outputFormat?.format))
84
+ return { ...outputFormat };
82
85
  return defaultDecimal;
86
+ }
83
87
  if (isUsedAsNumericColumn) {
84
88
  if (columnCurrentFormat?.type !== COLUMN_1.COLUMN.NUMERIC || withoutFormat)
85
89
  return defaultAbb;
@@ -91,7 +95,8 @@ const defineXYChartFormat = (column, settings) => {
91
95
  else if (hasDefaultFormat) {
92
96
  if (!outputFormat?.format)
93
97
  return defaultDecimal;
94
- if (!definition_1.STANDARD_NUMERIC_FORMATS.includes(outputFormat?.format) || constants_1.DURATION_PARTS_LIST.includes(outputFormat?.format)) {
98
+ if (!definition_1.STANDARD_NUMERIC_FORMATS.includes(outputFormat?.format) ||
99
+ constants_1.DURATION_PARTS_LIST.includes(outputFormat?.format)) {
95
100
  return {
96
101
  ...outputFormat,
97
102
  template: outputFormat?.format,
@@ -71,13 +71,7 @@ function resolveComparativeColumnCaption(chartModel, columnKey, allDatesText) {
71
71
  }
72
72
  const diffCols = comparativeAnalisis?.styles?.columnDiffs?.[uniqueCode] ?? [];
73
73
  const diffCol = diffCols[deltaIndex];
74
- const hasConfiguredDiffs = comparativeAnalisis?.styles?.columnDiffs?.[uniqueCode] != null;
75
74
  const diffName = diffCol?.name?.trim() || null;
76
- if (hasConfiguredDiffs) {
77
- if (diffName)
78
- return formatDeltaColumnCaption(diffName);
79
- return formatDeltaDefaultCaption(comparativeAnalisis.referencePeriod, comparativeAnalisis.compareTo, fallbackAllDates, defaultName);
80
- }
81
75
  if (diffName)
82
76
  return formatDeltaColumnCaption(diffName);
83
77
  if (customLabels[dataFieldKey])
@@ -178,7 +172,6 @@ function expandColumnListWithComparativeColumns(columnList, comparativeVirtualCo
178
172
  { id: "default", name: "" },
179
173
  ])
180
174
  : [{ id: "default", name: "" }];
181
- const hasConfiguredDiffs = comparativeData?.styles?.columnDiffs?.[uniqueCode] != null;
182
175
  const compLabel = customLabels[vc.compDataField] ??
183
176
  formatComparativePeriodCaption(comparativeData.compareTo, fallbackAllDates, defaultName);
184
177
  result.push({
@@ -197,13 +190,9 @@ function expandColumnListWithComparativeColumns(columnList, comparativeVirtualCo
197
190
  });
198
191
  if (vc.deltaDataField) {
199
192
  const firstDiffName = diffCols[0]?.name?.trim() || "";
200
- const resolvedFirstName = firstDiffName || null;
201
- const deltaLabel = hasConfiguredDiffs
202
- ? (resolvedFirstName ??
203
- formatDeltaDefaultCaption(comparativeData.referencePeriod, comparativeData.compareTo, fallbackAllDates, defaultName))
204
- : (resolvedFirstName ??
205
- customLabels[vc.deltaDataField] ??
206
- formatDeltaDefaultCaption(comparativeData.referencePeriod, comparativeData.compareTo, fallbackAllDates, defaultName));
193
+ const deltaLabel = firstDiffName ||
194
+ customLabels[vc.deltaDataField] ||
195
+ formatDeltaDefaultCaption(comparativeData.referencePeriod, comparativeData.compareTo, fallbackAllDates, defaultName);
207
196
  result.push({
208
197
  ...col,
209
198
  dataField: vc.deltaDataField,
@@ -218,13 +207,9 @@ function expandColumnListWithComparativeColumns(columnList, comparativeVirtualCo
218
207
  (vc.extraDeltaDataFields ?? []).forEach((df, j) => {
219
208
  const styleIndex = j + 1;
220
209
  const extraDiffName = diffCols[styleIndex]?.name?.trim() || "";
221
- const resolvedExtraName = extraDiffName || null;
222
- const extraLabel = hasConfiguredDiffs
223
- ? (resolvedExtraName ??
224
- formatDeltaDefaultCaption(comparativeData.referencePeriod, comparativeData.compareTo, fallbackAllDates, defaultName))
225
- : (resolvedExtraName ??
226
- customLabels[df] ??
227
- formatDeltaDefaultCaption(comparativeData.referencePeriod, comparativeData.compareTo, fallbackAllDates, defaultName));
210
+ const extraLabel = extraDiffName ||
211
+ customLabels[df] ||
212
+ formatDeltaDefaultCaption(comparativeData.referencePeriod, comparativeData.compareTo, fallbackAllDates, defaultName);
228
213
  result.push({
229
214
  ...col,
230
215
  dataField: df,
@@ -0,0 +1 @@
1
+ export declare const COUNT_SUPPORTED_FORMATS: string[];
@@ -0,0 +1,4 @@
1
+ export const COUNT_SUPPORTED_FORMATS = [
2
+ "Abbreviated",
3
+ "Scientific",
4
+ ];
@@ -1,4 +1,5 @@
1
1
  export * from "./CHART_GROUP";
2
+ export * from "./COUNT_SUPPORTED_FORMATS";
2
3
  export * from "./DATEGROUP_UNSUPPORT_FORMAT";
3
4
  export * from "./DATEGROUP_WITHOUT_FORMAT";
4
5
  export * from "./SHELF_TYPE";
@@ -1,4 +1,5 @@
1
1
  export * from "./CHART_GROUP";
2
+ export * from "./COUNT_SUPPORTED_FORMATS";
2
3
  export * from "./DATEGROUP_UNSUPPORT_FORMAT";
3
4
  export * from "./DATEGROUP_WITHOUT_FORMAT";
4
5
  export * from "./SHELF_TYPE";
@@ -2,6 +2,7 @@ import { AGGREGATE } from "../../charts/constants/AGGREGATE";
2
2
  import { COLUMN } from "../../columns/constants/COLUMN";
3
3
  import { isEmpty } from "../../general/mix/isEmpty";
4
4
  import { CHART_GROUPS } from "../constants/CHART_GROUP";
5
+ import { COUNT_SUPPORTED_FORMATS } from "../constants/COUNT_SUPPORTED_FORMATS";
5
6
  import { STRING_FORMAT } from "../constants/STRING_FORMAT";
6
7
  import { TABLE_TYPE } from "../constants/TABLE_TYPE";
7
8
  import { columnTypeByChart } from "./columnTypeByChart";
@@ -82,11 +83,16 @@ export const defineTableChartFormat = (column, settings) => {
82
83
  return defaultPercentage;
83
84
  if (selectedFormat && selectedFormat.format !== defaultText)
84
85
  return selectedFormat;
86
+ const isCountAggregate = aggregate?.label === AGGREGATE.COUNT ||
87
+ aggregate?.label === AGGREGATE.DISTINCTCOUNT;
85
88
  let output;
86
- if (isGroupedTable &&
87
- (aggregate?.label === AGGREGATE.COUNT ||
88
- aggregate?.label === AGGREGATE.DISTINCTCOUNT)) {
89
- output = defaultNumeric;
89
+ if (isGroupedTable && isCountAggregate) {
90
+ output = COUNT_SUPPORTED_FORMATS.includes(outputFormat?.format)
91
+ ? { ...outputFormat }
92
+ : defaultNumeric;
93
+ }
94
+ else if (STANDARD_NUMERIC_FORMATS.includes(outputFormat?.format)) {
95
+ output = { ...outputFormat };
90
96
  }
91
97
  else {
92
98
  output = defaultFormat || defaultNumeric;
@@ -5,6 +5,7 @@ import { isEmpty } from "../../general/mix/isEmpty";
5
5
  import { CALCULATION_LABEL } from "../../qrvey/constants/CALCULATION_LABEL";
6
6
  import { DURATION_PARTS_LIST, SHELF_TYPE } from "../constants";
7
7
  import { CHART_GROUPS } from "../constants/CHART_GROUP";
8
+ import { COUNT_SUPPORTED_FORMATS } from "../constants/COUNT_SUPPORTED_FORMATS";
8
9
  import { DATEGROUP_UNSUPPORT_FORMAT } from "../constants/DATEGROUP_UNSUPPORT_FORMAT";
9
10
  import { STRING_FORMAT } from "../constants/STRING_FORMAT";
10
11
  import { columnTypeByChart } from "./columnTypeByChart";
@@ -75,8 +76,11 @@ export const defineXYChartFormat = (column, settings) => {
75
76
  return defaultPercentage;
76
77
  if ((aggregate?.label === AGGREGATE.COUNT ||
77
78
  aggregate?.label === AGGREGATE.DISTINCTCOUNT) &&
78
- hasDefaultFormat)
79
+ hasDefaultFormat) {
80
+ if (COUNT_SUPPORTED_FORMATS.includes(outputFormat?.format))
81
+ return { ...outputFormat };
79
82
  return defaultDecimal;
83
+ }
80
84
  if (isUsedAsNumericColumn) {
81
85
  if (columnCurrentFormat?.type !== COLUMN.NUMERIC || withoutFormat)
82
86
  return defaultAbb;
@@ -88,7 +92,8 @@ export const defineXYChartFormat = (column, settings) => {
88
92
  else if (hasDefaultFormat) {
89
93
  if (!outputFormat?.format)
90
94
  return defaultDecimal;
91
- if (!STANDARD_NUMERIC_FORMATS.includes(outputFormat?.format) || DURATION_PARTS_LIST.includes(outputFormat?.format)) {
95
+ if (!STANDARD_NUMERIC_FORMATS.includes(outputFormat?.format) ||
96
+ DURATION_PARTS_LIST.includes(outputFormat?.format)) {
92
97
  return {
93
98
  ...outputFormat,
94
99
  template: outputFormat?.format,
@@ -53,13 +53,7 @@ export function resolveComparativeColumnCaption(chartModel, columnKey, allDatesT
53
53
  }
54
54
  const diffCols = comparativeAnalisis?.styles?.columnDiffs?.[uniqueCode] ?? [];
55
55
  const diffCol = diffCols[deltaIndex];
56
- const hasConfiguredDiffs = comparativeAnalisis?.styles?.columnDiffs?.[uniqueCode] != null;
57
56
  const diffName = diffCol?.name?.trim() || null;
58
- if (hasConfiguredDiffs) {
59
- if (diffName)
60
- return formatDeltaColumnCaption(diffName);
61
- return formatDeltaDefaultCaption(comparativeAnalisis.referencePeriod, comparativeAnalisis.compareTo, fallbackAllDates, defaultName);
62
- }
63
57
  if (diffName)
64
58
  return formatDeltaColumnCaption(diffName);
65
59
  if (customLabels[dataFieldKey])
@@ -160,7 +154,6 @@ export function expandColumnListWithComparativeColumns(columnList, comparativeVi
160
154
  { id: "default", name: "" },
161
155
  ])
162
156
  : [{ id: "default", name: "" }];
163
- const hasConfiguredDiffs = comparativeData?.styles?.columnDiffs?.[uniqueCode] != null;
164
157
  const compLabel = customLabels[vc.compDataField] ??
165
158
  formatComparativePeriodCaption(comparativeData.compareTo, fallbackAllDates, defaultName);
166
159
  result.push({
@@ -179,13 +172,9 @@ export function expandColumnListWithComparativeColumns(columnList, comparativeVi
179
172
  });
180
173
  if (vc.deltaDataField) {
181
174
  const firstDiffName = diffCols[0]?.name?.trim() || "";
182
- const resolvedFirstName = firstDiffName || null;
183
- const deltaLabel = hasConfiguredDiffs
184
- ? (resolvedFirstName ??
185
- formatDeltaDefaultCaption(comparativeData.referencePeriod, comparativeData.compareTo, fallbackAllDates, defaultName))
186
- : (resolvedFirstName ??
187
- customLabels[vc.deltaDataField] ??
188
- formatDeltaDefaultCaption(comparativeData.referencePeriod, comparativeData.compareTo, fallbackAllDates, defaultName));
175
+ const deltaLabel = firstDiffName ||
176
+ customLabels[vc.deltaDataField] ||
177
+ formatDeltaDefaultCaption(comparativeData.referencePeriod, comparativeData.compareTo, fallbackAllDates, defaultName);
189
178
  result.push({
190
179
  ...col,
191
180
  dataField: vc.deltaDataField,
@@ -200,13 +189,9 @@ export function expandColumnListWithComparativeColumns(columnList, comparativeVi
200
189
  (vc.extraDeltaDataFields ?? []).forEach((df, j) => {
201
190
  const styleIndex = j + 1;
202
191
  const extraDiffName = diffCols[styleIndex]?.name?.trim() || "";
203
- const resolvedExtraName = extraDiffName || null;
204
- const extraLabel = hasConfiguredDiffs
205
- ? (resolvedExtraName ??
206
- formatDeltaDefaultCaption(comparativeData.referencePeriod, comparativeData.compareTo, fallbackAllDates, defaultName))
207
- : (resolvedExtraName ??
208
- customLabels[df] ??
209
- formatDeltaDefaultCaption(comparativeData.referencePeriod, comparativeData.compareTo, fallbackAllDates, defaultName));
192
+ const extraLabel = extraDiffName ||
193
+ customLabels[df] ||
194
+ formatDeltaDefaultCaption(comparativeData.referencePeriod, comparativeData.compareTo, fallbackAllDates, defaultName);
210
195
  result.push({
211
196
  ...col,
212
197
  dataField: df,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@qrvey/utils",
3
- "version": "1.18.9",
3
+ "version": "1.18.11",
4
4
  "description": "Helper, Utils for all Qrvey Projects",
5
5
  "homepage": "https://bitbucket.org/qrvey/qrvey_utils/wiki/Home",
6
6
  "main": "dist/cjs/index.js",