diff options
author | Christoph Wurst <christoph@winzerhof-wurst.at> | 2019-04-08 16:53:53 +0300 |
---|---|---|
committer | Christoph Wurst <christoph@winzerhof-wurst.at> | 2019-04-09 12:02:53 +0300 |
commit | c1fbb530e48048f0b3594f6b0537c2d651d5ca99 (patch) | |
tree | 8596c8523b8d3f48130a8fc169a5c5095d7e9503 /src | |
parent | b1acb3019d71b94e20ffe56ac00644245b4282cf (diff) |
Add support for signatures
Signed-off-by: Christoph Wurst <christoph@winzerhof-wurst.at>
Diffstat (limited to 'src')
-rw-r--r-- | src/components/Composer.vue | 13 | ||||
-rw-r--r-- | src/components/SignatureSettings.vue | 90 | ||||
-rw-r--r-- | src/service/AccountService.js | 13 | ||||
-rw-r--r-- | src/store/actions.js | 9 | ||||
-rw-r--r-- | src/views/AccountSettings.vue | 14 |
5 files changed, 135 insertions, 4 deletions
diff --git a/src/components/Composer.vue b/src/components/Composer.vue index 8f8ca9a46..669cccab0 100644 --- a/src/components/Composer.vue +++ b/src/components/Composer.vue @@ -226,8 +226,10 @@ export default { beforeMount() { if (this.fromAccount) { this.selectedAlias = this.aliases.find(alias => alias.id === this.fromAccount) + } else { + this.selectedAlias = this.aliases[0] } - this.selectedAlias = this.aliases[0] + this.bodyVal = this.bodyWithSignature(this.selectedAlias, this.body) }, methods: { recipientToRfc822(recipient) { @@ -346,6 +348,15 @@ export default { formatAliases(alias) { return `${alias.name} <${alias.emailAddress}>` }, + bodyWithSignature(alias, body) { + console.info(alias) + + if (!alias || !alias.signature) { + return body + } + + return body + '\n\n--\n\n' + alias.signature + }, }, } </script> diff --git a/src/components/SignatureSettings.vue b/src/components/SignatureSettings.vue new file mode 100644 index 000000000..1a8ded313 --- /dev/null +++ b/src/components/SignatureSettings.vue @@ -0,0 +1,90 @@ +<!-- + - @copyright 2019 Christoph Wurst <christoph@winzerhof-wurst.at> + - + - @author 2019 Christoph Wurst <christoph@winzerhof-wurst.at> + - + - @license GNU AGPL version 3 or any later version + - + - This program is free software: you can redistribute it and/or modify + - it under the terms of the GNU Affero General Public License as + - published by the Free Software Foundation, either version 3 of the + - License, or (at your option) any later version. + - + - This program is distributed in the hope that it will be useful, + - but WITHOUT ANY WARRANTY; without even the implied warranty of + - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + - GNU Affero General Public License for more details. + - + - You should have received a copy of the GNU Affero General Public License + - along with this program. If not, see <http://www.gnu.org/licenses/>. + --> + +<template> + <div> + <h3>{{ t('mail', 'Signature') }}</h3> + <p> + {{ t('mail', 'A signature will be added to the text of new and response messages.') }} + </p> + <p> + <textarea v-model="signature" :disabled="loading"></textarea> + </p> + <p> + <input type="submit" :value="t('mail', 'Delete')" :disabled="loading" @click="deleteSignature" /> + <input + type="submit" + class="primary" + :value="t('mail', 'Save')" + :disabled="loading" + @click="saveSignature" + /> + </p> + </div> +</template> + +<script> +export default { + name: 'SignatureSettings', + props: { + account: { + type: Object, + required: true, + }, + }, + data() { + return { + loading: false, + } + }, + methods: { + deleteSignature() { + this.loading = true + + this.$store + .dispatch('updateAccountSignature', {account: this.account, signature: null}) + .then(() => { + console.info('signature deleted') + this.signature = '' + this.loading = false + }) + .catch(e => { + console.error('could not delete account signature', e) + throw e + }) + }, + saveSignature() { + this.loading = true + + this.$store + .dispatch('updateAccountSignature', {account: this.account, signature: this.signature}) + .then(() => { + console.info('signature updated') + this.loading = false + }) + .catch(e => { + console.error('could not update account signature', e) + throw e + }) + }, + }, +} +</script> diff --git a/src/service/AccountService.js b/src/service/AccountService.js index e07d05b86..2e32f5800 100644 --- a/src/service/AccountService.js +++ b/src/service/AccountService.js @@ -26,6 +26,19 @@ export const update = data => { .then(fixAccountId) } +export const updateSignature = (account, signature) => { + const url = generateUrl(`/apps/mail/api/accounts/{id}/signature`, { + id: account.id, + }) + const data = { + signature, + } + + return HttpClient.put(url, data) + .then(resp => resp.data) + .then(fixAccountId) +} + export const fetchAll = () => { const url = generateUrl('/apps/mail/api/accounts') diff --git a/src/store/actions.js b/src/store/actions.js index c9a3deea7..5018ef799 100644 --- a/src/store/actions.js +++ b/src/store/actions.js @@ -25,6 +25,7 @@ import {savePreference} from '../service/PreferenceService' import { create as createAccount, update as updateAccount, + updateSignature, deleteAccount, fetch as fetchAccount, fetchAll as fetchAllAccounts, @@ -80,6 +81,14 @@ export default { return account }) }, + updateAccountSignature({commit}, {account, signature}) { + return updateSignature(account, signature).then(() => { + console.debug('account signature updated') + account.signature = signature + commit('editAccount', account) + return account + }) + }, deleteAccount({commit}, account) { return deleteAccount(account.id) .then(account => { diff --git a/src/views/AccountSettings.vue b/src/views/AccountSettings.vue index 54e45aa70..56157c2c6 100644 --- a/src/views/AccountSettings.vue +++ b/src/views/AccountSettings.vue @@ -4,9 +4,11 @@ <template slot="content"> <div class="section"> <h2>{{ t('mail', 'Account Settings') }} - {{ email }}</h2> + <h3>{{ t('mail', 'Mail server') }}</h3> <div id="mail-settings"> <AccountForm :display-name="displayName" :email="email" :save="onSave" :account="account" /> </div> + <SignatureSettings :account="account" /> </div> </template> </AppContent> @@ -17,6 +19,7 @@ import {AppContent} from 'nextcloud-vue' import AccountForm from '../components/AccountForm' import Navigation from '../components/Navigation' +import SignatureSettings from '../components/SignatureSettings' export default { name: 'AccountSettings', @@ -24,14 +27,19 @@ export default { AccountForm, AppContent, Navigation, + SignatureSettings, + }, + data() { + const account = this.$store.getters.getAccount(this.$route.params.accountId) + return { + account, + signature: account.signature, + } }, computed: { menu() { return this.buildMenu() }, - account() { - return this.$store.getters.getAccount(this.$route.params.accountId) - }, displayName() { return this.$store.getters.getAccount(this.$route.params.accountId).name }, |