From 5bfbe15c24378c86c7c42bc30c963e0e9b715e37 Mon Sep 17 00:00:00 2001 From: Kailash Nadh Date: Sun, 31 Oct 2021 11:49:43 +0530 Subject: [PATCH] Fix campaign template preview not working without saving. Closes #553. --- cmd/campaigns.go | 8 ++++---- frontend/src/components/CampaignPreview.vue | 5 +++++ frontend/src/components/Editor.vue | 5 +++++ frontend/src/views/Campaign.vue | 1 + queries.sql | 2 +- 5 files changed, 16 insertions(+), 5 deletions(-) diff --git a/cmd/campaigns.go b/cmd/campaigns.go index f2a024e..a48cc2a 100644 --- a/cmd/campaigns.go +++ b/cmd/campaigns.go @@ -160,8 +160,9 @@ func handleGetCampaigns(c echo.Context) error { // handlePreviewCampaign renders the HTML preview of a campaign body. func handlePreviewCampaign(c echo.Context) error { var ( - app = c.Get("app").(*App) - id, _ = strconv.Atoi(c.Param("id")) + app = c.Get("app").(*App) + id, _ = strconv.Atoi(c.Param("id")) + tplID, _ = strconv.Atoi(c.FormValue("template_id")) ) if id < 1 { @@ -169,8 +170,7 @@ func handlePreviewCampaign(c echo.Context) error { } var camp models.Campaign - err := app.queries.GetCampaignForPreview.Get(&camp, id) - if err != nil { + if err := app.queries.GetCampaignForPreview.Get(&camp, id, tplID); err != nil { if err == sql.ErrNoRows { return echo.NewHTTPError(http.StatusBadRequest, app.i18n.Ts("globals.messages.notFound", "name", "{globals.terms.campaign}")) diff --git a/frontend/src/components/CampaignPreview.vue b/frontend/src/components/CampaignPreview.vue index b6a4446..71ded77 100644 --- a/frontend/src/components/CampaignPreview.vue +++ b/frontend/src/components/CampaignPreview.vue @@ -11,6 +11,7 @@