fix
This commit is contained in:
parent
a425445ff2
commit
4a3374701c
|
|
@ -5,6 +5,7 @@ import { useField } from "../utils/use-field";
|
||||||
import { FieldInput } from "./FieldInput";
|
import { FieldInput } from "./FieldInput";
|
||||||
import { Label } from "./Label";
|
import { Label } from "./Label";
|
||||||
import { validate } from "../utils/validate";
|
import { validate } from "../utils/validate";
|
||||||
|
import { call_prasi_events } from "lib/exports";
|
||||||
|
|
||||||
export const Field: FC<FieldProp> = (arg) => {
|
export const Field: FC<FieldProp> = (arg) => {
|
||||||
const showlabel = arg.show_label || "y";
|
const showlabel = arg.show_label || "y";
|
||||||
|
|
@ -39,6 +40,8 @@ export const Field: FC<FieldProp> = (arg) => {
|
||||||
|
|
||||||
fm.events.on_change(name, fm.data[name]);
|
fm.events.on_change(name, fm.data[name]);
|
||||||
fm.render();
|
fm.render();
|
||||||
|
|
||||||
|
call_prasi_events("field", "on_change", [fm, field]);
|
||||||
}
|
}
|
||||||
}, [fm.data[name]]);
|
}, [fm.data[name]]);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,7 @@ import { FieldLoading } from "lib/comps/ui/field-loading";
|
||||||
import { Typeahead } from "lib/comps/ui/typeahead";
|
import { Typeahead } from "lib/comps/ui/typeahead";
|
||||||
import { FC, useEffect } from "react";
|
import { FC, useEffect } from "react";
|
||||||
import { FMLocal, FieldLocal, FieldProp } from "../../typings";
|
import { FMLocal, FieldLocal, FieldProp } from "../../typings";
|
||||||
|
import { call_prasi_events } from "lib/exports";
|
||||||
|
|
||||||
export const TypeDropdown: FC<{
|
export const TypeDropdown: FC<{
|
||||||
field: FieldLocal;
|
field: FieldLocal;
|
||||||
|
|
@ -14,11 +15,12 @@ export const TypeDropdown: FC<{
|
||||||
options: [] as { value: string; label: string; data: any }[],
|
options: [] as { value: string; label: string; data: any }[],
|
||||||
});
|
});
|
||||||
|
|
||||||
const reload = (callback?: () => void) => {
|
const reload = async (callback?: () => void) => {
|
||||||
if (typeof arg.on_load === "function") {
|
if (typeof arg.on_load === "function") {
|
||||||
local.loaded = false;
|
local.loaded = false;
|
||||||
local.render();
|
local.render();
|
||||||
const options = arg.on_load({ field });
|
let options: any = null;
|
||||||
|
options = arg.on_load({ field });
|
||||||
if (options instanceof Promise) {
|
if (options instanceof Promise) {
|
||||||
options.then((res) => {
|
options.then((res) => {
|
||||||
if (Array.isArray(res)) {
|
if (Array.isArray(res)) {
|
||||||
|
|
|
||||||
|
|
@ -54,6 +54,15 @@ export const newField = async (
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
|
let sub_type = "text";
|
||||||
|
if (
|
||||||
|
["attachment", "file", "img", "image"].find((e) =>
|
||||||
|
field.name.includes(e)
|
||||||
|
)
|
||||||
|
) {
|
||||||
|
sub_type = "file";
|
||||||
|
}
|
||||||
|
|
||||||
return createItem({
|
return createItem({
|
||||||
component: {
|
component: {
|
||||||
id: "32550d01-42a3-4b15-a04a-2c2d5c3c8e67",
|
id: "32550d01-42a3-4b15-a04a-2c2d5c3c8e67",
|
||||||
|
|
@ -62,7 +71,7 @@ export const newField = async (
|
||||||
label: formatName(field.name),
|
label: formatName(field.name),
|
||||||
type,
|
type,
|
||||||
ext__required: field.optional ? "n" : "y",
|
ext__required: field.optional ? "n" : "y",
|
||||||
sub_type: "text",
|
sub_type,
|
||||||
ext__show_label: show ? "y" : "n",
|
ext__show_label: show ? "y" : "n",
|
||||||
child: {
|
child: {
|
||||||
childs: [],
|
childs: [],
|
||||||
|
|
|
||||||
|
|
@ -90,6 +90,7 @@ ${
|
||||||
|
|
||||||
return item;
|
return item;
|
||||||
} else {
|
} else {
|
||||||
|
call_prasi_events("form", "after_load", [opt?.fm]);
|
||||||
${opt?.after_load ? opt?.after_load : ""}
|
${opt?.after_load ? opt?.after_load : ""}
|
||||||
}
|
}
|
||||||
}`;
|
}`;
|
||||||
|
|
|
||||||
|
|
@ -20,9 +20,7 @@ const events = {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
field: {
|
field: {
|
||||||
on_init: async (fm: FMLocal, field: FieldLocal) => {},
|
|
||||||
on_change: async (fm: FMLocal, field: FieldLocal) => {},
|
on_change: async (fm: FMLocal, field: FieldLocal) => {},
|
||||||
options_load: async (fm: FMLocal, field: FieldLocal) => {},
|
|
||||||
},
|
},
|
||||||
tablelist: {
|
tablelist: {
|
||||||
after_load: async <T extends Prisma.ModelName>(
|
after_load: async <T extends Prisma.ModelName>(
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue