forked from frappe/builder
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuilderStore.ts
More file actions
79 lines (76 loc) · 2.28 KB
/
builderStore.ts
File metadata and controls
79 lines (76 loc) · 2.28 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
import BlockContextMenu from "@/components/BlockContextMenu.vue";
import { builderSettings } from "@/data/builderSettings";
import { BuilderSettings } from "@/types/Builder/BuilderSettings";
import RealTimeHandler from "@/utils/realtimeHandler";
import { useStorage } from "@vueuse/core";
import { defineStore } from "pinia";
import { toast } from "vue-sonner";
import type Dialog from "../components/Controls/Dialog.vue";
import BlockLayers from "./components/BlockLayers.vue";
declare global {
interface Window {
is_fc_site?: boolean | string;
}
}
const useBuilderStore = defineStore("builderStore", {
state: () => ({
activeLayers: <InstanceType<typeof BlockLayers> | null>null,
appDialogs: <(typeof Dialog)[]>[],
blockContextMenu: <InstanceType<typeof BlockContextMenu> | null>null,
propertyFilter: <string | null>null,
mode: <BuilderMode>"select", // check setEvents in BuilderCanvas for usage
lastMode: <BuilderMode>"select",
autoSave: true,
showSearchBlock: false,
builderLayout: {
rightPanelWidth: 275,
leftPanelWidth: 250,
scriptEditorHeight: 300,
optionsPanelWidth: 57,
},
leftPanelActiveTab: <LeftSidebarTabOption>"Layers",
rightPanelActiveTab: <RightSidebarTabOption>"Properties",
showDashboardSidebar: useStorage("showDashboardSidebar", true),
showRightPanel: <boolean>true,
showLeftPanel: <boolean>true,
showHTMLDialog: false,
showDataScriptDialog: false,
realtime: new RealTimeHandler(),
viewers: <UserInfo[]>[],
isFCSite: window.is_fc_site === "{{ is_fc_site }}" ? false : window.is_fc_site,
activeFolder: useStorage("activeFolder", ""),
}),
actions: {
setHomePage(route: string) {
return builderSettings.setValue
.submit({
home_page: route,
})
.then(() => {
toast.success("Homepage set successfully");
});
},
unsetHomePage() {
return builderSettings.setValue
.submit({
home_page: "",
})
.then(() => {
toast.success("This page will no longer be the homepage");
});
},
updateBuilderSettings(key: keyof BuilderSettings, value: any) {
return builderSettings.setValue
.submit({
[key]: value,
})
.then(() => {
builderSettings.reload();
});
},
openBuilderSettings() {
window.open("/app/builder-settings", "_blank");
},
},
});
export default useBuilderStore;