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

View File

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

View File

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