@qrvey/utils 1.5.0-0 → 1.5.0-3

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 (46) hide show
  1. package/README.md +1 -1
  2. package/dist/cjs/column_format/constants/DURATION_PARTS_LIST.d.ts +1 -0
  3. package/dist/cjs/column_format/constants/DURATION_PARTS_LIST.js +12 -0
  4. package/dist/cjs/column_format/constants/index.d.ts +1 -0
  5. package/dist/cjs/column_format/constants/index.js +1 -0
  6. package/dist/cjs/column_format/helpers/defineTableChartFormat.js +19 -10
  7. package/dist/cjs/column_format/helpers/defineXYChartFormat.js +4 -1
  8. package/dist/cjs/dates/constants/DATETIME_COLUMN_FORMAT.js +1 -0
  9. package/dist/cjs/filters/helpers/getTokensFromFilters.js +9 -4
  10. package/dist/cjs/format/definition.d.ts +2 -1
  11. package/dist/cjs/format/format.js +4 -1
  12. package/dist/cjs/format/localization.js +18 -2
  13. package/dist/cjs/globalization/interfaces/II18nResource.d.ts +2 -0
  14. package/dist/cjs/globalization/interfaces/chart_builder/II18nChartBuilderFormatValues.d.ts +1 -0
  15. package/dist/cjs/globalization/interfaces/common/II18nCommon.d.ts +1 -0
  16. package/dist/cjs/globalization/interfaces/tabular_view/II18nTabularView.d.ts +4 -0
  17. package/dist/cjs/globalization/interfaces/tabular_view/II18nTabularView.js +2 -0
  18. package/dist/cjs/globalization/labels/I18N_DEFAULT.js +2 -0
  19. package/dist/cjs/globalization/labels/chart_builder/I18N_CHART_BUILDER.js +1 -0
  20. package/dist/cjs/globalization/labels/common/I18N_COMMON.js +1 -0
  21. package/dist/cjs/globalization/labels/tabular_view/I18N_TABULAR_VIEW.d.ts +2 -0
  22. package/dist/cjs/globalization/labels/tabular_view/I18N_TABULAR_VIEW.js +7 -0
  23. package/dist/cjs/interfaces/format/IFormatOutputFormat.Interface.d.ts +1 -0
  24. package/dist/column_format/constants/DURATION_PARTS_LIST.d.ts +1 -0
  25. package/dist/column_format/constants/DURATION_PARTS_LIST.js +9 -0
  26. package/dist/column_format/constants/index.d.ts +1 -0
  27. package/dist/column_format/constants/index.js +1 -0
  28. package/dist/column_format/helpers/defineTableChartFormat.js +19 -10
  29. package/dist/column_format/helpers/defineXYChartFormat.js +4 -1
  30. package/dist/dates/constants/DATETIME_COLUMN_FORMAT.js +1 -0
  31. package/dist/filters/helpers/getTokensFromFilters.js +9 -4
  32. package/dist/format/definition.d.ts +2 -1
  33. package/dist/format/format.js +4 -1
  34. package/dist/format/localization.js +18 -2
  35. package/dist/globalization/interfaces/II18nResource.d.ts +2 -0
  36. package/dist/globalization/interfaces/chart_builder/II18nChartBuilderFormatValues.d.ts +1 -0
  37. package/dist/globalization/interfaces/common/II18nCommon.d.ts +1 -0
  38. package/dist/globalization/interfaces/tabular_view/II18nTabularView.d.ts +4 -0
  39. package/dist/globalization/interfaces/tabular_view/II18nTabularView.js +1 -0
  40. package/dist/globalization/labels/I18N_DEFAULT.js +2 -0
  41. package/dist/globalization/labels/chart_builder/I18N_CHART_BUILDER.js +1 -0
  42. package/dist/globalization/labels/common/I18N_COMMON.js +1 -0
  43. package/dist/globalization/labels/tabular_view/I18N_TABULAR_VIEW.d.ts +2 -0
  44. package/dist/globalization/labels/tabular_view/I18N_TABULAR_VIEW.js +4 -0
  45. package/dist/interfaces/format/IFormatOutputFormat.Interface.d.ts +1 -0
  46. 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-0*
1
+ # [@qrvey/utils](https://bitbucket.org/qrvey/qrvey_utils/wiki/Home) *1.5.0-3*
2
2
 
3
3
  > Helper, Utils for all Qrvey Projects
4
4
 
@@ -0,0 +1 @@
1
+ export declare const DURATION_PARTS_LIST: string[];
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.DURATION_PARTS_LIST = void 0;
4
+ exports.DURATION_PARTS_LIST = [
5
+ "D[d] HH[h] mm[m] ss[s]",
6
+ "HH:mm:ss",
7
+ "HH:mm",
8
+ "HH",
9
+ "mm",
10
+ "ss",
11
+ "SSS",
12
+ ];
@@ -4,3 +4,4 @@ export * from "./DATEGROUP_WITHOUT_FORMAT";
4
4
  export * from "./SHELF_TYPE";
5
5
  export * from "./STRING_FORMAT";
6
6
  export * from "./TABLE_TYPE";
7
+ export * from "./DURATION_PARTS_LIST";
@@ -20,3 +20,4 @@ __exportStar(require("./DATEGROUP_WITHOUT_FORMAT"), exports);
20
20
  __exportStar(require("./SHELF_TYPE"), exports);
21
21
  __exportStar(require("./STRING_FORMAT"), exports);
22
22
  __exportStar(require("./TABLE_TYPE"), exports);
23
+ __exportStar(require("./DURATION_PARTS_LIST"), exports);
@@ -10,6 +10,7 @@ const TABLE_TYPE_1 = require("../constants/TABLE_TYPE");
10
10
  const columnTypeByChart_1 = require("./columnTypeByChart");
11
11
  const CALCULATION_LABEL_1 = require("../../qrvey/constants/CALCULATION_LABEL");
12
12
  const DATEGROUP_UNSUPPORT_FORMAT_1 = require("../constants/DATEGROUP_UNSUPPORT_FORMAT");
13
+ const DURATION_PARTS_LIST_1 = require("../constants/DURATION_PARTS_LIST");
13
14
  /**
14
15
  * It returns the format of a column based on the column type, the chart type, and the chart settings
15
16
  * @param {IChartColumn} column - IChartColumn
@@ -60,17 +61,25 @@ const defineTableChartFormat = (column, settings) => {
60
61
  case COLUMN_1.COLUMN.NUMERIC:
61
62
  case COLUMN_1.COLUMN.RATING:
62
63
  case COLUMN_1.COLUMN.SLIDEBAR: {
63
- if (selectedFormat)
64
- return selectedFormat;
65
- if ((calculation === null || calculation === void 0 ? void 0 : calculation.value) === CALCULATION_LABEL_1.CALCULATION_LABEL.PDIFF)
66
- return defaultPercentage;
67
- if (hasDefaultFormat) {
68
- if ((aggregate === null || aggregate === void 0 ? void 0 : aggregate.label) === AGGREGATE_1.AGGREGATE.COUNT ||
69
- (aggregate === null || aggregate === void 0 ? void 0 : aggregate.label) === AGGREGATE_1.AGGREGATE.DISTINCTCOUNT)
70
- return defaultNumeric;
71
- return defaultFormat || defaultNumeric;
64
+ let output;
65
+ if (selectedFormat && selectedFormat.format !== "Default") {
66
+ output = selectedFormat;
72
67
  }
73
- return;
68
+ else if ((calculation === null || calculation === void 0 ? void 0 : calculation.value) === CALCULATION_LABEL_1.CALCULATION_LABEL.PDIFF) {
69
+ output = defaultPercentage;
70
+ }
71
+ else if (isGroupedTable &&
72
+ ((aggregate === null || aggregate === void 0 ? void 0 : aggregate.label) === AGGREGATE_1.AGGREGATE.COUNT ||
73
+ (aggregate === null || aggregate === void 0 ? void 0 : aggregate.label) === AGGREGATE_1.AGGREGATE.DISTINCTCOUNT)) {
74
+ output = defaultNumeric;
75
+ }
76
+ else {
77
+ output = defaultFormat || defaultNumeric;
78
+ }
79
+ if (DURATION_PARTS_LIST_1.DURATION_PARTS_LIST.includes(output === null || output === void 0 ? void 0 : output.format)) {
80
+ output = Object.assign(Object.assign({}, output), { template: output.format, format: "Duration" });
81
+ }
82
+ return output;
74
83
  }
75
84
  }
76
85
  };
@@ -7,6 +7,7 @@ const isEmpty_1 = require("../../general/mix/isEmpty");
7
7
  const CALCULATION_LABEL_1 = require("../../qrvey/constants/CALCULATION_LABEL");
8
8
  const CHART_GROUP_1 = require("../constants/CHART_GROUP");
9
9
  const DATEGROUP_UNSUPPORT_FORMAT_1 = require("../constants/DATEGROUP_UNSUPPORT_FORMAT");
10
+ const DURATION_PARTS_LIST_1 = require("../constants/DURATION_PARTS_LIST");
10
11
  const STRING_FORMAT_1 = require("../constants/STRING_FORMAT");
11
12
  const columnTypeByChart_1 = require("./columnTypeByChart");
12
13
  /**
@@ -37,6 +38,8 @@ const defineXYChartFormat = (column, settings) => {
37
38
  const hasDefaultFormat = (0, isEmpty_1.isEmpty)(selectedFormat) ||
38
39
  (outputFormat === null || outputFormat === void 0 ? void 0 : outputFormat.format) === defaultText ||
39
40
  (selectedFormat === null || selectedFormat === void 0 ? void 0 : selectedFormat.format) === defaultText;
41
+ const newOutputFormat = DURATION_PARTS_LIST_1.DURATION_PARTS_LIST.includes(outputFormat === null || outputFormat === void 0 ? void 0 : outputFormat.format)
42
+ ? Object.assign(Object.assign({}, outputFormat), { template: outputFormat.format, format: "Duration" }) : outputFormat;
40
43
  switch (columnType) {
41
44
  case COLUMN_1.COLUMN.YES_NO:
42
45
  case COLUMN_1.COLUMN.PHONE:
@@ -82,7 +85,7 @@ const defineXYChartFormat = (column, settings) => {
82
85
  return columnDefaultFormat;
83
86
  }
84
87
  else if (hasDefaultFormat) {
85
- return Object.assign({}, outputFormat);
88
+ return Object.assign({}, newOutputFormat);
86
89
  }
87
90
  else
88
91
  return selectedFormat;
@@ -8,4 +8,5 @@ exports.DATETIME_COLUMN_FORMAT = [
8
8
  "MM/DD/YYYY HH24:MI:SS",
9
9
  "DD/MM/YYYY HH24:MI:SS",
10
10
  "YYYY-MM-DD HH24:MI:SS",
11
+ "YYYY-MM-DD HH:mm:ss",
11
12
  ];
@@ -12,7 +12,7 @@ const isEmpty_1 = require("../../general/mix/isEmpty");
12
12
  * @returns {IFFilterTokens[]} An array of tokens that represents the filters object
13
13
  */
14
14
  function getTokensFromFilters(filters, options) {
15
- var _a, _b;
15
+ var _a, _b, _c;
16
16
  const tokens = [];
17
17
  const i18nService = options.i18nService;
18
18
  const settings = {
@@ -48,16 +48,21 @@ function getTokensFromFilters(filters, options) {
48
48
  });
49
49
  }
50
50
  for (const [index, filter] of Object.entries(database.filters)) {
51
- if (!(filter === null || filter === void 0 ? void 0 : filter.enabled))
51
+ if (!(filter === null || filter === void 0 ? void 0 : filter.enabled)) {
52
+ if (((_a = tokens[tokens.length - 1]) === null || _a === void 0 ? void 0 : _a.type) ===
53
+ FILTER_TOKENS_STRUCTURE_TYPE_1.FILTER_TOKENS_STRUCTURE_TYPE.LOGICAL_OPERATOR) {
54
+ tokens.pop();
55
+ }
52
56
  continue;
57
+ }
53
58
  const values = (0, getUIValues_1.getUIValues)(filter, settings);
54
59
  if (!thereIsFiltersWithValues)
55
60
  thereIsFiltersWithValues = true;
56
61
  let columnLabel = filter.column.label;
57
- if ((_a = filter === null || filter === void 0 ? void 0 : filter.column) === null || _a === void 0 ? void 0 : _a.aggregate) {
62
+ if ((_b = filter === null || filter === void 0 ? void 0 : filter.column) === null || _b === void 0 ? void 0 : _b.aggregate) {
58
63
  columnLabel +=
59
64
  " (" +
60
- i18nService.translate(`common.aggregate_labels.${(_b = filter === null || filter === void 0 ? void 0 : filter.column) === null || _b === void 0 ? void 0 : _b.aggregate.toLowerCase()}`) +
65
+ i18nService.translate(`common.aggregate_labels.${(_c = filter === null || filter === void 0 ? void 0 : filter.column) === null || _c === void 0 ? void 0 : _c.aggregate.toLowerCase()}`) +
61
66
  ")";
62
67
  }
63
68
  tokens.push({
@@ -18,7 +18,8 @@ export declare const enum LOCALE_FORMATS {
18
18
  CURRENCY = "Currency",
19
19
  PERCENTAGE = "Percentage",
20
20
  SCIENTIFIC = "Scientific",
21
- ABBREVIATED = "Abbreviated"
21
+ ABBREVIATED = "Abbreviated",
22
+ DURATION = "Duration"
22
23
  }
23
24
  export declare const enum LOCALE_STYLES {
24
25
  DECIMAL = "decimal",
@@ -14,6 +14,7 @@ const COLUMN_1 = require("../columns/constants/COLUMN");
14
14
  const FORMULA_1 = require("../formulas/constants/FORMULA");
15
15
  const localization_1 = require("./localization");
16
16
  const isObject_1 = require("../general/object/isObject");
17
+ const DURATION_PARTS_LIST_1 = require("../column_format/constants/DURATION_PARTS_LIST");
17
18
  dayjs_1.default.extend(advancedFormat_1.default); // Add support to advanced formats https://day.js.org/docs/en/plugin/advanced-format
18
19
  /**
19
20
  * Apply to the given date format to a date value
@@ -114,7 +115,9 @@ const addFormat = (value, outputFormat = "None", config) => {
114
115
  : outputFormat === null || outputFormat === void 0 ? void 0 : outputFormat.format);
115
116
  case "NUMERIC": {
116
117
  const parse = parseFloat(value);
117
- const withLocale = outputFormat !== "None" && (config === null || config === void 0 ? void 0 : config.lang);
118
+ const withLocale = (outputFormat !== "None" && (config === null || config === void 0 ? void 0 : config.lang)) ||
119
+ (outputFormat === null || outputFormat === void 0 ? void 0 : outputFormat.format) === "Duration" ||
120
+ DURATION_PARTS_LIST_1.DURATION_PARTS_LIST.includes[outputFormat === null || outputFormat === void 0 ? void 0 : outputFormat.format];
118
121
  return isNaN(parse)
119
122
  ? value
120
123
  : withLocale
@@ -4,6 +4,7 @@ exports.formatWithLocale = exports.chooseLang = exports.getLang = void 0;
4
4
  const DATETIME_COLUMN_FORMAT_1 = require("../dates/constants/DATETIME_COLUMN_FORMAT");
5
5
  const isEmpty_1 = require("../general/mix/isEmpty");
6
6
  const definition_1 = require("./definition");
7
+ const durationFormatter_1 = require("./duration/durationFormatter");
7
8
  const getLang = (locale) => {
8
9
  if (!locale)
9
10
  return;
@@ -61,10 +62,20 @@ function formatLocaleNumber(value, outputFormat, config) {
61
62
  const langOpts = options || getLocaleOptions(outputFormat);
62
63
  const valueToFormat = (outputFormat === null || outputFormat === void 0 ? void 0 : outputFormat.format) === "Percentage" /* LOCALE_FORMATS.PERCENTAGE */ ? value / 100 : value;
63
64
  try {
64
- const key = lang + JSON.stringify(langOpts);
65
+ const key = (outputFormat === null || outputFormat === void 0 ? void 0 : outputFormat.format) +
66
+ lang +
67
+ JSON.stringify(langOpts) +
68
+ ((outputFormat === null || outputFormat === void 0 ? void 0 : outputFormat.template) ? outputFormat.template : "");
65
69
  let formatter = NUMBER_FORMAT_CACHE[key];
66
70
  if (!formatter) {
67
- formatter = new Intl.NumberFormat([lang, definition_1.LANG_DEFAULT], langOpts);
71
+ const intlNumberFormat = new Intl.NumberFormat([lang, definition_1.LANG_DEFAULT], langOpts);
72
+ formatter =
73
+ (outputFormat === null || outputFormat === void 0 ? void 0 : outputFormat.format) === "Duration" /* LOCALE_FORMATS.DURATION */
74
+ ? new durationFormatter_1.DurationFormatter({
75
+ template: outputFormat === null || outputFormat === void 0 ? void 0 : outputFormat.template,
76
+ intlNumberFormat,
77
+ })
78
+ : intlNumberFormat;
68
79
  NUMBER_FORMAT_CACHE[key] = formatter;
69
80
  }
70
81
  return formatter.format(valueToFormat);
@@ -113,6 +124,11 @@ function getLocaleOptions(outputFormat) {
113
124
  maximumFractionDigits: decimals,
114
125
  minimumFractionDigits: decimals,
115
126
  };
127
+ case "Duration" /* LOCALE_FORMATS.DURATION */:
128
+ return {
129
+ maximumFractionDigits: 0,
130
+ minimumFractionDigits: 0,
131
+ };
116
132
  default:
117
133
  return {
118
134
  style: "decimal" /* LOCALE_STYLES.DECIMAL */,
@@ -11,6 +11,7 @@ import { II18nBucketBuilder } from "./bucket_builder/II18nBucketBuilder";
11
11
  import { II18nCrossTabs } from "./cross_tabs";
12
12
  import { II18nChartBuilder } from ".";
13
13
  import { II18nStyleThemes } from "./style_themes/II18nStyleThemes";
14
+ import { II18nTabularView } from './tabular_view/II18nTabularView';
14
15
  export interface II18nResource {
15
16
  bucket_builder?: II18nBucketBuilder;
16
17
  chart_builder?: II18nChartBuilder;
@@ -25,4 +26,5 @@ export interface II18nResource {
25
26
  panel?: II18nPanel;
26
27
  style_themes?: II18nStyleThemes;
27
28
  table_charts?: II18nTableCharts;
29
+ tabular_view?: II18nTabularView;
28
30
  }
@@ -14,4 +14,5 @@ export interface II18nChartBuilderFormatValues {
14
14
  custom: string;
15
15
  date_format: string;
16
16
  value_format: string;
17
+ duration: string;
17
18
  }
@@ -16,5 +16,6 @@ export interface II18nCommon {
16
16
  no_data_found: string;
17
17
  properties: II18nColumnProperties;
18
18
  search: string;
19
+ sort: string;
19
20
  units: II18nUnits;
20
21
  }
@@ -0,0 +1,4 @@
1
+ export interface II18nTabularView {
2
+ all: string;
3
+ select_columns: string;
4
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -11,6 +11,7 @@ const formula_builder_1 = require("./formula_builder");
11
11
  const I18N_FILTER_PANEL_1 = require("./filters/I18N_FILTER_PANEL");
12
12
  const I18N_FILTER_DISPLAY_1 = require("./filters/I18N_FILTER_DISPLAY");
13
13
  const I18N_BUCKET_BUILDER_1 = require("./bucket_builder/I18N_BUCKET_BUILDER");
14
+ const I18N_TABULAR_VIEW_1 = require("./tabular_view/I18N_TABULAR_VIEW");
14
15
  const cross_tabs_1 = require("./cross_tabs");
15
16
  const chart_builder_1 = require("./chart_builder");
16
17
  const style_themes_1 = require("./style_themes");
@@ -28,4 +29,5 @@ exports.I18N_DEFAULT = {
28
29
  panel: I18N_PANEL_1.I18N_PANEL,
29
30
  style_themes: style_themes_1.I18N_STYLE_THEMES,
30
31
  table_charts: table_charts_1.I18N_TABLE_CHARTS,
32
+ tabular_view: I18N_TABULAR_VIEW_1.I18N_TABULAR_VIEW
31
33
  };
@@ -26,6 +26,7 @@ exports.I18N_CHART_BUILDER = Object.assign(Object.assign(Object.assign(Object.as
26
26
  custom: "Custom Format",
27
27
  date_format: "Date Format",
28
28
  value_format: "Value Format",
29
+ duration: "Duration",
29
30
  }, chart_names: {
30
31
  bar: "Bar",
31
32
  line: "Line",
@@ -23,6 +23,7 @@ exports.I18N_COMMON = {
23
23
  no_data_found: "No Data Found",
24
24
  properties: I18N_COLUMN_PROPERTY_LABEL_1.I18N_COLUMN_PROPERTY_LABEL,
25
25
  search: "Search",
26
+ sort: "Sort",
26
27
  units: {
27
28
  day: RELATIVE_UNIT_INFO_1.RELATIVE_UNIT_INFO.DAY.label,
28
29
  month: RELATIVE_UNIT_INFO_1.RELATIVE_UNIT_INFO.MONTH.label,
@@ -0,0 +1,2 @@
1
+ import { II18nTabularView } from "../../interfaces/tabular_view/II18nTabularView";
2
+ export declare const I18N_TABULAR_VIEW: II18nTabularView;
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.I18N_TABULAR_VIEW = void 0;
4
+ exports.I18N_TABULAR_VIEW = {
5
+ all: "Todas",
6
+ select_columns: "Select Columns",
7
+ };
@@ -4,4 +4,5 @@ export interface IFormatOutputFormat extends IFormatDefaultFormat {
4
4
  currency?: IFormatCurrency;
5
5
  backup_currency?: IFormatCurrency;
6
6
  originalFormat?: IFormatOutputFormat;
7
+ template?: string;
7
8
  }
@@ -0,0 +1 @@
1
+ export declare const DURATION_PARTS_LIST: string[];
@@ -0,0 +1,9 @@
1
+ export const DURATION_PARTS_LIST = [
2
+ "D[d] HH[h] mm[m] ss[s]",
3
+ "HH:mm:ss",
4
+ "HH:mm",
5
+ "HH",
6
+ "mm",
7
+ "ss",
8
+ "SSS",
9
+ ];
@@ -4,3 +4,4 @@ export * from "./DATEGROUP_WITHOUT_FORMAT";
4
4
  export * from "./SHELF_TYPE";
5
5
  export * from "./STRING_FORMAT";
6
6
  export * from "./TABLE_TYPE";
7
+ export * from "./DURATION_PARTS_LIST";
@@ -4,3 +4,4 @@ export * from "./DATEGROUP_WITHOUT_FORMAT";
4
4
  export * from "./SHELF_TYPE";
5
5
  export * from "./STRING_FORMAT";
6
6
  export * from "./TABLE_TYPE";
7
+ export * from "./DURATION_PARTS_LIST";
@@ -7,6 +7,7 @@ import { TABLE_TYPE } from "../constants/TABLE_TYPE";
7
7
  import { columnTypeByChart } from "./columnTypeByChart";
8
8
  import { CALCULATION_LABEL } from "../../qrvey/constants/CALCULATION_LABEL";
9
9
  import { DATEGROUP_UNSUPPORT_FORMAT } from "../constants/DATEGROUP_UNSUPPORT_FORMAT";
10
+ import { DURATION_PARTS_LIST } from '../constants/DURATION_PARTS_LIST';
10
11
  /**
11
12
  * It returns the format of a column based on the column type, the chart type, and the chart settings
12
13
  * @param {IChartColumn} column - IChartColumn
@@ -57,17 +58,25 @@ export const defineTableChartFormat = (column, settings) => {
57
58
  case COLUMN.NUMERIC:
58
59
  case COLUMN.RATING:
59
60
  case COLUMN.SLIDEBAR: {
60
- if (selectedFormat)
61
- return selectedFormat;
62
- if ((calculation === null || calculation === void 0 ? void 0 : calculation.value) === CALCULATION_LABEL.PDIFF)
63
- return defaultPercentage;
64
- if (hasDefaultFormat) {
65
- if ((aggregate === null || aggregate === void 0 ? void 0 : aggregate.label) === AGGREGATE.COUNT ||
66
- (aggregate === null || aggregate === void 0 ? void 0 : aggregate.label) === AGGREGATE.DISTINCTCOUNT)
67
- return defaultNumeric;
68
- return defaultFormat || defaultNumeric;
61
+ let output;
62
+ if (selectedFormat && selectedFormat.format !== "Default") {
63
+ output = selectedFormat;
69
64
  }
70
- return;
65
+ else if ((calculation === null || calculation === void 0 ? void 0 : calculation.value) === CALCULATION_LABEL.PDIFF) {
66
+ output = defaultPercentage;
67
+ }
68
+ else if (isGroupedTable &&
69
+ ((aggregate === null || aggregate === void 0 ? void 0 : aggregate.label) === AGGREGATE.COUNT ||
70
+ (aggregate === null || aggregate === void 0 ? void 0 : aggregate.label) === AGGREGATE.DISTINCTCOUNT)) {
71
+ output = defaultNumeric;
72
+ }
73
+ else {
74
+ output = defaultFormat || defaultNumeric;
75
+ }
76
+ if (DURATION_PARTS_LIST.includes(output === null || output === void 0 ? void 0 : output.format)) {
77
+ output = Object.assign(Object.assign({}, output), { template: output.format, format: "Duration" });
78
+ }
79
+ return output;
71
80
  }
72
81
  }
73
82
  };
@@ -4,6 +4,7 @@ import { isEmpty } from "../../general/mix/isEmpty";
4
4
  import { CALCULATION_LABEL } from "../../qrvey/constants/CALCULATION_LABEL";
5
5
  import { CHART_GROUPS } from "../constants/CHART_GROUP";
6
6
  import { DATEGROUP_UNSUPPORT_FORMAT } from "../constants/DATEGROUP_UNSUPPORT_FORMAT";
7
+ import { DURATION_PARTS_LIST } from "../constants/DURATION_PARTS_LIST";
7
8
  import { STRING_FORMAT } from "../constants/STRING_FORMAT";
8
9
  import { columnTypeByChart } from "./columnTypeByChart";
9
10
  /**
@@ -34,6 +35,8 @@ export const defineXYChartFormat = (column, settings) => {
34
35
  const hasDefaultFormat = isEmpty(selectedFormat) ||
35
36
  (outputFormat === null || outputFormat === void 0 ? void 0 : outputFormat.format) === defaultText ||
36
37
  (selectedFormat === null || selectedFormat === void 0 ? void 0 : selectedFormat.format) === defaultText;
38
+ const newOutputFormat = DURATION_PARTS_LIST.includes(outputFormat === null || outputFormat === void 0 ? void 0 : outputFormat.format)
39
+ ? Object.assign(Object.assign({}, outputFormat), { template: outputFormat.format, format: "Duration" }) : outputFormat;
37
40
  switch (columnType) {
38
41
  case COLUMN.YES_NO:
39
42
  case COLUMN.PHONE:
@@ -79,7 +82,7 @@ export const defineXYChartFormat = (column, settings) => {
79
82
  return columnDefaultFormat;
80
83
  }
81
84
  else if (hasDefaultFormat) {
82
- return Object.assign({}, outputFormat);
85
+ return Object.assign({}, newOutputFormat);
83
86
  }
84
87
  else
85
88
  return selectedFormat;
@@ -5,4 +5,5 @@ export const DATETIME_COLUMN_FORMAT = [
5
5
  "MM/DD/YYYY HH24:MI:SS",
6
6
  "DD/MM/YYYY HH24:MI:SS",
7
7
  "YYYY-MM-DD HH24:MI:SS",
8
+ "YYYY-MM-DD HH:mm:ss",
8
9
  ];
@@ -9,7 +9,7 @@ import { isEmpty } from "../../general/mix/isEmpty";
9
9
  * @returns {IFFilterTokens[]} An array of tokens that represents the filters object
10
10
  */
11
11
  export function getTokensFromFilters(filters, options) {
12
- var _a, _b;
12
+ var _a, _b, _c;
13
13
  const tokens = [];
14
14
  const i18nService = options.i18nService;
15
15
  const settings = {
@@ -45,16 +45,21 @@ export function getTokensFromFilters(filters, options) {
45
45
  });
46
46
  }
47
47
  for (const [index, filter] of Object.entries(database.filters)) {
48
- if (!(filter === null || filter === void 0 ? void 0 : filter.enabled))
48
+ if (!(filter === null || filter === void 0 ? void 0 : filter.enabled)) {
49
+ if (((_a = tokens[tokens.length - 1]) === null || _a === void 0 ? void 0 : _a.type) ===
50
+ FILTER_TOKENS_STRUCTURE_TYPE.LOGICAL_OPERATOR) {
51
+ tokens.pop();
52
+ }
49
53
  continue;
54
+ }
50
55
  const values = getUIValues(filter, settings);
51
56
  if (!thereIsFiltersWithValues)
52
57
  thereIsFiltersWithValues = true;
53
58
  let columnLabel = filter.column.label;
54
- if ((_a = filter === null || filter === void 0 ? void 0 : filter.column) === null || _a === void 0 ? void 0 : _a.aggregate) {
59
+ if ((_b = filter === null || filter === void 0 ? void 0 : filter.column) === null || _b === void 0 ? void 0 : _b.aggregate) {
55
60
  columnLabel +=
56
61
  " (" +
57
- i18nService.translate(`common.aggregate_labels.${(_b = filter === null || filter === void 0 ? void 0 : filter.column) === null || _b === void 0 ? void 0 : _b.aggregate.toLowerCase()}`) +
62
+ i18nService.translate(`common.aggregate_labels.${(_c = filter === null || filter === void 0 ? void 0 : filter.column) === null || _c === void 0 ? void 0 : _c.aggregate.toLowerCase()}`) +
58
63
  ")";
59
64
  }
60
65
  tokens.push({
@@ -18,7 +18,8 @@ export declare const enum LOCALE_FORMATS {
18
18
  CURRENCY = "Currency",
19
19
  PERCENTAGE = "Percentage",
20
20
  SCIENTIFIC = "Scientific",
21
- ABBREVIATED = "Abbreviated"
21
+ ABBREVIATED = "Abbreviated",
22
+ DURATION = "Duration"
22
23
  }
23
24
  export declare const enum LOCALE_STYLES {
24
25
  DECIMAL = "decimal",
@@ -8,6 +8,7 @@ import { COLUMN } from "../columns/constants/COLUMN";
8
8
  import { FORMULA } from "../formulas/constants/FORMULA";
9
9
  import { formatWithLocale } from "./localization";
10
10
  import { isObject } from "../general/object/isObject";
11
+ import { DURATION_PARTS_LIST } from "../column_format/constants/DURATION_PARTS_LIST";
11
12
  dayjs.extend(advancedFormat); // Add support to advanced formats https://day.js.org/docs/en/plugin/advanced-format
12
13
  /**
13
14
  * Apply to the given date format to a date value
@@ -105,7 +106,9 @@ export const addFormat = (value, outputFormat = "None", config) => {
105
106
  : outputFormat === null || outputFormat === void 0 ? void 0 : outputFormat.format);
106
107
  case "NUMERIC": {
107
108
  const parse = parseFloat(value);
108
- const withLocale = outputFormat !== "None" && (config === null || config === void 0 ? void 0 : config.lang);
109
+ const withLocale = (outputFormat !== "None" && (config === null || config === void 0 ? void 0 : config.lang)) ||
110
+ (outputFormat === null || outputFormat === void 0 ? void 0 : outputFormat.format) === "Duration" ||
111
+ DURATION_PARTS_LIST.includes[outputFormat === null || outputFormat === void 0 ? void 0 : outputFormat.format];
109
112
  return isNaN(parse)
110
113
  ? value
111
114
  : withLocale
@@ -1,6 +1,7 @@
1
1
  import { DATETIME_COLUMN_FORMAT } from "../dates/constants/DATETIME_COLUMN_FORMAT";
2
2
  import { isEmpty } from "../general/mix/isEmpty";
3
3
  import { currencyISO, LANG_DEFAULT, CURRENCY_DEFAULT, DATETIME_OPTIONS, } from "./definition";
4
+ import { DurationFormatter } from "./duration/durationFormatter";
4
5
  export const getLang = (locale) => {
5
6
  if (!locale)
6
7
  return;
@@ -55,10 +56,20 @@ function formatLocaleNumber(value, outputFormat, config) {
55
56
  const langOpts = options || getLocaleOptions(outputFormat);
56
57
  const valueToFormat = (outputFormat === null || outputFormat === void 0 ? void 0 : outputFormat.format) === "Percentage" /* LOCALE_FORMATS.PERCENTAGE */ ? value / 100 : value;
57
58
  try {
58
- const key = lang + JSON.stringify(langOpts);
59
+ const key = (outputFormat === null || outputFormat === void 0 ? void 0 : outputFormat.format) +
60
+ lang +
61
+ JSON.stringify(langOpts) +
62
+ ((outputFormat === null || outputFormat === void 0 ? void 0 : outputFormat.template) ? outputFormat.template : "");
59
63
  let formatter = NUMBER_FORMAT_CACHE[key];
60
64
  if (!formatter) {
61
- formatter = new Intl.NumberFormat([lang, LANG_DEFAULT], langOpts);
65
+ const intlNumberFormat = new Intl.NumberFormat([lang, LANG_DEFAULT], langOpts);
66
+ formatter =
67
+ (outputFormat === null || outputFormat === void 0 ? void 0 : outputFormat.format) === "Duration" /* LOCALE_FORMATS.DURATION */
68
+ ? new DurationFormatter({
69
+ template: outputFormat === null || outputFormat === void 0 ? void 0 : outputFormat.template,
70
+ intlNumberFormat,
71
+ })
72
+ : intlNumberFormat;
62
73
  NUMBER_FORMAT_CACHE[key] = formatter;
63
74
  }
64
75
  return formatter.format(valueToFormat);
@@ -107,6 +118,11 @@ function getLocaleOptions(outputFormat) {
107
118
  maximumFractionDigits: decimals,
108
119
  minimumFractionDigits: decimals,
109
120
  };
121
+ case "Duration" /* LOCALE_FORMATS.DURATION */:
122
+ return {
123
+ maximumFractionDigits: 0,
124
+ minimumFractionDigits: 0,
125
+ };
110
126
  default:
111
127
  return {
112
128
  style: "decimal" /* LOCALE_STYLES.DECIMAL */,
@@ -11,6 +11,7 @@ import { II18nBucketBuilder } from "./bucket_builder/II18nBucketBuilder";
11
11
  import { II18nCrossTabs } from "./cross_tabs";
12
12
  import { II18nChartBuilder } from ".";
13
13
  import { II18nStyleThemes } from "./style_themes/II18nStyleThemes";
14
+ import { II18nTabularView } from './tabular_view/II18nTabularView';
14
15
  export interface II18nResource {
15
16
  bucket_builder?: II18nBucketBuilder;
16
17
  chart_builder?: II18nChartBuilder;
@@ -25,4 +26,5 @@ export interface II18nResource {
25
26
  panel?: II18nPanel;
26
27
  style_themes?: II18nStyleThemes;
27
28
  table_charts?: II18nTableCharts;
29
+ tabular_view?: II18nTabularView;
28
30
  }
@@ -14,4 +14,5 @@ export interface II18nChartBuilderFormatValues {
14
14
  custom: string;
15
15
  date_format: string;
16
16
  value_format: string;
17
+ duration: string;
17
18
  }
@@ -16,5 +16,6 @@ export interface II18nCommon {
16
16
  no_data_found: string;
17
17
  properties: II18nColumnProperties;
18
18
  search: string;
19
+ sort: string;
19
20
  units: II18nUnits;
20
21
  }
@@ -0,0 +1,4 @@
1
+ export interface II18nTabularView {
2
+ all: string;
3
+ select_columns: string;
4
+ }
@@ -8,6 +8,7 @@ import { I18N_FORMULA_BUILDER } from "./formula_builder";
8
8
  import { I18N_FILTER_PANEL } from "./filters/I18N_FILTER_PANEL";
9
9
  import { I18N_FILTER_DISPLAY } from "./filters/I18N_FILTER_DISPLAY";
10
10
  import { I18N_BUCKET_BUILDER } from "./bucket_builder/I18N_BUCKET_BUILDER";
11
+ import { I18N_TABULAR_VIEW } from './tabular_view/I18N_TABULAR_VIEW';
11
12
  import { I18N_CROSS_TABS } from "./cross_tabs";
12
13
  import { I18N_CHART_BUILDER } from "./chart_builder";
13
14
  import { I18N_STYLE_THEMES } from "./style_themes";
@@ -25,4 +26,5 @@ export const I18N_DEFAULT = {
25
26
  panel: I18N_PANEL,
26
27
  style_themes: I18N_STYLE_THEMES,
27
28
  table_charts: I18N_TABLE_CHARTS,
29
+ tabular_view: I18N_TABULAR_VIEW
28
30
  };
@@ -23,6 +23,7 @@ export const I18N_CHART_BUILDER = Object.assign(Object.assign(Object.assign(Obje
23
23
  custom: "Custom Format",
24
24
  date_format: "Date Format",
25
25
  value_format: "Value Format",
26
+ duration: "Duration",
26
27
  }, chart_names: {
27
28
  bar: "Bar",
28
29
  line: "Line",
@@ -20,6 +20,7 @@ export const I18N_COMMON = {
20
20
  no_data_found: "No Data Found",
21
21
  properties: I18N_COLUMN_PROPERTY_LABEL,
22
22
  search: "Search",
23
+ sort: "Sort",
23
24
  units: {
24
25
  day: RELATIVE_UNIT_INFO.DAY.label,
25
26
  month: RELATIVE_UNIT_INFO.MONTH.label,
@@ -0,0 +1,2 @@
1
+ import { II18nTabularView } from "../../interfaces/tabular_view/II18nTabularView";
2
+ export declare const I18N_TABULAR_VIEW: II18nTabularView;
@@ -0,0 +1,4 @@
1
+ export const I18N_TABULAR_VIEW = {
2
+ all: "Todas",
3
+ select_columns: "Select Columns",
4
+ };
@@ -4,4 +4,5 @@ export interface IFormatOutputFormat extends IFormatDefaultFormat {
4
4
  currency?: IFormatCurrency;
5
5
  backup_currency?: IFormatCurrency;
6
6
  originalFormat?: IFormatOutputFormat;
7
+ template?: string;
7
8
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@qrvey/utils",
3
- "version": "1.5.0-0",
3
+ "version": "1.5.0-3",
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",