@qrvey/utils 1.3.0-7 → 1.3.0

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 (141) hide show
  1. package/.eslintrc.json +2 -0
  2. package/README.md +503 -49
  3. package/bitbucket-pipelines.yml +24 -16
  4. package/dist/cjs/column_format/helpers/columnTypeByChart.d.ts +1 -1
  5. package/dist/cjs/column_format/helpers/defineXYChartFormat.js +4 -3
  6. package/dist/cjs/columns/helpers/getDatasetColumnByDatasets.d.ts +10 -0
  7. package/dist/cjs/columns/helpers/{getDatasetColumnyDatasets.js → getDatasetColumnByDatasets.js} +8 -1
  8. package/dist/cjs/columns/helpers/index.d.ts +1 -2
  9. package/dist/cjs/columns/helpers/index.js +1 -2
  10. package/dist/cjs/dates/adapters/index.d.ts +6 -0
  11. package/dist/cjs/dates/adapters/index.js +6 -0
  12. package/dist/cjs/filters/adapters/FDToLogic.js +3 -3
  13. package/dist/cjs/filters/helpers/backend/getLogicByDatasets.d.ts +11 -0
  14. package/dist/cjs/filters/helpers/backend/getLogicByDatasets.js +34 -0
  15. package/dist/cjs/filters/helpers/backend/getLogicByDatasetsColumns.d.ts +12 -0
  16. package/dist/cjs/filters/helpers/backend/getLogicByDatasetsColumns.js +47 -0
  17. package/dist/cjs/filters/helpers/backend/index.d.ts +2 -0
  18. package/dist/cjs/filters/helpers/backend/index.js +2 -0
  19. package/dist/cjs/filters/helpers/common/excludeFiltersByParams.js +1 -1
  20. package/dist/cjs/filters/helpers/common/getFiltersByDatasetsColumns.d.ts +10 -0
  21. package/dist/cjs/filters/helpers/common/getFiltersByDatasetsColumns.js +32 -0
  22. package/dist/cjs/filters/helpers/common/index.d.ts +1 -0
  23. package/dist/cjs/filters/helpers/common/index.js +1 -0
  24. package/dist/cjs/filters/helpers/getAvailableScopes.js +5 -5
  25. package/dist/cjs/filters/interfaces/backend/IFBExpression.d.ts +1 -0
  26. package/dist/cjs/filters/interfaces/common/IFSAvailableScope.d.ts +1 -0
  27. package/dist/cjs/filters/interfaces/functions/IFFGetLogicByDatasets.d.ts +6 -0
  28. package/dist/cjs/filters/interfaces/functions/IFFGetLogicByDatasets.js +2 -0
  29. package/dist/cjs/filters/interfaces/functions/IFFGetLogicByDatasetsColumns.d.ts +7 -0
  30. package/dist/cjs/filters/interfaces/functions/IFFGetLogicByDatasetsColumns.js +2 -0
  31. package/dist/cjs/filters/interfaces/functions/IFFiltersGetData.d.ts +1 -1
  32. package/dist/cjs/filters/interfaces/functions/index.d.ts +2 -0
  33. package/dist/cjs/filters/interfaces/functions/index.js +2 -0
  34. package/dist/cjs/filters/interfaces/index.d.ts +1 -0
  35. package/dist/cjs/filters/interfaces/index.js +1 -0
  36. package/dist/cjs/filters/services/Filters.api.js +11 -6
  37. package/dist/cjs/globalization/helpers/getI18nDateGroupLabel.js +1 -1
  38. package/dist/cjs/globalization/interfaces/chart_builder/II18nChartBuilderStyleOptions.d.ts +10 -0
  39. package/dist/cjs/globalization/interfaces/style_themes/II18nStyleThemesTheme.d.ts +1 -0
  40. package/dist/cjs/globalization/labels/chart_builder/I18N_CHART_BUILDER_LAYER_OPTIONS.js +1 -1
  41. package/dist/cjs/globalization/labels/chart_builder/I18N_CHART_BUILDER_STYLE_OPTIONS.js +10 -0
  42. package/dist/cjs/globalization/labels/style_themes/I18N_STYLE_THEMES.js +1 -0
  43. package/dist/cjs/qrvey/helpers/getDatasetByColumn.d.ts +9 -0
  44. package/dist/cjs/{columns → qrvey}/helpers/getDatasetByColumn.js +8 -2
  45. package/dist/cjs/qrvey/helpers/index.d.ts +1 -0
  46. package/dist/cjs/qrvey/helpers/index.js +1 -0
  47. package/dist/cjs/services/adapters/BBranchesMapToUIBranchesMap.adapter.js +3 -3
  48. package/dist/cjs/services/adapters/BColumnsToUIColumns.adapter.js +5 -4
  49. package/dist/cjs/services/adapters/BDatasetsToUIDatasets.adapter.js +3 -2
  50. package/dist/cjs/services/adapters/BModelToUIModel.adapter.js +1 -1
  51. package/dist/column_format/helpers/defineXYChartFormat.js +4 -3
  52. package/dist/columns/helpers/getDatasetColumnByDatasets.d.ts +10 -0
  53. package/dist/columns/helpers/getDatasetColumnByDatasets.js +15 -0
  54. package/dist/columns/helpers/index.d.ts +1 -2
  55. package/dist/columns/helpers/index.js +1 -2
  56. package/dist/dates/adapters/index.d.ts +6 -0
  57. package/dist/dates/adapters/index.js +6 -0
  58. package/dist/filters/adapters/FDToLogic.js +3 -3
  59. package/dist/filters/helpers/backend/getLogicByDatasets.d.ts +11 -0
  60. package/dist/filters/helpers/backend/getLogicByDatasets.js +30 -0
  61. package/dist/filters/helpers/backend/getLogicByDatasetsColumns.d.ts +12 -0
  62. package/dist/filters/helpers/backend/getLogicByDatasetsColumns.js +43 -0
  63. package/dist/filters/helpers/backend/index.d.ts +2 -0
  64. package/dist/filters/helpers/backend/index.js +2 -0
  65. package/dist/filters/helpers/common/excludeFiltersByParams.js +1 -1
  66. package/dist/filters/helpers/common/getFiltersByDatasetsColumns.d.ts +10 -0
  67. package/dist/filters/helpers/common/getFiltersByDatasetsColumns.js +28 -0
  68. package/dist/filters/helpers/common/index.d.ts +1 -0
  69. package/dist/filters/helpers/common/index.js +1 -0
  70. package/dist/filters/helpers/getAvailableScopes.js +5 -5
  71. package/dist/filters/interfaces/backend/IFBExpression.d.ts +1 -0
  72. package/dist/filters/interfaces/common/IFSAvailableScope.d.ts +1 -0
  73. package/dist/filters/interfaces/functions/IFFGetLogicByDatasets.d.ts +6 -0
  74. package/dist/filters/interfaces/functions/IFFGetLogicByDatasets.js +1 -0
  75. package/dist/filters/interfaces/functions/IFFGetLogicByDatasetsColumns.d.ts +7 -0
  76. package/dist/filters/interfaces/functions/IFFGetLogicByDatasetsColumns.js +1 -0
  77. package/dist/filters/interfaces/functions/IFFiltersGetData.d.ts +1 -1
  78. package/dist/filters/interfaces/functions/index.d.ts +2 -0
  79. package/dist/filters/interfaces/functions/index.js +2 -0
  80. package/dist/filters/interfaces/index.d.ts +1 -0
  81. package/dist/filters/interfaces/index.js +1 -0
  82. package/dist/filters/services/Filters.api.js +11 -6
  83. package/dist/globalization/helpers/getI18nDateGroupLabel.js +1 -1
  84. package/dist/globalization/interfaces/chart_builder/II18nChartBuilderStyleOptions.d.ts +10 -0
  85. package/dist/globalization/interfaces/style_themes/II18nStyleThemesTheme.d.ts +1 -0
  86. package/dist/globalization/labels/chart_builder/I18N_CHART_BUILDER_LAYER_OPTIONS.js +1 -1
  87. package/dist/globalization/labels/chart_builder/I18N_CHART_BUILDER_STYLE_OPTIONS.js +10 -0
  88. package/dist/globalization/labels/style_themes/I18N_STYLE_THEMES.js +1 -0
  89. package/dist/qrvey/helpers/getDatasetByColumn.d.ts +9 -0
  90. package/dist/qrvey/helpers/getDatasetByColumn.js +12 -0
  91. package/dist/qrvey/helpers/index.d.ts +1 -0
  92. package/dist/qrvey/helpers/index.js +1 -0
  93. package/dist/services/adapters/BBranchesMapToUIBranchesMap.adapter.js +3 -3
  94. package/dist/services/adapters/BColumnsToUIColumns.adapter.js +5 -4
  95. package/dist/services/adapters/BDatasetsToUIDatasets.adapter.js +3 -2
  96. package/dist/services/adapters/BModelToUIModel.adapter.js +1 -1
  97. package/jest.config.js +1 -1
  98. package/package.json +5 -4
  99. package/src/column_format/helpers/defineXYChartFormat.ts +4 -5
  100. package/src/columns/helpers/{getDatasetColumnyDatasets.ts → getDatasetColumnByDatasets.ts} +9 -1
  101. package/src/columns/helpers/index.ts +1 -2
  102. package/src/dates/adapters/index.ts +6 -0
  103. package/src/filters/adapters/FDToLogic.ts +5 -5
  104. package/src/filters/helpers/backend/getLogicByDatasets.ts +37 -0
  105. package/src/filters/helpers/backend/getLogicByDatasetsColumns.ts +52 -0
  106. package/src/filters/helpers/backend/index.ts +2 -0
  107. package/src/filters/helpers/common/excludeFiltersByParams.ts +1 -1
  108. package/src/filters/helpers/common/getFiltersByDatasetsColumns.ts +40 -0
  109. package/src/filters/helpers/common/index.ts +1 -0
  110. package/src/filters/helpers/getAvailableScopes.ts +4 -4
  111. package/src/filters/interfaces/backend/IFBExpression.ts +1 -0
  112. package/src/filters/interfaces/common/IFSAvailableScope.ts +1 -0
  113. package/src/filters/interfaces/functions/IFFGetLogicByDatasets.ts +6 -0
  114. package/src/filters/interfaces/functions/IFFGetLogicByDatasetsColumns.ts +7 -0
  115. package/src/filters/interfaces/functions/IFFiltersGetData.ts +1 -1
  116. package/src/filters/interfaces/functions/index.ts +2 -0
  117. package/src/filters/interfaces/index.ts +1 -0
  118. package/src/filters/services/Filters.api.ts +11 -3
  119. package/src/globalization/helpers/getI18nDateGroupLabel.ts +1 -1
  120. package/src/globalization/interfaces/chart_builder/II18nChartBuilderStyleOptions.ts +10 -0
  121. package/src/globalization/interfaces/style_themes/II18nStyleThemesTheme.ts +1 -0
  122. package/src/globalization/labels/chart_builder/I18N_CHART_BUILDER_LAYER_OPTIONS.ts +1 -1
  123. package/src/globalization/labels/chart_builder/I18N_CHART_BUILDER_STYLE_OPTIONS.ts +10 -0
  124. package/src/globalization/labels/style_themes/I18N_STYLE_THEMES.ts +1 -0
  125. package/src/qrvey/helpers/getDatasetByColumn.ts +15 -0
  126. package/src/qrvey/helpers/index.ts +1 -0
  127. package/src/services/adapters/BBranchesMapToUIBranchesMap.adapter.ts +3 -3
  128. package/src/services/adapters/BColumnsToUIColumns.adapter.ts +5 -4
  129. package/src/services/adapters/BDatasetsToUIDatasets.adapter.ts +3 -2
  130. package/src/services/adapters/BModelToUIModel.adapter.ts +1 -1
  131. package/test/filters/backend/getLogicByDatasetsColumns.test.js +312 -0
  132. package/test/tokens/isTokenLabel.test.js +259 -0
  133. package/tsconfig.json +1 -4
  134. package/dist/cjs/columns/helpers/getDatasetByColumn.d.ts +0 -3
  135. package/dist/cjs/columns/helpers/getDatasetColumnyDatasets.d.ts +0 -3
  136. package/dist/columns/helpers/getDatasetByColumn.d.ts +0 -3
  137. package/dist/columns/helpers/getDatasetByColumn.js +0 -6
  138. package/dist/columns/helpers/getDatasetColumnyDatasets.d.ts +0 -3
  139. package/dist/columns/helpers/getDatasetColumnyDatasets.js +0 -8
  140. package/src/columns/helpers/getDatasetByColumn.ts +0 -9
  141. package/test/tokens/isTokenLabel.test.ts +0 -129
@@ -1,6 +1,7 @@
1
1
  export * from './areStaticColumnValues';
2
2
  export * from './getCategorizableExpression';
3
3
  export * from './getDataAnswersByColumn';
4
+ export * from './getDatasetByColumn';
4
5
  export * from './getDropdownAnswers';
5
6
  export * from './getExpressionAnswers';
6
7
  export * from './getImageAnswers';
@@ -17,6 +17,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
17
17
  __exportStar(require("./areStaticColumnValues"), exports);
18
18
  __exportStar(require("./getCategorizableExpression"), exports);
19
19
  __exportStar(require("./getDataAnswersByColumn"), exports);
20
+ __exportStar(require("./getDatasetByColumn"), exports);
20
21
  __exportStar(require("./getDropdownAnswers"), exports);
21
22
  __exportStar(require("./getExpressionAnswers"), exports);
22
23
  __exportStar(require("./getImageAnswers"), exports);
@@ -11,9 +11,9 @@ const BColumnsToUIColumns_adapter_1 = require("./BColumnsToUIColumns.adapter");
11
11
  function BBranchesMapToUIBranchesMap(branchesMap) {
12
12
  if ((0, isEmpty_1.isEmpty)(branchesMap))
13
13
  return [];
14
- return branchesMap.map(branchesMap => ({
15
- questionid: branchesMap.questionid,
16
- branches: branchesMap.branches.map(branch => ({
14
+ return branchesMap.map(branchMap => ({
15
+ questionid: branchMap.questionid,
16
+ branches: branchMap.branches.map(branch => ({
17
17
  columns: (0, BColumnsToUIColumns_adapter_1.BColumnsToUIColumns)(branch.questions.data)
18
18
  }))
19
19
  }));
@@ -1,25 +1,26 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.BColumnsToUIColumns = void 0;
4
+ const getAttribute_1 = require("../../general/object/getAttribute");
4
5
  function BColumnsToUIColumns(columns = [], dataset) {
5
6
  return columns.map(column => ({
6
7
  answers: column.answers,
7
- bucketid: column.bucketId,
8
+ bucketid: (0, getAttribute_1.getAttribute)(column, 'bucket_id'),
8
9
  expressionCategory: column.activeCat,
9
10
  expressionNegative: column.negative,
10
11
  expressionPositive: column.positive,
11
12
  expressionWords: column.words,
12
- formulaid: column.formulaId,
13
+ formulaid: (0, getAttribute_1.getAttribute)(column, 'formula_id'),
13
14
  formulaType: column.formulaType,
14
15
  geogroup: column.geogroup,
15
16
  id: column.id,
16
17
  imageUploadOption: column.imageUploadOption,
17
18
  label: column.text,
18
19
  linked: column.linked,
19
- linkid: (dataset === null || dataset === void 0 ? void 0 : dataset.linkid) || column.linkid,
20
+ linkid: (0, getAttribute_1.getAttribute)(dataset, 'link_id') || (0, getAttribute_1.getAttribute)(column, 'link_id'),
20
21
  outputFormat: column.outputFormat,
21
22
  property: column.property,
22
- qrveyid: (dataset === null || dataset === void 0 ? void 0 : dataset.qrveyid) || column.qrveyid,
23
+ qrveyid: (0, getAttribute_1.getAttribute)(dataset, 'qrvey_id') || (0, getAttribute_1.getAttribute)(column, 'qrvey_id'),
23
24
  slidebarValue: column.sliderVal,
24
25
  lookupValue: column.value,
25
26
  type: column.type,
@@ -1,12 +1,13 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.BDatasetsToUIDatasets = void 0;
4
+ const getAttribute_1 = require("../../general/object/getAttribute");
4
5
  const BColumnsToUIColumns_adapter_1 = require("./BColumnsToUIColumns.adapter");
5
6
  function BDatasetsToUIDatasets(datasets = []) {
6
7
  return datasets.map(dataset => ({
7
- qrveyid: dataset.qrveyid,
8
+ qrveyid: (0, getAttribute_1.getAttribute)(dataset, 'qrvey_id'),
8
9
  label: dataset.name,
9
- linkid: dataset.linkid,
10
+ linkid: (0, getAttribute_1.getAttribute)(dataset, 'link_id'),
10
11
  options: (0, BColumnsToUIColumns_adapter_1.BColumnsToUIColumns)(dataset.options, dataset),
11
12
  }));
12
13
  }
@@ -12,7 +12,7 @@ function BModelToUIModel(model) {
12
12
  appid: model.appid,
13
13
  branchesMap: (0, BBranchesMapToUIBranchesMap_adapter_1.BBranchesMapToUIBranchesMap)(model.branchesMap),
14
14
  columnOrder: model.questionOrder,
15
- columns: (0, BColumnsToUIColumns_adapter_1.BColumnsToUIColumns)(model.questions.data),
15
+ columns: (0, BColumnsToUIColumns_adapter_1.BColumnsToUIColumns)(model.questions.data, { qrveyid: model.qrveyid }),
16
16
  createDate: model.createDate,
17
17
  datalinkInfo: model.datalinkInfo,
18
18
  modifyDate: model.modifyDate,
@@ -13,6 +13,7 @@ import { columnTypeByChart } from "./columnTypeByChart";
13
13
  export const defineXYChartFormat = (column, settings) => {
14
14
  const { aggregate, type, defaultFormat, outputFormat, selectedFormat, dateGroup } = column;
15
15
  const { shelfType, withoutFormat } = settings;
16
+ const columnDefaultFormat = defaultFormat || outputFormat;
16
17
  //Defaults
17
18
  const defaultText = 'Default';
18
19
  //const defaultNumeric = { type: 'NUMERIC', format: 'Numeric' };
@@ -20,7 +21,7 @@ export const defineXYChartFormat = (column, settings) => {
20
21
  const columnType = columnTypeByChart(column, shelfType, CHART_GROUPS.XY);
21
22
  const noFormatSupported = DATEGROUP_UNSUPPORT_FORMAT.some(gp => gp === (dateGroup === null || dateGroup === void 0 ? void 0 : dateGroup.label));
22
23
  const isUsedAsNumericColumn = type !== columnType;
23
- const hasDefaultFormat = (isEmpty(selectedFormat) && (outputFormat === null || outputFormat === void 0 ? void 0 : outputFormat.format) === defaultText) || ((selectedFormat === null || selectedFormat === void 0 ? void 0 : selectedFormat.format) === defaultText);
24
+ const hasDefaultFormat = isEmpty(selectedFormat) || ((outputFormat === null || outputFormat === void 0 ? void 0 : outputFormat.format) === defaultText) || ((selectedFormat === null || selectedFormat === void 0 ? void 0 : selectedFormat.format) === defaultText);
24
25
  switch (columnType) {
25
26
  case COLUMN.YES_NO:
26
27
  case COLUMN.PHONE:
@@ -38,7 +39,7 @@ export const defineXYChartFormat = (column, settings) => {
38
39
  return STRING_FORMAT.NONE;
39
40
  }
40
41
  else if (hasDefaultFormat) {
41
- return Object.assign(Object.assign({}, defaultFormat), { format: defaultText, originalFormat: Object.assign({}, outputFormat) });
42
+ return Object.assign(Object.assign({}, columnDefaultFormat), { format: defaultText, originalFormat: Object.assign({}, outputFormat) });
42
43
  }
43
44
  else {
44
45
  return selectedFormat;
@@ -59,7 +60,7 @@ export const defineXYChartFormat = (column, settings) => {
59
60
  }
60
61
  else {
61
62
  if (withoutFormat === true) {
62
- return defaultFormat;
63
+ return columnDefaultFormat;
63
64
  }
64
65
  else if (hasDefaultFormat) {
65
66
  return Object.assign({}, outputFormat);
@@ -0,0 +1,10 @@
1
+ import { IDataset } from "../../qrvey/interfaces/IDataset";
2
+ import { IColumn } from "../interfaces/IColumn";
3
+ /**
4
+ * Gets a column from a dataset.
5
+ * Recieves a partial column object and received a full column object from the Dataset
6
+ * @param column a partial column object
7
+ * @param datasets the datasets to look for the colun
8
+ * @returns the Column object
9
+ */
10
+ export declare function getDatasetColumnByDatasets(column: Partial<IColumn>, datasets: IDataset[]): IColumn;
@@ -0,0 +1,15 @@
1
+ import { isEmpty } from "../../general/mix/isEmpty";
2
+ import { getDatasetColumn } from "./getDatasetColumn";
3
+ /**
4
+ * Gets a column from a dataset.
5
+ * Recieves a partial column object and received a full column object from the Dataset
6
+ * @param column a partial column object
7
+ * @param datasets the datasets to look for the colun
8
+ * @returns the Column object
9
+ */
10
+ export function getDatasetColumnByDatasets(column, datasets) {
11
+ if (isEmpty(column) || isEmpty(datasets))
12
+ return;
13
+ const dataset = datasets.find(_dataset => _dataset.qrveyid === column.qrveyid);
14
+ return getDatasetColumn(column, dataset);
15
+ }
@@ -1,7 +1,6 @@
1
1
  export * from './getColumnsLabel';
2
- export * from './getDatasetByColumn';
3
2
  export * from './getDatasetColumn';
4
- export * from './getDatasetColumnyDatasets';
3
+ export * from './getDatasetColumnByDatasets';
5
4
  export * from './getModelColumn';
6
5
  export * from './isComplexColumn';
7
6
  export * from './isDateColumn';
@@ -1,7 +1,6 @@
1
1
  export * from './getColumnsLabel';
2
- export * from './getDatasetByColumn';
3
2
  export * from './getDatasetColumn';
4
- export * from './getDatasetColumnyDatasets';
3
+ export * from './getDatasetColumnByDatasets';
5
4
  export * from './getModelColumn';
6
5
  export * from './isComplexColumn';
7
6
  export * from './isDateColumn';
@@ -1,3 +1,9 @@
1
+ export * from './dateToHms';
2
+ export * from './dateToMdyDate';
3
+ export * from './dateToMonthYear';
4
+ export * from './dateToQuarterYear';
5
+ export * from './dateToWeekYear';
6
+ export * from './dateToYear';
1
7
  export * from './mdyDateToDate';
2
8
  export * from './monthYearToDate';
3
9
  export * from './quarterYearToDate';
@@ -1,3 +1,9 @@
1
+ export * from './dateToHms';
2
+ export * from './dateToMdyDate';
3
+ export * from './dateToMonthYear';
4
+ export * from './dateToQuarterYear';
5
+ export * from './dateToWeekYear';
6
+ export * from './dateToYear';
1
7
  export * from './mdyDateToDate';
2
8
  export * from './monthYearToDate';
3
9
  export * from './quarterYearToDate';
@@ -25,8 +25,9 @@ export function FDToLogic(filterData) {
25
25
  * @returns a filter logic array
26
26
  */
27
27
  function getLogicBodyFromFD21(filterData) {
28
- let logics = [];
29
- logics = filterData.scopes.reduce((logics, scope) => {
28
+ if (isEmpty(filterData))
29
+ return [];
30
+ return filterData.scopes.reduce((logics, scope) => {
30
31
  const logic = buildLogic(scope);
31
32
  let filters = [];
32
33
  if (scope.datasets.length > 0) {
@@ -38,7 +39,6 @@ function getLogicBodyFromFD21(filterData) {
38
39
  logics.push(Object.assign(Object.assign({}, logic), { filters }));
39
40
  return logics;
40
41
  }, []);
41
- return logics;
42
42
  }
43
43
  function buildLogic(scopeSection) {
44
44
  return {
@@ -0,0 +1,11 @@
1
+ import { IFBLogic } from "../../interfaces/backend/IFBLogic";
2
+ import { IFFGetLogicByDatasets } from "../../interfaces/functions/IFFGetLogicByDatasets";
3
+ /**
4
+ * [TODO: Add filterEmptyArrays to the filterNestedTree filter condition. Firstly, that function should accept this argument]
5
+ * Filters the logic by a qrveyids array
6
+ * If an qrveyid is not provided in the expression the filter passes normally
7
+ * @param logic The logic of the filter
8
+ * @param datasets The collection of qrveyids
9
+ * @returns a new filtered logic
10
+ */
11
+ export declare function getLogicByDatasets(logic: IFBLogic[], datasets?: string[], settings?: IFFGetLogicByDatasets): IFBLogic[];
@@ -0,0 +1,30 @@
1
+ import { filterNestedTree, _hasProperty } from "../../../general";
2
+ import { isEmpty } from "../../../general/mix/isEmpty";
3
+ /**
4
+ * [TODO: Add filterEmptyArrays to the filterNestedTree filter condition. Firstly, that function should accept this argument]
5
+ * Filters the logic by a qrveyids array
6
+ * If an qrveyid is not provided in the expression the filter passes normally
7
+ * @param logic The logic of the filter
8
+ * @param datasets The collection of qrveyids
9
+ * @returns a new filtered logic
10
+ */
11
+ export function getLogicByDatasets(logic, datasets = [], settings) {
12
+ if (isEmpty(logic))
13
+ return;
14
+ if (isEmpty(datasets))
15
+ return logic;
16
+ settings = getGetLogicByDatasetsSettings(settings);
17
+ return logic.map(_l => (Object.assign(Object.assign({}, _l), { filters: filterNestedTree(_l.filters, 'expressions', (expression) => {
18
+ const dataset = datasets.find(_data => _data === expression.qrveyid);
19
+ return (settings.letPassUndefinedProperties.qrveyid && !_hasProperty(expression, 'qrveyid')) || !isEmpty(dataset);
20
+ }) })));
21
+ }
22
+ function getGetLogicByDatasetsSettings(settings) {
23
+ var _a, _b, _c;
24
+ return {
25
+ filterEmptyArrays: (_a = settings === null || settings === void 0 ? void 0 : settings.filterEmptyArrays) !== null && _a !== void 0 ? _a : true,
26
+ letPassUndefinedProperties: {
27
+ qrveyid: (_c = (_b = settings === null || settings === void 0 ? void 0 : settings.letPassUndefinedProperties) === null || _b === void 0 ? void 0 : _b.qrveyid) !== null && _c !== void 0 ? _c : true
28
+ }
29
+ };
30
+ }
@@ -0,0 +1,12 @@
1
+ import { IDataset } from "../../../qrvey/interfaces/IDataset";
2
+ import { IFBLogic } from "../../interfaces/backend/IFBLogic";
3
+ import { IFFGetLogicByDatasetsColumns } from "../../interfaces/functions/IFFGetLogicByDatasetsColumns";
4
+ /**
5
+ * @todo MODULE NO READY
6
+ * Filters the logic by a datasets array
7
+ * If an qrveyid is not provided in the expression a the filter passes normally
8
+ * @param logic The logic of the filter
9
+ * @param datasets The collection of datasets
10
+ * @returns a new filtered logic
11
+ */
12
+ export declare function getLogicByDatasetsColumns(logic: IFBLogic[], datasets?: IDataset[], settings?: IFFGetLogicByDatasetsColumns): IFBLogic[];
@@ -0,0 +1,43 @@
1
+ import { filterNestedTree } from "../../../general/array/filterNestedTree";
2
+ import { isEmpty } from "../../../general/mix/isEmpty";
3
+ import { _hasProperty } from "../../../general/object/hasProperty";
4
+ /**
5
+ * @todo MODULE NO READY
6
+ * Filters the logic by a datasets array
7
+ * If an qrveyid is not provided in the expression a the filter passes normally
8
+ * @param logic The logic of the filter
9
+ * @param datasets The collection of datasets
10
+ * @returns a new filtered logic
11
+ */
12
+ export function getLogicByDatasetsColumns(logic, datasets = [], settings) {
13
+ if (isEmpty(logic))
14
+ return;
15
+ if (isEmpty(datasets))
16
+ return logic;
17
+ settings = getGetLogicByDatasetsSettings(settings);
18
+ return logic.map(_l => (Object.assign(Object.assign({}, _l), { filters: filterNestedTree(_l.filters, 'expressions', (expression) => {
19
+ const letQrveyidPass = settings.letPassUndefinedProperties.qrveyid || _hasProperty(expression, 'qrveyid');
20
+ let letQuestionidPass = settings.letPassUndefinedProperties.questionid || _hasProperty(expression, 'questionid');
21
+ const dataset = letQrveyidPass ? datasets.find(_data => _data.qrveyid === expression.qrveyid) : undefined;
22
+ if (!isEmpty(dataset)) {
23
+ const column = letQuestionidPass ? (dataset.options || []).find(option => option.id === expression.questionid) : undefined;
24
+ letQuestionidPass = letQuestionidPass || !isEmpty(column);
25
+ }
26
+ return (letQrveyidPass && !isEmpty(dataset)) && letQuestionidPass;
27
+ }) })));
28
+ }
29
+ /**
30
+ * Gets the default settings for the getLogicByDatasetsColumn function
31
+ * @param settings the settings given by the implementer
32
+ * @returns an object with all properties set
33
+ */
34
+ function getGetLogicByDatasetsSettings(settings) {
35
+ var _a, _b, _c, _d, _e;
36
+ return {
37
+ filterEmptyArrays: (_a = settings === null || settings === void 0 ? void 0 : settings.filterEmptyArrays) !== null && _a !== void 0 ? _a : true,
38
+ letPassUndefinedProperties: {
39
+ qrveyid: (_c = (_b = settings === null || settings === void 0 ? void 0 : settings.letPassUndefinedProperties) === null || _b === void 0 ? void 0 : _b.qrveyid) !== null && _c !== void 0 ? _c : true,
40
+ questionid: (_e = (_d = settings === null || settings === void 0 ? void 0 : settings.letPassUndefinedProperties) === null || _d === void 0 ? void 0 : _d.questionid) !== null && _e !== void 0 ? _e : true
41
+ }
42
+ };
43
+ }
@@ -6,5 +6,7 @@ export * from './getBackendGroupValue';
6
6
  export * from './getBackendProperty';
7
7
  export * from './getBackendValidator';
8
8
  export * from './getBackendValues';
9
+ export * from './getLogicByDatasets';
10
+ export * from './getLogicByDatasetsColumns';
9
11
  export * from './getLogicByScopes';
10
12
  export * from './getLogicByScopesHierarchy';
@@ -6,6 +6,8 @@ export * from './getBackendGroupValue';
6
6
  export * from './getBackendProperty';
7
7
  export * from './getBackendValidator';
8
8
  export * from './getBackendValues';
9
+ export * from './getLogicByDatasets';
10
+ export * from './getLogicByDatasetsColumns';
9
11
  export * from './getLogicByScopes';
10
12
  export * from './getLogicByScopesHierarchy';
11
13
  // export * from './hasDatasetRelatedFilters';
@@ -28,7 +28,7 @@ export function excludeFiltersByParams(filterData, params) {
28
28
  return Object.assign(Object.assign({}, filter), { values: (filter.values || []).map((value) => {
29
29
  if (Array.isArray(value) && value.length > 0) {
30
30
  const rankingValues = value;
31
- rankingValues.map(rValue => {
31
+ return rankingValues.map(rValue => {
32
32
  if (params.enableds == null || params.enableds === rValue.enabled)
33
33
  return rValue;
34
34
  }).filter(Boolean);
@@ -0,0 +1,10 @@
1
+ import { IDataset } from "../../../qrvey/interfaces/IDataset";
2
+ import { IFUData } from "../../interfaces/ui/IFUData";
3
+ /**
4
+ * Filtering the filters by the columns of datasets.
5
+ * Module specially for CLS.
6
+ * @param data the filter data
7
+ * @param datasets the collection of datasets and their columns
8
+ * @returns A new filter data with the filtered filters by columns
9
+ */
10
+ export declare function getFiltersByDatasetsColumns(data: IFUData, datasets?: IDataset[]): IFUData;
@@ -0,0 +1,28 @@
1
+ import { isEmpty } from "../../../general/mix/isEmpty";
2
+ /**
3
+ * Filtering the filters by the columns of datasets.
4
+ * Module specially for CLS.
5
+ * @param data the filter data
6
+ * @param datasets the collection of datasets and their columns
7
+ * @returns A new filter data with the filtered filters by columns
8
+ */
9
+ export function getFiltersByDatasetsColumns(data, datasets = []) {
10
+ if (isEmpty(data) || isEmpty(data.scopes))
11
+ return;
12
+ if (isEmpty(datasets))
13
+ return data;
14
+ const newData = Object.assign(Object.assign({}, data), { scopes: data.scopes.map(scope => (Object.assign(Object.assign({}, scope), { datasets: scope.datasets.map(filterDataset => {
15
+ const dataset = datasets.find(_data => _data.qrveyid === filterDataset.qrveyid);
16
+ if (!isEmpty(dataset)) {
17
+ return Object.assign(Object.assign({}, filterDataset), { filters: filterDataset.filters.map(filter => {
18
+ const column = (dataset.options || []).find(cInfo => cInfo.id === filter.column.id && cInfo.qrveyid === filter.column.qrveyid);
19
+ if (!isEmpty(column)) {
20
+ return Object.assign({}, filter);
21
+ }
22
+ }).filter(Boolean) });
23
+ }
24
+ }).filter(dataset => !isEmpty(dataset) && dataset.filters.length > 0) }))).filter(scope => !isEmpty(scope) && scope.datasets.length > 0) });
25
+ if (!isEmpty(newData) && newData.scopes.length > 0) {
26
+ return newData;
27
+ }
28
+ }
@@ -6,6 +6,7 @@ export * from './getFilterColumnLabel';
6
6
  export * from './getFilterid';
7
7
  export * from './getFilterLabel';
8
8
  export * from './getFiltersByAggregateColumn';
9
+ export * from './getFiltersByDatasetsColumns';
9
10
  export * from './getFiltersByParams';
10
11
  export * from './getFiltersByScopes';
11
12
  export * from './getFiltersByScopesIds';
@@ -6,6 +6,7 @@ export * from './getFilterColumnLabel';
6
6
  export * from './getFilterid';
7
7
  export * from './getFilterLabel';
8
8
  export * from './getFiltersByAggregateColumn';
9
+ export * from './getFiltersByDatasetsColumns';
9
10
  export * from './getFiltersByParams';
10
11
  export * from './getFiltersByScopes';
11
12
  export * from './getFiltersByScopesIds';
@@ -14,18 +14,18 @@ export function getAvailableScopes(config) {
14
14
  if (!isEmpty(config.predefinedScopes))
15
15
  scopes = config.predefinedScopes;
16
16
  scopes = [...scopes, { label: FILTER_SCOPE.GLOBAL, id: undefined }];
17
- if (config.tabid != null || config.pageid != null) {
17
+ if (config.tabid != null || config.pageid != null || config.panelid != null) {
18
18
  if (config.pageid)
19
19
  scopes = [...scopes, { label: FILTER_SCOPE.PAGE, id: config.pageid }];
20
20
  if (config.tabid)
21
21
  scopes = [...scopes, { label: FILTER_SCOPE.TAB, id: config.tabid }];
22
22
  if (config.defaultid)
23
23
  scopes = [...scopes, { label: FILTER_SCOPE.DEFAULT, id: config.defaultid }];
24
- scopes = [...scopes, { label: FILTER_SCOPE.CHART, id: config.tabid || config.pageid }];
24
+ if (config.panelid || config.tabid || config.pageid)
25
+ scopes = [...scopes, { label: FILTER_SCOPE.CHART, id: config.panelid || config.tabid || config.pageid }];
25
26
  }
26
- else {
27
- if (config.defaultid)
28
- scopes = [...scopes, { label: FILTER_SCOPE.DEFAULT, id: config.defaultid }];
27
+ else if (config.defaultid) {
28
+ scopes = [...scopes, { label: FILTER_SCOPE.DEFAULT, id: config.defaultid }];
29
29
  }
30
30
  return scopes;
31
31
  }
@@ -7,6 +7,7 @@ import { IFProperty } from "../IFProperty";
7
7
  export interface IFBExpression {
8
8
  enabled?: boolean;
9
9
  groupValue?: IFProperty;
10
+ qrveyid?: string;
10
11
  questionid?: string;
11
12
  questionType?: string;
12
13
  property?: IFProperty;
@@ -9,6 +9,7 @@ export interface IFSAvailableScope {
9
9
  qrveyid?: string;
10
10
  tabid?: string;
11
11
  pageid?: string;
12
+ panelid?: string;
12
13
  defaultid?: string;
13
14
  predefinedScopes?: IFSScopeID[];
14
15
  }
@@ -0,0 +1,6 @@
1
+ export interface IFFGetLogicByDatasets {
2
+ letPassUndefinedProperties?: {
3
+ qrveyid?: boolean;
4
+ };
5
+ filterEmptyArrays?: boolean;
6
+ }
@@ -0,0 +1,7 @@
1
+ export interface IFFGetLogicByDatasetsColumns {
2
+ letPassUndefinedProperties?: {
3
+ qrveyid?: boolean;
4
+ questionid?: boolean;
5
+ };
6
+ filterEmptyArrays?: boolean;
7
+ }
@@ -6,7 +6,7 @@ import { IFUChartSettings } from "../ui/IFUChartSettings";
6
6
  import { IFUFlattenedFilter } from "../ui/IFUFlattenedFilter";
7
7
  export interface IFFiltersGetData {
8
8
  chartRequest?: IFUChartSettings;
9
- dataset: IDataset;
9
+ datasets: IDataset[];
10
10
  filterData?: IFSData;
11
11
  filter: IFUFlattenedFilter;
12
12
  pageid?: string;
@@ -1,3 +1,5 @@
1
+ export * from './IFFGetLogicByDatasets';
2
+ export * from './IFFGetLogicByDatasetsColumns';
1
3
  export * from './IFFiltersGetData';
2
4
  export * from './IFFiltersGetValuesFromDataset';
3
5
  export * from './IFFiltersGetValuesFromModel';
@@ -1,3 +1,5 @@
1
+ export * from './IFFGetLogicByDatasets';
2
+ export * from './IFFGetLogicByDatasetsColumns';
1
3
  export * from './IFFiltersGetData';
2
4
  export * from './IFFiltersGetValuesFromDataset';
3
5
  export * from './IFFiltersGetValuesFromModel';
@@ -15,6 +15,7 @@
15
15
  export * from './backend/index';
16
16
  export * from './builder/index';
17
17
  export * from './common/index';
18
+ export * from './functions/index';
18
19
  export * from './panel/index';
19
20
  export * from './ui/index';
20
21
  export * from './IFDateProperty';
@@ -15,6 +15,7 @@
15
15
  export * from './backend/index';
16
16
  export * from './builder/index';
17
17
  export * from './common/index';
18
+ export * from './functions/index';
18
19
  export * from './panel/index';
19
20
  export * from './ui/index';
20
21
  export * from './IFDateProperty';
@@ -24,6 +24,9 @@ import { isEmpty } from '../../general/mix/isEmpty';
24
24
  import { getModel } from '../../services/api/getModel.api';
25
25
  import { areStaticColumnValues } from '../../qrvey/helpers/areStaticColumnValues';
26
26
  import { getValuesFromDataset } from '../helpers/common/getValuesFromDataset';
27
+ import { getDatasetByColumn } from '../../qrvey/helpers/getDatasetByColumn';
28
+ import { getLogicByDatasets } from '../helpers/backend/getLogicByDatasets';
29
+ import { getFiltersByParams } from '../helpers/common/getFiltersByParams';
27
30
  export class FiltersApi {
28
31
  constructor(cfg) {
29
32
  this.setConfig(cfg);
@@ -51,14 +54,14 @@ export class FiltersApi {
51
54
  // return DataTokensApi.getAll(config);
52
55
  // }
53
56
  getData(config, resetApi = false) {
54
- var _a, _b, _c, _d, _e;
57
+ var _a, _b, _c, _d, _e, _f;
55
58
  let promise;
56
59
  if (areStaticColumnValues((_a = config.filter) === null || _a === void 0 ? void 0 : _a.column) && isEmpty((_b = config.filter) === null || _b === void 0 ? void 0 : _b.column.aggregate)) {
57
60
  promise = getValuesFromDataset({
58
61
  column: (_c = config.filter) === null || _c === void 0 ? void 0 : _c.column,
59
62
  property: (_d = config.filter) === null || _d === void 0 ? void 0 : _d.property,
60
63
  lookupDisplay: (_e = config.filter) === null || _e === void 0 ? void 0 : _e.lookupDisplayIndex,
61
- dataset: config.dataset,
64
+ dataset: getDatasetByColumn((_f = config.filter) === null || _f === void 0 ? void 0 : _f.column, config.datasets),
62
65
  value: config.valueText,
63
66
  });
64
67
  }
@@ -92,12 +95,14 @@ export class FiltersApi {
92
95
  var _a;
93
96
  const scopes = this.getAvailableScopeIds(config);
94
97
  let filterData = getFiltersByVisibility(config.filterData, scopes);
98
+ const dataset = config.datasets.find(d => { var _a; return d.qrveyid === ((_a = config.filter) === null || _a === void 0 ? void 0 : _a.column.qrveyid); });
99
+ filterData = getFiltersByParams(filterData, { qrveyid: dataset.qrveyid }, { letPassUndefinedProperties: { filter: true }, filterEmptyArrays: { filter: false } });
95
100
  filterData = excludeFiltersByAggregateColumn(filterData);
96
101
  const logics = FDToLogic(filterData);
97
102
  const hierarchyLogic = getLogicByScopesHierarchy(logics, scopes, (_a = config.filter) === null || _a === void 0 ? void 0 : _a.extras.scope);
98
103
  return [
99
104
  ...hierarchyLogic,
100
- ...buildUserFilters(config.userFilters) || [],
105
+ ...getLogicByDatasets(buildUserFilters(config.userFilters), isEmpty(dataset) ? [] : [dataset.qrveyid]) || [],
101
106
  ];
102
107
  }
103
108
  getFilter(config) {
@@ -113,9 +118,9 @@ export class FiltersApi {
113
118
  * @returns a collection of the pair Scopes and Scope IDs
114
119
  */
115
120
  getAvailableScopeIds(config) {
116
- var _a, _b, _c, _d, _e, _f, _g;
117
- return getAvailableScopes(Object.assign(Object.assign({}, getAvailableScopesIDsByConfig(config)), { qrveyid: (_b = (_a = config.filter) === null || _a === void 0 ? void 0 : _a.column) === null || _b === void 0 ? void 0 : _b.qrveyid, defaultid: [FILTER_SCOPE.DEFAULT, FILTER_SCOPE.CHART].includes((_c = config.filter) === null || _c === void 0 ? void 0 : _c.extras.scope) && ((_e = (_d = config.filter) === null || _d === void 0 ? void 0 : _d.column) === null || _e === void 0 ? void 0 : _e.qrveyid), scope: undefined, predefinedScopes: [
118
- { label: FILTER_SCOPE.DATA, id: (_g = (_f = config.filter) === null || _f === void 0 ? void 0 : _f.column) === null || _g === void 0 ? void 0 : _g.qrveyid }
121
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j;
122
+ return getAvailableScopes(Object.assign(Object.assign({}, getAvailableScopesIDsByConfig(config)), { panelid: FILTER_SCOPE.CHART === ((_a = config.filter) === null || _a === void 0 ? void 0 : _a.extras.scope) ? (_b = config.filter) === null || _b === void 0 ? void 0 : _b.extras.scopeid : undefined, scopeid: (_c = config.filter) === null || _c === void 0 ? void 0 : _c.extras.scopeid, qrveyid: (_e = (_d = config.filter) === null || _d === void 0 ? void 0 : _d.column) === null || _e === void 0 ? void 0 : _e.qrveyid, defaultid: (_g = (_f = config.filter) === null || _f === void 0 ? void 0 : _f.column) === null || _g === void 0 ? void 0 : _g.qrveyid, scope: undefined, predefinedScopes: [
123
+ { label: FILTER_SCOPE.DATA, id: (_j = (_h = config.filter) === null || _h === void 0 ? void 0 : _h.column) === null || _j === void 0 ? void 0 : _j.qrveyid }
119
124
  ] }));
120
125
  }
121
126
  /**
@@ -25,7 +25,7 @@ function getI18nMonthLabel(label, translate) {
25
25
  }
26
26
  function getI18nYearMonthLabel(label, translate) {
27
27
  if (!isTokenLabel(label) && !isEmpty(translate)) {
28
- const month = getI18nMonthPropertyByIndex(DATE_YEAR_MONTHS.findIndex(month => month === label));
28
+ const month = getI18nMonthPropertyByIndex(DATE_YEAR_MONTHS.findIndex(_month => _month === label));
29
29
  if (!isEmpty(month))
30
30
  label = translate('common.date_grouping.' + month + '_mmm');
31
31
  }
@@ -11,6 +11,16 @@ export interface II18nChartBuilderStyleOptions {
11
11
  chart_type_disabled_message: string;
12
12
  comparision_color: string;
13
13
  data_labels_check: string;
14
+ data_labels_clustering: string;
15
+ data_labels_format: string;
16
+ data_labels_position: string;
17
+ data_labels_position_inside: string;
18
+ data_labels_position_outside: string;
19
+ data_labels_show_as: string;
20
+ data_labels_show_as_category: string;
21
+ data_labels_show_as_percentage: string;
22
+ data_labels_show_as_placeholder: string;
23
+ data_labels_show_as_value: string;
14
24
  default_format_title: string;
15
25
  display_outliers_check: string;
16
26
  line_opacity: string;
@@ -18,6 +18,7 @@ export interface II18nStyleThemesTheme {
18
18
  qrvey_theme: string;
19
19
  restore_to_default: string;
20
20
  save_theme: string;
21
+ show_header: string;
21
22
  show_title: string;
22
23
  table_header_styles: string;
23
24
  text_styles: string;
@@ -9,7 +9,7 @@ export const I18N_CHART_BUILDER_LAYER_OPTIONS = {
9
9
  type_logarithmic: 'Logarithmic',
10
10
  type_moving_average_trendline: 'Moving Average Trendline',
11
11
  type_polynomial: 'Polynomial',
12
- type_standard_regression: 'Standar Regression',
12
+ type_standard_regression: 'Standard Regression',
13
13
  intercept: 'Intercept',
14
14
  slope: 'Slope',
15
15
  legend: 'Trend Line'