@qrvey/utils 1.2.10-4 → 1.2.10-7

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 (55) hide show
  1. package/README.md +1 -1
  2. package/bitbucket-pipelines.yml +1 -1
  3. package/dist/cjs/filters/adapters/adaptFilterValues.js +1 -1
  4. package/dist/cjs/filters/adapters/flatUIToFD.js +4 -0
  5. package/dist/cjs/filters/adapters/flatUIToOldLogic.js +1 -1
  6. package/dist/cjs/filters/adapters/flatUIToUI.js +4 -0
  7. package/dist/cjs/filters/helpers/OLD_getAggFilters.d.ts +1 -1
  8. package/dist/cjs/filters/helpers/OLD_getAggFilters.js +1 -1
  9. package/dist/cjs/filters/helpers/backend/getBackendProperty.js +1 -1
  10. package/dist/cjs/filters/helpers/backend/getBackendValues.js +1 -1
  11. package/dist/cjs/filters/helpers/common/mergeFilters.js +36 -6
  12. package/dist/cjs/filters/interfaces/common/IFSValue.d.ts +1 -1
  13. package/dist/cjs/filters/interfaces/ui/IFUValue.d.ts +1 -1
  14. package/dist/cjs/filters/services/UChartPaginationApi.d.ts +2 -2
  15. package/dist/cjs/filters/services/UChartPaginationApi.js +2 -2
  16. package/dist/cjs/format/format.js +4 -2
  17. package/dist/cjs/format/localization.js +1 -1
  18. package/dist/cjs/qrvey/helpers/transformValue.js +3 -0
  19. package/dist/cjs/services/adapters/BBranchesMapToUIBranchesMap.adapter.d.ts +3 -3
  20. package/dist/cjs/services/adapters/BBranchesMapToUIBranchesMap.adapter.js +3 -3
  21. package/dist/filters/adapters/adaptFilterValues.js +1 -1
  22. package/dist/filters/adapters/flatUIToFD.js +4 -0
  23. package/dist/filters/adapters/flatUIToOldLogic.js +1 -1
  24. package/dist/filters/adapters/flatUIToUI.js +4 -0
  25. package/dist/filters/helpers/OLD_getAggFilters.d.ts +1 -1
  26. package/dist/filters/helpers/OLD_getAggFilters.js +1 -1
  27. package/dist/filters/helpers/backend/getBackendProperty.js +1 -1
  28. package/dist/filters/helpers/backend/getBackendValues.js +1 -1
  29. package/dist/filters/helpers/common/mergeFilters.js +36 -6
  30. package/dist/filters/interfaces/common/IFSValue.d.ts +1 -1
  31. package/dist/filters/interfaces/ui/IFUValue.d.ts +1 -1
  32. package/dist/filters/services/UChartPaginationApi.d.ts +2 -2
  33. package/dist/filters/services/UChartPaginationApi.js +2 -2
  34. package/dist/format/format.js +4 -2
  35. package/dist/format/localization.js +1 -1
  36. package/dist/qrvey/helpers/transformValue.js +3 -0
  37. package/dist/services/adapters/BBranchesMapToUIBranchesMap.adapter.d.ts +3 -3
  38. package/dist/services/adapters/BBranchesMapToUIBranchesMap.adapter.js +3 -3
  39. package/package.json +6 -5
  40. package/publishing.js +56 -50
  41. package/src/filters/adapters/adaptFilterValues.ts +1 -1
  42. package/src/filters/adapters/flatUIToFD.ts +5 -0
  43. package/src/filters/adapters/flatUIToOldLogic.ts +1 -1
  44. package/src/filters/adapters/flatUIToUI.ts +5 -0
  45. package/src/filters/helpers/OLD_getAggFilters.ts +1 -1
  46. package/src/filters/helpers/backend/getBackendProperty.ts +2 -1
  47. package/src/filters/helpers/backend/getBackendValues.ts +1 -1
  48. package/src/filters/helpers/common/mergeFilters.ts +34 -8
  49. package/src/filters/interfaces/common/IFSValue.ts +1 -1
  50. package/src/filters/interfaces/ui/IFUValue.ts +1 -1
  51. package/src/filters/services/UChartPaginationApi.ts +2 -4
  52. package/src/format/format.ts +3 -2
  53. package/src/format/localization.ts +1 -1
  54. package/src/qrvey/helpers/transformValue.ts +3 -0
  55. 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-6*
2
2
 
3
3
  > Helper, Utils for all Qrvey Projects
4
4
 
@@ -1,4 +1,4 @@
1
- image: node:14.17.3
1
+ image: node:16.14.1
2
2
 
3
3
  pipelines:
4
4
  default:
@@ -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;
@@ -115,8 +115,9 @@ function mergeFilterss(filters1 = [], filters2 = [], settings) {
115
115
  * @returns a new filter structure with overwritted props
116
116
  */
117
117
  function mergeFilterProps(filter1, filter2, settings) {
118
+ var _a, _b, _c;
118
119
  if (settings.overwriteFilterProps) {
119
- filter1 = Object.assign(Object.assign({}, filter1), { extras: filter2.extras, enabled: filter2.enabled || filter1.enabled, filterid: filter2.filterid, lookupDisplayIndex: filter2.lookupDisplayIndex, nullValues: filter2.nullValues, selectAll: filter2.selectAll });
120
+ filter1 = Object.assign(Object.assign({}, filter1), { collapsed: (_a = filter2.collapsed) !== null && _a !== void 0 ? _a : filter1.collapsed, displayed: (_b = filter2.displayed) !== null && _b !== void 0 ? _b : filter1.displayed, dateSection: filter2.dateSection, extras: filter2.extras, enabled: (_c = filter2.enabled) !== null && _c !== void 0 ? _c : filter1.enabled, filterid: filter2.filterid, lookupDisplayIndex: filter2.lookupDisplayIndex, nullValues: filter2.nullValues, selectAll: filter2.selectAll });
120
121
  }
121
122
  return filter1;
122
123
  }
@@ -133,31 +134,64 @@ function mergeValues(filter1, filter2, settings) {
133
134
  let newValues = [];
134
135
  let filter1Values = filter1.values || [];
135
136
  const filter2Values = filter2.values || [];
136
- if (!settings.overwriteValues) {
137
+ if (settings.overwriteValues) {
138
+ filter1Values = filter2Values;
139
+ newValues = filter1Values;
140
+ }
141
+ else {
137
142
  if ((0, isInValidator_1.isInValidator)(filter1.validator)) {
138
143
  newValues = filter2Values.reduce((values, value2) => {
144
+ var _a;
139
145
  const value1Index = filter1Values.findIndex(value1 => value2.anchor === value1.anchor && value2.cursor === value1.cursor && value2.includeCurrent === value1.includeCurrent && value2.isCalendarDate === value1.isCalendarDate && value2.number === value1.number && value2.unit === value1.unit);
140
146
  if (value1Index === -1) {
141
147
  values.push(value2);
142
148
  }
149
+ else {
150
+ values[value1Index] = {
151
+ anchor: value2.anchor,
152
+ cursor: value2.cursor,
153
+ enabled: (_a = value2.enabled) !== null && _a !== void 0 ? _a : values[value1Index].enabled,
154
+ includeCurrent: value2.includeCurrent,
155
+ isCalendarDate: value2.isCalendarDate,
156
+ number: value2.number,
157
+ unit: value2.unit,
158
+ };
159
+ }
143
160
  return values;
144
161
  }, filter1Values);
145
162
  }
146
163
  else if ((0, isRangeValidator_1.isRangeValidator)(filter1.validator)) {
147
164
  newValues = filter2Values.reduce((values, value2) => {
165
+ var _a;
148
166
  const value1Index = filter1Values.findIndex(value1 => value2.max === value1.max && value2.min === value1.min);
149
167
  if (value1Index === -1) {
150
168
  values.push(value2);
151
169
  }
170
+ else {
171
+ values[value1Index] = {
172
+ enabled: (_a = value2.enabled) !== null && _a !== void 0 ? _a : values[value1Index].enabled,
173
+ max: value2.max,
174
+ min: value2.min,
175
+ };
176
+ }
152
177
  return values;
153
178
  }, filter1Values);
154
179
  }
155
180
  else if ((0, isRegularValidator_1.isRegularValidator)(filter1.validator) || (0, isNullValidator_1.isNullValidator)(filter1.validator)) {
156
181
  newValues = filter2Values.reduce((values, value2) => {
182
+ var _a;
157
183
  const value1Index = filter1Values.findIndex(value1 => value2.imageUrl === value1.imageUrl && value2.value === value1.value);
158
184
  if (value1Index === -1) {
159
185
  values.push(value2);
160
186
  }
187
+ else {
188
+ values[value1Index] = {
189
+ enabled: (_a = value2.enabled) !== null && _a !== void 0 ? _a : values[value1Index].enabled,
190
+ imageUrl: value2.imageUrl,
191
+ value: value2.value,
192
+ valueid: value2.valueid,
193
+ };
194
+ }
161
195
  return values;
162
196
  }, filter1Values);
163
197
  }
@@ -166,9 +200,5 @@ function mergeValues(filter1, filter2, settings) {
166
200
  newValues = filter1Values;
167
201
  }
168
202
  }
169
- else {
170
- filter1Values = filter2Values;
171
- newValues = filter1Values;
172
- }
173
203
  return newValues;
174
204
  }
@@ -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;
@@ -111,8 +111,9 @@ function mergeFilterss(filters1 = [], filters2 = [], settings) {
111
111
  * @returns a new filter structure with overwritted props
112
112
  */
113
113
  function mergeFilterProps(filter1, filter2, settings) {
114
+ var _a, _b, _c;
114
115
  if (settings.overwriteFilterProps) {
115
- filter1 = Object.assign(Object.assign({}, filter1), { extras: filter2.extras, enabled: filter2.enabled || filter1.enabled, filterid: filter2.filterid, lookupDisplayIndex: filter2.lookupDisplayIndex, nullValues: filter2.nullValues, selectAll: filter2.selectAll });
116
+ filter1 = Object.assign(Object.assign({}, filter1), { collapsed: (_a = filter2.collapsed) !== null && _a !== void 0 ? _a : filter1.collapsed, displayed: (_b = filter2.displayed) !== null && _b !== void 0 ? _b : filter1.displayed, dateSection: filter2.dateSection, extras: filter2.extras, enabled: (_c = filter2.enabled) !== null && _c !== void 0 ? _c : filter1.enabled, filterid: filter2.filterid, lookupDisplayIndex: filter2.lookupDisplayIndex, nullValues: filter2.nullValues, selectAll: filter2.selectAll });
116
117
  }
117
118
  return filter1;
118
119
  }
@@ -129,31 +130,64 @@ function mergeValues(filter1, filter2, settings) {
129
130
  let newValues = [];
130
131
  let filter1Values = filter1.values || [];
131
132
  const filter2Values = filter2.values || [];
132
- if (!settings.overwriteValues) {
133
+ if (settings.overwriteValues) {
134
+ filter1Values = filter2Values;
135
+ newValues = filter1Values;
136
+ }
137
+ else {
133
138
  if (isInValidator(filter1.validator)) {
134
139
  newValues = filter2Values.reduce((values, value2) => {
140
+ var _a;
135
141
  const value1Index = filter1Values.findIndex(value1 => value2.anchor === value1.anchor && value2.cursor === value1.cursor && value2.includeCurrent === value1.includeCurrent && value2.isCalendarDate === value1.isCalendarDate && value2.number === value1.number && value2.unit === value1.unit);
136
142
  if (value1Index === -1) {
137
143
  values.push(value2);
138
144
  }
145
+ else {
146
+ values[value1Index] = {
147
+ anchor: value2.anchor,
148
+ cursor: value2.cursor,
149
+ enabled: (_a = value2.enabled) !== null && _a !== void 0 ? _a : values[value1Index].enabled,
150
+ includeCurrent: value2.includeCurrent,
151
+ isCalendarDate: value2.isCalendarDate,
152
+ number: value2.number,
153
+ unit: value2.unit,
154
+ };
155
+ }
139
156
  return values;
140
157
  }, filter1Values);
141
158
  }
142
159
  else if (isRangeValidator(filter1.validator)) {
143
160
  newValues = filter2Values.reduce((values, value2) => {
161
+ var _a;
144
162
  const value1Index = filter1Values.findIndex(value1 => value2.max === value1.max && value2.min === value1.min);
145
163
  if (value1Index === -1) {
146
164
  values.push(value2);
147
165
  }
166
+ else {
167
+ values[value1Index] = {
168
+ enabled: (_a = value2.enabled) !== null && _a !== void 0 ? _a : values[value1Index].enabled,
169
+ max: value2.max,
170
+ min: value2.min,
171
+ };
172
+ }
148
173
  return values;
149
174
  }, filter1Values);
150
175
  }
151
176
  else if (isRegularValidator(filter1.validator) || isNullValidator(filter1.validator)) {
152
177
  newValues = filter2Values.reduce((values, value2) => {
178
+ var _a;
153
179
  const value1Index = filter1Values.findIndex(value1 => value2.imageUrl === value1.imageUrl && value2.value === value1.value);
154
180
  if (value1Index === -1) {
155
181
  values.push(value2);
156
182
  }
183
+ else {
184
+ values[value1Index] = {
185
+ enabled: (_a = value2.enabled) !== null && _a !== void 0 ? _a : values[value1Index].enabled,
186
+ imageUrl: value2.imageUrl,
187
+ value: value2.value,
188
+ valueid: value2.valueid,
189
+ };
190
+ }
157
191
  return values;
158
192
  }, filter1Values);
159
193
  }
@@ -162,9 +196,5 @@ function mergeValues(filter1, filter2, settings) {
162
196
  newValues = filter1Values;
163
197
  }
164
198
  }
165
- else {
166
- filter1Values = filter2Values;
167
- newValues = filter1Values;
168
- }
169
199
  return newValues;
170
200
  }
@@ -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-4",
3
+ "version": "1.2.10-7",
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');
@@ -17,7 +22,6 @@ const question = util.promisify(rl.question).bind(rl);
17
22
  async function execute(command) {
18
23
  console.log(command);
19
24
  const response = await exec(command);
20
- console.log('response', response);
21
25
  if (response.error != null) {
22
26
  throw new Error(response.error);
23
27
  }
@@ -61,66 +65,57 @@ async function spawning(command, sArguments) {
61
65
  reject();
62
66
  }
63
67
  resolve();
64
-
65
68
  });
66
69
  });
67
70
  }
68
71
 
69
- async function openingPackageJson(settings) {
70
- console.log('>>> Opening package.json file...');
72
+ async function getPackageJson(settings) {
73
+ console.log('==>>> Opening package.json file...');
71
74
  const packageJson = await fs.readFileSync(settings.packagePath, 'utf8');
72
75
  const packageObject = JSON.parse(packageJson);
73
76
  if (packageObject != null) {
74
- console.log(`The current version is ${packageObject.version}`);
77
+ console.log(`**** The current version is ${packageObject.version}`);
75
78
  return packageObject.version;
76
79
  }
77
80
  return '';
78
81
  }
79
82
 
83
+ async function getNewVersion() {
84
+ console.log('==>>> Checking the new version provided...');
85
+ let newVersion;
86
+ const versionIndex = proc.argv.findIndex(function (argv) { return argv.includes('--np-new-version='); });
87
+ if (versionIndex > -1) {
88
+ const versionArg = proc.argv[versionIndex].split('--np-new-version=');
89
+ newVersion = versionArg[1] == null || versionArg[1] === '' ? undefined : versionArg[1];
90
+ }
91
+ if (newVersion == null) {
92
+ newVersion = question('No version provided. Type the new version: ');
93
+ }
94
+ console.log('**** Version to publish: ' + newVersion);
95
+ return newVersion;
96
+ }
97
+
80
98
  async function cleaningProject(settings) {
81
- console.log('>>> Cleaning project...');
99
+ console.log('==>>> Cleaning project...');
82
100
  await execute(`rm -f ${settings.packageLockPath}`);
83
101
  await execute(`rm -f -R ${settings.nodeModulesPath}`);
84
102
  await execute(`rm -f -R ${settings.distPath}`);
85
103
  }
86
104
 
87
105
  async function buildingBundle(_settings) {
88
- console.log('>>> Installing Dependencies...');
106
+ console.log('==>>> Installing Dependencies...');
89
107
  await execute('npm install');
90
108
 
91
- console.log('>>> Generating Build...');
109
+ console.log('==>>> Generating Build...');
92
110
  await execute('npm run build');
93
111
  }
94
112
 
95
- async function generatingDocument(settings) {
96
- console.log('>>> Generating Document...');
97
- await execute(`doxdox './dist/.+\\.js' --output ${settings.docsFileName} --ignore './dist/cjs/.+\\.js' --package ${settings.packagePath}`);
98
- }
99
-
100
- async function pushingChanges(settings) {
101
- console.log('>>> Commiting and Pushing Docs changes...');
102
-
103
- const gitStdout = await execute('git rev-parse --abbrev-ref HEAD');
104
- console.log('gitStdout', gitStdout);
105
- await execute(`git add ${settings.docsPath}`);
106
- await execute(`git commit -m "📝 docs: Updated docs${settings.packageVersion !== '' ? ' for ' + settings.packageVersion : ''}"`);
107
- await execute(`git push -u origin ${gitStdout}`);
108
- }
109
-
110
- async function revertChanges(settings) {
111
- console.log('>>> Checking for modifications...');
112
- console.warn(`>>> Unstaging posible changes from ${settings.docsFileName} file`);
113
- await execute(`git restore --staged ${settings.docsPath}`);
114
- console.warn(`>>> Discarting posible changes of ${settings.docsFileName} file`);
115
- await execute(`git checkout -- ${settings.docsPath}`);
116
- }
117
-
118
113
  async function startPublishingVersion(settings) {
119
114
  await callingPublisher(settings);
120
115
  }
121
116
 
122
117
  async function callingPublisher(settings) {
123
- console.log('>>> Calling Publisher');
118
+ console.log('==>>> Calling Publisher');
124
119
  let anyBranch = '', tag = '';
125
120
  const anyBranchIndex = proc.argv.findIndex(function (argv) { return argv.includes('--np-any-branch='); });
126
121
  const tagIndex = proc.argv.findIndex(function (argv) { return argv.includes('--np-tag='); });
@@ -132,49 +127,60 @@ async function callingPublisher(settings) {
132
127
  const tagArg = proc.argv[tagIndex].split('--np-tag=');
133
128
  tag = tagArg[1] == null || tagArg[1] === '' ? '' : proc.argv[tagIndex].replace('--np-tag=', '--tag=');
134
129
  }
135
- // await execute(`np ${settings.newVersion} ${anyBranch} ${tag}`);
136
130
  await spawning(`np ${settings.newVersion}`, [anyBranch, tag]);
137
131
  }
138
132
 
139
133
  async function startGeneratingDocs(settings) {
140
- console.log('>>> Starting of the Docs generation.');
134
+ console.log('==>>> Starting the Docs generation');
141
135
 
142
136
  await generatingDocument(settings);
143
137
  await pushingChanges(settings);
144
138
  }
145
139
 
146
- async function getNewVersion() {
147
- let newVersion;
148
- const versionIndex = proc.argv.findIndex(function (argv) { return argv.includes('--np-new-version='); });
149
- if (versionIndex > -1) {
150
- const versionArg = proc.argv[versionIndex].split('--np-new-version=');
151
- newVersion = versionArg[1] == null || versionArg[1] === '' ? undefined : versionArg[1];
152
- }
153
- if (newVersion == null) {
154
- newVersion = question('No version provided. Type the new version: ');
155
- }
156
- return newVersion;
140
+ async function generatingDocument(settings) {
141
+ console.log('==>>> Generating Document...');
142
+ await execute(`doxdox './dist/.+\\.js' --output ${settings.docsFileName} --ignore './dist/cjs/.+\\.js' --package ${settings.packagePath}`);
143
+ }
144
+
145
+ async function pushingChanges(settings) {
146
+ console.log('==>>> Commiting and Pushing Docs changes...');
147
+
148
+ const gitStdout = await execute('git rev-parse --abbrev-ref HEAD');
149
+ console.log('gitStdout', gitStdout);
150
+ await execute(`git add ${settings.docsPath}`);
151
+ await execute(`git commit -m "📝 docs: Updated docs${settings.newVersion != null || settings.newVersion !== '' ? ' for ' + settings.newVersion : ''}"`);
152
+ await execute(`git push -u origin ${gitStdout.stdout}`);
153
+ }
154
+
155
+ async function revertChanges(settings) {
156
+ console.log('>>> Checking for modifications...');
157
+ console.warn(`>>> Unstaging posible changes from ${settings.docsFileName} and ${settings.packageFileName} file`);
158
+ await execute(`git restore --staged ${settings.docsPath} ${settings.packagePath}`);
159
+ console.warn(`>>> Discarting posible changes of ${settings.docsFileName} and ${settings.packageFileName} file`);
160
+ await execute(`git checkout -- ${settings.docsPath} ${settings.packagePath}`);
157
161
  }
158
162
 
159
163
  async function init() {
160
164
  let settings = {
165
+ currentVersion: '',
161
166
  distPath: './dist',
162
167
  docsPath: './README.md',
163
168
  docsFileName: 'README.md',
164
169
  newVersion: undefined,
165
170
  nodeModulesPath: './node_modules',
171
+ packageFileName: 'package.json',
166
172
  packageLockPath: './package-lock.json',
167
173
  packagePath: './package.json',
168
- packageVersion: '',
174
+
169
175
  };
170
176
 
171
177
  console.log('Welcome. The publishing operationg will begin.');
172
178
  try {
173
- settings["packageVersion"] = await openingPackageJson(settings);
179
+ settings["currentVersion"] = await getPackageJson(settings);
174
180
  settings["newVersion"] = await getNewVersion();
175
181
 
176
- // await cleaningProject(settings);
177
- // await buildingBundle(settings);
182
+ await cleaningProject(settings);
183
+ await buildingBundle(settings);
178
184
  await startPublishingVersion(settings);
179
185
  await startGeneratingDocs(settings);
180
186
  console.info('Finished Publishing');
@@ -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
  }
@@ -134,8 +134,11 @@ function mergeFilterProps(filter1: IFSFilter, filter2: IFSFilter, settings?: IFF
134
134
  if (settings.overwriteFilterProps) {
135
135
  filter1 = {
136
136
  ...filter1,
137
+ collapsed: filter2.collapsed ?? filter1.collapsed,
138
+ displayed: filter2.displayed ?? filter1.displayed,
139
+ dateSection: filter2.dateSection,
137
140
  extras: filter2.extras,
138
- enabled: filter2.enabled || filter1.enabled,
141
+ enabled: filter2.enabled ?? filter1.enabled,
139
142
  filterid: filter2.filterid,
140
143
  lookupDisplayIndex: filter2.lookupDisplayIndex,
141
144
  nullValues: filter2.nullValues,
@@ -158,28 +161,54 @@ function mergeValues(filter1: IFSFilter, filter2: IFSFilter, settings?: IFFilter
158
161
  let newValues = [];
159
162
  let filter1Values = filter1.values || [];
160
163
  const filter2Values = filter2.values || [];
161
- if (!settings.overwriteValues) {
164
+ if (settings.overwriteValues) {
165
+ filter1Values = filter2Values;
166
+ newValues = filter1Values;
167
+ } else {
162
168
  if (isInValidator(filter1.validator)) {
163
- newValues = filter2Values.reduce((values: IFValue[], value2: IFSValueRelativeDate) => {
169
+ newValues = filter2Values.reduce((values: IFSValueRelativeDate[], value2: IFSValueRelativeDate) => {
164
170
  const value1Index = (filter1Values as IFSValueRelativeDate[]).findIndex(value1 => value2.anchor === value1.anchor && value2.cursor === value1.cursor && value2.includeCurrent === value1.includeCurrent && value2.isCalendarDate === value1.isCalendarDate && value2.number === value1.number && value2.unit === value1.unit);
165
171
  if (value1Index === -1) {
166
172
  values.push(value2);
173
+ } else {
174
+ values[value1Index] = {
175
+ anchor: value2.anchor,
176
+ cursor: value2.cursor,
177
+ enabled: value2.enabled ?? values[value1Index].enabled,
178
+ includeCurrent: value2.includeCurrent,
179
+ isCalendarDate: value2.isCalendarDate,
180
+ number: value2.number,
181
+ unit: value2.unit,
182
+ };
167
183
  }
168
184
  return values;
169
185
  }, filter1Values as IFValue[]);
170
186
  } else if (isRangeValidator(filter1.validator)) {
171
- newValues = filter2Values.reduce((values: IFValue[], value2: IFSValueRange) => {
187
+ newValues = filter2Values.reduce((values: IFSValueRange[], value2: IFSValueRange) => {
172
188
  const value1Index = (filter1Values as IFSValueRange[]).findIndex(value1 => value2.max === value1.max && value2.min === value1.min);
173
189
  if (value1Index === -1) {
174
190
  values.push(value2);
191
+ } else {
192
+ values[value1Index] = {
193
+ enabled: value2.enabled ?? values[value1Index].enabled,
194
+ max: value2.max,
195
+ min: value2.min,
196
+ };
175
197
  }
176
198
  return values;
177
199
  }, filter1Values as IFValue[]);
178
200
  } else if (isRegularValidator(filter1.validator) || isNullValidator(filter1.validator)) {
179
- newValues = filter2Values.reduce((values: IFValue[], value2: IFSValue) => {
201
+ newValues = filter2Values.reduce((values: IFSValue[], value2: IFSValue) => {
180
202
  const value1Index = (filter1Values as IFSValue[]).findIndex(value1 => value2.imageUrl === value1.imageUrl && value2.value === value1.value);
181
203
  if (value1Index === -1) {
182
204
  values.push(value2);
205
+ } else {
206
+ values[value1Index] = {
207
+ enabled: value2.enabled ?? values[value1Index].enabled,
208
+ imageUrl: value2.imageUrl,
209
+ value: value2.value,
210
+ valueid: value2.valueid,
211
+ };
183
212
  }
184
213
  return values;
185
214
  }, filter1Values as IFValue[]);
@@ -187,9 +216,6 @@ function mergeValues(filter1: IFSFilter, filter2: IFSFilter, settings?: IFFilter
187
216
  filter1Values = filter1Values.concat(filter2Values);
188
217
  newValues = filter1Values;
189
218
  }
190
- } else {
191
- filter1Values = filter2Values;
192
- newValues = filter1Values;
193
219
  }
194
220
 
195
221
  return newValues;
@@ -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 [];