@qrvey/utils 1.2.10-5 → 1.2.10-6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (51) hide show
  1. package/README.md +1 -1
  2. package/dist/cjs/filters/adapters/adaptFilterValues.js +1 -1
  3. package/dist/cjs/filters/adapters/flatUIToFD.js +4 -0
  4. package/dist/cjs/filters/adapters/flatUIToOldLogic.js +1 -1
  5. package/dist/cjs/filters/adapters/flatUIToUI.js +4 -0
  6. package/dist/cjs/filters/helpers/OLD_getAggFilters.d.ts +1 -1
  7. package/dist/cjs/filters/helpers/OLD_getAggFilters.js +1 -1
  8. package/dist/cjs/filters/helpers/backend/getBackendProperty.js +1 -1
  9. package/dist/cjs/filters/helpers/backend/getBackendValues.js +1 -1
  10. package/dist/cjs/filters/interfaces/common/IFSValue.d.ts +1 -1
  11. package/dist/cjs/filters/interfaces/ui/IFUValue.d.ts +1 -1
  12. package/dist/cjs/filters/services/UChartPaginationApi.d.ts +2 -2
  13. package/dist/cjs/filters/services/UChartPaginationApi.js +2 -2
  14. package/dist/cjs/format/format.js +4 -2
  15. package/dist/cjs/format/localization.js +1 -1
  16. package/dist/cjs/qrvey/helpers/transformValue.js +3 -0
  17. package/dist/cjs/services/adapters/BBranchesMapToUIBranchesMap.adapter.d.ts +3 -3
  18. package/dist/cjs/services/adapters/BBranchesMapToUIBranchesMap.adapter.js +3 -3
  19. package/dist/filters/adapters/adaptFilterValues.js +1 -1
  20. package/dist/filters/adapters/flatUIToFD.js +4 -0
  21. package/dist/filters/adapters/flatUIToOldLogic.js +1 -1
  22. package/dist/filters/adapters/flatUIToUI.js +4 -0
  23. package/dist/filters/helpers/OLD_getAggFilters.d.ts +1 -1
  24. package/dist/filters/helpers/OLD_getAggFilters.js +1 -1
  25. package/dist/filters/helpers/backend/getBackendProperty.js +1 -1
  26. package/dist/filters/helpers/backend/getBackendValues.js +1 -1
  27. package/dist/filters/interfaces/common/IFSValue.d.ts +1 -1
  28. package/dist/filters/interfaces/ui/IFUValue.d.ts +1 -1
  29. package/dist/filters/services/UChartPaginationApi.d.ts +2 -2
  30. package/dist/filters/services/UChartPaginationApi.js +2 -2
  31. package/dist/format/format.js +4 -2
  32. package/dist/format/localization.js +1 -1
  33. package/dist/qrvey/helpers/transformValue.js +3 -0
  34. package/dist/services/adapters/BBranchesMapToUIBranchesMap.adapter.d.ts +3 -3
  35. package/dist/services/adapters/BBranchesMapToUIBranchesMap.adapter.js +3 -3
  36. package/package.json +6 -5
  37. package/publishing.js +6 -1
  38. package/src/filters/adapters/adaptFilterValues.ts +1 -1
  39. package/src/filters/adapters/flatUIToFD.ts +5 -0
  40. package/src/filters/adapters/flatUIToOldLogic.ts +1 -1
  41. package/src/filters/adapters/flatUIToUI.ts +5 -0
  42. package/src/filters/helpers/OLD_getAggFilters.ts +1 -1
  43. package/src/filters/helpers/backend/getBackendProperty.ts +2 -1
  44. package/src/filters/helpers/backend/getBackendValues.ts +1 -1
  45. package/src/filters/interfaces/common/IFSValue.ts +1 -1
  46. package/src/filters/interfaces/ui/IFUValue.ts +1 -1
  47. package/src/filters/services/UChartPaginationApi.ts +2 -4
  48. package/src/format/format.ts +3 -2
  49. package/src/format/localization.ts +1 -1
  50. package/src/qrvey/helpers/transformValue.ts +3 -0
  51. package/src/services/adapters/BBranchesMapToUIBranchesMap.adapter.ts +3 -3
package/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # [@qrvey/utils](https://bitbucket.org/qrvey/qrvey_utils/wiki/Home) *1.2.10-2*
1
+ # [@qrvey/utils](https://bitbucket.org/qrvey/qrvey_utils/wiki/Home) *1.2.10-5*
2
2
 
3
3
  > Helper, Utils for all Qrvey Projects
4
4
 
@@ -10,7 +10,7 @@ const COLUMN_1 = require("../../columns/constants/COLUMN");
10
10
  * @returns A new value array with the filled properties.
11
11
  */
12
12
  function adaptFilterValues(filter) {
13
- const setValue = value => (Object.assign(Object.assign({}, value), { enabled: (0, isEmpty_1.isEmpty)(value.enabled) ? true : value.enabled }));
13
+ const setValue = value => (Object.assign(Object.assign({}, value), { value: (0, isEmpty_1.isEmpty)(value.value) ? undefined : value.value, enabled: (0, isEmpty_1.isEmpty)(value.enabled) ? true : value.enabled }));
14
14
  if (filter.column.type === COLUMN_1.COLUMN.RANKING && (0, isEmpty_1.isEmpty)(filter.column.aggregate)) {
15
15
  return (filter.values || []).map(rValues => rValues.map(setValue));
16
16
  }
@@ -6,6 +6,7 @@ const isEmpty_1 = require("../../general/mix/isEmpty");
6
6
  const adaptFilterValues_1 = require("./adaptFilterValues");
7
7
  const FILTER_SECTION_1 = require("../constants/common/FILTER_SECTION");
8
8
  const FILTER_STRUCTURE_VERSION_1 = require("../constants/common/FILTER_STRUCTURE_VERSION");
9
+ const cloneDeep_1 = require("../../general/object/cloneDeep");
9
10
  /**
10
11
  * Generates a filter data structure from the flatttened UI filters.
11
12
  * @param uFilters Array of flattened filters from UI
@@ -82,8 +83,11 @@ function buildDataset(uFilter) {
82
83
  * @returns an filter structure
83
84
  */
84
85
  function buildFilter(uFilter) {
86
+ uFilter = (0, cloneDeep_1.cloneDeep)(uFilter);
85
87
  const info = !(0, isEmpty_1.isEmpty)(uFilter.extras.info) ? { icon: uFilter.extras.info.icon, label: uFilter.extras.info.label } : undefined;
86
88
  const property = (0, adaptDateGroupingProperty_1.adaptDateGroupingProperty)(uFilter.property);
89
+ delete uFilter.extras.scopeInfo;
90
+ delete uFilter.extras.dataset;
87
91
  return {
88
92
  collapsed: uFilter.collapsed,
89
93
  column: {
@@ -359,7 +359,7 @@ function getResultValues(values, props) {
359
359
  return (values || []).map((value) => {
360
360
  if (value.enabled) {
361
361
  if (props.column.type === COLUMN_1.COLUMN.IMAGE) {
362
- return value.valueid;
362
+ return value.valueid || value.imageUrl || value.value;
363
363
  }
364
364
  else {
365
365
  return value.value;
@@ -7,6 +7,7 @@ const FILTER_SECTION_1 = require("../constants/common/FILTER_SECTION");
7
7
  const FILTER_STRUCTURE_VERSION_1 = require("../constants/common/FILTER_STRUCTURE_VERSION");
8
8
  const getLastIndexFromArray_1 = require("../../general/array/getLastIndexFromArray");
9
9
  const isEmpty_1 = require("../../general/mix/isEmpty");
10
+ const cloneDeep_1 = require("../../general/object/cloneDeep");
10
11
  /**
11
12
  * Generates a UI filter data structure from the flatttened UI filters.
12
13
  * @param uFilters Array of flattened filters from UI
@@ -89,8 +90,11 @@ function buildDataset(uFilter) {
89
90
  * @returns an filter structure
90
91
  */
91
92
  function buildFilter(uFilter) {
93
+ uFilter = (0, cloneDeep_1.cloneDeep)(uFilter);
92
94
  const info = !(0, isEmpty_1.isEmpty)(uFilter.extras.info) ? { icon: uFilter.extras.info.icon, label: uFilter.extras.info.label } : undefined;
93
95
  const property = (0, adaptDateGroupingProperty_1.adaptDateGroupingProperty)(uFilter.property);
96
+ delete uFilter.extras.scopeInfo;
97
+ delete uFilter.extras.dataset;
94
98
  return {
95
99
  collapsed: uFilter.collapsed,
96
100
  column: {
@@ -4,6 +4,6 @@ import { OLD_IFilterLogic } from "../interfaces/OLD_IFilterLogic";
4
4
  * @deprecated soon
5
5
  * @param logics
6
6
  * @param summaries
7
- * @returns
7
+ * @returns the filter aggregate structure
8
8
  */
9
9
  export declare function getAggFilters(logics?: OLD_IFilterLogic[], summaries?: any[]): IFBFilterAggregate;
@@ -10,7 +10,7 @@ const FILTER_OPERATOR_1 = require("../constants/common/FILTER_OPERATOR");
10
10
  * @deprecated soon
11
11
  * @param logics
12
12
  * @param summaries
13
- * @returns
13
+ * @returns the filter aggregate structure
14
14
  */
15
15
  function getAggFilters(logics = [], summaries = []) {
16
16
  const aggregateFilters = getAggregateFilters(logics);
@@ -23,7 +23,7 @@ function getBackendProperty(filter) {
23
23
  return filter.property.concat('_').concat(filter.lookupDisplayIndex.toString());
24
24
  }
25
25
  else if (filter.column.type === COLUMN_1.COLUMN.IMAGE) {
26
- return COLUMN_PROPERTY_1.COLUMN_PROPERTY.IMAGE_ANSWER_ID;
26
+ return filter.values.every(value => (0, isEmpty_1.isEmpty)(value.valueid)) ? undefined : COLUMN_PROPERTY_1.COLUMN_PROPERTY.IMAGE_ANSWER_ID;
27
27
  }
28
28
  }
29
29
  return filter.property;
@@ -77,7 +77,7 @@ function getResultValues(values, filter) {
77
77
  return (values || []).map((value) => {
78
78
  if (value.enabled) {
79
79
  if (filter.column.type === COLUMN_1.COLUMN.IMAGE) {
80
- return value.valueid;
80
+ return value.valueid || value.imageUrl || value.value;
81
81
  }
82
82
  else {
83
83
  return value.value;
@@ -4,6 +4,6 @@
4
4
  export interface IFSValue {
5
5
  enabled?: boolean;
6
6
  imageUrl?: string;
7
- value: string;
7
+ value?: string;
8
8
  valueid?: string;
9
9
  }
@@ -4,6 +4,6 @@
4
4
  export interface IFUValue {
5
5
  enabled?: boolean;
6
6
  imageUrl?: string;
7
- value: string;
7
+ value?: string;
8
8
  valueid?: string;
9
9
  }
@@ -9,7 +9,7 @@ export default class UChartPaginationApi {
9
9
  uFilter: IFUFlattenedFilter;
10
10
  /**
11
11
  * Gets afterKey object
12
- * @returns
12
+ * @returns the afterKey object
13
13
  */
14
14
  getAfterKey: () => any;
15
15
  /**
@@ -38,7 +38,7 @@ export default class UChartPaginationApi {
38
38
  /**
39
39
  * Get a dimension body structure foor pagination endpoint
40
40
  * @param dimensions
41
- * @returns
41
+ * @returns the dimension body structure
42
42
  */
43
43
  private _getDimensionsBodyAdapter;
44
44
  /**
@@ -21,7 +21,7 @@ class UChartPaginationApi {
21
21
  constructor() {
22
22
  /**
23
23
  * Gets afterKey object
24
- * @returns
24
+ * @returns the afterKey object
25
25
  */
26
26
  this.getAfterKey = () => {
27
27
  return this.afterKey;
@@ -100,7 +100,7 @@ class UChartPaginationApi {
100
100
  /**
101
101
  * Get a dimension body structure foor pagination endpoint
102
102
  * @param dimensions
103
- * @returns
103
+ * @returns the dimension body structure
104
104
  */
105
105
  this._getDimensionsBodyAdapter = (dimensions = []) => {
106
106
  return dimensions.map(dimension => ({
@@ -27,7 +27,8 @@ function formatDate(dateString, format) {
27
27
  return dateString;
28
28
  if (!isValidDateString(dateString))
29
29
  return dateString;
30
- return (0, dayjs_1.default)(dateString.split('.')[0]).format(format.replace('HH24:', 'HH:').replace('MI:SS', 'mm:ss').replace('MM:SS', 'mm:ss'));
30
+ const dateValue = dateString === null || dateString === void 0 ? void 0 : dateString.replace(/Z$/i, '');
31
+ return (0, dayjs_1.default)(dateValue.split('.')[0]).format(format.replace('HH24:', 'HH:').replace('MI:SS', 'mm:ss').replace('MM:SS', 'mm:ss'));
31
32
  }
32
33
  exports.formatDate = formatDate;
33
34
  function formatAbbreviated(num, decimals) {
@@ -85,12 +86,13 @@ function formatFileSize(bytes) {
85
86
  }
86
87
  exports.formatFileSize = formatFileSize;
87
88
  const addFormat = (value, outputFormat = 'None', config) => {
89
+ var _a, _b;
88
90
  if ((0, isEmpty_1.isEmpty)(value) || typeof value === 'object' && (0, isEmpty_1.isEmpty)(value[0]))
89
91
  return value;
90
92
  switch (outputFormat.type) {
91
93
  case 'DATE':
92
94
  case 'DATETIME':
93
- return (config === null || config === void 0 ? void 0 : config.lang) && outputFormat.format === 'Default' ? (0, localization_1.formatWithLocale)(value, outputFormat, config) : formatDate(value, outputFormat.format);
95
+ return (config === null || config === void 0 ? void 0 : config.lang) && outputFormat.format === 'Default' ? (0, localization_1.formatWithLocale)(value, outputFormat, config) : formatDate(value, (outputFormat === null || outputFormat === void 0 ? void 0 : outputFormat.format) === 'Default' && ((_a = outputFormat === null || outputFormat === void 0 ? void 0 : outputFormat.originalFormat) === null || _a === void 0 ? void 0 : _a.format) ? (_b = outputFormat === null || outputFormat === void 0 ? void 0 : outputFormat.originalFormat) === null || _b === void 0 ? void 0 : _b.format : outputFormat === null || outputFormat === void 0 ? void 0 : outputFormat.format);
94
96
  case 'NUMERIC': {
95
97
  const parse = parseFloat(value);
96
98
  const withLocale = outputFormat !== 'None' && (config === null || config === void 0 ? void 0 : config.lang);
@@ -32,7 +32,7 @@ const formatWithLocale = (value, outputFormat, config = {}) => {
32
32
  exports.formatWithLocale = formatWithLocale;
33
33
  function formatLocaleDate(value, outputFormat, config) {
34
34
  const { lang = definition_1.LANG_DEFAULT, options } = config;
35
- const dateValue = value === null || value === void 0 ? void 0 : value.replace('.000Z', '');
35
+ const dateValue = value === null || value === void 0 ? void 0 : value.replace(/Z$/i, '');
36
36
  const dateParam = new Date(dateValue);
37
37
  let langOpts = options;
38
38
  if (outputFormat === null || outputFormat === void 0 ? void 0 : outputFormat.originalFormat) {
@@ -6,6 +6,7 @@ const isNumericalColumn_1 = require("../../columns/helpers/isNumericalColumn");
6
6
  const DATE_GROUPING_PROPERTY_1 = require("../../dates/constants/DATE_GROUPING_PROPERTY");
7
7
  const DATE_GROUPING_TIME_PROPERTY_1 = require("../../dates/constants/DATE_GROUPING_TIME_PROPERTY");
8
8
  const format_1 = require("../../format/format");
9
+ const isEmpty_1 = require("../../general/mix/isEmpty");
9
10
  const getI18nDateGroupLabel_1 = require("../../globalization/helpers/getI18nDateGroupLabel");
10
11
  const getValueWithSuffixes_1 = require("./getValueWithSuffixes");
11
12
  /**
@@ -15,6 +16,8 @@ const getValueWithSuffixes_1 = require("./getValueWithSuffixes");
15
16
  * @returns A transformed value
16
17
  */
17
18
  function transformValue(value, settings) {
19
+ if ((0, isEmpty_1.isEmpty)(value))
20
+ return value;
18
21
  const valueWithI18n = (0, getI18nDateGroupLabel_1.getI18nDateGroupLabel)(value, settings.property, settings.translate);
19
22
  const valueWithLocalization = (0, format_1.addFormat)(valueWithI18n, getOutputFormat(settings), getFormatConfig(settings));
20
23
  return (0, getValueWithSuffixes_1.getValueWithSuffixes)(valueWithLocalization, { suffixTranslateLabel: settings.suffixTranslateLabel, translate: settings.translate });
@@ -1,8 +1,8 @@
1
1
  import { IBModelBranchesMap } from "../../qrvey/interfaces/IBModelBranchesMap";
2
2
  import { IModelBranchesMap } from "../../qrvey/interfaces/IModelBranchesMap";
3
3
  /**
4
- *
5
- * @param branchesMap
6
- * @returns
4
+ * Adapts the branches map from backend to the UI branches map
5
+ * @param branchesMap the backend branches map
6
+ * @returns The Branches map array
7
7
  */
8
8
  export declare function BBranchesMapToUIBranchesMap(branchesMap: IBModelBranchesMap[]): IModelBranchesMap[];
@@ -4,9 +4,9 @@ exports.BBranchesMapToUIBranchesMap = void 0;
4
4
  const isEmpty_1 = require("../../general/mix/isEmpty");
5
5
  const BColumnsToUIColumns_adapter_1 = require("./BColumnsToUIColumns.adapter");
6
6
  /**
7
- *
8
- * @param branchesMap
9
- * @returns
7
+ * Adapts the branches map from backend to the UI branches map
8
+ * @param branchesMap the backend branches map
9
+ * @returns The Branches map array
10
10
  */
11
11
  function BBranchesMapToUIBranchesMap(branchesMap) {
12
12
  if ((0, isEmpty_1.isEmpty)(branchesMap))
@@ -7,7 +7,7 @@ import { COLUMN } from "../../columns/constants/COLUMN";
7
7
  * @returns A new value array with the filled properties.
8
8
  */
9
9
  export function adaptFilterValues(filter) {
10
- const setValue = value => (Object.assign(Object.assign({}, value), { enabled: isEmpty(value.enabled) ? true : value.enabled }));
10
+ const setValue = value => (Object.assign(Object.assign({}, value), { value: isEmpty(value.value) ? undefined : value.value, enabled: isEmpty(value.enabled) ? true : value.enabled }));
11
11
  if (filter.column.type === COLUMN.RANKING && isEmpty(filter.column.aggregate)) {
12
12
  return (filter.values || []).map(rValues => rValues.map(setValue));
13
13
  }
@@ -3,6 +3,7 @@ import { isEmpty } from "../../general/mix/isEmpty";
3
3
  import { adaptFilterValues } from "./adaptFilterValues";
4
4
  import { FILTER_SECTION } from "../constants/common/FILTER_SECTION";
5
5
  import { FILTER_STRUCTURE_VERSION } from "../constants/common/FILTER_STRUCTURE_VERSION";
6
+ import { cloneDeep } from "../../general/object/cloneDeep";
6
7
  /**
7
8
  * Generates a filter data structure from the flatttened UI filters.
8
9
  * @param uFilters Array of flattened filters from UI
@@ -78,8 +79,11 @@ function buildDataset(uFilter) {
78
79
  * @returns an filter structure
79
80
  */
80
81
  function buildFilter(uFilter) {
82
+ uFilter = cloneDeep(uFilter);
81
83
  const info = !isEmpty(uFilter.extras.info) ? { icon: uFilter.extras.info.icon, label: uFilter.extras.info.label } : undefined;
82
84
  const property = adaptDateGroupingProperty(uFilter.property);
85
+ delete uFilter.extras.scopeInfo;
86
+ delete uFilter.extras.dataset;
83
87
  return {
84
88
  collapsed: uFilter.collapsed,
85
89
  column: {
@@ -353,7 +353,7 @@ function getResultValues(values, props) {
353
353
  return (values || []).map((value) => {
354
354
  if (value.enabled) {
355
355
  if (props.column.type === COLUMN.IMAGE) {
356
- return value.valueid;
356
+ return value.valueid || value.imageUrl || value.value;
357
357
  }
358
358
  else {
359
359
  return value.value;
@@ -4,6 +4,7 @@ import { FILTER_SECTION } from "../constants/common/FILTER_SECTION";
4
4
  import { FILTER_STRUCTURE_VERSION } from "../constants/common/FILTER_STRUCTURE_VERSION";
5
5
  import { getLastIndexFromArray } from "../../general/array/getLastIndexFromArray";
6
6
  import { isEmpty } from "../../general/mix/isEmpty";
7
+ import { cloneDeep } from "../../general/object/cloneDeep";
7
8
  /**
8
9
  * Generates a UI filter data structure from the flatttened UI filters.
9
10
  * @param uFilters Array of flattened filters from UI
@@ -85,8 +86,11 @@ function buildDataset(uFilter) {
85
86
  * @returns an filter structure
86
87
  */
87
88
  function buildFilter(uFilter) {
89
+ uFilter = cloneDeep(uFilter);
88
90
  const info = !isEmpty(uFilter.extras.info) ? { icon: uFilter.extras.info.icon, label: uFilter.extras.info.label } : undefined;
89
91
  const property = adaptDateGroupingProperty(uFilter.property);
92
+ delete uFilter.extras.scopeInfo;
93
+ delete uFilter.extras.dataset;
90
94
  return {
91
95
  collapsed: uFilter.collapsed,
92
96
  column: {
@@ -4,6 +4,6 @@ import { OLD_IFilterLogic } from "../interfaces/OLD_IFilterLogic";
4
4
  * @deprecated soon
5
5
  * @param logics
6
6
  * @param summaries
7
- * @returns
7
+ * @returns the filter aggregate structure
8
8
  */
9
9
  export declare function getAggFilters(logics?: OLD_IFilterLogic[], summaries?: any[]): IFBFilterAggregate;
@@ -7,7 +7,7 @@ import { FILTER_OPERATOR } from "../constants/common/FILTER_OPERATOR";
7
7
  * @deprecated soon
8
8
  * @param logics
9
9
  * @param summaries
10
- * @returns
10
+ * @returns the filter aggregate structure
11
11
  */
12
12
  export function getAggFilters(logics = [], summaries = []) {
13
13
  const aggregateFilters = getAggregateFilters(logics);
@@ -20,7 +20,7 @@ export function getBackendProperty(filter) {
20
20
  return filter.property.concat('_').concat(filter.lookupDisplayIndex.toString());
21
21
  }
22
22
  else if (filter.column.type === COLUMN.IMAGE) {
23
- return COLUMN_PROPERTY.IMAGE_ANSWER_ID;
23
+ return filter.values.every(value => isEmpty(value.valueid)) ? undefined : COLUMN_PROPERTY.IMAGE_ANSWER_ID;
24
24
  }
25
25
  }
26
26
  return filter.property;
@@ -73,7 +73,7 @@ function getResultValues(values, filter) {
73
73
  return (values || []).map((value) => {
74
74
  if (value.enabled) {
75
75
  if (filter.column.type === COLUMN.IMAGE) {
76
- return value.valueid;
76
+ return value.valueid || value.imageUrl || value.value;
77
77
  }
78
78
  else {
79
79
  return value.value;
@@ -4,6 +4,6 @@
4
4
  export interface IFSValue {
5
5
  enabled?: boolean;
6
6
  imageUrl?: string;
7
- value: string;
7
+ value?: string;
8
8
  valueid?: string;
9
9
  }
@@ -4,6 +4,6 @@
4
4
  export interface IFUValue {
5
5
  enabled?: boolean;
6
6
  imageUrl?: string;
7
- value: string;
7
+ value?: string;
8
8
  valueid?: string;
9
9
  }
@@ -9,7 +9,7 @@ export default class UChartPaginationApi {
9
9
  uFilter: IFUFlattenedFilter;
10
10
  /**
11
11
  * Gets afterKey object
12
- * @returns
12
+ * @returns the afterKey object
13
13
  */
14
14
  getAfterKey: () => any;
15
15
  /**
@@ -38,7 +38,7 @@ export default class UChartPaginationApi {
38
38
  /**
39
39
  * Get a dimension body structure foor pagination endpoint
40
40
  * @param dimensions
41
- * @returns
41
+ * @returns the dimension body structure
42
42
  */
43
43
  private _getDimensionsBodyAdapter;
44
44
  /**
@@ -16,7 +16,7 @@ export default class UChartPaginationApi {
16
16
  constructor() {
17
17
  /**
18
18
  * Gets afterKey object
19
- * @returns
19
+ * @returns the afterKey object
20
20
  */
21
21
  this.getAfterKey = () => {
22
22
  return this.afterKey;
@@ -95,7 +95,7 @@ export default class UChartPaginationApi {
95
95
  /**
96
96
  * Get a dimension body structure foor pagination endpoint
97
97
  * @param dimensions
98
- * @returns
98
+ * @returns the dimension body structure
99
99
  */
100
100
  this._getDimensionsBodyAdapter = (dimensions = []) => {
101
101
  return dimensions.map(dimension => ({
@@ -21,7 +21,8 @@ export function formatDate(dateString, format) {
21
21
  return dateString;
22
22
  if (!isValidDateString(dateString))
23
23
  return dateString;
24
- return dayjs(dateString.split('.')[0]).format(format.replace('HH24:', 'HH:').replace('MI:SS', 'mm:ss').replace('MM:SS', 'mm:ss'));
24
+ const dateValue = dateString === null || dateString === void 0 ? void 0 : dateString.replace(/Z$/i, '');
25
+ return dayjs(dateValue.split('.')[0]).format(format.replace('HH24:', 'HH:').replace('MI:SS', 'mm:ss').replace('MM:SS', 'mm:ss'));
25
26
  }
26
27
  export function formatAbbreviated(num, decimals) {
27
28
  if (num == 0)
@@ -76,12 +77,13 @@ export function formatFileSize(bytes) {
76
77
  return megaBytes < 10 ? `${fixDecimals(megaBytes)} MB` : `${Math.round(megaBytes)} MB`;
77
78
  }
78
79
  export const addFormat = (value, outputFormat = 'None', config) => {
80
+ var _a, _b;
79
81
  if (isEmpty(value) || typeof value === 'object' && isEmpty(value[0]))
80
82
  return value;
81
83
  switch (outputFormat.type) {
82
84
  case 'DATE':
83
85
  case 'DATETIME':
84
- return (config === null || config === void 0 ? void 0 : config.lang) && outputFormat.format === 'Default' ? formatWithLocale(value, outputFormat, config) : formatDate(value, outputFormat.format);
86
+ return (config === null || config === void 0 ? void 0 : config.lang) && outputFormat.format === 'Default' ? formatWithLocale(value, outputFormat, config) : formatDate(value, (outputFormat === null || outputFormat === void 0 ? void 0 : outputFormat.format) === 'Default' && ((_a = outputFormat === null || outputFormat === void 0 ? void 0 : outputFormat.originalFormat) === null || _a === void 0 ? void 0 : _a.format) ? (_b = outputFormat === null || outputFormat === void 0 ? void 0 : outputFormat.originalFormat) === null || _b === void 0 ? void 0 : _b.format : outputFormat === null || outputFormat === void 0 ? void 0 : outputFormat.format);
85
87
  case 'NUMERIC': {
86
88
  const parse = parseFloat(value);
87
89
  const withLocale = outputFormat !== 'None' && (config === null || config === void 0 ? void 0 : config.lang);
@@ -26,7 +26,7 @@ export const formatWithLocale = (value, outputFormat, config = {}) => {
26
26
  };
27
27
  function formatLocaleDate(value, outputFormat, config) {
28
28
  const { lang = LANG_DEFAULT, options } = config;
29
- const dateValue = value === null || value === void 0 ? void 0 : value.replace('.000Z', '');
29
+ const dateValue = value === null || value === void 0 ? void 0 : value.replace(/Z$/i, '');
30
30
  const dateParam = new Date(dateValue);
31
31
  let langOpts = options;
32
32
  if (outputFormat === null || outputFormat === void 0 ? void 0 : outputFormat.originalFormat) {
@@ -3,6 +3,7 @@ import { isNumericalColumn } from "../../columns/helpers/isNumericalColumn";
3
3
  import { DATE_GROUPING_PROPERTY } from "../../dates/constants/DATE_GROUPING_PROPERTY";
4
4
  import { DATE_GROUPING_TIME_PROPERTY } from "../../dates/constants/DATE_GROUPING_TIME_PROPERTY";
5
5
  import { addFormat } from "../../format/format";
6
+ import { isEmpty } from "../../general/mix/isEmpty";
6
7
  import { getI18nDateGroupLabel } from "../../globalization/helpers/getI18nDateGroupLabel";
7
8
  import { getValueWithSuffixes } from "./getValueWithSuffixes";
8
9
  /**
@@ -12,6 +13,8 @@ import { getValueWithSuffixes } from "./getValueWithSuffixes";
12
13
  * @returns A transformed value
13
14
  */
14
15
  export function transformValue(value, settings) {
16
+ if (isEmpty(value))
17
+ return value;
15
18
  const valueWithI18n = getI18nDateGroupLabel(value, settings.property, settings.translate);
16
19
  const valueWithLocalization = addFormat(valueWithI18n, getOutputFormat(settings), getFormatConfig(settings));
17
20
  return getValueWithSuffixes(valueWithLocalization, { suffixTranslateLabel: settings.suffixTranslateLabel, translate: settings.translate });
@@ -1,8 +1,8 @@
1
1
  import { IBModelBranchesMap } from "../../qrvey/interfaces/IBModelBranchesMap";
2
2
  import { IModelBranchesMap } from "../../qrvey/interfaces/IModelBranchesMap";
3
3
  /**
4
- *
5
- * @param branchesMap
6
- * @returns
4
+ * Adapts the branches map from backend to the UI branches map
5
+ * @param branchesMap the backend branches map
6
+ * @returns The Branches map array
7
7
  */
8
8
  export declare function BBranchesMapToUIBranchesMap(branchesMap: IBModelBranchesMap[]): IModelBranchesMap[];
@@ -1,9 +1,9 @@
1
1
  import { isEmpty } from "../../general/mix/isEmpty";
2
2
  import { BColumnsToUIColumns } from "./BColumnsToUIColumns.adapter";
3
3
  /**
4
- *
5
- * @param branchesMap
6
- * @returns
4
+ * Adapts the branches map from backend to the UI branches map
5
+ * @param branchesMap the backend branches map
6
+ * @returns The Branches map array
7
7
  */
8
8
  export function BBranchesMapToUIBranchesMap(branchesMap) {
9
9
  if (isEmpty(branchesMap))
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@qrvey/utils",
3
- "version": "1.2.10-5",
3
+ "version": "1.2.10-6",
4
4
  "description": "Helper, Utils for all Qrvey Projects",
5
5
  "homepage": "https://bitbucket.org/qrvey/qrvey_utils/wiki/Home",
6
6
  "main": "dist/index.js",
@@ -19,15 +19,16 @@
19
19
  "license": "MIT",
20
20
  "devDependencies": {
21
21
  "@types/jest": "27.4.1",
22
+ "@typescript-eslint/eslint-plugin": "5.15.0",
23
+ "@typescript-eslint/parser": "5.15.0",
22
24
  "doxdox": "3.0.0",
25
+ "eslint": "8.11.0",
23
26
  "jest": "27.5.1",
27
+ "jsdoc": "3.6.10",
24
28
  "np": "7.6.0",
25
29
  "ts-jest": "27.1.3",
26
30
  "typedoc": "0.22.13",
27
- "typescript": "4.6.2",
28
- "@typescript-eslint/eslint-plugin": "5.15.0",
29
- "@typescript-eslint/parser": "5.15.0",
30
- "eslint": "8.11.0"
31
+ "typescript": "4.6.2"
31
32
  },
32
33
  "dependencies": {
33
34
  "d3": "6.3.1",
package/publishing.js CHANGED
@@ -1,4 +1,9 @@
1
- // IN DEVELOPMENT
1
+ /**
2
+ * New version for publishing a new version of Qrvey Utils
3
+ * 1- Publish the version with np
4
+ * 2- Update the README.md doc with doxdox
5
+ */
6
+
2
7
  const fs = require('fs');
3
8
  const util = require('util');
4
9
  const childProcess = require('child_process');
@@ -15,7 +15,7 @@ import { IFSValueRelativeDate } from "../interfaces/common/IFSValueRelativeDate"
15
15
  * @returns A new value array with the filled properties.
16
16
  */
17
17
  export function adaptFilterValues(filter: IFSFilter): IFValue[] {
18
- const setValue = value => ({ ...value, enabled: isEmpty(value.enabled) ? true : value.enabled });
18
+ const setValue = value => ({ ...value, value: isEmpty(value.value) ? undefined : value.value, enabled: isEmpty(value.enabled) ? true : value.enabled });
19
19
 
20
20
  if (filter.column.type === COLUMN.RANKING && isEmpty(filter.column.aggregate)) {
21
21
  return ((filter.values || []) as IFSValueRanking[][]).map(rValues => rValues.map(setValue));
@@ -9,6 +9,7 @@ import { IFSData } from "../interfaces/common/IFSData";
9
9
  import { IFSScope } from "../interfaces/common/IFSScope";
10
10
  import { IFSFilter } from "../interfaces/common/IFSFilter";
11
11
  import { IFSDataset } from "../interfaces/common/IFSDataset";
12
+ import { cloneDeep } from "../../general/object/cloneDeep";
12
13
 
13
14
  /**
14
15
  * Generates a filter data structure from the flatttened UI filters.
@@ -90,9 +91,13 @@ function buildDataset(uFilter: IFUFlattenedFilter): IFSDataset {
90
91
  * @returns an filter structure
91
92
  */
92
93
  function buildFilter(uFilter: IFUFlattenedFilter): IFSFilter {
94
+ uFilter = cloneDeep(uFilter);
95
+
93
96
  const info = !isEmpty(uFilter.extras.info) ? { icon: uFilter.extras.info.icon, label: uFilter.extras.info.label } : undefined;
94
97
  const property = adaptDateGroupingProperty(uFilter.property);
95
98
 
99
+ delete uFilter.extras.scopeInfo;
100
+ delete uFilter.extras.dataset;
96
101
  return {
97
102
  collapsed: uFilter.collapsed,
98
103
  column: {
@@ -410,7 +410,7 @@ function getRankingValues(values: IFSValueRanking[][], rankingGroupIndex?: numbe
410
410
  return (values || []).map((value: IFSValue) => {
411
411
  if (value.enabled) {
412
412
  if (props.column.type === COLUMN.IMAGE) {
413
- return value.valueid;
413
+ return value.valueid || value.imageUrl || value.value;
414
414
  } else {
415
415
  return value.value;
416
416
  }
@@ -10,6 +10,7 @@ import { IFUFilter } from "../interfaces/ui/IFUFilter";
10
10
  import { IFUDataset } from "../interfaces/ui/IFUDataset";
11
11
  import { getLastIndexFromArray } from "../../general/array/getLastIndexFromArray";
12
12
  import { isEmpty } from "../../general/mix/isEmpty";
13
+ import { cloneDeep } from "../../general/object/cloneDeep";
13
14
 
14
15
  /**
15
16
  * Generates a UI filter data structure from the flatttened UI filters.
@@ -96,9 +97,13 @@ function buildDataset(uFilter: IFUFlattenedFilter): IFUDataset {
96
97
  * @returns an filter structure
97
98
  */
98
99
  function buildFilter(uFilter: IFUFlattenedFilter): IFUFilter {
100
+ uFilter = cloneDeep(uFilter);
101
+
99
102
  const info = !isEmpty(uFilter.extras.info) ? { icon: uFilter.extras.info.icon, label: uFilter.extras.info.label } : undefined;
100
103
  const property = adaptDateGroupingProperty(uFilter.property);
101
104
 
105
+ delete uFilter.extras.scopeInfo;
106
+ delete uFilter.extras.dataset;
102
107
  return {
103
108
  collapsed: uFilter.collapsed,
104
109
  column: {
@@ -13,7 +13,7 @@ import { OLD_IFilterLogic } from "../interfaces/OLD_IFilterLogic";
13
13
  * @deprecated soon
14
14
  * @param logics
15
15
  * @param summaries
16
- * @returns
16
+ * @returns the filter aggregate structure
17
17
  */
18
18
  export function getAggFilters(logics: OLD_IFilterLogic[] = [], summaries: any[] = []): IFBFilterAggregate {
19
19
  const aggregateFilters: OLD_IFilterLogic[] = getAggregateFilters(logics) as OLD_IFilterLogic[];
@@ -3,6 +3,7 @@ import { COLUMN_PROPERTY } from "../../../columns/constants/COLUMN_PROPERTY";
3
3
  import { isDateColumn } from "../../../columns/helpers/isDateColumn";
4
4
  import { isEmpty } from "../../../general/mix/isEmpty";
5
5
  import { IFSFilter } from "../../interfaces/common/IFSFilter";
6
+ import { IFSValue } from "../../interfaces/common/IFSValue";
6
7
  import { IFProperty } from "../../interfaces/IFProperty";
7
8
  import { isNullValidator } from "../common/isNullValidator";
8
9
 
@@ -20,7 +21,7 @@ export function getBackendProperty(filter: IFSFilter): IFProperty {
20
21
  } else if (filter.column.type === COLUMN.LOOKUP && filter.property === COLUMN_PROPERTY.LOOKUP_DISPLAY && filter.lookupDisplayIndex != null) {
21
22
  return filter.property.concat('_').concat(filter.lookupDisplayIndex.toString()) as any;
22
23
  } else if (filter.column.type === COLUMN.IMAGE) {
23
- return COLUMN_PROPERTY.IMAGE_ANSWER_ID;
24
+ return (filter.values as IFSValue[]).every(value => isEmpty(value.valueid)) ? undefined : COLUMN_PROPERTY.IMAGE_ANSWER_ID;
24
25
  }
25
26
  }
26
27
  return filter.property;
@@ -84,7 +84,7 @@ function getResultValues(values: IFSValue[], filter: IFSFilter): IFBExpressionVa
84
84
  return (values || []).map((value: IFSValue) => {
85
85
  if (value.enabled) {
86
86
  if (filter.column.type === COLUMN.IMAGE) {
87
- return value.valueid;
87
+ return value.valueid || value.imageUrl || value.value;
88
88
  } else {
89
89
  return value.value;
90
90
  }
@@ -4,6 +4,6 @@
4
4
  export interface IFSValue {
5
5
  enabled?: boolean; // True: the value is enabled; False: the value is disabled
6
6
  imageUrl?: string; // URL for a image. This is common for images column type.
7
- value: string; // The value to filter
7
+ value?: string; // The value to filter
8
8
  valueid?: string; // Mostly for webform columns that need an ID. Alias for answerid in the model object.
9
9
  }
@@ -4,6 +4,6 @@
4
4
  export interface IFUValue {
5
5
  enabled?: boolean; // Optional flag to enabled the value
6
6
  imageUrl?: string; // URL from Image type
7
- value: string; // A string value
7
+ value?: string; // A string value
8
8
  valueid?: string; // For values that need a value ID or answer ID
9
9
  }
@@ -1,5 +1,3 @@
1
-
2
-
3
1
  import { isNumericalColumn } from "../../columns/helpers/isNumericalColumn";
4
2
  import { isDateColumn } from "../../columns/helpers/isDateColumn";
5
3
  import { getAggFilters } from "../helpers/OLD_getAggFilters";
@@ -31,7 +29,7 @@ export default class UChartPaginationApi {
31
29
 
32
30
  /**
33
31
  * Gets afterKey object
34
- * @returns
32
+ * @returns the afterKey object
35
33
  */
36
34
  getAfterKey = (): any => {
37
35
  return this.afterKey;
@@ -127,7 +125,7 @@ export default class UChartPaginationApi {
127
125
  /**
128
126
  * Get a dimension body structure foor pagination endpoint
129
127
  * @param dimensions
130
- * @returns
128
+ * @returns the dimension body structure
131
129
  */
132
130
  private _getDimensionsBodyAdapter = (dimensions = []) => {
133
131
  return dimensions.map(dimension => ({
@@ -23,7 +23,8 @@ function isValidDateString(dateString = '') {
23
23
  export function formatDate(dateString, format) {
24
24
  if (isEmpty(dateString) || !isNaN(dateString) || format === 'Default') return dateString;
25
25
  if (!isValidDateString(dateString)) return dateString;
26
- return dayjs(dateString.split('.')[0]).format(format.replace('HH24:', 'HH:').replace('MI:SS', 'mm:ss').replace('MM:SS', 'mm:ss'));
26
+ const dateValue = dateString?.replace(/Z$/i, '');
27
+ return dayjs(dateValue.split('.')[0]).format(format.replace('HH24:', 'HH:').replace('MI:SS', 'mm:ss').replace('MM:SS', 'mm:ss'));
27
28
  }
28
29
 
29
30
  export function formatAbbreviated(num, decimals) {
@@ -89,7 +90,7 @@ export const addFormat = (value: any, outputFormat: any = 'None', config?: IForm
89
90
  switch (outputFormat.type) {
90
91
  case 'DATE':
91
92
  case 'DATETIME':
92
- return config?.lang && outputFormat.format === 'Default' ? formatWithLocale(value, outputFormat, config) : formatDate(value, outputFormat.format);
93
+ return config?.lang && outputFormat.format === 'Default' ? formatWithLocale(value, outputFormat, config) : formatDate(value, outputFormat?.format === 'Default' && outputFormat?.originalFormat?.format ? outputFormat?.originalFormat?.format : outputFormat?.format);
93
94
  case 'NUMERIC': {
94
95
  const parse = parseFloat(value);
95
96
  const withLocale = outputFormat !== 'None' && config?.lang;
@@ -29,7 +29,7 @@ export const formatWithLocale = (value: any, outputFormat: IFormatOutputFormat,
29
29
 
30
30
  function formatLocaleDate(value: any, outputFormat: IFormatOutputFormat, config: IFormatConfig) {
31
31
  const { lang = LANG_DEFAULT, options } = config;
32
- const dateValue = value?.replace('.000Z', '');
32
+ const dateValue = value?.replace(/Z$/i, '');
33
33
  const dateParam = new Date(dateValue);
34
34
  let langOpts = options;
35
35
  if (outputFormat?.originalFormat) {
@@ -4,6 +4,7 @@ import { IDateColumnPropertyType } from "../../columns/interfaces/IDateColumnPro
4
4
  import { DATE_GROUPING_PROPERTY } from "../../dates/constants/DATE_GROUPING_PROPERTY";
5
5
  import { DATE_GROUPING_TIME_PROPERTY } from "../../dates/constants/DATE_GROUPING_TIME_PROPERTY";
6
6
  import { addFormat } from "../../format/format";
7
+ import { isEmpty } from "../../general/mix/isEmpty";
7
8
  import { getI18nDateGroupLabel } from "../../globalization/helpers/getI18nDateGroupLabel";
8
9
  import { ITransformValueSettings } from "../interfaces/ITransformValueSettings";
9
10
  import { getValueWithSuffixes } from "./getValueWithSuffixes";
@@ -15,6 +16,8 @@ import { getValueWithSuffixes } from "./getValueWithSuffixes";
15
16
  * @returns A transformed value
16
17
  */
17
18
  export function transformValue(value: string, settings: ITransformValueSettings): string {
19
+ if (isEmpty(value)) return value;
20
+
18
21
  const valueWithI18n = getI18nDateGroupLabel(value, settings.property as IDateColumnPropertyType, settings.translate);
19
22
 
20
23
  const valueWithLocalization = addFormat(valueWithI18n, getOutputFormat(settings), getFormatConfig(settings));
@@ -4,9 +4,9 @@ import { IModelBranchesMap } from "../../qrvey/interfaces/IModelBranchesMap";
4
4
  import { BColumnsToUIColumns } from "./BColumnsToUIColumns.adapter";
5
5
 
6
6
  /**
7
- *
8
- * @param branchesMap
9
- * @returns
7
+ * Adapts the branches map from backend to the UI branches map
8
+ * @param branchesMap the backend branches map
9
+ * @returns The Branches map array
10
10
  */
11
11
  export function BBranchesMapToUIBranchesMap(branchesMap: IBModelBranchesMap[]): IModelBranchesMap[] {
12
12
  if (isEmpty(branchesMap)) return [];