Add helper button on campaign UI to fill default archive meta JSON.
This commit is contained in:
parent
c52a06728c
commit
73bb6081fc
1 changed files with 23 additions and 19 deletions
|
@ -217,16 +217,25 @@
|
|||
</div>
|
||||
</b-field>
|
||||
|
||||
<b-field :label="$tc('globals.terms.template')" label-position="on-border">
|
||||
<b-select :placeholder="$tc('globals.terms.template')" v-model="form.archiveTemplateId"
|
||||
name="template" :disabled="!canArchive || !form.archive" required>
|
||||
<template v-for="t in templates">
|
||||
<option v-if="t.type === 'campaign'"
|
||||
:value="t.id" :key="t.id">{{ t.name }}</option>
|
||||
</template>
|
||||
</b-select>
|
||||
</b-field>
|
||||
<div class="columns">
|
||||
<div class="column is-8">
|
||||
<b-field :label="$tc('globals.terms.template')" label-position="on-border">
|
||||
<b-select :placeholder="$tc('globals.terms.template')"
|
||||
v-model="form.archiveTemplateId" name="template"
|
||||
:disabled="!canArchive || !form.archive" required>
|
||||
<template v-for="t in templates">
|
||||
<option v-if="t.type === 'campaign'"
|
||||
:value="t.id" :key="t.id">{{ t.name }}</option>
|
||||
</template>
|
||||
</b-select>
|
||||
</b-field>
|
||||
</div>
|
||||
|
||||
<div class="column has-text-right">
|
||||
<a v-if="!this.form.archiveMetaStr || this.form.archiveMetaStr === '{}'"
|
||||
class="button" href="#" @click.prevent="onFillArchiveMeta">{}</a>
|
||||
</div>
|
||||
</div>
|
||||
<b-field :label="$t('campaigns.archiveMeta')"
|
||||
:message="$t('campaigns.archiveMetaHelp')" label-position="on-border">
|
||||
<b-input v-model="form.archiveMetaStr" name="archive_meta" type="textarea"
|
||||
|
@ -331,6 +340,11 @@ export default Vue.extend({
|
|||
}
|
||||
},
|
||||
|
||||
onFillArchiveMeta() {
|
||||
const archiveStr = `{"email": "email@domain.com", "name": "${this.$t('globals.fields.name')}", "attribs": {}}`;
|
||||
this.form.archiveMetaStr = this.$utils.getPref('campaign.archiveMetaStr') || JSON.stringify(JSON.parse(archiveStr), null, 4);
|
||||
},
|
||||
|
||||
onSubmit(typ) {
|
||||
// Validate custom JSON headers.
|
||||
if (this.form.headersStr && this.form.headersStr !== '[]') {
|
||||
|
@ -356,11 +370,6 @@ export default Vue.extend({
|
|||
this.form.archiveMeta = {};
|
||||
}
|
||||
|
||||
// Cache the campaign archive metadata for the next one.
|
||||
if (this.isEditing) {
|
||||
this.$utils.setPref('campaign.archiveMetaStr', this.form.archiveMetaStr);
|
||||
}
|
||||
|
||||
switch (typ) {
|
||||
case 'create':
|
||||
this.createCampaign();
|
||||
|
@ -387,11 +396,6 @@ export default Vue.extend({
|
|||
content: { contentType: data.contentType, body: data.body },
|
||||
};
|
||||
|
||||
if (this.form.archiveMetaStr === '{}') {
|
||||
const archiveStr = `{"email": "email@domain.com", "name": "${this.$t('globals.fields.name')}", "attribs": {}}`;
|
||||
this.form.archiveMetaStr = this.$utils.getPref('campaign.archiveMetaStr') || JSON.stringify(JSON.parse(archiveStr), null, 4);
|
||||
}
|
||||
|
||||
if (data.sendAt !== null) {
|
||||
this.form.sendLater = true;
|
||||
this.form.sendAtDate = dayjs(data.sendAt).toDate();
|
||||
|
|
Loading…
Reference in a new issue