md, gen field raw
This commit is contained in:
parent
d580b6ccad
commit
d3e5147a59
|
|
@ -1,8 +1,62 @@
|
|||
export const generateFilter = (data: any, item: PrasiItem, commit: boolean) => {
|
||||
console.log("log", { data, item, commit });
|
||||
};
|
||||
import { createId } from "@paralleldrive/cuid2";
|
||||
import { generateForm } from "lib/exports";
|
||||
import { createItem } from "lib/gen/utils";
|
||||
|
||||
const frameFilter = {
|
||||
export const generateFilter = async (data: any, item: PrasiItem, commit: boolean) => {
|
||||
console.log("log", { data, item, commit });
|
||||
|
||||
const props: Record<string, PropVal> = {
|
||||
gen__table: {
|
||||
mode: "string",
|
||||
value: eval(data.gen__table.value)
|
||||
,
|
||||
},
|
||||
name: {
|
||||
mode: "string",
|
||||
value: eval(data.gen__table.value),
|
||||
},
|
||||
gen__fields: {
|
||||
mode: "raw",
|
||||
value: data.gen__fields.value,
|
||||
},
|
||||
deps: {
|
||||
mode: "raw",
|
||||
value: `({ md: typeof md !== "undefined" ? md : undefined })`,
|
||||
},
|
||||
on_load: {
|
||||
mode: "string",
|
||||
value: "",
|
||||
},
|
||||
on_submit: {
|
||||
mode: "string",
|
||||
value: "",
|
||||
},
|
||||
body: {
|
||||
mode: "jsx",
|
||||
value: createItem({
|
||||
name: "item",
|
||||
childs: [],
|
||||
}),
|
||||
},
|
||||
};
|
||||
const new_item: any = {
|
||||
type: "item",
|
||||
name: "item",
|
||||
component: {
|
||||
id: "c4e65c26-4f36-48aa-a5b3-0771feac082e",
|
||||
props,
|
||||
},
|
||||
};
|
||||
await generateForm(async (props: any) => {}, props, new_item, false, true);
|
||||
const fields = new_item?.component?.props?.body?.value?.childs?.[0]?.childs || [];
|
||||
console.log(fields)
|
||||
const fieldsFilter = createFilter(fields)
|
||||
await item.edit.setChilds([fieldsFilter])
|
||||
await item.edit.commit();
|
||||
// console.log({fields})
|
||||
};
|
||||
const createFilter:any = (fields: any) => {
|
||||
const result = {
|
||||
dim: { h: "full", w: "full", hUnit: "px", wUnit: "px" },
|
||||
name: "Wrapped",
|
||||
type: "item",
|
||||
|
|
@ -14,7 +68,7 @@ const frameFilter = {
|
|||
type: "item",
|
||||
childs: [
|
||||
{
|
||||
id: "r9u5j1gxxbuv73x8magw7smp",
|
||||
id:createId(),
|
||||
adv: {
|
||||
js: '<ScrollArea className={cx(props.className, "")} orientation={orientation}>{child}</ScrollArea>',
|
||||
css: "",
|
||||
|
|
@ -24,12 +78,6 @@ const frameFilter = {
|
|||
dim: { h: "full", w: "full" },
|
||||
name: "scroll-area",
|
||||
type: "item",
|
||||
childs: [
|
||||
{
|
||||
name: "jsx:child",
|
||||
id: "c7nakvqt2ih6zbbrnq59omup",
|
||||
},
|
||||
],
|
||||
script: {
|
||||
props: {
|
||||
orientation: { value: '"vertical"', valueBuilt: '"vertical"' },
|
||||
|
|
@ -54,7 +102,7 @@ const frameFilter = {
|
|||
childs: [
|
||||
{
|
||||
bg: { pos: "center", size: "cover", color: "" },
|
||||
id: "j1jtff4t8hvk4c2zn2spseww",
|
||||
id:createId(),
|
||||
adv: {
|
||||
js: '<div {...props} className={cx(props.className, "")} id="cek">\n {children}\n</div>',
|
||||
jsBuilt:
|
||||
|
|
@ -65,7 +113,7 @@ const frameFilter = {
|
|||
type: "item",
|
||||
childs: [
|
||||
{
|
||||
id: "tlfpdpv1g6y7f7klumtbecet",
|
||||
id:createId(),
|
||||
dim: {
|
||||
h: "fit",
|
||||
w: "full",
|
||||
|
|
@ -76,7 +124,7 @@ const frameFilter = {
|
|||
type: "item",
|
||||
childs: [
|
||||
{
|
||||
id: "epmv1gh58uso1iyi747oqlpf",
|
||||
id:createId(),
|
||||
adv: {
|
||||
js: '<div {...props} className={cx(props.className, "form-fields")}>\n {children}\n</div>',
|
||||
jsBuilt:
|
||||
|
|
@ -90,7 +138,7 @@ const frameFilter = {
|
|||
},
|
||||
name: "fields-filter",
|
||||
type: "item",
|
||||
childs: [],
|
||||
childs: fields,
|
||||
layout: {
|
||||
dir: "row",
|
||||
gap: 0,
|
||||
|
|
@ -111,10 +159,6 @@ const frameFilter = {
|
|||
script: {},
|
||||
},
|
||||
valueBuilt: '"hello"',
|
||||
jsxCalledBy: [
|
||||
"yych4cm4do7t4jt0d42dasrk",
|
||||
"ehqmu8gsesbvqyxmiw8l580t",
|
||||
],
|
||||
},
|
||||
orientation: {
|
||||
idx: 1,
|
||||
|
|
@ -138,19 +182,19 @@ const frameFilter = {
|
|||
hidden: false,
|
||||
},
|
||||
{
|
||||
id: "s9kb580m1bjmpe4xj9dtkgnz",
|
||||
id:createId(),
|
||||
dim: { h: "fit", w: "full", hUnit: "px", wUnit: "px" },
|
||||
name: "Wrapped",
|
||||
type: "item",
|
||||
childs: [
|
||||
{
|
||||
id: "hf0pxf4slu2xqhcuoropnkc6",
|
||||
id:createId(),
|
||||
dim: { h: "fit", w: "full", hUnit: "px", wUnit: "px" },
|
||||
name: "Reset",
|
||||
type: "item",
|
||||
childs: [
|
||||
{
|
||||
id: "jvnbd14f1sgcnmdhy4dcfuo4",
|
||||
id:createId(),
|
||||
adv: {
|
||||
js: '<Button\n {...props}\n onClick={(e) => {\n if (!isEditor) on_click(e);\n }}\n variant={variant !== "primary" ? variant : undefined}\n size={size !== "default" ? size : undefined}\n>\n {label}\n</Button>',
|
||||
css: "& {\n display: flex;\n\n &:hover {\n cursor: pointer;\n\n\n\n\n\n // &.mobile {}\n // &.desktop {}\n // &:hover {}\n }\n}",
|
||||
|
|
@ -160,12 +204,6 @@ const frameFilter = {
|
|||
dim: { h: "full", w: "full" },
|
||||
name: "button",
|
||||
type: "item",
|
||||
childs: [
|
||||
{
|
||||
name: "jsx: label",
|
||||
id: "k59ppuxhzf4tnkb4b4enyxxe",
|
||||
},
|
||||
],
|
||||
mobile: { linktag: {} },
|
||||
script: {
|
||||
props: {
|
||||
|
|
@ -203,7 +241,7 @@ const frameFilter = {
|
|||
type: "string",
|
||||
value: '"hello"',
|
||||
content: {
|
||||
id: "bb91ryll6mtk827zpibo6k65",
|
||||
id:createId(),
|
||||
adv: {
|
||||
js: '<div {...props} className={cx(props.className, "")}>\n {children}\n</div>',
|
||||
css: "",
|
||||
|
|
@ -215,7 +253,7 @@ const frameFilter = {
|
|||
type: "item",
|
||||
childs: [
|
||||
{
|
||||
id: "zhmnkaup9uxpou42lyn4splr",
|
||||
id:createId(),
|
||||
adv: {
|
||||
js: '<div {...props} className={cx(props.className, "")}>\n Reset\n</div>',
|
||||
css: "",
|
||||
|
|
@ -234,10 +272,6 @@ const frameFilter = {
|
|||
script: {},
|
||||
},
|
||||
valueBuilt: '"hello"',
|
||||
jsxCalledBy: [
|
||||
"frq12uxc65i9zn8myzan4huk",
|
||||
"q278u9p4cejubvfwqc72ey73",
|
||||
],
|
||||
},
|
||||
variant: {
|
||||
idx: 3,
|
||||
|
|
@ -266,19 +300,18 @@ const frameFilter = {
|
|||
},
|
||||
},
|
||||
},
|
||||
originalId: "q278u9p4cejubvfwqc72ey73",
|
||||
},
|
||||
],
|
||||
padding: { b: 10, l: 10, r: 0, t: 10 },
|
||||
},
|
||||
{
|
||||
id: "zidglf2tal6pgxe6c1ey7i5x",
|
||||
id:createId(),
|
||||
dim: { h: "fit", w: "full", hUnit: "px", wUnit: "px" },
|
||||
name: "Apply",
|
||||
type: "item",
|
||||
childs: [
|
||||
{
|
||||
id: "hjaeik76bqh3ufszscmzw0bm",
|
||||
id:createId(),
|
||||
adv: {
|
||||
js: '<Button\n {...props}\n onClick={(e) => {\n if (!isEditor) on_click(e);\n }}\n variant={variant !== "primary" ? variant : undefined}\n size={size !== "default" ? size : undefined}\n>\n {label}\n</Button>',
|
||||
css: "& {\n display: flex;\n\n &:hover {\n cursor: pointer;\n\n\n\n\n\n // &.mobile {}\n // &.desktop {}\n // &:hover {}\n }\n}",
|
||||
|
|
@ -288,13 +321,6 @@ const frameFilter = {
|
|||
dim: { h: "full", w: "full" },
|
||||
name: "button",
|
||||
type: "item",
|
||||
childs: [
|
||||
{
|
||||
name: "jsx: label",
|
||||
id: "w8i2j4uq3a186ozueanxisx9",
|
||||
originalId: "hglwmigw09h2b8a9vlz2cme5",
|
||||
},
|
||||
],
|
||||
mobile: { linktag: {} },
|
||||
script: {
|
||||
props: {
|
||||
|
|
@ -335,7 +361,7 @@ const frameFilter = {
|
|||
type: "string",
|
||||
value: '"hello"',
|
||||
content: {
|
||||
id: "dlq5kemqyq8d0os6uu34l4wd",
|
||||
id:createId(),
|
||||
adv: {
|
||||
js: '<div {...props} className={cx(props.className, "")}>\n {children}\n</div>',
|
||||
css: "",
|
||||
|
|
@ -347,7 +373,7 @@ const frameFilter = {
|
|||
type: "item",
|
||||
childs: [
|
||||
{
|
||||
id: "nbho83c6uggcc4mxjn0e2tr9",
|
||||
id:createId(),
|
||||
adv: {
|
||||
js: '<div {...props} className={cx(props.className, "")}>\n Apply\n</div>',
|
||||
css: "",
|
||||
|
|
@ -366,10 +392,6 @@ const frameFilter = {
|
|||
script: {},
|
||||
},
|
||||
valueBuilt: '"hello"',
|
||||
jsxCalledBy: [
|
||||
"frq12uxc65i9zn8myzan4huk",
|
||||
"q278u9p4cejubvfwqc72ey73",
|
||||
],
|
||||
},
|
||||
variant: {
|
||||
idx: 3,
|
||||
|
|
@ -398,7 +420,6 @@ const frameFilter = {
|
|||
},
|
||||
},
|
||||
},
|
||||
originalId: "q278u9p4cejubvfwqc72ey73",
|
||||
},
|
||||
],
|
||||
padding: { b: 10, l: 10, r: 0, t: 10 },
|
||||
|
|
@ -409,3 +430,6 @@ const frameFilter = {
|
|||
},
|
||||
],
|
||||
};
|
||||
return result
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -121,9 +121,6 @@ export const generateForm = async (
|
|||
align: "top-left",
|
||||
},
|
||||
};
|
||||
// const existing_childs = (
|
||||
// (item.component?.props.body as any)?.content as IItem
|
||||
// )?.childs;
|
||||
|
||||
let new_body = createItem({
|
||||
name: "item",
|
||||
|
|
@ -153,73 +150,6 @@ export const generateForm = async (
|
|||
submit,
|
||||
].filter((e) => e),
|
||||
});
|
||||
|
||||
// if (Array.isArray(existing_childs) && existing_childs.length > 0) {
|
||||
// walkGenForm(new_body, existing_childs as any);
|
||||
// }
|
||||
|
||||
// const prop_item = propFromItem(item);
|
||||
// const current_body = prop_item?.body?.value as IItem;
|
||||
|
||||
// if (current_body) {
|
||||
// const mapping = mapCompItemTree(new_body, {
|
||||
// shouldAdd({ item }) {
|
||||
// if (item.component?.props?.sub_type?.value === "table-edit")
|
||||
// return "add-skip-children";
|
||||
|
||||
// return "add";
|
||||
// },
|
||||
// });
|
||||
|
||||
// reduceItemMapping(current_body, mapping, (old_item, new_item) => {
|
||||
// const pold = propFromItem(old_item);
|
||||
// const pnew = propFromItem(new_item);
|
||||
|
||||
// let result = old_item;
|
||||
// if (
|
||||
// result.component &&
|
||||
// result.component?.id === "32550d01-42a3-4b15-a04a-2c2d5c3c8e67"
|
||||
// ) {
|
||||
// if (pold.type.value !== pnew.type.value) {
|
||||
// result = new_item;
|
||||
// } else if (pold.sub_type.value !== pnew.sub_type.value) {
|
||||
// result = new_item;
|
||||
// }
|
||||
|
||||
// copyProps(old_item, new_item, [
|
||||
// "placeholder",
|
||||
// "label",
|
||||
// "link__url",
|
||||
// "ext__width",
|
||||
// "opt__load_trigger",
|
||||
// "ext__on_change",
|
||||
// "ext__description",
|
||||
// "ext__show_label",
|
||||
// "ext__disabled",
|
||||
// "ext__prefix",
|
||||
// "ext__suffix",
|
||||
// ]);
|
||||
// }
|
||||
|
||||
// return result;
|
||||
// });
|
||||
|
||||
// if (
|
||||
// mapping["32550d01-42a3-4b15-a04a-2c2d5c3c8e67"] &&
|
||||
// Object.keys(mapping["32550d01-42a3-4b15-a04a-2c2d5c3c8e67"]).length > 0
|
||||
// ) {
|
||||
// for (const val of Object.values(
|
||||
// mapping["32550d01-42a3-4b15-a04a-2c2d5c3c8e67"]
|
||||
// )) {
|
||||
// current_body.childs?.[0]?.childs.push(val);
|
||||
// }
|
||||
// }
|
||||
|
||||
// if (current_body?.childs?.length > 0) {
|
||||
// new_body = current_body;
|
||||
// }
|
||||
// }
|
||||
|
||||
if (commit) {
|
||||
Object.keys(result).map((e) => {
|
||||
item.edit.setProp(e, result[e]);
|
||||
|
|
|
|||
|
|
@ -128,7 +128,7 @@ export const MasterDetail: FC<MDProps> = (arg) => {
|
|||
md.header.render();
|
||||
}, [title]);
|
||||
}
|
||||
// return <>MD</>
|
||||
|
||||
return (
|
||||
<div
|
||||
className={cx(
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
import { BreadItem } from "lib/comps/custom/Breadcrumb";
|
||||
import { fetchLinkParams, parseLink } from "lib/utils/fetch-link-params";
|
||||
import { MDLocal } from "./typings";
|
||||
import { BreadItem } from "lib/comps/custom/Breadcrumb";
|
||||
|
||||
export const masterDetailParseHash = (md: MDLocal) => {
|
||||
let raw_hash = decodeURIComponent(location.hash);
|
||||
|
|
@ -8,7 +8,6 @@ export const masterDetailParseHash = (md: MDLocal) => {
|
|||
md.params.hash = {};
|
||||
md.params.tabs = {};
|
||||
|
||||
let has_detail = false;
|
||||
for (const h of raw_hash.split("#")) {
|
||||
if (h) {
|
||||
if (h.includes("=")) {
|
||||
|
|
@ -16,9 +15,6 @@ export const masterDetailParseHash = (md: MDLocal) => {
|
|||
if (tab_name && tab_val) {
|
||||
md.params.hash[tab_name] = tab_val;
|
||||
}
|
||||
if (tab_name === md.name) {
|
||||
has_detail = true;
|
||||
}
|
||||
} else if (h.includes("~")) {
|
||||
const [tab_name, tab_val] = h.split("~");
|
||||
if (tab_name && tab_val) {
|
||||
|
|
@ -28,10 +24,6 @@ export const masterDetailParseHash = (md: MDLocal) => {
|
|||
}
|
||||
}
|
||||
|
||||
if (!has_detail) {
|
||||
md.selected = null;
|
||||
}
|
||||
|
||||
md.params.links = md.params.links.filter((e) => e);
|
||||
|
||||
const parsed_link = parseLink();
|
||||
|
|
@ -77,15 +69,9 @@ export const masterDetailApplyParams = (md: MDLocal) => {
|
|||
delete md.params.hash[md.name];
|
||||
}
|
||||
|
||||
let has_detail = false;
|
||||
for (const [k, v] of Object.entries(md.params.hash)) {
|
||||
if (k === md.name) {
|
||||
has_detail = true;
|
||||
}
|
||||
|
||||
hash += `#${k}=${v}`;
|
||||
}
|
||||
|
||||
for (const [k, v] of Object.entries(md.params.tabs)) {
|
||||
hash += `#${k}~${v}`;
|
||||
}
|
||||
|
|
@ -93,20 +79,15 @@ export const masterDetailApplyParams = (md: MDLocal) => {
|
|||
if (!isEditor) {
|
||||
location.hash = hash;
|
||||
}
|
||||
|
||||
if(!isEditor){
|
||||
if(md.props.tab_mode === "v-tab" || md.props.tab_mode === "h-tab"){
|
||||
try{
|
||||
if (
|
||||
row &&
|
||||
md?.childs?.form?.fm &&
|
||||
md?.childs?.form?.fm?.status === "ready" &&
|
||||
md.selected?.id
|
||||
) {
|
||||
if(row && md?.childs?.form?.fm && md?.childs?.form?.fm?.status === "ready" && md.selected?.id){
|
||||
md.childs.form.fm.reload();
|
||||
// console.log("MASUK???")
|
||||
}
|
||||
} catch (ex) {}
|
||||
}catch(ex){
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
|
|||
Loading…
Reference in New Issue