From 70d7a229ff82ad575b2e622d4ef36e2e450849f9 Mon Sep 17 00:00:00 2001 From: ccheng-dev Date: Mon, 28 Oct 2024 09:57:10 +0100 Subject: [PATCH] fix(Felamimail/js): reply message using reply to header --- tine20/Felamimail/css/Felamimail.css | 4 ++-- tine20/Felamimail/js/MailDetailsPanel.js | 19 ++++++++++++------- tine20/Felamimail/js/MessageEditDialog.js | 6 +++--- tine20/Felamimail/js/RecipientGrid.js | 11 +++++++++++ tine20/Felamimail/translations/de.po | 3 +++ 5 files changed, 31 insertions(+), 12 deletions(-) diff --git a/tine20/Felamimail/css/Felamimail.css b/tine20/Felamimail/css/Felamimail.css index a7d47a0b43..ea34aa0aae 100644 --- a/tine20/Felamimail/css/Felamimail.css +++ b/tine20/Felamimail/css/Felamimail.css @@ -152,7 +152,7 @@ .preview-panel-felamimail-headers { background-color: #dddddd; overflow: auto; - padding: 5px; + padding: 10px; } .preview-panel-felamimail-header-row { @@ -162,7 +162,7 @@ .preview-panel-felamimail-header-row-left { font-weight: bold; - min-width: 50px; + min-width: 60px; text-align: right; } diff --git a/tine20/Felamimail/js/MailDetailsPanel.js b/tine20/Felamimail/js/MailDetailsPanel.js index 29f3f98f84..a6548a5b00 100644 --- a/tine20/Felamimail/js/MailDetailsPanel.js +++ b/tine20/Felamimail/js/MailDetailsPanel.js @@ -224,8 +224,9 @@ Ext.extend(Tine.Felamimail.MailDetailsPanel, Ext.Panel, { }, showInfo(values) { const app = Tine.Tinebase.appMgr.get('Felamimail'); - const items = ['subject', 'date', 'from', 'to', 'cc', 'bcc', 'extra']; + const items = ['subject', 'date', 'from', 'to', 'reply-to', 'cc', 'bcc', 'extra']; const headerBlock = document.createElement('div'); + headerBlock.className = 'preview-panel-felamimail-headers'; items.forEach((header) => { let value = ''; @@ -235,9 +236,12 @@ Ext.extend(Tine.Felamimail.MailDetailsPanel, Ext.Panel, { if (header === 'date') value = this.showDate(values.sent, values); if (header === 'extra') headerValue = this.panel.showExtraHeaderButton(); - if (['to', 'cc', 'bcc'].includes(header)) { + if (['to', 'reply-to', 'cc', 'bcc'].includes(header)) { if (!values.headers.hasOwnProperty(header)) return; - const emails = this.panel.record.get(header); + let emails = this.panel.record.get(header) || values.headers[header]; + if (typeof emails === 'string') { + emails = emails.split(/[,;]\s*/).map((email) => {return {email: email};}); + } if (emails.length === 0) return; //TODO: bcc only store email in \Zend_Mail::addBcc($email), do we want to change it ? emails.forEach((emailData, idx) => { @@ -653,17 +657,18 @@ Ext.extend(Tine.Felamimail.MailDetailsPanel, Ext.Panel, { renderHeaderRaw(header, value) { const row = document.createElement('div'); row.style.display = 'flex'; - row.style.margin = '5px'; + row.style.flexDirection = 'row'; + row.style.margin = '5px 0'; row.style.textAlign = 'left'; const rowLeft = document.createElement('div'); rowLeft.textContent = header; - rowLeft.style.minWidth = '60px'; + rowLeft.style.minWidth = '100px'; const rowRight = document.createElement('div'); rowRight.innerHTML = value; - if (header.length > 10 || value.length > 50) { + if (header.length > 15) { row.style.flexDirection = 'column'; - rowRight.style.paddingLeft = '55px'; + rowRight.style.paddingLeft = '100px'; } row.appendChild(rowLeft); row.appendChild(rowRight); diff --git a/tine20/Felamimail/js/MessageEditDialog.js b/tine20/Felamimail/js/MessageEditDialog.js index 8122ffbb32..92023ea77d 100644 --- a/tine20/Felamimail/js/MessageEditDialog.js +++ b/tine20/Felamimail/js/MessageEditDialog.js @@ -889,6 +889,8 @@ Tine.Felamimail.MessageEditDialog = Ext.extend(Tine.widgets.dialog.EditDialog, { const replyToName = this.replyTo.get('from_name'); const replyToToken = this.replyTo.get('from')?.[0]; + // reply-to header has the highest priority + if (replyToHeader) return replyToHeader; // we might get the recipient token from server if (replyToToken && replyToToken?.email) return this.replyTo.get('from'); if (replyToEmail) { @@ -901,9 +903,7 @@ Tine.Felamimail.MessageEditDialog = Ext.extend(Tine.widgets.dialog.EditDialog, { 'contact_record': '' }]; } - if (replyToHeader) { - return [replyToHeader]; - } + return []; }, diff --git a/tine20/Felamimail/js/RecipientGrid.js b/tine20/Felamimail/js/RecipientGrid.js index 377fd57c5d..a60dccdf0d 100644 --- a/tine20/Felamimail/js/RecipientGrid.js +++ b/tine20/Felamimail/js/RecipientGrid.js @@ -724,6 +724,17 @@ Tine.Felamimail.RecipientGrid = Ext.extend(Ext.grid.EditorGridPanel, { ['to', 'cc', 'bcc'].forEach((type) => { const promise = new Promise(async (resolve) => { let contacts = this.record.data[type]; + + await Promise.all(contacts.map(async (contact) => { + if (_.isString(contact) && (contact.includes(',') || contact.includes(';'))) { + return await Tine.Tinebase.common.findContactsByEmailString(contact); + } else { + return contact; + } + })).then((result) => { + contacts = result.flat(); + }); + let emails = _.filter(contacts, (addressData) => {return _.isString(addressData)}); if (emails.length > 0) { emails = _.join(emails, ', '); diff --git a/tine20/Felamimail/translations/de.po b/tine20/Felamimail/translations/de.po index d0762b56a6..bddfd6be79 100644 --- a/tine20/Felamimail/translations/de.po +++ b/tine20/Felamimail/translations/de.po @@ -392,6 +392,9 @@ msgstr "Format beibehalten" msgid "Reply-To" msgstr "Antwortadresse" +msgid "Reply-to" +msgstr "Antwort an" + #: Model/Account.php:312 msgid "E-Mail" msgstr "E-Mail"