@centreon/ui 24.11.25 → 24.12.1

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@centreon/ui",
3
- "version": "24.11.25",
3
+ "version": "24.12.1",
4
4
  "description": "Centreon UI Components",
5
5
  "scripts": {
6
6
  "update:deps": "pnpx npm-check-updates -i --format group",
@@ -95,8 +95,8 @@ describe(SingleConnectedAutocompleteField, () => {
95
95
  });
96
96
 
97
97
  await waitFor(() => {
98
- expect(getFetchCall(2)).toEqual(
99
- `${baseEndpoint}?page=1&search=%7B%22%24and%22%3A%5B%7B%22%24or%22%3A%5B%7B%22host.name%22%3A%7B%22%24lk%22%3A%22%25My%20Option%202%25%22%7D%7D%5D%7D%5D%7D`
98
+ expect(decodeURIComponent(getFetchCall(2))).toEqual(
99
+ 'endpoint?page=1&search={"$and":[{"$and":[{"host.name":{"$lk":"%My Option 2%"}}]}]}'
100
100
  );
101
101
  });
102
102
  });
@@ -34,7 +34,7 @@ export interface ConnectedAutoCompleteFieldProps<TData> {
34
34
  allowUniqOption?: boolean;
35
35
  baseEndpoint?: string;
36
36
  changeIdValue: (item: TData) => number | string;
37
- conditionField?: keyof SelectEntry;
37
+ exclusionOptionProperty?: keyof SelectEntry;
38
38
  field: string;
39
39
  getEndpoint: ({ search, page }) => string;
40
40
  getRenderedOptionText: (option: TData) => string;
@@ -55,7 +55,7 @@ const ConnectedAutocompleteField = (
55
55
  field,
56
56
  labelKey,
57
57
  open,
58
- conditionField = 'name',
58
+ exclusionOptionProperty = 'id',
59
59
  searchConditions = [],
60
60
  getRenderedOptionText = (option): string => option.name?.toString(),
61
61
  getRequestHeaders,
@@ -106,7 +106,7 @@ const ConnectedAutocompleteField = (
106
106
  ],
107
107
  isPaginated: true,
108
108
  queryOptions: {
109
- cacheTime: 0,
109
+ gcTime: 0,
110
110
  enabled: false,
111
111
  staleTime: 0,
112
112
  suspense: false
@@ -134,10 +134,11 @@ const ConnectedAutocompleteField = (
134
134
  : [selectedValue];
135
135
 
136
136
  return {
137
- field: conditionField,
137
+ operator: '$and',
138
+ field,
138
139
  values: {
139
140
  $ni: map(
140
- prop(conditionField),
141
+ prop(exclusionOptionProperty),
141
142
  selectedValues as Array<
142
143
  Record<keyof SelectEntry, string | undefined>
143
144
  >
@@ -154,6 +155,7 @@ const ConnectedAutocompleteField = (
154
155
  }
155
156
 
156
157
  return {
158
+ operator: '$and',
157
159
  field,
158
160
  values: {
159
161
  $lk: `%${searchedValue}%`
@@ -322,12 +324,13 @@ const ConnectedAutocompleteField = (
322
324
  <AutocompleteField
323
325
  filterOptions={(opt): SelectEntry => opt}
324
326
  loading={isFetching}
325
- open={optionsOpen}
326
327
  options={
327
328
  allowUniqOption ? uniqBy(getRenderedOptionText, options) : options
328
329
  }
329
330
  renderOption={renderOptions}
330
- onChange={(_, value) => setAutocompleteChangedValue(value)}
331
+ onChange={(_, value) => {
332
+ setAutocompleteChangedValue(value);
333
+ }}
331
334
  onClose={(): void => setOptionsOpen(false)}
332
335
  onOpen={(): void => setOptionsOpen(true)}
333
336
  onTextChange={changeText}
@@ -93,8 +93,14 @@ const getConditionsSearchQueryParameterValue = (
93
93
  equals(listField, field)
94
94
  );
95
95
 
96
+ const globalOperator = filteredItems.every(({ operator }) =>
97
+ equals(operator, filteredItems[0].operator)
98
+ )
99
+ ? filteredItems[0].operator || '$or'
100
+ : '$or';
101
+
96
102
  return {
97
- $or: flatten(
103
+ [globalOperator]: flatten(
98
104
  filteredItems.map(({ value, values }) => {
99
105
  if (!isNil(value)) {
100
106
  return [
@@ -63,6 +63,7 @@ export interface ConditionsSearchParameter {
63
63
  field: string;
64
64
  value?: unknown;
65
65
  values?: ConditionValue;
66
+ operator?: '$and' | '$or';
66
67
  }
67
68
 
68
69
  type SearchPatterns = Array<{ [field: string]: { $rg: string } }>;