Fix 'Send test' not reflecting campaign body on first page load

This commit is contained in:
Kailash Nadh 2020-10-17 23:38:29 +05:30
parent 13aac1af28
commit 50e488fc01
2 changed files with 14 additions and 1 deletions

View File

@ -118,6 +118,7 @@ export default {
isPreviewing: false, isPreviewing: false,
isMediaVisible: false, isMediaVisible: false,
isEditorFullscreen: false, isEditorFullscreen: false,
isReady: false,
form: { form: {
body: '', body: '',
format: this.contentType, format: this.contentType,
@ -195,6 +196,8 @@ export default {
}, },
onEditorReady() { onEditorReady() {
this.isReady = true;
// Hack to focus the editor on page load. // Hack to focus the editor on page load.
this.$nextTick(() => { this.$nextTick(() => {
window.setTimeout(() => this.$refs.quill.quill.focus(), 100); window.setTimeout(() => this.$refs.quill.quill.focus(), 100);
@ -202,6 +205,10 @@ export default {
}, },
onEditorChange() { onEditorChange() {
if (!this.isReady) {
return;
}
// The parent's v-model gets { contentType, body }. // The parent's v-model gets { contentType, body }.
this.$emit('input', { contentType: this.form.format, body: this.form.body }); this.$emit('input', { contentType: this.form.format, body: this.form.body });
}, },

View File

@ -198,7 +198,13 @@ export default Vue.extend({
getCampaign(id) { getCampaign(id) {
return this.$api.getCampaign(id).then((data) => { return this.$api.getCampaign(id).then((data) => {
this.data = data; this.data = data;
this.form = { ...this.form, ...data }; this.form = {
...this.form,
...data,
// The structure that is populated by editor input event.
content: { contentType: data.contentType, body: data.body },
};
if (data.sendAt !== null) { if (data.sendAt !== null) {
this.form.sendLater = true; this.form.sendLater = true;