@irontec/ivoz-ui 1.6.0 → 1.6.2

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.
@@ -69,7 +69,7 @@ const FastSearchField = (props, ref) => {
69
69
  };
70
70
  useEffect(() => {
71
71
  //reset value
72
- setValue((firstColumnCriteria === null || firstColumnCriteria === void 0 ? void 0 : firstColumnCriteria.value) || '');
72
+ setValue(decodeURIComponent(firstColumnCriteria === null || firstColumnCriteria === void 0 ? void 0 : firstColumnCriteria.value) || '');
73
73
  }, [firstColumnCriteria]);
74
74
  useEffect(() => {
75
75
  if (isDatetime) {
@@ -45,7 +45,7 @@ export default function ContentFilterSelector(props) {
45
45
  newCriteria[idx] = {
46
46
  name,
47
47
  type,
48
- value,
48
+ value: decodeURIComponent(value),
49
49
  };
50
50
  setCriteria(newCriteria);
51
51
  };
@@ -23,7 +23,7 @@ import useFirstColumn from './Content/hook/useFirstColumn';
23
23
  import { criteriaToArray, queryStringToCriteria } from './List.helpers';
24
24
  import useQueryStringParams from './useQueryStringParams';
25
25
  const List = function (props) {
26
- const { path, foreignKeyResolver, entityService, routeMap, className, List: EntityListDecorator } = props;
26
+ const { path, foreignKeyResolver, entityService, routeMap, className, List: EntityListDecorator, } = props;
27
27
  const location = useLocation();
28
28
  const match = useCurrentPathMatch();
29
29
  const params = useParams();
@@ -99,7 +99,10 @@ const List = function (props) {
99
99
  }
100
100
  setPrevReqQuerystring(reqQuerystring);
101
101
  const criteria = queryStringToCriteria();
102
- setQueryStringCriteria(criteria);
102
+ const sanitizeData = criteria.map((row) => {
103
+ return Object.assign(Object.assign({}, row), { value: encodeURIComponent(row.value) });
104
+ });
105
+ setQueryStringCriteria(sanitizeData);
103
106
  setCriteriaIsReady(true);
104
107
  }, [
105
108
  reqQuerystring,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@irontec/ivoz-ui",
3
- "version": "1.6.0",
3
+ "version": "1.6.2",
4
4
  "description": "UI library used in ivozprovider",
5
5
  "license": "GPL-3.0",
6
6
  "main": "index.js",
@@ -5,9 +5,9 @@ import { useCallback, useEffect, useState, } from 'react';
5
5
  import { getI18n } from 'react-i18next';
6
6
  import { StyledAutocompleteTextField } from '../TextField';
7
7
  const Autocomplete = (props) => {
8
- var _a;
8
+ var _a, _b;
9
9
  const { name, label, required, multiple, disabled, onChange, onBlur, choices, error, errorMsg, helperText, hasChanged, } = props;
10
- const value = props.value || null;
10
+ const value = (_a = props.value) !== null && _a !== void 0 ? _a : null;
11
11
  const i18n = getI18n();
12
12
  let className = props.className;
13
13
  if (hasChanged) {
@@ -84,13 +84,35 @@ const Autocomplete = (props) => {
84
84
  ? false
85
85
  : true;
86
86
  }
87
+ const autoDefaultValue = (value) => {
88
+ if (value !== '__auto__') {
89
+ return value;
90
+ }
91
+ if (arrayChoices.length === 0) {
92
+ return value;
93
+ }
94
+ const realChoices = arrayChoices.filter((dac) => dac.id != '__null__');
95
+ if (realChoices.length != 1) {
96
+ return '__null__';
97
+ }
98
+ return realChoices[0].id;
99
+ };
87
100
  let autocompleteValue;
88
101
  if (multiple) {
89
102
  autocompleteValue = arrayChoices.length ? value : [];
90
103
  }
91
104
  else {
105
+ const autoValue = autoDefaultValue(value);
92
106
  autocompleteValue =
93
- (_a = arrayChoices === null || arrayChoices === void 0 ? void 0 : arrayChoices.find((item) => `${item.id}` === `${value}`)) !== null && _a !== void 0 ? _a : null;
107
+ (_b = arrayChoices === null || arrayChoices === void 0 ? void 0 : arrayChoices.find((item) => `${item.id}` === `${autoValue}`)) !== null && _b !== void 0 ? _b : null;
108
+ if (autoValue != value) {
109
+ onChange({
110
+ target: {
111
+ name: name,
112
+ value: autoValue,
113
+ },
114
+ });
115
+ }
94
116
  }
95
117
  return (_jsx(MuiAutocomplete, { className: 'autocomplete ' + className, value: autocompleteValue, multiple: multiple, disabled: disabled, disableClearable: disableClearable, onChange: onChangeWrapper, onBlur: onBlur, options: arrayChoices, getOptionLabel: getOptionLabel, isOptionEqualToValue: isOptionEqualToValue, filterSelectedOptions: true, renderInput: renderInput, renderOption: (props, option) => (_jsx(Box, Object.assign({ component: 'li', className: 'autocomplete-option', "data-value": option.id }, props, { children: option.label }))) }));
96
118
  };