-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add helper button on campaign UI to fill default archive meta JSON.
- Loading branch information
Showing
1 changed file
with
23 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 protected]", "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 protected]", "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(); | ||
|