|
|
@ -528,13 +528,12 @@ const [useProvideSharedFormStore, useSharedFormStore] = useInjectionState((share |
|
|
|
} |
|
|
|
} |
|
|
|
case UITypes.LinkToAnotherRecord: |
|
|
|
case UITypes.LinkToAnotherRecord: |
|
|
|
case UITypes.Links: { |
|
|
|
case UITypes.Links: { |
|
|
|
const refTableMeta = await getMeta((c.colOptions as LinkToAnotherRecordType)?.fk_related_model_id) |
|
|
|
const values = Array.isArray(value) ? value : value.split(',') |
|
|
|
const pkCol = refTableMeta?.columns?.find((col) => col.pk) |
|
|
|
const rows = await loadLinkedRecords(c, values) |
|
|
|
preFillValue = (Array.isArray(value) ? value : [value]).map((id) => ({ |
|
|
|
|
|
|
|
[pkCol?.title as string]: id, |
|
|
|
preFillValue = rows |
|
|
|
})) |
|
|
|
|
|
|
|
// if bt/oo then extract object from array
|
|
|
|
// if bt/oo then extract object from array
|
|
|
|
if(c.colOptions?.type === RelationTypes.BELONGS_TO || c.colOptions?.type === RelationTypes.ONE_TO_ONE) { |
|
|
|
if (c.colOptions?.type === RelationTypes.BELONGS_TO || c.colOptions?.type === RelationTypes.ONE_TO_ONE) { |
|
|
|
preFillValue = preFillValue[0] |
|
|
|
preFillValue = preFillValue[0] |
|
|
|
} |
|
|
|
} |
|
|
|
// Todo: create an api which will fetch query params records and then autofill records
|
|
|
|
// Todo: create an api which will fetch query params records and then autofill records
|
|
|
@ -554,6 +553,30 @@ const [useProvideSharedFormStore, useSharedFormStore] = useInjectionState((share |
|
|
|
return preFillValue |
|
|
|
return preFillValue |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
async function loadLinkedRecords(column: ColumnType, ids: string[]) { |
|
|
|
|
|
|
|
const relatedMeta = await getMeta((column.colOptions as LinkToAnotherRecordType)?.fk_related_model_id) |
|
|
|
|
|
|
|
const pkCol = relatedMeta?.columns?.find((col) => col.pk) |
|
|
|
|
|
|
|
const pvCol = relatedMeta?.columns?.find((col) => col.pv) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return ( |
|
|
|
|
|
|
|
await api.public.dataRelationList( |
|
|
|
|
|
|
|
route.params.viewId as string, |
|
|
|
|
|
|
|
column.id, |
|
|
|
|
|
|
|
{}, |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
headers: { |
|
|
|
|
|
|
|
'xc-password': '', // sharedViewPassword.value,
|
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
query: { |
|
|
|
|
|
|
|
limit: Math.max(25, ids.length), |
|
|
|
|
|
|
|
where: `(${pkCol.title},in,${ids.join(',')})`, |
|
|
|
|
|
|
|
fields: [pkCol.title, pvCol.title], |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
)?.list |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
let intvl: NodeJS.Timeout |
|
|
|
let intvl: NodeJS.Timeout |
|
|
|
/** reset form if show_blank_form is true */ |
|
|
|
/** reset form if show_blank_form is true */ |
|
|
|
watch(submitted, (nextVal) => { |
|
|
|
watch(submitted, (nextVal) => { |
|
|
|