fix layout login
This commit is contained in:
parent
0338bac9d0
commit
15d9f703e3
|
|
@ -58,6 +58,7 @@ export const FieldMoney: FC<{
|
||||||
input.render();
|
input.render();
|
||||||
}
|
}
|
||||||
}}
|
}}
|
||||||
|
inputMode="decimal"
|
||||||
value={formatCurrency(input.value) || 0}
|
value={formatCurrency(input.value) || 0}
|
||||||
disabled={disabled}
|
disabled={disabled}
|
||||||
className={cx(
|
className={cx(
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,9 @@
|
||||||
import { createItem } from "lib/gen/utils";
|
import { createItem, parseGenField } from "lib/gen/utils";
|
||||||
import { genTableEdit } from "./gen-table-edit";
|
import { genTableEdit } from "./gen-table-edit";
|
||||||
import { createId } from "@paralleldrive/cuid2";
|
import { createId } from "@paralleldrive/cuid2";
|
||||||
|
import { on_load_rel } from "./on_load_rel";
|
||||||
|
import { generateSelect } from "lib/exports";
|
||||||
|
import { getColumn } from "./gen-rel-many";
|
||||||
|
|
||||||
export const generateRelation = async (
|
export const generateRelation = async (
|
||||||
data: {
|
data: {
|
||||||
|
|
@ -37,7 +40,121 @@ export const generateRelation = async (
|
||||||
} else {
|
} else {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
} else {
|
} else if (sub_type === "dropdown") {
|
||||||
|
let table = "" as string;
|
||||||
|
try {
|
||||||
|
table = eval(data.rel__gen_table.value);
|
||||||
|
} catch (e) {
|
||||||
|
table = data.rel__gen_table.value;
|
||||||
|
}
|
||||||
|
const raw_fields = JSON.parse(data.rel__gen_fields.value) as (
|
||||||
|
| string
|
||||||
|
| { value: string; checked: string[] }
|
||||||
|
)[];
|
||||||
|
let pk = "";
|
||||||
|
let pks: Record<string, string> = {};
|
||||||
|
const fields = parseGenField(raw_fields);
|
||||||
|
const res = generateSelect(fields);
|
||||||
|
const load = on_load_rel({
|
||||||
|
pk: res.pk,
|
||||||
|
table,
|
||||||
|
select: res.select,
|
||||||
|
pks: {},
|
||||||
|
type: "dropdown",
|
||||||
|
});
|
||||||
|
|
||||||
|
const result = {
|
||||||
|
opt__on_load: load,
|
||||||
|
opt__get_value: `\
|
||||||
|
(arg: {
|
||||||
|
options: { label: string; value: string; item?: string }[];
|
||||||
|
fm: FMLocal;
|
||||||
|
name: string;
|
||||||
|
type: string;
|
||||||
|
}) => {
|
||||||
|
const { options, fm, name, type } = arg;
|
||||||
|
if (isEditor) {
|
||||||
|
return fm.data[name];
|
||||||
|
}
|
||||||
|
let result = null;
|
||||||
|
result = fm.data[name];
|
||||||
|
try {
|
||||||
|
const data = fm.data[name];
|
||||||
|
if (typeof data === "object") {
|
||||||
|
if (typeof data?.connect?.id !== "undefined") {
|
||||||
|
result = data.connect.id;
|
||||||
|
}else if (typeof data?.id !== "undefined") {
|
||||||
|
result = data.id;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (ex) { }
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
`,
|
||||||
|
opt__set_value: `\
|
||||||
|
(arg: {
|
||||||
|
selected: any[];
|
||||||
|
options: { label: string; value: string; item?: string }[];
|
||||||
|
fm: FMLocal;
|
||||||
|
name: string;
|
||||||
|
type: string;
|
||||||
|
}) => {
|
||||||
|
const { selected, options, fm, name, type } = arg;
|
||||||
|
|
||||||
|
if (selected[0]) {
|
||||||
|
fm.data[name] = {
|
||||||
|
connect: {
|
||||||
|
id: selected[0],
|
||||||
|
},
|
||||||
|
};
|
||||||
|
}
|
||||||
|
fm.render();
|
||||||
|
}
|
||||||
|
`,
|
||||||
|
opt__label: `\
|
||||||
|
(
|
||||||
|
row: { value: string; label: string; data?: any },
|
||||||
|
mode: "list" | "label", opt: any
|
||||||
|
) => {
|
||||||
|
const cols = ${JSON.stringify(getColumn(res))};
|
||||||
|
|
||||||
|
const prefix = treePrefix({
|
||||||
|
//@ts-ignore
|
||||||
|
rel__feature, rel__id_parent, row, mode, opt
|
||||||
|
});
|
||||||
|
|
||||||
|
if (isEditor) {
|
||||||
|
return row.label;
|
||||||
|
}
|
||||||
|
const result = [];
|
||||||
|
if (!!row.data && !row.label && !Array.isArray(row.data)) {
|
||||||
|
if(cols.length > 0){
|
||||||
|
cols.map((e) => {
|
||||||
|
if (row.data[e]) {
|
||||||
|
result.push(row.data[e]);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return prefix + result.join(" - ");
|
||||||
|
} else {
|
||||||
|
const fields = parseGenField(rel__gen_fields);
|
||||||
|
return prefix + fields
|
||||||
|
.filter((e) => !e.is_pk)
|
||||||
|
.map((e) => row.data[e.name])
|
||||||
|
.filter((e) => e)
|
||||||
|
.join(" - ");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return prefix + row.label;
|
||||||
|
}
|
||||||
|
`,
|
||||||
|
} as any;
|
||||||
|
Object.keys(result).map((e) => {
|
||||||
|
item.edit.setProp(e, {
|
||||||
|
mode: "raw",
|
||||||
|
value: result[e],
|
||||||
|
});
|
||||||
|
});
|
||||||
|
await item.edit.commit();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -83,7 +83,7 @@ export const Layout: FC<LYTChild> = (props) => {
|
||||||
if (!w.user) {
|
if (!w.user) {
|
||||||
local.loading = true;
|
local.loading = true;
|
||||||
isMobile
|
isMobile
|
||||||
? loadSession("/m/auth/login")
|
? loadSession(props.login_url || "/m/auth/login")
|
||||||
: loadSession(props.login_url || "/auth/login");
|
: loadSession(props.login_url || "/auth/login");
|
||||||
|
|
||||||
local.loading = false;
|
local.loading = false;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue