Skip to content

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

Fix broken 'send campaign' shortcut on the Lists UI

Kailash Nadhce108c848736
diff --git a/frontend/src/views/Campaign.vue b/frontend/src/views/Campaign.vue
index ba5ac229..279ff20b 100644
--- a/frontend/src/views/Campaign.vue
+++ b/frontend/src/views/Campaign.vue
@@ -170,6 +170,9 @@ export default Vue.extend({
data: {},
+ // IDs from ?list_id query param.
+ selListIDs: [],
+
// Binds form input values.
form: {
name: '',
@@ -333,6 +336,20 @@ export default Vue.extend({
canStart() {
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() {
@@ -341,6 +358,18 @@ export default Vue.extend({
// New campaign.
if (id === 'new') {
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 {
const intID = parseInt(id, 10);
if (intID <= 0 || Number.isNaN(intID)) {
diff --git a/frontend/src/views/Lists.vue b/frontend/src/views/Lists.vue
index f9e9639b..45b70a0b 100644
--- a/frontend/src/views/Lists.vue
+++ b/frontend/src/views/Lists.vue
@@ -67,7 +67,7 @@
<b-table-column class="actions" align="right">
<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-icon icon="rocket-launch-outline" size="is-small" />
</b-tooltip>