@centreon/ui 26.11.7 → 26.11.8
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
|
@@ -45,14 +45,20 @@ const ConnectedAutocomplete = ({
|
|
|
45
45
|
const isMultiple = equals(type, InputType.MultiConnectedAutocomplete);
|
|
46
46
|
|
|
47
47
|
const getEndpoint = (parameters: GetEndpointParams): string => {
|
|
48
|
+
// Once a value is selected the field prepends a `$ni` condition excluding
|
|
49
|
+
// it, so the typed text is not necessarily the first condition -- and
|
|
50
|
+
// clearing the text leaves no `$lk` condition at all.
|
|
51
|
+
const searchedValue = parameters?.search?.conditions?.find(
|
|
52
|
+
(condition) => condition?.values?.$lk
|
|
53
|
+
)?.values?.$lk as string | undefined;
|
|
54
|
+
|
|
48
55
|
const nameQueryParameters =
|
|
49
|
-
connectedAutocomplete?.useNewAPIFormat &&
|
|
56
|
+
connectedAutocomplete?.useNewAPIFormat && searchedValue
|
|
50
57
|
? [
|
|
51
58
|
{
|
|
52
59
|
name: 'name[lk]',
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
).slice(1, -1)
|
|
60
|
+
// The field wraps the typed text in `%`.
|
|
61
|
+
value: searchedValue.slice(1, -1)
|
|
56
62
|
}
|
|
57
63
|
]
|
|
58
64
|
: [];
|
|
@@ -166,6 +172,7 @@ const ConnectedAutocomplete = ({
|
|
|
166
172
|
return useMemoComponent({
|
|
167
173
|
Component: (
|
|
168
174
|
<TypedAutocompleteField
|
|
175
|
+
baseEndpoint={connectedAutocomplete?.baseEndpoint}
|
|
169
176
|
chipProps={chipProps}
|
|
170
177
|
dataTestId={dataTestId}
|
|
171
178
|
decoder={connectedAutocomplete?.decoder}
|
|
@@ -187,6 +194,7 @@ const ConnectedAutocomplete = ({
|
|
|
187
194
|
onBlur={blur}
|
|
188
195
|
onChange={changeAutocomplete}
|
|
189
196
|
optionProperty={connectedAutocomplete?.optionProperty}
|
|
197
|
+
queryKey={connectedAutocomplete?.queryKey}
|
|
190
198
|
required={isRequired}
|
|
191
199
|
searchConditions={connectedAutocomplete?.additionalConditionParameters}
|
|
192
200
|
value={value ?? null}
|
|
@@ -88,6 +88,12 @@ export interface InputProps {
|
|
|
88
88
|
useNewAPIFormat?: boolean;
|
|
89
89
|
additionalConditionParameters: Array<ConditionsSearchParameter>;
|
|
90
90
|
customQueryParameters: Array<QueryParameter>;
|
|
91
|
+
// The API the options are read from. Left out, the request goes to the
|
|
92
|
+
// default `./api/latest` as it always has.
|
|
93
|
+
baseEndpoint?: string;
|
|
94
|
+
// What the options are cached under. Left out, the field's label is used,
|
|
95
|
+
// which two fields reading different endpoints can share.
|
|
96
|
+
queryKey?: string;
|
|
91
97
|
chipColor?: string;
|
|
92
98
|
endpoint?: string;
|
|
93
99
|
filterKey?: string;
|
|
@@ -126,8 +126,11 @@ const ConnectedAutocompleteField = (
|
|
|
126
126
|
search: searchParameter
|
|
127
127
|
});
|
|
128
128
|
},
|
|
129
|
+
// Two fields can carry the same label and read different APIs, and
|
|
130
|
+
// would otherwise share each other's options.
|
|
129
131
|
getQueryKey: () => [
|
|
130
132
|
`autocomplete-${queryKey || props.label}`,
|
|
133
|
+
baseEndpoint,
|
|
131
134
|
page,
|
|
132
135
|
searchParameter
|
|
133
136
|
],
|