From a7d1ed4449f7a90f7de326950d4ae5e96da0025e Mon Sep 17 00:00:00 2001 From: mahula Date: Thu, 28 Jul 2022 13:07:57 +0200 Subject: [PATCH] refactor TransactionLink.vue to use mixins for link copying --- .../TransactionLinks/TransactionLink.vue | 39 ++----------------- 1 file changed, 4 insertions(+), 35 deletions(-) diff --git a/frontend/src/components/TransactionLinks/TransactionLink.vue b/frontend/src/components/TransactionLinks/TransactionLink.vue index fe5e44658..8eb6b4250 100644 --- a/frontend/src/components/TransactionLinks/TransactionLink.vue +++ b/frontend/src/components/TransactionLinks/TransactionLink.vue @@ -18,14 +18,14 @@ - + {{ $t('gdd_per_link.copy-link') }} {{ $t('gdd_per_link.copy-link-with-text') }} @@ -76,9 +76,11 @@ import MemoRow from '../TransactionRows/MemoRow' import DateRow from '../TransactionRows/DateRow' import DecayRow from '../TransactionRows/DecayRow' import FigureQrCode from '@/components/QrCode/FigureQrCode.vue' +import { copyLinks } from '@/mixins/copyLinks' export default { name: 'TransactionLink', + mixins: [copyLinks], components: { TypeIcon, AmountAndNameRow, @@ -88,43 +90,10 @@ export default { FigureQrCode, }, props: { - amount: { type: String, required: true }, - link: { type: String, required: true }, holdAvailableAmount: { type: String, required: true }, id: { type: Number, required: true }, - memo: { type: String, required: true }, - validUntil: { type: String, required: true }, }, methods: { - copy() { - navigator.clipboard - .writeText(this.link) - .then(() => { - this.toastSuccess(this.$t('gdd_per_link.link-copied')) - }) - .catch(() => { - this.$bvModal.show('modalPopoverCopyError' + this.id) - this.toastError(this.$t('gdd_per_link.not-copied')) - }) - }, - copyLinkWithText() { - navigator.clipboard - .writeText( - `${this.link} -${this.$store.state.firstName} ${this.$t('transaction-link.send_you')} ${this.amount} Gradido. -"${this.memo}" -${this.$t('gdd_per_link.credit-your-gradido')} ${this.$t('gdd_per_link.validUntilDate', { - date: this.$d(new Date(this.validUntil), 'short'), - })}`, - ) - .then(() => { - this.toastSuccess(this.$t('gdd_per_link.link-and-text-copied')) - }) - .catch(() => { - this.$bvModal.show('modalPopoverCopyError' + this.id) - this.toastError(this.$t('gdd_per_link.not-copied')) - }) - }, deleteLink() { this.$bvModal.msgBoxConfirm(this.$t('gdd_per_link.delete-the-link')).then(async (value) => { if (value)