Fix campaign template preview not working without saving. Closes #553.
This commit is contained in:
parent
644f98fe60
commit
5bfbe15c24
5 changed files with 16 additions and 5 deletions
|
@ -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}"))
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
<section expanded class="modal-card-body preview">
|
||||
<b-loading :active="isLoading" :is-full-page="false"></b-loading>
|
||||
<form v-if="body" method="post" :action="previewURL" target="iframe" ref="form">
|
||||
<input type="hidden" name="template_id" :value="templateId" />
|
||||
<input type="hidden" name="content_type" :value="contentType" />
|
||||
<input type="hidden" name="body" :value="body" />
|
||||
</form>
|
||||
|
@ -44,6 +45,10 @@ export default {
|
|||
type: String,
|
||||
body: String,
|
||||
contentType: String,
|
||||
templateId: {
|
||||
type: Number,
|
||||
default: 0,
|
||||
},
|
||||
},
|
||||
|
||||
data() {
|
||||
|
|
|
@ -77,6 +77,7 @@
|
|||
:id="id"
|
||||
:title="title"
|
||||
:contentType="form.format"
|
||||
:templateId="templateId"
|
||||
:body="form.body"></campaign-preview>
|
||||
|
||||
<!-- image picker -->
|
||||
|
@ -156,6 +157,10 @@ export default {
|
|||
title: String,
|
||||
body: String,
|
||||
contentType: String,
|
||||
templateId: {
|
||||
type: Number,
|
||||
default: 0,
|
||||
},
|
||||
disabled: Boolean,
|
||||
},
|
||||
|
||||
|
|
|
@ -160,6 +160,7 @@
|
|||
v-model="form.content"
|
||||
:id="data.id"
|
||||
:title="data.name"
|
||||
:templateId="form.templateId"
|
||||
:contentType="data.contentType"
|
||||
:body="data.body"
|
||||
:disabled="!canEdit"
|
||||
|
|
|
@ -495,7 +495,7 @@ SELECT campaigns.*, COALESCE(templates.body, (SELECT body FROM templates WHERE i
|
|||
) l
|
||||
) AS lists
|
||||
FROM campaigns
|
||||
LEFT JOIN templates ON (templates.id = campaigns.template_id)
|
||||
LEFT JOIN templates ON (templates.id = (CASE WHEN $2=0 THEN campaigns.template_id ELSE $2 END))
|
||||
WHERE campaigns.id = $1;
|
||||
|
||||
-- name: get-campaign-status
|
||||
|
|
Loading…
Reference in a new issue