diff --git a/app/Models/Banking/Transaction.php b/app/Models/Banking/Transaction.php index c2fca7d0e..0c4cf8e33 100644 --- a/app/Models/Banking/Transaction.php +++ b/app/Models/Banking/Transaction.php @@ -565,7 +565,7 @@ class Transaction extends Model 'permission' => 'read-banking-transactions', 'attributes' => [ 'id' => 'index-line-actions-send-email-' . $this->type . '-' . $this->id, - '@click' => 'onEmail("' . route('modals.transactions.emails.create', $this->id) . '")', + '@click' => 'onSendEmail("' . route('modals.transactions.emails.create', $this->id) . '")', ], ]; } diff --git a/app/Models/Document/Document.php b/app/Models/Document/Document.php index e0ad24709..7855528f8 100644 --- a/app/Models/Document/Document.php +++ b/app/Models/Document/Document.php @@ -615,7 +615,7 @@ class Document extends Model 'permission' => 'read-' . $group . '-' . $permission_prefix, 'attributes' => [ 'id' => 'index-line-actions-send-email-' . $this->type . '-' . $this->id, - '@click' => 'onEmail("' . route('modals.'. $prefix . '.emails.create', $this->id) . '")', + '@click' => 'onSendEmail("' . route('modals.'. $prefix . '.emails.create', $this->id) . '")', ], ]; } diff --git a/resources/assets/js/mixins/global.js b/resources/assets/js/mixins/global.js index c938855c6..b262b5e60 100644 --- a/resources/assets/js/mixins/global.js +++ b/resources/assets/js/mixins/global.js @@ -586,6 +586,104 @@ export default { this.onChangeCurrency(currency_code); }, + async onSendEmail(route) { + let email = { + modal: false, + route: route, + title: '', + html: '', + buttons:{} + }; + + let email_promise = Promise.resolve(window.axios.get(email.route)); + + if (this.email_template) { + email_promise = Promise.resolve(window.axios.get(email.route, { + params: { + email_template: this.email_template + } + })); + } + + this.email_template = false; + + email_promise.then(response => { + email.modal = true; + email.title = response.data.data.title; + email.html = response.data.html; + email.buttons = response.data.data.buttons; + + this.component = Vue.component('add-new-component', (resolve, reject) => { + resolve({ + template: '
', + + components: { + AkauntingDropzoneFileUpload, + AkauntingContactCard, + AkauntingCompanyEdit, + AkauntingEditItemColumns, + AkauntingItemButton, + AkauntingDocumentButton, + AkauntingSearch, + AkauntingRadioGroup, + AkauntingSelect, + AkauntingSelectRemote, + AkauntingMoney, + AkauntingModal, + AkauntingModalAddNew, + AkauntingDate, + AkauntingRecurring, + AkauntingHtmlEditor, + AkauntingCountdown, + AkauntingCurrencyConversion, + AkauntingConnectTransactions, + AkauntingSwitch, + AkauntingSlider, + AkauntingColor, + CardForm, + [Select.name]: Select, + [Option.name]: Option, + [Steps.name]: Steps, + [Step.name]: Step, + [Button.name]: Button, + [Link.name]: Link, + [Tooltip.name]: Tooltip, + [ColorPicker.name]: ColorPicker, + }, + + data: function () { + return { + form:{}, + email: email, + } + }, + + methods: { + onSubmit(event) { + this.$emit('submit', event); + + event.submit(); + }, + + onCancel() { + this.email.modal = false; + this.email.html = null; + + let documentClasses = document.body.classList; + + documentClasses.remove('overflow-y-hidden', 'overflow-overlay', '-ml-4'); + }, + } + }) + }); + }) + .catch(error => { + }) + .finally(function () { + // always executed + }); + }, + onShareLink(url) { let share = { modal: false, diff --git a/resources/assets/js/views/banking/transactions.js b/resources/assets/js/views/banking/transactions.js index 6cc9348f9..fddf0f982 100644 --- a/resources/assets/js/views/banking/transactions.js +++ b/resources/assets/js/views/banking/transactions.js @@ -33,62 +33,6 @@ const app = new Vue({ }, methods: { - async onEmail(route) { - let email = { - modal: false, - route: route, - title: '', - html: '', - buttons:{} - }; - - let email_promise = Promise.resolve(window.axios.get(email.route)); - - email_promise.then(response => { - email.modal = true; - email.title = response.data.data.title; - email.html = response.data.html; - email.buttons = response.data.data.buttons; - - this.component = Vue.component('add-new-component', (resolve, reject) => { - resolve({ - template: '
', - - mixins: [ - Global - ], - - data: function () { - return { - form:{}, - email: email, - } - }, - - methods: { - onSubmit(event) { - this.$emit('submit', event); - - event.submit(); - }, - - onCancel() { - this.email.modal = false; - this.email.html = null; - - let documentClasses = document.body.classList; - - documentClasses.remove('overflow-y-hidden', 'overflow-overlay', '-ml-4'); - }, - } - }) - }); - }) - .catch(error => { - }) - .finally(function () { - // always executed - }); - }, + // }, }); diff --git a/resources/assets/js/views/common/documents.js b/resources/assets/js/views/common/documents.js index 26fe67ac2..f0d1b1a3b 100644 --- a/resources/assets/js/views/common/documents.js +++ b/resources/assets/js/views/common/documents.js @@ -827,77 +827,10 @@ const app = new Vue({ }); }, - async onEmail(route) { - let email = { - modal: false, - route: route, - title: '', - html: '', - buttons:{} - }; - - let email_promise = Promise.resolve(window.axios.get(email.route)); - - if (this.email_template) { - email_promise = Promise.resolve(window.axios.get(email.route, { - params: { - email_template: this.email_template - } - })); - } - - this.email_template = false; - - email_promise.then(response => { - email.modal = true; - email.title = response.data.data.title; - email.html = response.data.html; - email.buttons = response.data.data.buttons; - - this.component = Vue.component('add-new-component', (resolve, reject) => { - resolve({ - template: '
', - - mixins: [ - Global - ], - - data: function () { - return { - form:{}, - email: email, - } - }, - - methods: { - onSubmit(event) { - this.$emit('submit', event); - event.submit(); - }, - - onCancel() { - this.email.modal = false; - this.email.html = null; - - let documentClasses = document.body.classList; - - documentClasses.remove('overflow-y-hidden', 'overflow-overlay', '-ml-4'); - }, - } - }) - }); - }) - .catch(error => { - }) - .finally(function () { - // always executed - }); - }, - onEmailViaTemplate(route, template) { this.email_template = template; - this.onEmail(route); + this.onSendEmail(route); }, // Change currency get money @@ -1108,7 +1041,7 @@ const app = new Vue({ let email_route = document.getElementById('senddocument_route').value; - this.onEmail(email_route); + this.onSendEmail(email_route); } this.page_loaded = true; diff --git a/resources/views/components/documents/show/more-buttons.blade.php b/resources/views/components/documents/show/more-buttons.blade.php index 5f986a179..70ac7f7ab 100644 --- a/resources/views/components/documents/show/more-buttons.blade.php +++ b/resources/views/components/documents/show/more-buttons.blade.php @@ -65,7 +65,7 @@ @if (! $hideEmail) @if ($document->contact_email) - + {{ trans($textEmail) }} @else diff --git a/resources/views/components/documents/show/send.blade.php b/resources/views/components/documents/show/send.blade.php index 165280d91..8dab77b2e 100644 --- a/resources/views/components/documents/show/send.blade.php +++ b/resources/views/components/documents/show/send.blade.php @@ -13,7 +13,7 @@
@if (! $hideEmail) @if ($document->contact_email) - + {{ trans($textEmail) }} @else diff --git a/resources/views/components/transactions/show/more-buttons.blade.php b/resources/views/components/transactions/show/more-buttons.blade.php index 31699d0fc..51eda8727 100644 --- a/resources/views/components/transactions/show/more-buttons.blade.php +++ b/resources/views/components/transactions/show/more-buttons.blade.php @@ -86,7 +86,7 @@ @if ($transaction->isNotTransferTransaction()) @if (! $hideButtonEmail) @if (! empty($transaction->contact) && $transaction->contact->email) - + {{ trans('invoices.send_mail') }} @else