@qrvey/utils 1.4.0-5 → 1.4.0-6

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.4.0-5*
1
+ # [@qrvey/utils](https://bitbucket.org/qrvey/qrvey_utils/wiki/Home) *1.4.0-6*
2
2
 
3
3
  > Helper, Utils for all Qrvey Projects
4
4
 
@@ -1,7 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.defineXYChartFormat = void 0;
4
- const __1 = require("../..");
4
+ const AGGREGATE_1 = require("../../charts/constants/AGGREGATE");
5
+ const COLUMN_1 = require("../../columns/constants/COLUMN");
6
+ const isEmpty_1 = require("../../general/mix/isEmpty");
5
7
  const CHART_GROUP_1 = require("../constants/CHART_GROUP");
6
8
  const DATEGROUP_UNSUPPORT_FORMAT_1 = require("../constants/DATEGROUP_UNSUPPORT_FORMAT");
7
9
  const STRING_FORMAT_1 = require("../constants/STRING_FORMAT");
@@ -19,26 +21,30 @@ const defineXYChartFormat = (column, settings) => {
19
21
  const columnDefaultFormat = defaultFormat || outputFormat;
20
22
  //Defaults
21
23
  const defaultText = "Default";
22
- const defaultAbb = { type: "NUMERIC", format: "Abbreviated" };
24
+ const defaultAbb = { type: "NUMERIC", format: "Abbreviated" /* LOCALE_FORMATS.ABBREVIATED */ };
25
+ const defaultDecimal = { type: "NUMERIC", format: "Decimal" /* LOCALE_FORMATS.DECIMAL */ };
23
26
  const columnType = (0, columnTypeByChart_1.columnTypeByChart)(column, shelfType, CHART_GROUP_1.CHART_GROUPS.XY);
24
27
  const noFormatSupported = DATEGROUP_UNSUPPORT_FORMAT_1.DATEGROUP_UNSUPPORT_FORMAT.some((gp) => gp === (dateGroup === null || dateGroup === void 0 ? void 0 : dateGroup.label));
25
28
  const isUsedAsNumericColumn = type !== columnType;
26
- const hasDefaultFormat = (0, __1.isEmpty)(selectedFormat) ||
29
+ const columnCurrentFormat = isUsedAsNumericColumn
30
+ ? selectedFormat
31
+ : outputFormat;
32
+ const hasDefaultFormat = (0, isEmpty_1.isEmpty)(selectedFormat) ||
27
33
  (outputFormat === null || outputFormat === void 0 ? void 0 : outputFormat.format) === defaultText ||
28
34
  (selectedFormat === null || selectedFormat === void 0 ? void 0 : selectedFormat.format) === defaultText;
29
35
  switch (columnType) {
30
- case __1.COLUMN.YES_NO:
31
- case __1.COLUMN.PHONE:
32
- case __1.COLUMN.SINGLE_CHOICE:
33
- case __1.COLUMN.LONGTEXT:
34
- case __1.COLUMN.DROPDOWN:
35
- case __1.COLUMN.EXPRESSION:
36
- case __1.COLUMN.NAME:
37
- case __1.COLUMN.EMAIL_FORM:
38
- case __1.COLUMN.IMAGE:
39
- case __1.COLUMN.TEXT_LABEL:
36
+ case COLUMN_1.COLUMN.YES_NO:
37
+ case COLUMN_1.COLUMN.PHONE:
38
+ case COLUMN_1.COLUMN.SINGLE_CHOICE:
39
+ case COLUMN_1.COLUMN.LONGTEXT:
40
+ case COLUMN_1.COLUMN.DROPDOWN:
41
+ case COLUMN_1.COLUMN.EXPRESSION:
42
+ case COLUMN_1.COLUMN.NAME:
43
+ case COLUMN_1.COLUMN.EMAIL_FORM:
44
+ case COLUMN_1.COLUMN.IMAGE:
45
+ case COLUMN_1.COLUMN.TEXT_LABEL:
40
46
  return STRING_FORMAT_1.STRING_FORMAT.NONE;
41
- case __1.COLUMN.DATE: {
47
+ case COLUMN_1.COLUMN.DATE: {
42
48
  if (noFormatSupported) {
43
49
  return STRING_FORMAT_1.STRING_FORMAT.NONE;
44
50
  }
@@ -49,16 +55,20 @@ const defineXYChartFormat = (column, settings) => {
49
55
  return selectedFormat;
50
56
  }
51
57
  }
52
- case __1.COLUMN.NUMERIC:
53
- case __1.COLUMN.RATING:
54
- case __1.COLUMN.SLIDEBAR: {
58
+ case COLUMN_1.COLUMN.NUMERIC:
59
+ case COLUMN_1.COLUMN.RATING:
60
+ case COLUMN_1.COLUMN.SLIDEBAR: {
61
+ if (((aggregate === null || aggregate === void 0 ? void 0 : aggregate.label) === AGGREGATE_1.AGGREGATE.COUNT ||
62
+ (aggregate === null || aggregate === void 0 ? void 0 : aggregate.label) === AGGREGATE_1.AGGREGATE.DISTINCTCOUNT) &&
63
+ hasDefaultFormat)
64
+ return defaultDecimal;
55
65
  if (isUsedAsNumericColumn) {
56
- if (((aggregate === null || aggregate === void 0 ? void 0 : aggregate.label) === __1.AGGREGATE.COUNT && hasDefaultFormat) ||
57
- (isUsedAsNumericColumn && (outputFormat === null || outputFormat === void 0 ? void 0 : outputFormat.type) !== __1.COLUMN.NUMERIC) ||
66
+ if ((isUsedAsNumericColumn &&
67
+ (columnCurrentFormat === null || columnCurrentFormat === void 0 ? void 0 : columnCurrentFormat.type) !== COLUMN_1.COLUMN.NUMERIC) ||
58
68
  withoutFormat)
59
69
  return defaultAbb;
60
70
  else
61
- return outputFormat;
71
+ return columnCurrentFormat;
62
72
  }
63
73
  else {
64
74
  if (withoutFormat === true) {
@@ -1,4 +1,6 @@
1
- import { AGGREGATE, COLUMN, isEmpty } from "../..";
1
+ import { AGGREGATE } from "../../charts/constants/AGGREGATE";
2
+ import { COLUMN } from "../../columns/constants/COLUMN";
3
+ import { isEmpty } from "../../general/mix/isEmpty";
2
4
  import { CHART_GROUPS } from "../constants/CHART_GROUP";
3
5
  import { DATEGROUP_UNSUPPORT_FORMAT } from "../constants/DATEGROUP_UNSUPPORT_FORMAT";
4
6
  import { STRING_FORMAT } from "../constants/STRING_FORMAT";
@@ -16,10 +18,14 @@ export const defineXYChartFormat = (column, settings) => {
16
18
  const columnDefaultFormat = defaultFormat || outputFormat;
17
19
  //Defaults
18
20
  const defaultText = "Default";
19
- const defaultAbb = { type: "NUMERIC", format: "Abbreviated" };
21
+ const defaultAbb = { type: "NUMERIC", format: "Abbreviated" /* LOCALE_FORMATS.ABBREVIATED */ };
22
+ const defaultDecimal = { type: "NUMERIC", format: "Decimal" /* LOCALE_FORMATS.DECIMAL */ };
20
23
  const columnType = columnTypeByChart(column, shelfType, CHART_GROUPS.XY);
21
24
  const noFormatSupported = DATEGROUP_UNSUPPORT_FORMAT.some((gp) => gp === (dateGroup === null || dateGroup === void 0 ? void 0 : dateGroup.label));
22
25
  const isUsedAsNumericColumn = type !== columnType;
26
+ const columnCurrentFormat = isUsedAsNumericColumn
27
+ ? selectedFormat
28
+ : outputFormat;
23
29
  const hasDefaultFormat = isEmpty(selectedFormat) ||
24
30
  (outputFormat === null || outputFormat === void 0 ? void 0 : outputFormat.format) === defaultText ||
25
31
  (selectedFormat === null || selectedFormat === void 0 ? void 0 : selectedFormat.format) === defaultText;
@@ -49,13 +55,17 @@ export const defineXYChartFormat = (column, settings) => {
49
55
  case COLUMN.NUMERIC:
50
56
  case COLUMN.RATING:
51
57
  case COLUMN.SLIDEBAR: {
58
+ if (((aggregate === null || aggregate === void 0 ? void 0 : aggregate.label) === AGGREGATE.COUNT ||
59
+ (aggregate === null || aggregate === void 0 ? void 0 : aggregate.label) === AGGREGATE.DISTINCTCOUNT) &&
60
+ hasDefaultFormat)
61
+ return defaultDecimal;
52
62
  if (isUsedAsNumericColumn) {
53
- if (((aggregate === null || aggregate === void 0 ? void 0 : aggregate.label) === AGGREGATE.COUNT && hasDefaultFormat) ||
54
- (isUsedAsNumericColumn && (outputFormat === null || outputFormat === void 0 ? void 0 : outputFormat.type) !== COLUMN.NUMERIC) ||
63
+ if ((isUsedAsNumericColumn &&
64
+ (columnCurrentFormat === null || columnCurrentFormat === void 0 ? void 0 : columnCurrentFormat.type) !== COLUMN.NUMERIC) ||
55
65
  withoutFormat)
56
66
  return defaultAbb;
57
67
  else
58
- return outputFormat;
68
+ return columnCurrentFormat;
59
69
  }
60
70
  else {
61
71
  if (withoutFormat === true) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@qrvey/utils",
3
- "version": "1.4.0-5",
3
+ "version": "1.4.0-6",
4
4
  "description": "Helper, Utils for all Qrvey Projects",
5
5
  "homepage": "https://bitbucket.org/qrvey/qrvey_utils/wiki/Home",
6
6
  "main": "dist/index.js",