@qrvey/utils 1.5.0-11 → 1.5.0-12

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.
@@ -26,8 +26,7 @@ const columnTypeByChart = (column, shelfType, chartGroup, isGroupedTable) => {
26
26
  (chartGroup === CHART_GROUP_1.CHART_GROUPS.TABLES &&
27
27
  isGroupedTable === true &&
28
28
  shelfType === SHELF_TYPE_1.SHELF_TYPE.COLUMNS) ||
29
- (chartGroup === CHART_GROUP_1.CHART_GROUPS.XY &&
30
- (shelfType === SHELF_TYPE_1.SHELF_TYPE.VALUE || shelfType === SHELF_TYPE_1.SHELF_TYPE.SERIES));
29
+ (chartGroup === CHART_GROUP_1.CHART_GROUPS.XY && shelfType === SHELF_TYPE_1.SHELF_TYPE.VALUE);
31
30
  return isNumericalColumn === true ? __1.NUMERICAL_COLUMN.NUMERIC : currentType;
32
31
  };
33
32
  exports.columnTypeByChart = columnTypeByChart;
@@ -4,5 +4,6 @@ export declare enum FILTER_TOKENS_STRUCTURE_TYPE {
4
4
  COLUMN_NAME = "COLUMN_NAME",
5
5
  VALIDATOR = "VALIDATOR",
6
6
  VALUE = "VALUE",
7
- LOGICAL_OPERATOR = "LOGICAL_OPERATOR"
7
+ LOGICAL_OPERATOR = "LOGICAL_OPERATOR",
8
+ CHART_NAME = "CHART_NAME"
8
9
  }
@@ -9,4 +9,5 @@ var FILTER_TOKENS_STRUCTURE_TYPE;
9
9
  FILTER_TOKENS_STRUCTURE_TYPE["VALIDATOR"] = "VALIDATOR";
10
10
  FILTER_TOKENS_STRUCTURE_TYPE["VALUE"] = "VALUE";
11
11
  FILTER_TOKENS_STRUCTURE_TYPE["LOGICAL_OPERATOR"] = "LOGICAL_OPERATOR";
12
+ FILTER_TOKENS_STRUCTURE_TYPE["CHART_NAME"] = "CHART_NAME";
12
13
  })(FILTER_TOKENS_STRUCTURE_TYPE = exports.FILTER_TOKENS_STRUCTURE_TYPE || (exports.FILTER_TOKENS_STRUCTURE_TYPE = {}));
@@ -10,7 +10,10 @@ const FILTER_TOKENS_STRUCTURE_TYPE_1 = require("../constants/common/FILTER_TOKEN
10
10
  function filtersTokensToString(tokens) {
11
11
  let str = "";
12
12
  for (const token of tokens) {
13
- if (token.type === FILTER_TOKENS_STRUCTURE_TYPE_1.FILTER_TOKENS_STRUCTURE_TYPE.SCOPE) {
13
+ if ([
14
+ FILTER_TOKENS_STRUCTURE_TYPE_1.FILTER_TOKENS_STRUCTURE_TYPE.SCOPE,
15
+ FILTER_TOKENS_STRUCTURE_TYPE_1.FILTER_TOKENS_STRUCTURE_TYPE.CHART_NAME,
16
+ ].includes(token.type)) {
14
17
  str += `\n`;
15
18
  }
16
19
  str += `${token.token} `;
@@ -5,6 +5,7 @@ const getUIValues_1 = require("./ui/getUIValues");
5
5
  const getFilterPropertyLabel_1 = require("./ui/getFilterPropertyLabel");
6
6
  const FILTER_TOKENS_STRUCTURE_TYPE_1 = require("../constants/common/FILTER_TOKENS_STRUCTURE_TYPE");
7
7
  const isEmpty_1 = require("../../general/mix/isEmpty");
8
+ const constants_1 = require("../constants");
8
9
  /**
9
10
  * It takes a filter object and returns an array of tokens that represent the filter
10
11
  * @param {IFUData} filters - The filters object.
@@ -12,7 +13,7 @@ const isEmpty_1 = require("../../general/mix/isEmpty");
12
13
  * @returns {IFFilterTokens[]} An array of tokens that represents the filters object
13
14
  */
14
15
  function getTokensFromFilters(filters, options) {
15
- var _a, _b, _c;
16
+ var _a, _b, _c, _d;
16
17
  const tokens = [];
17
18
  const i18nService = options.i18nService;
18
19
  const settings = {
@@ -58,11 +59,24 @@ function getTokensFromFilters(filters, options) {
58
59
  const values = (0, getUIValues_1.getUIValues)(filter, settings);
59
60
  if (!thereIsFiltersWithValues)
60
61
  thereIsFiltersWithValues = true;
62
+ if (options.showChartName && scope.scope === constants_1.FILTER_SCOPE.CHART) {
63
+ const searchToken = tokens.find((token) => token.token === filter.extras.filterLabel + ":");
64
+ if (!searchToken) {
65
+ if (((_b = tokens[tokens.length - 1]) === null || _b === void 0 ? void 0 : _b.type) ===
66
+ FILTER_TOKENS_STRUCTURE_TYPE_1.FILTER_TOKENS_STRUCTURE_TYPE.LOGICAL_OPERATOR) {
67
+ tokens.pop();
68
+ }
69
+ tokens.push({
70
+ token: filter.extras.filterLabel + ":",
71
+ type: FILTER_TOKENS_STRUCTURE_TYPE_1.FILTER_TOKENS_STRUCTURE_TYPE.CHART_NAME,
72
+ });
73
+ }
74
+ }
61
75
  let columnLabel = filter.column.label;
62
- if ((_b = filter === null || filter === void 0 ? void 0 : filter.column) === null || _b === void 0 ? void 0 : _b.aggregate) {
76
+ if ((_c = filter === null || filter === void 0 ? void 0 : filter.column) === null || _c === void 0 ? void 0 : _c.aggregate) {
63
77
  columnLabel +=
64
78
  " (" +
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()}`) +
79
+ i18nService.translate(`common.aggregate_labels.${(_d = filter === null || filter === void 0 ? void 0 : filter.column) === null || _d === void 0 ? void 0 : _d.aggregate.toLowerCase()}`) +
66
80
  ")";
67
81
  }
68
82
  tokens.push({
@@ -53,7 +53,7 @@ exports.I18N_CHART_BUILDER_STYLE_OPTIONS = {
53
53
  single_color: "Single color",
54
54
  },
55
55
  color_by_values: {
56
- title: "Color by values",
56
+ title: "Color by value",
57
57
  subtitle: "Customize the colors for each category",
58
58
  search_placeholder: "Search Values",
59
59
  restore_default: "Restore Default Colors",
@@ -23,7 +23,6 @@ export const columnTypeByChart = (column, shelfType, chartGroup, isGroupedTable)
23
23
  (chartGroup === CHART_GROUPS.TABLES &&
24
24
  isGroupedTable === true &&
25
25
  shelfType === SHELF_TYPE.COLUMNS) ||
26
- (chartGroup === CHART_GROUPS.XY &&
27
- (shelfType === SHELF_TYPE.VALUE || shelfType === SHELF_TYPE.SERIES));
26
+ (chartGroup === CHART_GROUPS.XY && shelfType === SHELF_TYPE.VALUE);
28
27
  return isNumericalColumn === true ? NUMERICAL_COLUMN.NUMERIC : currentType;
29
28
  };
@@ -4,5 +4,6 @@ export declare enum FILTER_TOKENS_STRUCTURE_TYPE {
4
4
  COLUMN_NAME = "COLUMN_NAME",
5
5
  VALIDATOR = "VALIDATOR",
6
6
  VALUE = "VALUE",
7
- LOGICAL_OPERATOR = "LOGICAL_OPERATOR"
7
+ LOGICAL_OPERATOR = "LOGICAL_OPERATOR",
8
+ CHART_NAME = "CHART_NAME"
8
9
  }
@@ -6,4 +6,5 @@ export var FILTER_TOKENS_STRUCTURE_TYPE;
6
6
  FILTER_TOKENS_STRUCTURE_TYPE["VALIDATOR"] = "VALIDATOR";
7
7
  FILTER_TOKENS_STRUCTURE_TYPE["VALUE"] = "VALUE";
8
8
  FILTER_TOKENS_STRUCTURE_TYPE["LOGICAL_OPERATOR"] = "LOGICAL_OPERATOR";
9
+ FILTER_TOKENS_STRUCTURE_TYPE["CHART_NAME"] = "CHART_NAME";
9
10
  })(FILTER_TOKENS_STRUCTURE_TYPE || (FILTER_TOKENS_STRUCTURE_TYPE = {}));
@@ -7,7 +7,10 @@ import { FILTER_TOKENS_STRUCTURE_TYPE } from "../constants/common/FILTER_TOKENS_
7
7
  export function filtersTokensToString(tokens) {
8
8
  let str = "";
9
9
  for (const token of tokens) {
10
- if (token.type === FILTER_TOKENS_STRUCTURE_TYPE.SCOPE) {
10
+ if ([
11
+ FILTER_TOKENS_STRUCTURE_TYPE.SCOPE,
12
+ FILTER_TOKENS_STRUCTURE_TYPE.CHART_NAME,
13
+ ].includes(token.type)) {
11
14
  str += `\n`;
12
15
  }
13
16
  str += `${token.token} `;
@@ -2,6 +2,7 @@ import { getUIValues } from "./ui/getUIValues";
2
2
  import { getFilterPropertyLabel } from "./ui/getFilterPropertyLabel";
3
3
  import { FILTER_TOKENS_STRUCTURE_TYPE } from "../constants/common/FILTER_TOKENS_STRUCTURE_TYPE";
4
4
  import { isEmpty } from "../../general/mix/isEmpty";
5
+ import { FILTER_SCOPE } from "../constants";
5
6
  /**
6
7
  * It takes a filter object and returns an array of tokens that represent the filter
7
8
  * @param {IFUData} filters - The filters object.
@@ -9,7 +10,7 @@ import { isEmpty } from "../../general/mix/isEmpty";
9
10
  * @returns {IFFilterTokens[]} An array of tokens that represents the filters object
10
11
  */
11
12
  export function getTokensFromFilters(filters, options) {
12
- var _a, _b, _c;
13
+ var _a, _b, _c, _d;
13
14
  const tokens = [];
14
15
  const i18nService = options.i18nService;
15
16
  const settings = {
@@ -55,11 +56,24 @@ export function getTokensFromFilters(filters, options) {
55
56
  const values = getUIValues(filter, settings);
56
57
  if (!thereIsFiltersWithValues)
57
58
  thereIsFiltersWithValues = true;
59
+ if (options.showChartName && scope.scope === FILTER_SCOPE.CHART) {
60
+ const searchToken = tokens.find((token) => token.token === filter.extras.filterLabel + ":");
61
+ if (!searchToken) {
62
+ if (((_b = tokens[tokens.length - 1]) === null || _b === void 0 ? void 0 : _b.type) ===
63
+ FILTER_TOKENS_STRUCTURE_TYPE.LOGICAL_OPERATOR) {
64
+ tokens.pop();
65
+ }
66
+ tokens.push({
67
+ token: filter.extras.filterLabel + ":",
68
+ type: FILTER_TOKENS_STRUCTURE_TYPE.CHART_NAME,
69
+ });
70
+ }
71
+ }
58
72
  let columnLabel = filter.column.label;
59
- if ((_b = filter === null || filter === void 0 ? void 0 : filter.column) === null || _b === void 0 ? void 0 : _b.aggregate) {
73
+ if ((_c = filter === null || filter === void 0 ? void 0 : filter.column) === null || _c === void 0 ? void 0 : _c.aggregate) {
60
74
  columnLabel +=
61
75
  " (" +
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()}`) +
76
+ i18nService.translate(`common.aggregate_labels.${(_d = filter === null || filter === void 0 ? void 0 : filter.column) === null || _d === void 0 ? void 0 : _d.aggregate.toLowerCase()}`) +
63
77
  ")";
64
78
  }
65
79
  tokens.push({
@@ -50,7 +50,7 @@ export const I18N_CHART_BUILDER_STYLE_OPTIONS = {
50
50
  single_color: "Single color",
51
51
  },
52
52
  color_by_values: {
53
- title: "Color by values",
53
+ title: "Color by value",
54
54
  subtitle: "Customize the colors for each category",
55
55
  search_placeholder: "Search Values",
56
56
  restore_default: "Restore Default Colors",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@qrvey/utils",
3
- "version": "1.5.0-11",
3
+ "version": "1.5.0-12",
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",