Fix broken 'send campaign' shortcut on the Lists UI

This commit is contained in:
Kailash Nadh 2020-11-21 16:11:59 +05:30
parent cde0b4b42a
commit ce108c8487
2 changed files with 30 additions and 1 deletions

View File

@ -170,6 +170,9 @@ export default Vue.extend({
data: {}, data: {},
// IDs from ?list_id query param.
selListIDs: [],
// Binds form input values. // Binds form input values.
form: { form: {
name: '', name: '',
@ -333,6 +336,20 @@ export default Vue.extend({
canStart() { canStart() {
return this.data.status === 'draft' && !this.data.sendAt; return this.data.status === 'draft' && !this.data.sendAt;
}, },
selectedLists() {
if (this.selListIDs.length === 0 || !this.lists.results) {
return [];
}
return this.lists.results.filter((l) => this.selListIDs.indexOf(l.id) > -1);
},
},
watch: {
selectedLists() {
this.form.lists = this.selectedLists;
},
}, },
mounted() { mounted() {
@ -341,6 +358,18 @@ export default Vue.extend({
// New campaign. // New campaign.
if (id === 'new') { if (id === 'new') {
this.isNew = true; this.isNew = true;
if (this.$route.query.list_id) {
// Multiple list_id query params.
let strIds = [];
if (typeof this.$route.query.list_id === 'object') {
strIds = this.$route.query.list_id;
} else {
strIds = [this.$route.query.list_id];
}
this.selListIDs = strIds.map((v) => parseInt(v, 10));
}
} else { } else {
const intID = parseInt(id, 10); const intID = parseInt(id, 10);
if (intID <= 0 || Number.isNaN(intID)) { if (intID <= 0 || Number.isNaN(intID)) {

View File

@ -67,7 +67,7 @@
<b-table-column class="actions" align="right"> <b-table-column class="actions" align="right">
<div> <div>
<router-link :to="`/campaign/new?list_id=${props.row.id}`"> <router-link :to="`/campaigns/new?list_id=${props.row.id}`">
<b-tooltip label="Send campaign" type="is-dark"> <b-tooltip label="Send campaign" type="is-dark">
<b-icon icon="rocket-launch-outline" size="is-small" /> <b-icon icon="rocket-launch-outline" size="is-small" />
</b-tooltip> </b-tooltip>