Skip to content

High performance, self-hosted, newsletter and mailing list manager with a modern dashboard. Single binary app.

Fix `clone campaign` by fetching campaign body on clone.

Kailash Nadh445d7e53a4ad
diff --git a/frontend/src/components/VisualEditor.vue b/frontend/src/components/VisualEditor.vue
index 0dd019c9..57b442c7 100644
--- a/frontend/src/components/VisualEditor.vue
+++ b/frontend/src/components/VisualEditor.vue
@@ -68,9 +68,10 @@ export default {
this.$emit('change', { source: JSON.stringify(data), body });
},
});
- } else {
- // setDocument appends the content to the container. Clear it first.
- // em.resetDocument();
+ }
+
+ if (!source) {
+ return;
}
// setDocument() will trigger onChange() that produces both bodySource and body (HTML).
diff --git a/frontend/src/views/Campaign.vue b/frontend/src/views/Campaign.vue
index 9fea8372..b776f07b 100644
--- a/frontend/src/views/Campaign.vue
+++ b/frontend/src/views/Campaign.vue
@@ -102,7 +102,7 @@
</div>
<div class="column is-6">
<b-field :label="$t('campaigns.format')" label-position="on-border" class="mr-4 mb-0">
- <b-select v-model="form.content.contentType" :disabled="disabled || isEditing" value="richtext"
+ <b-select v-model="form.content.contentType" :disabled="!canEdit || isEditing" value="richtext"
expanded>
<option v-for="(name, f) in contentTypes" :key="f" name="format" :value="f"
:data-cy="`check-${f}`">
diff --git a/frontend/src/views/Campaigns.vue b/frontend/src/views/Campaigns.vue
index 83f460a7..759f7646 100644
--- a/frontend/src/views/Campaigns.vue
+++ b/frontend/src/views/Campaigns.vue
@@ -404,7 +404,15 @@ export default Vue.extend({
});
},
- cloneCampaign(name, c) {
+ async cloneCampaign(name, c) {
+ // Fetch the template body from the server.
+ let body = '';
+ let bodySource = null;
+ await this.$api.getCampaign(c.id).then((data) => {
+ body = data.body;
+ bodySource = data.bodySource;
+ });
+
const now = this.$utils.getDate();
const sendLater = !!c.sendAt;
let sendAt = null;
@@ -422,8 +430,8 @@ export default Vue.extend({
messenger: c.messenger,
tags: c.tags,
template_id: c.templateId,
- body: c.body,
- body_source: c.bodySource,
+ body,
+ body_source: bodySource,
altbody: c.altbody,
headers: c.headers,
send_later: sendLater,