|
7 | 7 | import type { BaseField, FieldOptions } from '$lib/Fields';
|
8 | 8 | import type { CrudDefinition } from '$lib/Crud';
|
9 | 9 |
|
10 |
| - import { List } from '$lib/Crud/Operations'; |
| 10 | + import { type CrudOperation, List } from '$lib/Crud/Operations'; |
11 | 11 |
|
12 | 12 | import type { Action } from '$lib/Actions';
|
13 | 13 |
|
|
76 | 76 | ]).then((results) => results[0]);
|
77 | 77 | }
|
78 | 78 |
|
79 |
| - rows = providerResponse.then((responseResults) => { |
| 79 | + type Item = {id?: null|string|number, __crud_operation?: CrudOperation, [key: string]: unknown}; |
| 80 | +
|
| 81 | + rows = providerResponse.then((responseResults): Item[] => { |
80 | 82 | if (
|
81 | 83 | responseResults &&
|
82 | 84 | !Array.isArray(responseResults) &&
|
|
87 | 89 | );
|
88 | 90 | }
|
89 | 91 |
|
90 |
| - let finalRows = |
91 |
| - responseResults instanceof PaginatedResults |
| 92 | + let finalRows: Array<Item> = |
| 93 | + (responseResults instanceof PaginatedResults |
92 | 94 | ? responseResults.currentItems
|
93 |
| - : responseResults; |
| 95 | + : responseResults) as Array<Item>; |
94 | 96 |
|
95 | 97 | paginator = responseResults instanceof PaginatedResults ? responseResults : undefined;
|
96 | 98 |
|
|
100 | 102 |
|
101 | 103 | // Make sure final results always have the "id" field,
|
102 | 104 | // which is mandatory for Carbon's DataTable.
|
103 |
| - finalRows = finalRows.map((result: object) => { |
| 105 | + finalRows = finalRows.map((result: Item) => { |
104 | 106 | if (!result.id && crud.options.identifierFieldName !== 'id') {
|
105 |
| - result.id = result[crud.options.identifierFieldName]; |
| 107 | + result.id = String(result[crud.options.identifierFieldName] || ''); |
106 | 108 | }
|
107 | 109 |
|
108 | 110 | result.__crud_operation = operation;
|
|
162 | 164 | {onSort}
|
163 | 165 | sortable={sortableDataTable}
|
164 | 166 | filters={configuredFilters}
|
| 167 | + filtersValues={requestParameters.filters} |
165 | 168 | theme={dashboard.theme}
|
166 | 169 | on:submitFilters={onFiltersSubmit}
|
167 | 170 | >
|
|
0 commit comments