fix layout
This commit is contained in:
parent
f9b2aad39d
commit
21b55c165c
|
|
@ -1,8 +1,9 @@
|
||||||
import { validate } from "uuid";
|
import { validate } from "uuid";
|
||||||
import { ESite } from "../../../../web/src/nova/ed/logic/ed-global";
|
import { ESite } from "../../../../web/src/nova/ed/logic/ed-global";
|
||||||
|
import { IRoot } from "../../../../web/src/utils/types/root";
|
||||||
import { SAction } from "../actions";
|
import { SAction } from "../actions";
|
||||||
import { SyncConnection } from "../type";
|
|
||||||
import { activity } from "../entity/activity";
|
import { activity } from "../entity/activity";
|
||||||
|
import { SyncConnection } from "../type";
|
||||||
|
|
||||||
export const site_load: SAction["site"]["load"] = async function (
|
export const site_load: SAction["site"]["load"] = async function (
|
||||||
this: SyncConnection,
|
this: SyncConnection,
|
||||||
|
|
@ -20,13 +21,24 @@ export const site_load: SAction["site"]["load"] = async function (
|
||||||
|
|
||||||
activity.site.room(site.id).join({ ws: this.ws });
|
activity.site.room(site.id).join({ ws: this.ws });
|
||||||
|
|
||||||
|
let layout = undefined;
|
||||||
|
const _layout = await db.page.findFirst({
|
||||||
|
where: {
|
||||||
|
id_site: id,
|
||||||
|
is_deleted: false,
|
||||||
|
is_default_layout: true,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
if (_layout) layout = _layout.content_tree as IRoot;
|
||||||
|
|
||||||
return {
|
return {
|
||||||
id: site.id,
|
id: site.id,
|
||||||
|
name: site.name,
|
||||||
config: config as ESite["config"],
|
config: config as ESite["config"],
|
||||||
domain: site.domain,
|
domain: site.domain,
|
||||||
js: site.js || "",
|
js: site.js || "",
|
||||||
js_compiled: site.js_compiled || "",
|
js_compiled: site.js_compiled || "",
|
||||||
name: site.name,
|
layout,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2,12 +2,12 @@ import { NodeModel } from "@minoru/react-dnd-treeview";
|
||||||
import { FC, ReactElement } from "react";
|
import { FC, ReactElement } from "react";
|
||||||
import { deepClone } from "web-utils";
|
import { deepClone } from "web-utils";
|
||||||
import { SAction } from "../../../../../srv/ws/sync/actions";
|
import { SAction } from "../../../../../srv/ws/sync/actions";
|
||||||
|
import { parseJs } from "../../../../../srv/ws/sync/editor/parser/parse-js";
|
||||||
import { clientStartSync } from "../../../utils/sync/ws-client";
|
import { clientStartSync } from "../../../utils/sync/ws-client";
|
||||||
import { IItem, MItem } from "../../../utils/types/item";
|
import { IItem, MItem } from "../../../utils/types/item";
|
||||||
import { DComp, DPage } from "../../../utils/types/root";
|
import { DComp, DPage, IRoot } from "../../../utils/types/root";
|
||||||
import { ISection } from "../../../utils/types/section";
|
import { ISection } from "../../../utils/types/section";
|
||||||
import { IText, MText } from "../../../utils/types/text";
|
import { IText, MText } from "../../../utils/types/text";
|
||||||
import { parseJs } from "../../../../../srv/ws/sync/editor/parser/parse-js";
|
|
||||||
|
|
||||||
export const EmptySite = {
|
export const EmptySite = {
|
||||||
id: "",
|
id: "",
|
||||||
|
|
@ -16,6 +16,7 @@ export const EmptySite = {
|
||||||
config: { api_url: "" },
|
config: { api_url: "" },
|
||||||
js: "",
|
js: "",
|
||||||
js_compiled: "",
|
js_compiled: "",
|
||||||
|
layout: undefined as undefined | IRoot,
|
||||||
};
|
};
|
||||||
|
|
||||||
export type ESite = typeof EmptySite;
|
export type ESite = typeof EmptySite;
|
||||||
|
|
|
||||||
|
|
@ -12,6 +12,7 @@ export const EdMain = () => {
|
||||||
{!p.page.building && (
|
{!p.page.building && (
|
||||||
<View
|
<View
|
||||||
mode={p.mode}
|
mode={p.mode}
|
||||||
|
layout={{ show: false, root: p.site.layout }}
|
||||||
isEditor={true}
|
isEditor={true}
|
||||||
api_url={p.site.config.api_url}
|
api_url={p.site.config.api_url}
|
||||||
component={{
|
component={{
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,13 @@
|
||||||
import { ReactElement } from "react";
|
import { ReactElement } from "react";
|
||||||
import { IContent } from "../../../utils/types/general";
|
import { IContent } from "../../../utils/types/general";
|
||||||
import { EdMeta, PG } from "../../ed/logic/ed-global";
|
import { EdMeta, PG } from "../../ed/logic/ed-global";
|
||||||
|
import { IRoot } from "../../../utils/types/root";
|
||||||
|
|
||||||
export const ViewGlobal = {
|
export const ViewGlobal = {
|
||||||
mode: "" as "desktop" | "mobile",
|
mode: "" as "desktop" | "mobile",
|
||||||
status: "init" as "init" | "load-code" | "loading-code" | "ready" | "rebuild",
|
status: "init" as "init" | "load-code" | "loading-code" | "ready" | "rebuild",
|
||||||
current: { site_id: "", page_id: "" },
|
current: { site_id: "", page_id: "" },
|
||||||
|
layout: { show: false, root: undefined as void | IRoot },
|
||||||
meta: {} as Record<string, EdMeta>,
|
meta: {} as Record<string, EdMeta>,
|
||||||
entry: [] as string[],
|
entry: [] as string[],
|
||||||
bodyCache: null as null | ReactElement,
|
bodyCache: null as null | ReactElement,
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,7 @@ import { vLoadCode } from "./logic/load-code";
|
||||||
import { VLoad, VLoadComponent } from "./logic/types";
|
import { VLoad, VLoadComponent } from "./logic/types";
|
||||||
import { VEntry } from "./render/entry";
|
import { VEntry } from "./render/entry";
|
||||||
import { ErrorBox } from "./render/meta/script/error-box";
|
import { ErrorBox } from "./render/meta/script/error-box";
|
||||||
|
import { IRoot } from "../../utils/types/root";
|
||||||
|
|
||||||
type ViewProp = {
|
type ViewProp = {
|
||||||
load: VLoad;
|
load: VLoad;
|
||||||
|
|
@ -16,6 +17,7 @@ type ViewProp = {
|
||||||
page_id: string;
|
page_id: string;
|
||||||
api_url: string;
|
api_url: string;
|
||||||
mode: "desktop" | "mobile";
|
mode: "desktop" | "mobile";
|
||||||
|
layout?: { root: undefined | IRoot; show: boolean };
|
||||||
isEditor?: boolean;
|
isEditor?: boolean;
|
||||||
bind?: (arg: { render: () => void }) => void;
|
bind?: (arg: { render: () => void }) => void;
|
||||||
hidden?: (item: IContent) => boolean;
|
hidden?: (item: IContent) => boolean;
|
||||||
|
|
@ -36,6 +38,7 @@ export const View: FC<ViewProp> = (props) => {
|
||||||
const BoxedView: FC<ViewProp> = ({
|
const BoxedView: FC<ViewProp> = ({
|
||||||
load,
|
load,
|
||||||
site_id,
|
site_id,
|
||||||
|
layout,
|
||||||
page_id,
|
page_id,
|
||||||
bind,
|
bind,
|
||||||
hover,
|
hover,
|
||||||
|
|
@ -55,6 +58,8 @@ const BoxedView: FC<ViewProp> = ({
|
||||||
if (v.current.page_id !== page_id || v.current.site_id !== site_id) {
|
if (v.current.page_id !== page_id || v.current.site_id !== site_id) {
|
||||||
v.status = "init";
|
v.status = "init";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
v.layout = layout ? layout : { show: false, root: undefined };
|
||||||
v.component.map = component.map;
|
v.component.map = component.map;
|
||||||
v.component.load = component.load;
|
v.component.load = component.load;
|
||||||
|
|
||||||
|
|
@ -96,4 +101,3 @@ const BoxedView: FC<ViewProp> = ({
|
||||||
|
|
||||||
return <div className="flex flex-1 flex-col relative">{v.bodyCache}</div>;
|
return <div className="flex flex-1 flex-col relative">{v.bodyCache}</div>;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue