()
| 329 | let autoSortEnabled = field && fieldMetadata?.type == Type.String && domainItems.length < 200; |
| 330 | |
| 331 | let autoSortFunction = () => { |
| 332 | setAutoSortInferRunning(true); |
| 333 | let message = { |
| 334 | method: 'POST', |
| 335 | headers: { 'Content-Type': 'application/json', }, |
| 336 | body: JSON.stringify({ |
| 337 | items: domainItems, |
| 338 | field: field?.name, |
| 339 | model: activeModel |
| 340 | }), |
| 341 | }; |
| 342 | |
| 343 | apiRequest<any>(getUrls().SORT_DATA_URL, message) |
| 344 | .then(({ data }) => { |
| 345 | setAutoSortInferRunning(false); |
| 346 | |
| 347 | let candidate = data.result?.[0] ?? data[0]; |
| 348 | |
| 349 | if (candidate?.['status'] == 'ok') { |
| 350 | let sortRes = {values: candidate['content']['sorted_values'], reason: candidate['content']['reason']} |
| 351 | setAutoSortResult(sortRes.values); |
| 352 | } |
| 353 | }).catch((error) => { |
| 354 | setAutoSortInferRunning(false); |
| 355 | setAutoSortResult(undefined); |
| 356 | |
| 357 | dispatch(dfActions.addMessages({ |
| 358 | "timestamp": Date.now(), |
| 359 | "component": "EncodingBox", |
| 360 | "type": "error", |
| 361 | "value": t('encoding.autoSortServerError') |
| 362 | })); |
| 363 | }); |
| 364 | } |
| 365 | |
| 366 | let sortByOptions = [ |
| 367 | radioLabel("auto", "auto", `sort-by-auto`) |
nothing calls this directly
no test coverage detected