fix relation

This commit is contained in:
Rizky 2024-06-26 01:41:07 -07:00
parent ad39b108c5
commit 0ddd31fecc
5 changed files with 5 additions and 6 deletions

View File

@ -85,16 +85,14 @@ export const TypeDropdown: FC<{
<Typeahead
value={Array.isArray(value) ? value : [value]}
onSelect={({ search, item }) => {
console.log(search, item);
if (item) {
const result = arg.opt_set_value({
arg.opt_set_value({
fm,
name: field.name,
type: field.type,
options: local.options,
selected: [item.value],
});
console.log(item, result);
}
return item?.value || search;

View File

@ -107,7 +107,7 @@ export const newField = async (
const res = generateSelect(fields);
const load = on_load_rel({
pk: res.pk,
table: arg.name,
table: arg.relation.to.table,
select: res.select,
pks: {},
});

View File

@ -25,6 +25,7 @@ export const generateField = async (
) as any;
const pk = fields.find((e: any) => get(e, "is_pk")) as any;
const pk_master = master.relation.fields.find((e: any) => get(e, "is_pk"));
const load = on_load_rel({
pk: generateSelect(parseGenField(master.value.checked)).pk,
table: master?.name,

View File

@ -16,6 +16,7 @@ export const genRelMany = (prop: {
// select master
if (master) {
const select = generateSelect(master.relation.fields);
result.on_load = on_load_rel({
pk: select.pk,
table: master.name,

View File

@ -40,8 +40,7 @@ async (opt) => {
raw_id = md.selected[pk];
}
}
if (parseInt(raw_id)) raw_id = parseInt(raw_id);
${opt?.before_load ? opt.before_load : `let id = raw_id`}
let item = {};
let where = {