@qrvey/utils 1.18.11 → 1.18.16

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.11*
1
+ # [@qrvey/utils](https://bitbucket.org/qrvey/qrvey_utils/wiki/Home) *1.18.16*
2
2
 
3
3
  > Helper, Utils for all Qrvey Projects
4
4
 
@@ -5,6 +5,8 @@ exports.formatDeltaColumnCaption = formatDeltaColumnCaption;
5
5
  exports.formatReferenceColumnCaption = formatReferenceColumnCaption;
6
6
  exports.stripColumnMarker = stripColumnMarker;
7
7
  exports.resolveComparativeColumnCaption = resolveComparativeColumnCaption;
8
+ exports.isNullDateOperator = isNullDateOperator;
9
+ exports.formatPeriodLabel = formatPeriodLabel;
8
10
  exports.formatComparativePeriodCaption = formatComparativePeriodCaption;
9
11
  exports.formatDeltaDefaultCaption = formatDeltaDefaultCaption;
10
12
  exports.computeComparativeVirtualColumns = computeComparativeVirtualColumns;
@@ -78,25 +80,29 @@ function resolveComparativeColumnCaption(chartModel, columnKey, allDatesText) {
78
80
  return formatDeltaColumnCaption(customLabels[dataFieldKey]);
79
81
  return formatDeltaDefaultCaption(comparativeAnalisis.referencePeriod, comparativeAnalisis.compareTo, fallbackAllDates, defaultName);
80
82
  }
81
- function formatComparativePeriodCaption(period, allDatesText, colLabel = "") {
82
- if (!period?.date1) {
83
- return colLabel ? `${colLabel} - ${allDatesText}` : allDatesText;
84
- }
83
+ function isNullDateOperator(operator) {
84
+ const id = String(operator?.label ?? operator?.key ?? "").toUpperCase();
85
+ return id === "IS_NULL" || id === "IS_NOT_NULL";
86
+ }
87
+ function formatPeriodLabel(period, allDatesText) {
88
+ if (isNullDateOperator(period?.operator))
89
+ return period.operator.text || allDatesText;
90
+ if (period?.customLabel)
91
+ return period.customLabel;
92
+ if (!period?.date1)
93
+ return allDatesText;
85
94
  const d1 = period.formattedDate1 ?? period.date1;
86
95
  const d2 = period.formattedDate2 ?? period.date2;
87
96
  const dateRange = period.date2 ? `${d1} - ${d2}` : d1;
88
- return colLabel ? `${colLabel} - ${dateRange}` : dateRange;
97
+ return period.presetName ? `${period.presetName} (${dateRange})` : dateRange;
98
+ }
99
+ function formatComparativePeriodCaption(period, allDatesText, colLabel = "") {
100
+ const periodLabel = formatPeriodLabel(period, allDatesText);
101
+ return colLabel ? `${colLabel} - ${periodLabel}` : periodLabel;
89
102
  }
90
103
  function formatDeltaDefaultCaption(referencePeriod, compareTo, allDatesText, colLabel = "") {
91
- const fmtPeriodFn = (p) => {
92
- if (!p?.date1)
93
- return allDatesText;
94
- const d1 = p.formattedDate1 ?? p.date1;
95
- const d2 = p.formattedDate2 ?? p.date2;
96
- return p.date2 ? `${d1} - ${d2}` : d1;
97
- };
98
- const ref = fmtPeriodFn(referencePeriod);
99
- const cmp = fmtPeriodFn(compareTo);
104
+ const ref = formatPeriodLabel(referencePeriod, allDatesText);
105
+ const cmp = formatPeriodLabel(compareTo, allDatesText);
100
106
  const comparison = ref && cmp ? `${ref} vs ${cmp}` : ref || cmp;
101
107
  const prefix = colLabel
102
108
  ? `${exports.DELTA_COLUMN_PREFIX} ${colLabel}`
@@ -324,7 +330,7 @@ function buildComparativeChartComparison(myBus, chart, groups) {
324
330
  if (!periodData || !periodData.operator)
325
331
  return null;
326
332
  const operatorLabel = periodData.operator.label;
327
- const isNullType = operatorLabel === "IS_NULL" || operatorLabel === "IS_NOT_NULL";
333
+ const isNullType = isNullDateOperator(periodData.operator);
328
334
  if (!isNullType && !periodData.date1)
329
335
  return null;
330
336
  const validationType = mapOperatorToValidationType(operatorLabel);
@@ -11,6 +11,8 @@ export interface ComparativeVirtualColumn {
11
11
  deltaDataField?: string;
12
12
  extraDeltaDataFields?: string[];
13
13
  }
14
+ export declare function isNullDateOperator(operator: any): boolean;
15
+ export declare function formatPeriodLabel(period: any, allDatesText: string): string;
14
16
  export declare function formatComparativePeriodCaption(period: any, allDatesText: string, colLabel?: string): string;
15
17
  export declare function formatDeltaDefaultCaption(referencePeriod: any, compareTo: any, allDatesText: string, colLabel?: string): string;
16
18
  export declare function computeComparativeVirtualColumns(isGrouped: boolean, myBus: any, chart: any, getChartColumns: () => any[]): ComparativeVirtualColumn[];
@@ -60,25 +60,29 @@ export function resolveComparativeColumnCaption(chartModel, columnKey, allDatesT
60
60
  return formatDeltaColumnCaption(customLabels[dataFieldKey]);
61
61
  return formatDeltaDefaultCaption(comparativeAnalisis.referencePeriod, comparativeAnalisis.compareTo, fallbackAllDates, defaultName);
62
62
  }
63
- export function formatComparativePeriodCaption(period, allDatesText, colLabel = "") {
64
- if (!period?.date1) {
65
- return colLabel ? `${colLabel} - ${allDatesText}` : allDatesText;
66
- }
63
+ export function isNullDateOperator(operator) {
64
+ const id = String(operator?.label ?? operator?.key ?? "").toUpperCase();
65
+ return id === "IS_NULL" || id === "IS_NOT_NULL";
66
+ }
67
+ export function formatPeriodLabel(period, allDatesText) {
68
+ if (isNullDateOperator(period?.operator))
69
+ return period.operator.text || allDatesText;
70
+ if (period?.customLabel)
71
+ return period.customLabel;
72
+ if (!period?.date1)
73
+ return allDatesText;
67
74
  const d1 = period.formattedDate1 ?? period.date1;
68
75
  const d2 = period.formattedDate2 ?? period.date2;
69
76
  const dateRange = period.date2 ? `${d1} - ${d2}` : d1;
70
- return colLabel ? `${colLabel} - ${dateRange}` : dateRange;
77
+ return period.presetName ? `${period.presetName} (${dateRange})` : dateRange;
78
+ }
79
+ export function formatComparativePeriodCaption(period, allDatesText, colLabel = "") {
80
+ const periodLabel = formatPeriodLabel(period, allDatesText);
81
+ return colLabel ? `${colLabel} - ${periodLabel}` : periodLabel;
71
82
  }
72
83
  export function formatDeltaDefaultCaption(referencePeriod, compareTo, allDatesText, colLabel = "") {
73
- const fmtPeriodFn = (p) => {
74
- if (!p?.date1)
75
- return allDatesText;
76
- const d1 = p.formattedDate1 ?? p.date1;
77
- const d2 = p.formattedDate2 ?? p.date2;
78
- return p.date2 ? `${d1} - ${d2}` : d1;
79
- };
80
- const ref = fmtPeriodFn(referencePeriod);
81
- const cmp = fmtPeriodFn(compareTo);
84
+ const ref = formatPeriodLabel(referencePeriod, allDatesText);
85
+ const cmp = formatPeriodLabel(compareTo, allDatesText);
82
86
  const comparison = ref && cmp ? `${ref} vs ${cmp}` : ref || cmp;
83
87
  const prefix = colLabel
84
88
  ? `${DELTA_COLUMN_PREFIX} ${colLabel}`
@@ -306,7 +310,7 @@ export function buildComparativeChartComparison(myBus, chart, groups) {
306
310
  if (!periodData || !periodData.operator)
307
311
  return null;
308
312
  const operatorLabel = periodData.operator.label;
309
- const isNullType = operatorLabel === "IS_NULL" || operatorLabel === "IS_NOT_NULL";
313
+ const isNullType = isNullDateOperator(periodData.operator);
310
314
  if (!isNullType && !periodData.date1)
311
315
  return null;
312
316
  const validationType = mapOperatorToValidationType(operatorLabel);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@qrvey/utils",
3
- "version": "1.18.11",
3
+ "version": "1.18.16",
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",
@@ -83,7 +83,7 @@
83
83
  ],
84
84
  "overrides": {
85
85
  "brace-expansion": "^5.0.8",
86
- "js-yaml": "4.3.0"
86
+ "js-yaml": "5.4.1"
87
87
  },
88
88
  "sideEffects": false,
89
89
  "types": "dist/index.d.ts"