From d9beb0d3b32fc3c2afdbfca95ff6fba4328cd75d Mon Sep 17 00:00:00 2001 From: Tsanie Lily Date: Thu, 13 Apr 2023 01:02:06 +0800 Subject: [PATCH] . --- lib/app/communications/customer.js | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/lib/app/communications/customer.js b/lib/app/communications/customer.js index 8ad5947..4428a42 100644 --- a/lib/app/communications/customer.js +++ b/lib/app/communications/customer.js @@ -64,7 +64,7 @@ class CustomerCommunication { element.dispatchEvent(new Event('change')); } - get #statusLink() { return this.#container.querySelector('.check-status-link') } + get #statusLink() { return this.#container.querySelector('.check-status-link>input') } get statusLinkEnabled() { return this.#statusLink?.disabled !== true } set statusLinkEnabled(flag) { const element = this.#statusLink; @@ -115,17 +115,17 @@ class CustomerCommunication { const mp = String(c.MobilePhone).trim(); const email = String(c.Email).trim(); const pref = String(c.ContactPreference); - if (pref === '0' && !isPhone(mp) || + if ((pref === '0' || pref === '2') && !isPhone(mp) || pref === '1' && !isEmail(email)) { continue; } - const to = pref === '0' ? mp : email; + const to = pref === '0' || pref === '2' ? mp : email; const item = createElement('div', 'contact-item', - createIcon('fa-light', pref === '0' ? 'comment-lines' : 'envelope'), + createIcon('fa-light', pref === '0' ? 'comment-lines' : pref === '2' ? 'mobile' : 'envelope'), setTooltip(createElement('span', span => { span.dataset.to = to; span.dataset.name = c.Name; - span.innerText = to; + span.innerText = nullOrEmpty(to) ? c.Name : to; }), to, true) ); this.#contacts.appendChild(item); @@ -363,7 +363,13 @@ class CustomerCommunication { key: 'type', type: Grid.ColumnTypes.Icon, width: 50, - filter: c => String(c.ContactPreference) === '0' ? 'comment-lines' : 'envelope', + filter: c => { + switch (String(c.ContactPreference)) { + case '0': return 'comment-lines'; + case '2': return 'mobile'; + default: return 'envelope'; + } + }, className: 'icon-contact-type', iconType: 'fa-light' }; @@ -715,6 +721,11 @@ class CustomerCommunication { button.appendChild(createIcon('fa-solid', 'paper-plane')); setTooltip(button, r('sendMessage', 'Send Message')); button.addEventListener('click', () => { + const val = this.#enter.value; + if (nullOrEmpty(val?.trim())) { + showAlert(r('error', 'Error'), r('messageRequired', 'Please input the message.'), 'warn'); + return; + } if (typeof this.#option.onAddMessage === 'function') { this.#option.onAddMessage(this.#enter.value); }