Skip to content

Commit

Permalink
fix: Template preview modal
Browse files Browse the repository at this point in the history
  • Loading branch information
surajshetty3416 committed Apr 4, 2024
1 parent aa7fd30 commit 358975f
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
2 changes: 1 addition & 1 deletion frontend/src/components/TemplatePagePreview.vue
Expand Up @@ -11,7 +11,7 @@
<span class="inline-block max-w-[160px] py-2 text-sm text-gray-700 dark:text-zinc-200">
<div class="flex items-center gap-1">
<p class="truncate">
{{ page.page_title || page.page_name }}
{{ page.template_name || page.page_title || page.page_name }}
</p>
</div>
</span>
Expand Down
1 change: 1 addition & 0 deletions frontend/src/data/webPage.ts
Expand Up @@ -39,6 +39,7 @@ const templates = createListResource({
"dynamic_route",
"modified",
"is_template",
"template_name",
"owner",
],
filters: {
Expand Down
10 changes: 7 additions & 3 deletions frontend/src/store.ts
Expand Up @@ -90,7 +90,7 @@ const useStore = defineStore("store", {
getRootBlock() {
return getBlockInstance(getBlockTemplate("body"));
},
getPageData() {
getPageBlocks() {
return [this.activeCanvas?.getFirstBlock()];
},
async setPage(pageName: string, resetCanvas = true) {
Expand All @@ -114,7 +114,11 @@ const useStore = defineStore("store", {
if (!Array.isArray(blocks)) {
this.pushBlocks([blocks]);
}
this.pageBlocks = [getBlockInstance(blocks[0])];
if (blocks.length === 0) {
this.pageBlocks = [getBlockInstance(getBlockTemplate("body"))];
} else {
this.pageBlocks = [getBlockInstance(blocks[0])];
}
this.pageName = page.page_name as string;
this.route = page.route || "/" + this.pageName.toLowerCase().replace(/ /g, "-");
this.selectedPage = page.name;
Expand Down Expand Up @@ -298,7 +302,7 @@ const useStore = defineStore("store", {
window.open(`/${route}`, "builder-preview");
},
savePage() {
this.pageBlocks = this.getPageData() as Block[];
this.pageBlocks = this.getPageBlocks() as Block[];
const pageData = JSON.stringify(this.pageBlocks);

const args = {
Expand Down

0 comments on commit 358975f

Please sign in to comment.