From 13a252a7b33bc4a290e6809ffd13872c233be13e Mon Sep 17 00:00:00 2001 From: Kailash Nadh Date: Sat, 1 Aug 2020 15:31:13 +0530 Subject: [PATCH] Add missing 'opt-in' campaign feature to the new UI --- campaigns.go | 8 +------- frontend/src/views/Campaigns.vue | 3 +++ frontend/src/views/Lists.vue | 26 +++++++++++++++++++++----- 3 files changed, 25 insertions(+), 12 deletions(-) diff --git a/campaigns.go b/campaigns.go index ceb4bd3..351c037 100644 --- a/campaigns.go +++ b/campaigns.go @@ -638,13 +638,9 @@ func makeOptinCampaignMessage(o campaignReq, app *App) (campaignReq, error) { } // Construct the opt-in URL with list IDs. - var ( - listIDs = url.Values{} - listNames = make([]string, 0, len(lists)) - ) + listIDs := url.Values{} for _, l := range lists { listIDs.Add("l", l.UUID) - listNames = append(listNames, l.Name) } // optinURLFunc := template.URL("{{ OptinURL }}?" + listIDs.Encode()) optinURLAttr := template.HTMLAttr(fmt.Sprintf(`href="{{ OptinURL }}%s"`, listIDs.Encode())) @@ -660,8 +656,6 @@ func makeOptinCampaignMessage(o campaignReq, app *App) (campaignReq, error) { "Error compiling opt-in campaign template.") } - o.Name = "Opt-in campaign " + strings.Join(listNames, ", ") - o.Subject = "Confirm your subscription(s)" o.Body = b.String() return o, nil } diff --git a/frontend/src/views/Campaigns.vue b/frontend/src/views/Campaigns.vue index 74a95d6..c568a45 100644 --- a/frontend/src/views/Campaigns.vue +++ b/frontend/src/views/Campaigns.vue @@ -45,6 +45,9 @@

+ + {{ props.row.type }} + {{ props.row.name }}

diff --git a/frontend/src/views/Lists.vue b/frontend/src/views/Lists.vue index 0a6c960..7d8e124 100644 --- a/frontend/src/views/Lists.vue +++ b/frontend/src/views/Lists.vue @@ -36,14 +36,13 @@ {{ ' ' }} {{ props.row.optin }} {{ ' ' }} - + Send opt-in campaign - +
@@ -149,10 +148,27 @@ export default Vue.extend({ }, ); }, + + createOptinCampaign(list) { + const data = { + name: `Opt-in to ${list.name}`, + subject: `Confirm subscription(s) ${list.name}`, + lists: [list.id], + from_email: this.serverConfig.fromEmail, + content_type: 'richtext', + messenger: 'email', + type: 'optin', + }; + + this.$api.createCampaign(data).then((d) => { + this.$router.push({ name: 'campaign', hash: '#content', params: { id: d.id } }); + }); + return false; + }, }, computed: { - ...mapState(['lists', 'loading']), + ...mapState(['lists', 'serverConfig', 'loading']), }, mounted() {