@qrvey/utils 1.4.5 → 1.4.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.
package/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # [@qrvey/utils](https://bitbucket.org/qrvey/qrvey_utils/wiki/Home) *1.4.5*
1
+ # [@qrvey/utils](https://bitbucket.org/qrvey/qrvey_utils/wiki/Home) *1.4.7*
2
2
 
3
3
  > Helper, Utils for all Qrvey Projects
4
4
 
@@ -2,6 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.excludeFiltersByParams = void 0;
4
4
  const isEmpty_1 = require("../../../general/mix/isEmpty");
5
+ const cloneDeep_1 = require("../../../general/object/cloneDeep");
5
6
  /**
6
7
  * Excludes filters from the given Filters.
7
8
  * The validation to filter the stored filter is depending on:
@@ -22,6 +23,7 @@ function excludeFiltersByParams(filterData, params) {
22
23
  return;
23
24
  if ((0, isEmpty_1.isEmpty)(params))
24
25
  return filterData;
26
+ filterData = (0, cloneDeep_1.cloneDeep)(filterData);
25
27
  filterData.scopes = filterData.scopes
26
28
  .map((scope) => {
27
29
  if (resolveScopeConditions(scope, params)) {
@@ -55,8 +57,7 @@ function excludeFiltersByParams(filterData, params) {
55
57
  .filter((filter) => {
56
58
  var _a;
57
59
  return !(0, isEmpty_1.isEmpty)(filter) &&
58
- filter.selectAll &&
59
- ((_a = filter.values) === null || _a === void 0 ? void 0 : _a.length) > 0;
60
+ (filter.selectAll || ((_a = filter.values) === null || _a === void 0 ? void 0 : _a.length) > 0);
60
61
  }) });
61
62
  }
62
63
  })
@@ -71,7 +72,7 @@ function resolveScopeConditions(scope, params) {
71
72
  return ((params.enableds == null || params.enableds !== scope.enabled) &&
72
73
  ((0, isEmpty_1.isEmpty)(params.scope) || scope.scope !== params.scope) &&
73
74
  ((0, isEmpty_1.isEmpty)(params.scopeid) || scope.scopeid !== params.scopeid) &&
74
- scope.datasets.filter.length > 0);
75
+ scope.datasets.length > 0);
75
76
  }
76
77
  function resolveDatasetConditions(dataset, params) {
77
78
  return ((params.enableds == null || params.enableds !== dataset.enabled) &&
@@ -25,6 +25,6 @@ function resolveScopeConditions(scope, params, letPassUndefinedProperties = fals
25
25
  (letPassUndefinedProperties && scope.scopeid == null) ||
26
26
  (letPassUndefinedParams && (0, isEmpty_1.isEmpty)(params.scopeid)) ||
27
27
  scope.scopeid === params.scopeid) &&
28
- scope.datasets.filter.length > 0);
28
+ scope.datasets.length > 0);
29
29
  }
30
30
  exports.resolveScopeConditions = resolveScopeConditions;
@@ -15,11 +15,14 @@ const localization_1 = require("../../format/localization");
15
15
  * @returns a promise
16
16
  */
17
17
  function getDatasetColumns(config, qrveyid) {
18
- const lang = (0, localization_1.chooseLang)(config);
18
+ const params = {};
19
+ const lang = (0, localization_1.chooseLang)(config).replace(/^en(\-US){0,1}$/, ""); // Performance: set to undefined when lang is 'es' or 'es-US'
20
+ if (lang)
21
+ params.lang = lang;
19
22
  return Request_1.default.post(Object.assign(Object.assign({}, config), { qrveyid, endpoint: CHART_ENDPOINT_1.CHART_ENDPOINT }), "/question/list", {
20
23
  optionsAttributes: (0, getDefaultQuestionListOptionsAttributes_1.getDefaultQuestionListOptionsAttributes)(),
21
24
  extend: true,
22
- }, { lang })
25
+ }, params)
23
26
  .then(BDatasetsToUIDatasets_adapter_1.BDatasetsToUIDatasets)
24
27
  .catch((_e) => []);
25
28
  }
@@ -17,11 +17,14 @@ const QUESTION_LIST_BULK_ENDPOINT_1 = require("../constants/QUESTION_LIST_BULK_E
17
17
  */
18
18
  function getDatasetsByIds(config, qrveyids = []) {
19
19
  if (Array.isArray(qrveyids) && !(0, isEmpty_1.isEmpty)(qrveyids)) {
20
- const lang = (0, localization_1.chooseLang)(config);
20
+ const params = {};
21
+ const lang = (0, localization_1.chooseLang)(config).replace(/^en(\-US){0,1}$/, ""); // Performance: set to undefined when lang is 'es' or 'es-US';
22
+ if (lang)
23
+ params.lang = lang;
21
24
  return Request_1.default.post(Object.assign(Object.assign({}, config), { endpoint: QUESTION_LIST_BULK_ENDPOINT_1.QUESTION_LIST_BULK_ENDPOINT }), "", {
22
25
  optionsAttributes: (0, getDefaultQuestionListOptionsAttributes_1.getDefaultQuestionListOptionsAttributes)(),
23
26
  qrveyids,
24
- }, { lang })
27
+ }, params)
25
28
  .then((response) => (0, BDatasetsToUIDatasets_adapter_1.BDatasetsToUIDatasets)((response === null || response === void 0 ? void 0 : response.data) || []))
26
29
  .catch((_e) => []);
27
30
  }
@@ -1,4 +1,5 @@
1
1
  import { isEmpty } from "../../../general/mix/isEmpty";
2
+ import { cloneDeep } from "../../../general/object/cloneDeep";
2
3
  /**
3
4
  * Excludes filters from the given Filters.
4
5
  * The validation to filter the stored filter is depending on:
@@ -19,6 +20,7 @@ export function excludeFiltersByParams(filterData, params) {
19
20
  return;
20
21
  if (isEmpty(params))
21
22
  return filterData;
23
+ filterData = cloneDeep(filterData);
22
24
  filterData.scopes = filterData.scopes
23
25
  .map((scope) => {
24
26
  if (resolveScopeConditions(scope, params)) {
@@ -52,8 +54,7 @@ export function excludeFiltersByParams(filterData, params) {
52
54
  .filter((filter) => {
53
55
  var _a;
54
56
  return !isEmpty(filter) &&
55
- filter.selectAll &&
56
- ((_a = filter.values) === null || _a === void 0 ? void 0 : _a.length) > 0;
57
+ (filter.selectAll || ((_a = filter.values) === null || _a === void 0 ? void 0 : _a.length) > 0);
57
58
  }) });
58
59
  }
59
60
  })
@@ -67,7 +68,7 @@ function resolveScopeConditions(scope, params) {
67
68
  return ((params.enableds == null || params.enableds !== scope.enabled) &&
68
69
  (isEmpty(params.scope) || scope.scope !== params.scope) &&
69
70
  (isEmpty(params.scopeid) || scope.scopeid !== params.scopeid) &&
70
- scope.datasets.filter.length > 0);
71
+ scope.datasets.length > 0);
71
72
  }
72
73
  function resolveDatasetConditions(dataset, params) {
73
74
  return ((params.enableds == null || params.enableds !== dataset.enabled) &&
@@ -22,5 +22,5 @@ export function resolveScopeConditions(scope, params, letPassUndefinedProperties
22
22
  (letPassUndefinedProperties && scope.scopeid == null) ||
23
23
  (letPassUndefinedParams && isEmpty(params.scopeid)) ||
24
24
  scope.scopeid === params.scopeid) &&
25
- scope.datasets.filter.length > 0);
25
+ scope.datasets.length > 0);
26
26
  }
@@ -9,11 +9,14 @@ import { chooseLang } from "../../format/localization";
9
9
  * @returns a promise
10
10
  */
11
11
  export function getDatasetColumns(config, qrveyid) {
12
- const lang = chooseLang(config);
12
+ const params = {};
13
+ const lang = chooseLang(config).replace(/^en(\-US){0,1}$/, ""); // Performance: set to undefined when lang is 'es' or 'es-US'
14
+ if (lang)
15
+ params.lang = lang;
13
16
  return Request.post(Object.assign(Object.assign({}, config), { qrveyid, endpoint: CHART_ENDPOINT }), "/question/list", {
14
17
  optionsAttributes: getDefaultQuestionListOptionsAttributes(),
15
18
  extend: true,
16
- }, { lang })
19
+ }, params)
17
20
  .then(BDatasetsToUIDatasets)
18
21
  .catch((_e) => []);
19
22
  }
@@ -11,11 +11,14 @@ import { QUESTION_LIST_BULK_ENDPOINT } from "../constants/QUESTION_LIST_BULK_END
11
11
  */
12
12
  export function getDatasetsByIds(config, qrveyids = []) {
13
13
  if (Array.isArray(qrveyids) && !isEmpty(qrveyids)) {
14
- const lang = chooseLang(config);
14
+ const params = {};
15
+ const lang = chooseLang(config).replace(/^en(\-US){0,1}$/, ""); // Performance: set to undefined when lang is 'es' or 'es-US';
16
+ if (lang)
17
+ params.lang = lang;
15
18
  return Request.post(Object.assign(Object.assign({}, config), { endpoint: QUESTION_LIST_BULK_ENDPOINT }), "", {
16
19
  optionsAttributes: getDefaultQuestionListOptionsAttributes(),
17
20
  qrveyids,
18
- }, { lang })
21
+ }, params)
19
22
  .then((response) => BDatasetsToUIDatasets((response === null || response === void 0 ? void 0 : response.data) || []))
20
23
  .catch((_e) => []);
21
24
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@qrvey/utils",
3
- "version": "1.4.5",
3
+ "version": "1.4.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",