CardView lookup çağrısı düzeltildi.
This commit is contained in:
parent
f39a3e5764
commit
9cc77fb3a1
1 changed files with 1 additions and 24 deletions
|
|
@ -213,7 +213,6 @@ const getInitialExtraFilters = (gridDto?: GridDto): GridExtraFilterState[] =>
|
|||
const loadCascadeLookupDisplayValues = async (
|
||||
columns: any[],
|
||||
rows: Record<string, any>[],
|
||||
knownValues: Record<string, Map<string, string>> = {},
|
||||
) => {
|
||||
const entries = await Promise.all(
|
||||
columns
|
||||
|
|
@ -224,27 +223,9 @@ const loadCascadeLookupDisplayValues = async (
|
|||
.split(',')
|
||||
.map((field) => field.trim())
|
||||
.filter(Boolean)
|
||||
const parentValueLists: string[][] = parentFields.map((field) => {
|
||||
const values = Object.entries(knownValues).find(
|
||||
([key]) => key.toLowerCase() === field.toLowerCase(),
|
||||
)?.[1]
|
||||
return values ? [...values.keys()] : []
|
||||
})
|
||||
const preloadContexts = parentValueLists.every((values) => values.length > 0)
|
||||
? parentValueLists.reduce<Record<string, any>[]>(
|
||||
(contexts, values, index) =>
|
||||
contexts
|
||||
.flatMap((context) =>
|
||||
values.map((value) => ({ ...context, [parentFields[index]]: value })),
|
||||
)
|
||||
.slice(0, 100),
|
||||
[{}],
|
||||
)
|
||||
: []
|
||||
const sourceRows = rows.length > 0 ? rows : preloadContexts
|
||||
const contexts = [
|
||||
...new Map(
|
||||
sourceRows.map((row) => [
|
||||
rows.map((row) => [
|
||||
JSON.stringify(parentFields.map((field: string) => getValueByField(row, field))),
|
||||
row,
|
||||
]),
|
||||
|
|
@ -719,10 +700,6 @@ const CardView = (props: CardViewProps) => {
|
|||
let active = true
|
||||
const columns = getLookupColumns()
|
||||
loadLookupDisplayValues(columns)
|
||||
.then(async (values) => ({
|
||||
...values,
|
||||
...(await loadCascadeLookupDisplayValues(columns, [], values)),
|
||||
}))
|
||||
.then((values) => {
|
||||
if (!active) return
|
||||
applyLookupDisplayValues(values)
|
||||
|
|
|
|||
Loading…
Reference in a new issue