Fix redirect after new campaign creation

This commit is contained in:
Kailash Nadh 2020-07-05 14:08:30 +05:30
parent 1bcd350b20
commit f2030a1768
3 changed files with 23 additions and 11 deletions

View File

@ -86,7 +86,9 @@ export default {
mounted() { mounted() {
setTimeout(() => { setTimeout(() => {
this.$refs.form.submit(); if (this.$refs.form) {
this.$refs.form.submit();
}
}, 100); }, 100);
}, },
}; };

View File

@ -29,6 +29,7 @@
:disabled="disabled" :disabled="disabled"
placeholder="Content here" placeholder="Content here"
@change="onEditorChange($event)" @change="onEditorChange($event)"
@ready="onEditorReady($event)"
/> />
<!-- raw html editor //--> <!-- raw html editor //-->
@ -142,6 +143,13 @@ export default {
); );
}, },
onEditorReady() {
// Hack to focus the editor on page load.
this.$nextTick(() => {
window.setTimeout(() => this.$refs.quill.quill.focus(), 100);
});
},
onEditorChange() { onEditorChange() {
// 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 });
@ -156,8 +164,7 @@ export default {
}, },
onMediaSelect(m) { onMediaSelect(m) {
this.$refs.quill.quill this.$refs.quill.quill.insertEmbed(10, 'image', m.uri);
.insertEmbed(10, 'image', m.uri);
}, },
}, },

View File

@ -181,7 +181,7 @@ export default Vue.extend({
}, },
getCampaign(id) { getCampaign(id) {
this.$api.getCampaign(id).then((r) => { return this.$api.getCampaign(id).then((r) => {
this.data = r.data; this.data = r.data;
this.form = { ...this.form, ...r.data }; this.form = { ...this.form, ...r.data };
@ -237,12 +237,12 @@ export default Vue.extend({
}; };
this.$api.createCampaign(data).then((r) => { this.$api.createCampaign(data).then((r) => {
this.$router.push({ name: 'campaign', params: { id: r.data.id } }); this.$router.push({ name: 'campaign', hash: '#content', params: { id: r.data.id } });
this.data = r.data; // this.data = r.data;
this.isEditing = true; // this.isEditing = true;
this.isNew = false; // this.isNew = false;
this.activeTab = 1; // this.activeTab = 1;
}); });
return false; return false;
}, },
@ -326,7 +326,6 @@ export default Vue.extend({
mounted() { mounted() {
const { id } = this.$route.params; const { id } = this.$route.params;
// New campaign. // New campaign.
if (id === 'new') { if (id === 'new') {
this.isNew = true; this.isNew = true;
@ -355,7 +354,11 @@ export default Vue.extend({
// Fetch campaign. // Fetch campaign.
if (this.isEditing) { if (this.isEditing) {
this.getCampaign(id); this.getCampaign(id).then(() => {
if (this.$route.hash === '#content') {
this.activeTab = 1;
}
});
} }
this.$nextTick(() => { this.$nextTick(() => {