Add missing 'opt-in' campaign feature to the new UI

This commit is contained in:
Kailash Nadh 2020-08-01 15:31:13 +05:30
parent 818da1bb4d
commit 13a252a7b3
3 changed files with 25 additions and 12 deletions

View File

@ -638,13 +638,9 @@ func makeOptinCampaignMessage(o campaignReq, app *App) (campaignReq, error) {
} }
// Construct the opt-in URL with list IDs. // Construct the opt-in URL with list IDs.
var ( listIDs := url.Values{}
listIDs = url.Values{}
listNames = make([]string, 0, len(lists))
)
for _, l := range lists { for _, l := range lists {
listIDs.Add("l", l.UUID) listIDs.Add("l", l.UUID)
listNames = append(listNames, l.Name)
} }
// optinURLFunc := template.URL("{{ OptinURL }}?" + listIDs.Encode()) // optinURLFunc := template.URL("{{ OptinURL }}?" + listIDs.Encode())
optinURLAttr := template.HTMLAttr(fmt.Sprintf(`href="{{ OptinURL }}%s"`, 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.") "Error compiling opt-in campaign template.")
} }
o.Name = "Opt-in campaign " + strings.Join(listNames, ", ")
o.Subject = "Confirm your subscription(s)"
o.Body = b.String() o.Body = b.String()
return o, nil return o, nil
} }

View File

@ -45,6 +45,9 @@
<b-table-column field="name" label="Name" sortable width="25%"> <b-table-column field="name" label="Name" sortable width="25%">
<div> <div>
<p> <p>
<b-tag v-if="props.row.type !== 'regular'" class="is-small">
{{ props.row.type }}
</b-tag>
<router-link :to="{ name: 'campaign', params: { 'id': props.row.id }}"> <router-link :to="{ name: 'campaign', params: { 'id': props.row.id }}">
{{ props.row.name }}</router-link> {{ props.row.name }}</router-link>
</p> </p>

View File

@ -36,14 +36,13 @@
{{ ' ' }} {{ ' ' }}
{{ props.row.optin }} {{ props.row.optin }}
</b-tag>{{ ' ' }} </b-tag>{{ ' ' }}
<router-link :to="{name: 'campaign', params: {id: 'new'}, <a v-if="props.row.optin === 'double'" class="is-size-7 send-optin"
query: {type: 'optin', 'list_id': props.row.id}}" href="#" @click="$utils.confirm(null, () => createOptinCampaign(props.row))">
v-if="props.row.optin === 'double'" class="is-size-7 send-optin">
<b-tooltip label="Send opt-in campaign" type="is-dark"> <b-tooltip label="Send opt-in campaign" type="is-dark">
<b-icon icon="rocket-launch-outline" size="is-small" /> <b-icon icon="rocket-launch-outline" size="is-small" />
Send opt-in campaign Send opt-in campaign
</b-tooltip> </b-tooltip>
</router-link> </a>
</div> </div>
</b-table-column> </b-table-column>
@ -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: { computed: {
...mapState(['lists', 'loading']), ...mapState(['lists', 'serverConfig', 'loading']),
}, },
mounted() { mounted() {