This commit is contained in:
rizky 2024-07-21 21:57:49 -07:00
parent 96a07a79cb
commit 2ee3940d5f
3 changed files with 31 additions and 21 deletions

View File

@ -89,7 +89,7 @@ export const TableList: FC<TableListProp> = ({
on_load, on_load,
child, child,
PassProp, PassProp,
mode, mode: _mode,
on_init, on_init,
_item, _item,
gen_fields, gen_fields,
@ -106,6 +106,7 @@ export const TableList: FC<TableListProp> = ({
__props, __props,
md, md,
}) => { }) => {
let mode = _mode;
if (mode === "auto") { if (mode === "auto") {
if (w.isMobile) { if (w.isMobile) {
mode = "list"; mode = "list";
@ -113,6 +114,7 @@ export const TableList: FC<TableListProp> = ({
mode = "table"; mode = "table";
} }
} }
let ls_sort = localStorage.getItem( let ls_sort = localStorage.getItem(
`sort-${location.pathname}-${location.hash}-${name}` `sort-${location.pathname}-${location.hash}-${name}`
) as unknown as { columns: any; orderBy: any }; ) as unknown as { columns: any; orderBy: any };
@ -302,14 +304,14 @@ export const TableList: FC<TableListProp> = ({
); );
let childs: any[] = []; let childs: any[] = [];
let sub_name = ["fields"]; let sub_name: string[] = [];
switch (mode) { switch (mode) {
case "table": case "table":
sub_name = ["tbl-col", "table: columns"]; sub_name = ["tbl-col", "table: columns"];
break; break;
case "list": case "list":
sub_name = ["list-row", "list: rows"]; sub_name = ["list-row", "list: fields"];
break; break;
} }
@ -567,6 +569,18 @@ export const TableList: FC<TableListProp> = ({
} }
let data = local.data || []; let data = local.data || [];
if (isEditor) {
if (data.length > 0) {
w.prasi_table_list_temp_data = data;
} else if (
w.prasi_table_list_temp_data &&
w.prasi_table_list_temp_data.length > 0
) {
data = w.prasi_table_list_temp_data;
}
}
if (id_parent && local.pk && local.sort.columns.length === 0) { if (id_parent && local.pk && local.sort.columns.length === 0) {
data = sortTree(local.data, id_parent, local.pk.name); data = sortTree(local.data, id_parent, local.pk.name);
} }
@ -753,7 +767,7 @@ export const TableList: FC<TableListProp> = ({
data.map((e, idx) => { data.map((e, idx) => {
return ( return (
<div <div
className="c-flex-grow" className="c-flex-grow c-flex"
onClick={(ev) => { onClick={(ev) => {
if (!isEditor && typeof row_click === "function") { if (!isEditor && typeof row_click === "function") {
row_click({ row_click({
@ -766,7 +780,7 @@ export const TableList: FC<TableListProp> = ({
}} }}
> >
<PassProp idx={idx} row={e} col={{}} rows={local.data}> <PassProp idx={idx} row={e} col={{}} rows={local.data}>
{child} {mode_child}
</PassProp> </PassProp>
</div> </div>
); );

View File

@ -79,17 +79,15 @@ export const generateTableList = async (
name: e.name, name: e.name,
title: formatName(e.name), title: formatName(e.name),
child: createItem({ child: createItem({
childs: [ name: "cell",
createItem({ padding: {
name: "cell", l: 8,
padding: { b: 0,
l: 8, t: 0,
b: 0, r: 8,
t: 0, },
r: 8, adv: {
}, js: `\
adv: {
js: `\
<div {...props} className={cx(props.className, "")}> <div {...props} className={cx(props.className, "")}>
${ ${
arg.mode === "list" arg.mode === "list"
@ -97,12 +95,10 @@ ${
: `<FormatValue value={col.value} name={col.name} gen_fields={gen__fields} ${tree_depth} />` : `<FormatValue value={col.value} name={col.name} gen_fields={gen__fields} ${tree_depth} />`
} }
</div>`, </div>`,
jsBuilt: `\ jsBuilt: `\
render(React.createElement("div", Object.assign({}, props, { className: cx(props.className, "") }),React.createElement(FormatValue, { value: col.value, name: col.name, gen_fields: gen__fields, ${tree_depth_built} }))); render(React.createElement("div", Object.assign({}, props, { className: cx(props.className, "") }),React.createElement(FormatValue, { value: col.value, name: col.name, gen_fields: gen__fields, ${tree_depth_built} })));
`, `,
}, },
}),
],
}), }),
}, },
}, },

View File

@ -5,7 +5,7 @@ export const modeTableList = (mode: string) => {
sub_name = "table: columns"; sub_name = "table: columns";
break; break;
case "list": case "list":
sub_name = "list: rows"; sub_name = "list: fields";
break; break;
} }
return sub_name; return sub_name;