@qrvey/utils 1.5.0-5 → 1.5.0-8

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 (28) hide show
  1. package/README.md +1 -1
  2. package/dist/cjs/column_format/helpers/defineTableChartFormat.js +2 -2
  3. package/dist/cjs/filters/helpers/common/excludeFiltersByParams.js +4 -3
  4. package/dist/cjs/filters/helpers/common/resolveScopeConditions.js +1 -1
  5. package/dist/cjs/format/definition.d.ts +1 -0
  6. package/dist/cjs/format/definition.js +8 -1
  7. package/dist/cjs/format/duration/durationFormatter.js +0 -4
  8. package/dist/cjs/globalization/interfaces/chart_builder/II18nChartBuilder.d.ts +2 -0
  9. package/dist/cjs/globalization/interfaces/chart_builder/II18nChartBuilderDurationParts.d.ts +9 -0
  10. package/dist/cjs/globalization/interfaces/chart_builder/II18nChartBuilderDurationParts.js +2 -0
  11. package/dist/cjs/globalization/interfaces/chart_builder/index.d.ts +1 -0
  12. package/dist/cjs/globalization/interfaces/chart_builder/index.js +1 -0
  13. package/dist/cjs/globalization/labels/chart_builder/I18N_CHART_BUILDER.js +8 -0
  14. package/dist/cjs/globalization/labels/chart_builder/I18N_CHART_BUILDER_STYLE_OPTIONS.js +1 -1
  15. package/dist/column_format/helpers/defineTableChartFormat.js +2 -2
  16. package/dist/filters/helpers/common/excludeFiltersByParams.js +4 -3
  17. package/dist/filters/helpers/common/resolveScopeConditions.js +1 -1
  18. package/dist/format/definition.d.ts +1 -0
  19. package/dist/format/definition.js +7 -0
  20. package/dist/format/duration/durationFormatter.js +0 -4
  21. package/dist/globalization/interfaces/chart_builder/II18nChartBuilder.d.ts +2 -0
  22. package/dist/globalization/interfaces/chart_builder/II18nChartBuilderDurationParts.d.ts +9 -0
  23. package/dist/globalization/interfaces/chart_builder/II18nChartBuilderDurationParts.js +1 -0
  24. package/dist/globalization/interfaces/chart_builder/index.d.ts +1 -0
  25. package/dist/globalization/interfaces/chart_builder/index.js +1 -0
  26. package/dist/globalization/labels/chart_builder/I18N_CHART_BUILDER.js +8 -0
  27. package/dist/globalization/labels/chart_builder/I18N_CHART_BUILDER_STYLE_OPTIONS.js +1 -1
  28. package/package.json +1 -1
package/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # [@qrvey/utils](https://bitbucket.org/qrvey/qrvey_utils/wiki/Home) *1.5.0-5*
1
+ # [@qrvey/utils](https://bitbucket.org/qrvey/qrvey_utils/wiki/Home) *1.5.0-8*
2
2
 
3
3
  > Helper, Utils for all Qrvey Projects
4
4
 
@@ -8,9 +8,9 @@ const CHART_GROUP_1 = require("../constants/CHART_GROUP");
8
8
  const STRING_FORMAT_1 = require("../constants/STRING_FORMAT");
9
9
  const TABLE_TYPE_1 = require("../constants/TABLE_TYPE");
10
10
  const columnTypeByChart_1 = require("./columnTypeByChart");
11
+ const definition_1 = require("../../format/definition");
11
12
  const CALCULATION_LABEL_1 = require("../../qrvey/constants/CALCULATION_LABEL");
12
13
  const DATEGROUP_UNSUPPORT_FORMAT_1 = require("../constants/DATEGROUP_UNSUPPORT_FORMAT");
13
- const DURATION_PARTS_LIST_1 = require("../constants/DURATION_PARTS_LIST");
14
14
  /**
15
15
  * It returns the format of a column based on the column type, the chart type, and the chart settings
16
16
  * @param {IChartColumn} column - IChartColumn
@@ -76,7 +76,7 @@ const defineTableChartFormat = (column, settings) => {
76
76
  else {
77
77
  output = defaultFormat || defaultNumeric;
78
78
  }
79
- if (DURATION_PARTS_LIST_1.DURATION_PARTS_LIST.includes(output === null || output === void 0 ? void 0 : output.format)) {
79
+ if (!definition_1.STANDARD_NUMERIC_FORMATS.includes(output === null || output === void 0 ? void 0 : output.format)) {
80
80
  output = Object.assign(Object.assign({}, output), { template: output.format, format: "Duration" });
81
81
  }
82
82
  return output;
@@ -2,6 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.excludeFiltersByParams = void 0;
4
4
  const isEmpty_1 = require("../../../general/mix/isEmpty");
5
+ const cloneDeep_1 = require("../../../general/object/cloneDeep");
5
6
  /**
6
7
  * Excludes filters from the given Filters.
7
8
  * The validation to filter the stored filter is depending on:
@@ -22,6 +23,7 @@ function excludeFiltersByParams(filterData, params) {
22
23
  return;
23
24
  if ((0, isEmpty_1.isEmpty)(params))
24
25
  return filterData;
26
+ filterData = (0, cloneDeep_1.cloneDeep)(filterData);
25
27
  filterData.scopes = filterData.scopes
26
28
  .map((scope) => {
27
29
  if (resolveScopeConditions(scope, params)) {
@@ -55,8 +57,7 @@ function excludeFiltersByParams(filterData, params) {
55
57
  .filter((filter) => {
56
58
  var _a;
57
59
  return !(0, isEmpty_1.isEmpty)(filter) &&
58
- filter.selectAll &&
59
- ((_a = filter.values) === null || _a === void 0 ? void 0 : _a.length) > 0;
60
+ (filter.selectAll || ((_a = filter.values) === null || _a === void 0 ? void 0 : _a.length) > 0);
60
61
  }) });
61
62
  }
62
63
  })
@@ -71,7 +72,7 @@ function resolveScopeConditions(scope, params) {
71
72
  return ((params.enableds == null || params.enableds !== scope.enabled) &&
72
73
  ((0, isEmpty_1.isEmpty)(params.scope) || scope.scope !== params.scope) &&
73
74
  ((0, isEmpty_1.isEmpty)(params.scopeid) || scope.scopeid !== params.scopeid) &&
74
- scope.datasets.filter.length > 0);
75
+ scope.datasets.length > 0);
75
76
  }
76
77
  function resolveDatasetConditions(dataset, params) {
77
78
  return ((params.enableds == null || params.enableds !== dataset.enabled) &&
@@ -25,6 +25,6 @@ function resolveScopeConditions(scope, params, letPassUndefinedProperties = fals
25
25
  (letPassUndefinedProperties && scope.scopeid == null) ||
26
26
  (letPassUndefinedParams && (0, isEmpty_1.isEmpty)(params.scopeid)) ||
27
27
  scope.scopeid === params.scopeid) &&
28
- scope.datasets.filter.length > 0);
28
+ scope.datasets.length > 0);
29
29
  }
30
30
  exports.resolveScopeConditions = resolveScopeConditions;
@@ -21,6 +21,7 @@ export declare const enum LOCALE_FORMATS {
21
21
  ABBREVIATED = "Abbreviated",
22
22
  DURATION = "Duration"
23
23
  }
24
+ export declare const STANDARD_NUMERIC_FORMATS: LOCALE_FORMATS[];
24
25
  export declare const enum LOCALE_STYLES {
25
26
  DECIMAL = "decimal",
26
27
  PERCENT = "percent",
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.DEFAULT_OPTIONS = exports.DURATION_PARTS = exports.PARTS_REGEX = exports.DATETIME_OPTIONS = exports.CURRENCY_DEFAULT = exports.LANG_DEFAULT = exports.currencyISO = exports.isTextColumn = exports.supportNumericFormatting = exports.hasfileSizeProperty = exports.appliesFormatting = exports.DATEGROUP_FORMATTING_UNSUPPORT = exports.QUESTION_FORMAT_SUPPORT = exports.numericalFields = exports.complexFields = exports.textFields = void 0;
3
+ exports.DEFAULT_OPTIONS = exports.DURATION_PARTS = exports.PARTS_REGEX = exports.DATETIME_OPTIONS = exports.CURRENCY_DEFAULT = exports.LANG_DEFAULT = exports.STANDARD_NUMERIC_FORMATS = exports.currencyISO = exports.isTextColumn = exports.supportNumericFormatting = exports.hasfileSizeProperty = exports.appliesFormatting = exports.DATEGROUP_FORMATTING_UNSUPPORT = exports.QUESTION_FORMAT_SUPPORT = exports.numericalFields = exports.complexFields = exports.textFields = void 0;
4
4
  const isComplexColumn_1 = require("../columns/helpers/isComplexColumn");
5
5
  const COLUMN_1 = require("../columns/constants/COLUMN");
6
6
  const Charts_Const_1 = require("../constants/Charts.Const");
@@ -104,6 +104,13 @@ exports.currencyISO = [
104
104
  { text: "฿ (THB)", label: "THB" },
105
105
  { text: "RM (MYR)", label: "MYR" },
106
106
  ];
107
+ exports.STANDARD_NUMERIC_FORMATS = [
108
+ "Abbreviated" /* LOCALE_FORMATS.ABBREVIATED */,
109
+ "Currency" /* LOCALE_FORMATS.CURRENCY */,
110
+ "Decimal" /* LOCALE_FORMATS.DECIMAL */,
111
+ "Percentage" /* LOCALE_FORMATS.PERCENTAGE */,
112
+ "Scientific" /* LOCALE_FORMATS.SCIENTIFIC */,
113
+ ];
107
114
  exports.LANG_DEFAULT = "en-US";
108
115
  exports.CURRENCY_DEFAULT = { text: "$ (USD)", label: "USD" };
109
116
  exports.DATETIME_OPTIONS = {
@@ -133,10 +133,6 @@ class DurationFormatter {
133
133
  number %= part.ms;
134
134
  return store;
135
135
  }, {});
136
- if (!Number.isInteger(number))
137
- return number === null
138
- ? null
139
- : this.valueFormatter.format(number).padStart(this.parts.length, "0");
140
136
  if ((0, isEmpty_1.isEmpty)(this.template))
141
137
  return this.valueFormatter
142
138
  .format(number)
@@ -69,6 +69,7 @@ import { II18nChartBuilderTimePeriod } from "./II18nChartBuilderTimePeriod";
69
69
  import { II18nChartBuilderTimePeriodCustomRange } from "./II18nChartBuilderTimePeriodCustomRange";
70
70
  import { II18nChartBuilderWordCloud } from "./II18nChartBuilderWordCloud";
71
71
  import { II18nChartBuilderBoxWhisker } from "./II18nChartBuilderBoxWhisker";
72
+ import { II18nChartBuilderDurationParts } from "./II18nChartBuilderDurationParts";
72
73
  export interface II18nChartBuilder {
73
74
  action_panel: II18nChartBuilderActionPanel;
74
75
  aggregated_formula: II18nChartBuilderAggregatedFormulas;
@@ -141,4 +142,5 @@ export interface II18nChartBuilder {
141
142
  trend_chart: II18nChartBuilderTrendChart;
142
143
  trends_line: II18nChartBuilderTrendsLine;
143
144
  word_cloud: II18nChartBuilderWordCloud;
145
+ duration_parts: II18nChartBuilderDurationParts;
144
146
  }
@@ -0,0 +1,9 @@
1
+ export interface II18nChartBuilderDurationParts {
2
+ full_duration: string;
3
+ hour_minute_seconds: string;
4
+ hour_minutes: string;
5
+ hours: string;
6
+ minutes: string;
7
+ seconds: string;
8
+ milliseconds: string;
9
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -70,3 +70,4 @@ export * from "./II18nChartBuilderTimePeriod";
70
70
  export * from "./II18nChartBuilderTimePeriodCustomRange";
71
71
  export * from "./II18nChartBuilderWordCloud";
72
72
  export * from "./II18nChartBuilderBoxWhisker";
73
+ export * from "./II18nChartBuilderDurationParts";
@@ -86,3 +86,4 @@ __exportStar(require("./II18nChartBuilderTimePeriod"), exports);
86
86
  __exportStar(require("./II18nChartBuilderTimePeriodCustomRange"), exports);
87
87
  __exportStar(require("./II18nChartBuilderWordCloud"), exports);
88
88
  __exportStar(require("./II18nChartBuilderBoxWhisker"), exports);
89
+ __exportStar(require("./II18nChartBuilderDurationParts"), exports);
@@ -27,6 +27,14 @@ exports.I18N_CHART_BUILDER = Object.assign(Object.assign(Object.assign(Object.as
27
27
  date_format: "Date Format",
28
28
  value_format: "Value Format",
29
29
  duration: "Duration",
30
+ }, duration_parts: {
31
+ full_duration: "D[d] HH[h] mm[m] ss[s]",
32
+ hour_minute_seconds: "HH:mm:ss",
33
+ hour_minutes: "HH:mm",
34
+ hours: "HH",
35
+ minutes: "mm",
36
+ seconds: "ss (Seconds)",
37
+ milliseconds: "SSS (Milliseconds)",
30
38
  }, chart_names: {
31
39
  bar: "Bar",
32
40
  line: "Line",
@@ -44,7 +44,7 @@ exports.I18N_CHART_BUILDER_STYLE_OPTIONS = {
44
44
  },
45
45
  color_settings: {
46
46
  color_by_category: "By category",
47
- color_by_value_title: "Color by value",
47
+ color_by_value_title: "Color by values",
48
48
  match_color: "Match colors across charts",
49
49
  select_color: "Color",
50
50
  select_color_type: "Color type",
@@ -5,9 +5,9 @@ import { CHART_GROUPS } from "../constants/CHART_GROUP";
5
5
  import { STRING_FORMAT } from "../constants/STRING_FORMAT";
6
6
  import { TABLE_TYPE } from "../constants/TABLE_TYPE";
7
7
  import { columnTypeByChart } from "./columnTypeByChart";
8
+ import { STANDARD_NUMERIC_FORMATS } from "../../format/definition";
8
9
  import { CALCULATION_LABEL } from "../../qrvey/constants/CALCULATION_LABEL";
9
10
  import { DATEGROUP_UNSUPPORT_FORMAT } from "../constants/DATEGROUP_UNSUPPORT_FORMAT";
10
- import { DURATION_PARTS_LIST } from '../constants/DURATION_PARTS_LIST';
11
11
  /**
12
12
  * It returns the format of a column based on the column type, the chart type, and the chart settings
13
13
  * @param {IChartColumn} column - IChartColumn
@@ -73,7 +73,7 @@ export const defineTableChartFormat = (column, settings) => {
73
73
  else {
74
74
  output = defaultFormat || defaultNumeric;
75
75
  }
76
- if (DURATION_PARTS_LIST.includes(output === null || output === void 0 ? void 0 : output.format)) {
76
+ if (!STANDARD_NUMERIC_FORMATS.includes(output === null || output === void 0 ? void 0 : output.format)) {
77
77
  output = Object.assign(Object.assign({}, output), { template: output.format, format: "Duration" });
78
78
  }
79
79
  return output;
@@ -1,4 +1,5 @@
1
1
  import { isEmpty } from "../../../general/mix/isEmpty";
2
+ import { cloneDeep } from "../../../general/object/cloneDeep";
2
3
  /**
3
4
  * Excludes filters from the given Filters.
4
5
  * The validation to filter the stored filter is depending on:
@@ -19,6 +20,7 @@ export function excludeFiltersByParams(filterData, params) {
19
20
  return;
20
21
  if (isEmpty(params))
21
22
  return filterData;
23
+ filterData = cloneDeep(filterData);
22
24
  filterData.scopes = filterData.scopes
23
25
  .map((scope) => {
24
26
  if (resolveScopeConditions(scope, params)) {
@@ -52,8 +54,7 @@ export function excludeFiltersByParams(filterData, params) {
52
54
  .filter((filter) => {
53
55
  var _a;
54
56
  return !isEmpty(filter) &&
55
- filter.selectAll &&
56
- ((_a = filter.values) === null || _a === void 0 ? void 0 : _a.length) > 0;
57
+ (filter.selectAll || ((_a = filter.values) === null || _a === void 0 ? void 0 : _a.length) > 0);
57
58
  }) });
58
59
  }
59
60
  })
@@ -67,7 +68,7 @@ function resolveScopeConditions(scope, params) {
67
68
  return ((params.enableds == null || params.enableds !== scope.enabled) &&
68
69
  (isEmpty(params.scope) || scope.scope !== params.scope) &&
69
70
  (isEmpty(params.scopeid) || scope.scopeid !== params.scopeid) &&
70
- scope.datasets.filter.length > 0);
71
+ scope.datasets.length > 0);
71
72
  }
72
73
  function resolveDatasetConditions(dataset, params) {
73
74
  return ((params.enableds == null || params.enableds !== dataset.enabled) &&
@@ -22,5 +22,5 @@ export function resolveScopeConditions(scope, params, letPassUndefinedProperties
22
22
  (letPassUndefinedProperties && scope.scopeid == null) ||
23
23
  (letPassUndefinedParams && isEmpty(params.scopeid)) ||
24
24
  scope.scopeid === params.scopeid) &&
25
- scope.datasets.filter.length > 0);
25
+ scope.datasets.length > 0);
26
26
  }
@@ -21,6 +21,7 @@ export declare const enum LOCALE_FORMATS {
21
21
  ABBREVIATED = "Abbreviated",
22
22
  DURATION = "Duration"
23
23
  }
24
+ export declare const STANDARD_NUMERIC_FORMATS: LOCALE_FORMATS[];
24
25
  export declare const enum LOCALE_STYLES {
25
26
  DECIMAL = "decimal",
26
27
  PERCENT = "percent",
@@ -97,6 +97,13 @@ export const currencyISO = [
97
97
  { text: "฿ (THB)", label: "THB" },
98
98
  { text: "RM (MYR)", label: "MYR" },
99
99
  ];
100
+ export const STANDARD_NUMERIC_FORMATS = [
101
+ "Abbreviated" /* LOCALE_FORMATS.ABBREVIATED */,
102
+ "Currency" /* LOCALE_FORMATS.CURRENCY */,
103
+ "Decimal" /* LOCALE_FORMATS.DECIMAL */,
104
+ "Percentage" /* LOCALE_FORMATS.PERCENTAGE */,
105
+ "Scientific" /* LOCALE_FORMATS.SCIENTIFIC */,
106
+ ];
100
107
  export const LANG_DEFAULT = "en-US";
101
108
  export const CURRENCY_DEFAULT = { text: "$ (USD)", label: "USD" };
102
109
  export const DATETIME_OPTIONS = {
@@ -130,10 +130,6 @@ export class DurationFormatter {
130
130
  number %= part.ms;
131
131
  return store;
132
132
  }, {});
133
- if (!Number.isInteger(number))
134
- return number === null
135
- ? null
136
- : this.valueFormatter.format(number).padStart(this.parts.length, "0");
137
133
  if (isEmpty(this.template))
138
134
  return this.valueFormatter
139
135
  .format(number)
@@ -69,6 +69,7 @@ import { II18nChartBuilderTimePeriod } from "./II18nChartBuilderTimePeriod";
69
69
  import { II18nChartBuilderTimePeriodCustomRange } from "./II18nChartBuilderTimePeriodCustomRange";
70
70
  import { II18nChartBuilderWordCloud } from "./II18nChartBuilderWordCloud";
71
71
  import { II18nChartBuilderBoxWhisker } from "./II18nChartBuilderBoxWhisker";
72
+ import { II18nChartBuilderDurationParts } from "./II18nChartBuilderDurationParts";
72
73
  export interface II18nChartBuilder {
73
74
  action_panel: II18nChartBuilderActionPanel;
74
75
  aggregated_formula: II18nChartBuilderAggregatedFormulas;
@@ -141,4 +142,5 @@ export interface II18nChartBuilder {
141
142
  trend_chart: II18nChartBuilderTrendChart;
142
143
  trends_line: II18nChartBuilderTrendsLine;
143
144
  word_cloud: II18nChartBuilderWordCloud;
145
+ duration_parts: II18nChartBuilderDurationParts;
144
146
  }
@@ -0,0 +1,9 @@
1
+ export interface II18nChartBuilderDurationParts {
2
+ full_duration: string;
3
+ hour_minute_seconds: string;
4
+ hour_minutes: string;
5
+ hours: string;
6
+ minutes: string;
7
+ seconds: string;
8
+ milliseconds: string;
9
+ }
@@ -70,3 +70,4 @@ export * from "./II18nChartBuilderTimePeriod";
70
70
  export * from "./II18nChartBuilderTimePeriodCustomRange";
71
71
  export * from "./II18nChartBuilderWordCloud";
72
72
  export * from "./II18nChartBuilderBoxWhisker";
73
+ export * from "./II18nChartBuilderDurationParts";
@@ -70,3 +70,4 @@ export * from "./II18nChartBuilderTimePeriod";
70
70
  export * from "./II18nChartBuilderTimePeriodCustomRange";
71
71
  export * from "./II18nChartBuilderWordCloud";
72
72
  export * from "./II18nChartBuilderBoxWhisker";
73
+ export * from "./II18nChartBuilderDurationParts";
@@ -24,6 +24,14 @@ export const I18N_CHART_BUILDER = Object.assign(Object.assign(Object.assign(Obje
24
24
  date_format: "Date Format",
25
25
  value_format: "Value Format",
26
26
  duration: "Duration",
27
+ }, duration_parts: {
28
+ full_duration: "D[d] HH[h] mm[m] ss[s]",
29
+ hour_minute_seconds: "HH:mm:ss",
30
+ hour_minutes: "HH:mm",
31
+ hours: "HH",
32
+ minutes: "mm",
33
+ seconds: "ss (Seconds)",
34
+ milliseconds: "SSS (Milliseconds)",
27
35
  }, chart_names: {
28
36
  bar: "Bar",
29
37
  line: "Line",
@@ -41,7 +41,7 @@ export const I18N_CHART_BUILDER_STYLE_OPTIONS = {
41
41
  },
42
42
  color_settings: {
43
43
  color_by_category: "By category",
44
- color_by_value_title: "Color by value",
44
+ color_by_value_title: "Color by values",
45
45
  match_color: "Match colors across charts",
46
46
  select_color: "Color",
47
47
  select_color_type: "Color type",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@qrvey/utils",
3
- "version": "1.5.0-5",
3
+ "version": "1.5.0-8",
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",