-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpage-builder.ts
65 lines (59 loc) · 2.19 KB
/
page-builder.ts
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
/*
* Copyright (c) 2023. Selldone® Business OS™
*
* Author: M.Pajuhaan
* Web: https://selldone.com
* ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
*
* All rights reserved. In the weave of time, where traditions and innovations intermingle, this content was crafted.
* From the essence of thought, through the corridors of creativity, each word, and sentiment has been molded.
* Not just to exist, but to inspire. Like an artist's stroke or a sculptor's chisel, every nuance is deliberate.
* Our journey is not just about reaching a destination, but about creating a masterpiece.
* Tread carefully, for you're treading on dreams.
*/
import {App} from "vue";
import Builder, {builder} from "./Builder";
import "./styles/page-builder.scss";
import {isFunction} from "lodash-es";
import {Page} from "@selldone/core-js/models/shop/page/page.model";
export function SetupPageBuilder(app: App, options: Partial<builder.IOptions>) {
console.log("⚽ 1. Setup Page builder", options);
if (!options)
throw new Error("Options are not set in the setup page builder!");
if (options.mode === "view") {
// install the builder
app.use(Builder, options);
} else if (options.mode === "edit") {
if (!options.server) {
throw new Error(
"In the edit mode options should have 'server' property! Correct it in SetupPageBuilder(...,here)",
);
}
// Use the uploadImageUrl function if provided
if (
!options.server?.uploadImageUrl ||
!isFunction(options.server?.uploadImageUrl)
) {
console.error(
"Edit mode. Invalid uploadImageUrl function in SetupPageBuilder(...,here)!",
);
} else {
const test = options.server?.uploadImageUrl("page", {
id: 0,
shop_id: 0,
} as Page);
if (!test) {
console.error(
"Invalid uploadImageUrl! Generated test upload image path is " + test,
);
}
}
// install the builder
app.use(Builder, options);
} else {
console.error(
"Invalid page builder initial mode! Use 'edit' or 'view'!",
options?.mode,
);
}
}