fix table edit
This commit is contained in:
parent
c9e591fac3
commit
3cbe406f67
|
|
@ -62,6 +62,9 @@ export const TableEdit: FC<{
|
||||||
.table-list-inner {
|
.table-list-inner {
|
||||||
position: relative !important;
|
position: relative !important;
|
||||||
}
|
}
|
||||||
|
.typeahead-arrow {
|
||||||
|
margin-right: 10px;
|
||||||
|
}
|
||||||
`,
|
`,
|
||||||
value.length === 0 &&
|
value.length === 0 &&
|
||||||
(show_header === "n"
|
(show_header === "n"
|
||||||
|
|
@ -83,12 +86,16 @@ export const TableEdit: FC<{
|
||||||
<TableList
|
<TableList
|
||||||
row_height={(row) => {
|
row_height={(row) => {
|
||||||
const rh = local.rowHeight.get(row);
|
const rh = local.rowHeight.get(row);
|
||||||
|
|
||||||
|
let h = 50;
|
||||||
if (rh) {
|
if (rh) {
|
||||||
for (const div of Object.values(rh)) {
|
for (const div of Object.values(rh)) {
|
||||||
if (div.offsetHeight > 50) return div.offsetHeight + 6;
|
if (div) {
|
||||||
|
if (div.offsetHeight > 50) h = div.offsetHeight + 6;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return 50;
|
return h;
|
||||||
}}
|
}}
|
||||||
feature={[]}
|
feature={[]}
|
||||||
child={child}
|
child={child}
|
||||||
|
|
@ -118,6 +125,14 @@ export const TableEdit: FC<{
|
||||||
local.tbl = tbl;
|
local.tbl = tbl;
|
||||||
|
|
||||||
const key = props.column.key;
|
const key = props.column.key;
|
||||||
|
|
||||||
|
if (!local.rowHeight.has(props.row)) {
|
||||||
|
local.rowHeight.set(props.row, {});
|
||||||
|
}
|
||||||
|
const rh = local.rowHeight.get(props.row);
|
||||||
|
if (rh && tbl.el) {
|
||||||
|
rh[props.column.key] = tbl.el.querySelector(".field");
|
||||||
|
}
|
||||||
return (
|
return (
|
||||||
<PassProp
|
<PassProp
|
||||||
idx={props.rowIdx}
|
idx={props.rowIdx}
|
||||||
|
|
@ -129,17 +144,6 @@ export const TableEdit: FC<{
|
||||||
}}
|
}}
|
||||||
rows={tbl.data}
|
rows={tbl.data}
|
||||||
fm={fm_row}
|
fm={fm_row}
|
||||||
field_ref={(ref: any) => {
|
|
||||||
if (ref) {
|
|
||||||
if (!local.rowHeight.has(props.row)) {
|
|
||||||
local.rowHeight.set(props.row, {});
|
|
||||||
}
|
|
||||||
const rh = local.rowHeight.get(props.row);
|
|
||||||
if (rh) {
|
|
||||||
rh[props.column.key] = ref;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}}
|
|
||||||
fm_parent={parent}
|
fm_parent={parent}
|
||||||
ext_fm={{
|
ext_fm={{
|
||||||
idx: props.rowIdx,
|
idx: props.rowIdx,
|
||||||
|
|
|
||||||
|
|
@ -320,7 +320,7 @@ return (React.createElement(React.Fragment, null,
|
||||||
false
|
false
|
||||||
),
|
),
|
||||||
});
|
});
|
||||||
} else {
|
} else if (!opt.is_from_table_edit) {
|
||||||
type = "link";
|
type = "link";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -58,9 +58,9 @@ export const genRelMany = (prop: {
|
||||||
data.map((e) => {
|
data.map((e) => {
|
||||||
try {
|
try {
|
||||||
if (typeof e === "object") {
|
if (typeof e === "object") {
|
||||||
if (typeof e["${master.name}"].connect?.${pk_master.name} === "string") {
|
if (typeof e["${master.name}"]?.connect?.${pk_master.name} !== "undefined") {
|
||||||
selected.push(e["${master.name}"].connect.${pk_master.name});
|
selected.push(e["${master.name}"].connect.${pk_master.name});
|
||||||
} else if (typeof e["${master.name}"]?.${pk_master.name} === "string") {
|
} else if (typeof e["${master.name}"]?.${pk_master.name}!== "undefined") {
|
||||||
selected.push(e["${master.name}"].${pk_master.name});
|
selected.push(e["${master.name}"].${pk_master.name});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -92,15 +92,18 @@ export const genRelMany = (prop: {
|
||||||
break;
|
break;
|
||||||
case "multi-option":
|
case "multi-option":
|
||||||
let parent = {} as any;
|
let parent = {} as any;
|
||||||
try {
|
call_prasi_events("form", "relation_before_save", ["${arg.relation.to.table}", parent]);
|
||||||
|
|
||||||
|
if (fm.data.id){
|
||||||
parent = {
|
parent = {
|
||||||
|
...parent,
|
||||||
${arg.relation.from.table}: {
|
${arg.relation.from.table}: {
|
||||||
connect: {
|
connect: {
|
||||||
${arg.relation.from.fields[0]}: fm.data.id || null,
|
${arg.relation.from.fields[0]}: fm.data.id || null,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
} catch (e) {}
|
}
|
||||||
fm.data[name] = selected.map((e) => {
|
fm.data[name] = selected.map((e) => {
|
||||||
return {
|
return {
|
||||||
${master.name}: {
|
${master.name}: {
|
||||||
|
|
|
||||||
|
|
@ -46,7 +46,7 @@ export const genTableEdit = async (
|
||||||
parent_table: table,
|
parent_table: table,
|
||||||
value,
|
value,
|
||||||
on_change: `() => { ext_fm.change(); }`,
|
on_change: `() => { ext_fm.change(); }`,
|
||||||
is_from_table_edit: true
|
is_from_table_edit: true,
|
||||||
},
|
},
|
||||||
false
|
false
|
||||||
);
|
);
|
||||||
|
|
@ -78,6 +78,7 @@ export const genTableEdit = async (
|
||||||
props: {
|
props: {
|
||||||
name: "option",
|
name: "option",
|
||||||
title: "",
|
title: "",
|
||||||
|
width: "`75`",
|
||||||
child: {
|
child: {
|
||||||
id: createId(),
|
id: createId(),
|
||||||
name: "option",
|
name: "option",
|
||||||
|
|
@ -88,6 +89,7 @@ export const genTableEdit = async (
|
||||||
adv: { css: "" },
|
adv: { css: "" },
|
||||||
dim: { h: "fit", w: "fit" },
|
dim: { h: "fit", w: "fit" },
|
||||||
name: "info",
|
name: "info",
|
||||||
|
hidden: "all",
|
||||||
type: "item",
|
type: "item",
|
||||||
childs: [
|
childs: [
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -73,7 +73,7 @@ async (arg: {
|
||||||
items = sortTree(items, rel__id_parent, "${pk}");
|
items = sortTree(items, rel__id_parent, "${pk}");
|
||||||
}
|
}
|
||||||
|
|
||||||
if(items.length){
|
if(Array.isArray(items) && items.length){
|
||||||
const cols = ${JSON.stringify(cols)};
|
const cols = ${JSON.stringify(cols)};
|
||||||
const getLabel = (data: any) => {
|
const getLabel = (data: any) => {
|
||||||
const result = [];
|
const result = [];
|
||||||
|
|
|
||||||
|
|
@ -15,6 +15,14 @@ export const generateSelect = (data: Array<any>) => {
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
select[f.name].select[r.name] = true;
|
select[f.name].select[r.name] = true;
|
||||||
|
|
||||||
|
if (r.relation) {
|
||||||
|
if (r.relation?.fields) {
|
||||||
|
select[f.name].select[r.name] = {
|
||||||
|
select: generateSelect(r.relation?.fields).select,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -316,7 +316,7 @@ export const Typeahead: FC<{
|
||||||
return item;
|
return item;
|
||||||
}
|
}
|
||||||
|
|
||||||
const item = local.options.find((item) => item.value === value);
|
const item = local.options.find((e) => e.value === value);
|
||||||
return item;
|
return item;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
@ -378,7 +378,6 @@ export const Typeahead: FC<{
|
||||||
) : (
|
) : (
|
||||||
<></>
|
<></>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
<TypeaheadOptions
|
<TypeaheadOptions
|
||||||
popup={true}
|
popup={true}
|
||||||
onOpenChange={(open) => {
|
onOpenChange={(open) => {
|
||||||
|
|
@ -534,11 +533,10 @@ export const Typeahead: FC<{
|
||||||
onKeyDown={keydown}
|
onKeyDown={keydown}
|
||||||
/>
|
/>
|
||||||
</TypeaheadOptions>
|
</TypeaheadOptions>
|
||||||
|
|
||||||
{local.mode === "single" && (
|
{local.mode === "single" && (
|
||||||
<div
|
<div
|
||||||
className={cx(
|
className={cx(
|
||||||
"c-absolute c-pointer-events-none c-z-10 c-inset-0 c-left-auto c-flex c-items-center ",
|
"typeahead-arrow c-absolute c-pointer-events-none c-z-10 c-inset-0 c-left-auto c-flex c-items-center ",
|
||||||
" c-justify-center c-w-6 c-mr-1 c-my-2 c-bg-white",
|
" c-justify-center c-w-6 c-mr-1 c-my-2 c-bg-white",
|
||||||
disabled && "c-hidden"
|
disabled && "c-hidden"
|
||||||
)}
|
)}
|
||||||
|
|
|
||||||
|
|
@ -78,6 +78,7 @@ type SimplifiedItem = {
|
||||||
dim?: any;
|
dim?: any;
|
||||||
layout?: any;
|
layout?: any;
|
||||||
border?: any;
|
border?: any;
|
||||||
|
hidden?: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
export const createItem = (arg: SimplifiedItem): any => {
|
export const createItem = (arg: SimplifiedItem): any => {
|
||||||
|
|
@ -145,6 +146,7 @@ export const createItem = (arg: SimplifiedItem): any => {
|
||||||
type: "item",
|
type: "item",
|
||||||
component,
|
component,
|
||||||
adv: arg.adv,
|
adv: arg.adv,
|
||||||
|
hidden: arg.hidden,
|
||||||
childs: arg.childs?.map(createItem) || [],
|
childs: arg.childs?.map(createItem) || [],
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue