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() {
setTimeout(() => {
this.$refs.form.submit();
if (this.$refs.form) {
this.$refs.form.submit();
}
}, 100);
},
};

View File

@ -29,6 +29,7 @@
:disabled="disabled"
placeholder="Content here"
@change="onEditorChange($event)"
@ready="onEditorReady($event)"
/>
<!-- 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() {
// The parent's v-model gets { contentType, body }.
this.$emit('input', { contentType: this.form.format, body: this.form.body });
@ -156,8 +164,7 @@ export default {
},
onMediaSelect(m) {
this.$refs.quill.quill
.insertEmbed(10, 'image', m.uri);
this.$refs.quill.quill.insertEmbed(10, 'image', m.uri);
},
},

View File

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