This commit is contained in:
2024-08-30 17:36:21 +08:00
parent a3f0288c92
commit eec9d6045c
19 changed files with 332 additions and 219 deletions

View File

@@ -215,7 +215,7 @@ export default class CustomerCommunication {
let tipstr;
if (c.OptOut || c.OptOut_BC || c.selected === false) {
icon = 'times';
tipstr = r('P_CU_OPTEDOUT_PROMPT', 'User has opted out of messages');
tipstr = r('FLTL_03200', 'User has opted out of messages');
}
else {
switch (pref) {
@@ -224,20 +224,20 @@ export default class CustomerCommunication {
icon = 'times';
if (c.MobilePhoneStatus === 412) {
// landline
tipstr = r('P_CU_LANDLINE', 'Landline');
tipstr = r('FLTL_01707', 'Landline');
}
} else {
icon = 'comment-lines';
}
method = r('P_CU_TEXTSTO_COLON', 'Texts to:');
method = r('FLTL_02924', 'Texts to:');
break;
case '2':
icon = 'phone';
tipstr = r('P_CU_NOMESSAGE', 'No Messages Sent');
tipstr = r('FLTL_01991', 'No Messages Sent');
break;
default:
icon = 'envelope';
method = r('P_CU_EMAILSTO_COLON', 'Emails to:');
method = r('FLTL_01109', 'Emails to:');
break;
}
}
@@ -254,7 +254,7 @@ export default class CustomerCommunication {
this._var.contacts.appendChild(item);
let tip = tipstr || `${method} ${to}`;
if (span.scrollWidth > span.offsetWidth) {
tip = r('P_WO_NAME_COLON', 'Name:') + ` ${c.Name}\n${tip}`;
tip = r('FLTL_01970', 'Name:') + ` ${c.Name}\n${tip}`;
}
setTooltip(span, tip);
}
@@ -315,8 +315,8 @@ export default class CustomerCommunication {
if (this._var.option.customerReadonly === true) {
div.style.display = 'none';
} else {
div.querySelector('.title-company-name').innerText = r('P_WO_NOCUSTOMERASSIGNED', 'No Customer Assigned');
companyCode.innerText = ' /\n' + r('P_WO_SELECTCUSTOMER', 'Select Customer');
div.querySelector('.title-company-name').innerText = r('FLTL_01985', 'No Customer Assigned');
companyCode.innerText = ' /\n' + r('FLTL_02654', 'Select Customer');
companyCode.style.display = '';
}
} else {
@@ -337,8 +337,8 @@ export default class CustomerCommunication {
const companyCode = div.querySelector('.title-company-code');
if (companyCode != null) {
if (nullOrEmpty(option.companyName)) {
div.querySelector('.title-company-name').innerText = r('P_WO_NOCUSTOMERASSIGNED', 'No Customer Assigned');
companyCode.innerText = ' /\n' + r('P_WO_SELECTCUSTOMER', 'Select Customer');
div.querySelector('.title-company-name').innerText = r('FLTL_01985', 'No Customer Assigned');
companyCode.innerText = ' /\n' + r('FLTL_02654', 'Select Customer');
companyCode.style.display = '';
} else {
div.querySelector('.title-company-name').innerText = option.companyName;
@@ -364,7 +364,7 @@ export default class CustomerCommunication {
this._var.followers.replaceChildren();
if (followers?.length > 0) {
this._var.container.querySelector('.follower-bar').style.display = '';
setTooltip(this._var.buttonFollower, r('P_CU_EDITFOLLOWERS', 'Edit Followers'));
setTooltip(this._var.buttonFollower, r('FLTL_01054', 'Edit Followers'));
this._var.container.querySelector('.follower-bar>.bar-list').appendChild(this._var.buttonFollower);
for (let f of followers) {
if (f.OptOut) {
@@ -375,10 +375,10 @@ export default class CustomerCommunication {
const email = String(f.Email).trim();
const tips = [];
if (f.SendEmail) {
tips.push(r('P_CU_EMAILSTO_COLON', 'Emails to:') + ` ${email}`);
tips.push(r('FLTL_01109', 'Emails to:') + ` ${email}`);
}
if (f.SendText) {
tips.push(r('P_CU_TEXTSTO_COLON', 'Texts to:') + ` ${mpDisplay}`);
tips.push(r('FLTL_02924', 'Texts to:') + ` ${mpDisplay}`);
}
let icon;
if (f.SendText && f.SendEmail) {
@@ -402,13 +402,13 @@ export default class CustomerCommunication {
);
this._var.followers.appendChild(item);
if (span.scrollWidth > span.offsetWidth) {
tips.splice(0, 0, r('P_WO_NAME_COLON', 'Name:') + ` ${f.Name}`);
tips.splice(0, 0, r('FLTL_01970', 'Name:') + ` ${f.Name}`);
}
setTooltip(span, tips.join('\n'));
}
} else {
this._var.container.querySelector('.follower-bar').style.display = 'none';
setTooltip(this._var.buttonFollower, r('P_CR_ADDFOLLOWERS', 'Add Followers'));
setTooltip(this._var.buttonFollower, r('FLTL_00116', 'Add Followers'));
this._var.container.querySelector('.button-edit-contacts').insertAdjacentElement('beforebegin', this._var.buttonFollower)
}
this._var.message.scrollTop = this._var.message.scrollHeight
@@ -429,8 +429,8 @@ export default class CustomerCommunication {
uncheckedNode: createIcon('fa-regular', 'ban'),
onchange: function () {
setTooltip(checkAutoUpdate, this.checked ?
r('P_CU_AUTOUPDATESENABLED', 'Auto Updates Enabled') :
r('P_CU_AUTOUPDATESDISABLED', 'Auto Updates Disabled'));
r('FLTL_00420', 'Auto Updates Enabled') :
r('FLTL_00419', 'Auto Updates Disabled'));
}
});
if (option.autoUpdatesVisible === false) {
@@ -445,8 +445,8 @@ export default class CustomerCommunication {
uncheckedNode: createIcon('fa-regular', 'unlink'),
onchange: function () {
setTooltip(checkLink, this.checked ?
r('P_WO_STATUSLINKINCLUDED', 'Status Link Included') :
r('P_WO_STATUSLINKEXCLUDED', 'Status Link Excluded'));
r('FLTL_02830', 'Status Link Included') :
r('FLTL_02829', 'Status Link Excluded'));
if (typeof option.onStatusLinkChanged === 'function') {
option.onStatusLinkChanged.call(This, this.checked);
}
@@ -460,7 +460,7 @@ export default class CustomerCommunication {
createElement('div', null,
createElement('div', div => {
div.className = 'title-module';
div.innerText = option.title ?? r('P_WO_CUSTOMERCOMMUNICATION', 'Customer Communication');
div.innerText = option.title ?? r('FLTL_00732', 'Customer Communication');
},
createHideMessageTitleButton(this, 'showMessageHidden')
),
@@ -472,7 +472,7 @@ export default class CustomerCommunication {
createElement('span', span => {
span.className = 'title-company-name';
if (nullOrEmpty(option.companyName)) {
span.innerText = r('P_WO_NOCUSTOMERASSIGNED', 'No Customer Assigned');
span.innerText = r('FLTL_01985', 'No Customer Assigned');
} else {
span.innerText = option.companyName;
}
@@ -482,7 +482,7 @@ export default class CustomerCommunication {
if (option.customerReadonly === true) {
span.style.display = 'none';
} else if (nullOrEmpty(option.companyName)) {
span.innerText = ' /\n' + r('P_WO_SELECTCUSTOMER', 'Select Customer');
span.innerText = ' /\n' + r('FLTL_02654', 'Select Customer');
} else if (!nullOrEmpty(option.companyCode)) {
span.innerText = ' / ' + option.companyCode;
} else {
@@ -494,7 +494,7 @@ export default class CustomerCommunication {
if (option.recordReadonly) {
span.style.display = 'none';
}
setTooltip(span, r('P_WO_SELECTCUSTOMER', 'Select Customer'));
setTooltip(span, r('FLTL_02654', 'Select Customer'));
if (typeof option.onAddCompany === 'function') {
span.addEventListener('click', () => option.onAddCompany.call(this));
}
@@ -504,8 +504,8 @@ export default class CustomerCommunication {
)
),
[
setTooltip(checkAutoUpdate, r('P_CU_AUTOUPDATESENABLED', 'Auto Updates Enabled')),
setTooltip(checkLink, r('P_WO_STATUSLINKEXCLUDED', 'Status Link Excluded'))
setTooltip(checkAutoUpdate, r('FLTL_00420', 'Auto Updates Enabled')),
setTooltip(checkLink, r('FLTL_02829', 'Status Link Excluded'))
]
);
// contacts
@@ -514,7 +514,7 @@ export default class CustomerCommunication {
this._var.followers = this._createFollowers(container, option);
// enter box
const enter = createElement('textarea', 'ui-text');
enter.placeholder = r('P_CU_ENTERMESSAGEHERE', 'Enter Message Here');
enter.placeholder = r('FLTL_01157', 'Enter Message Here');
option.maxLength ??= 3000;
enter.maxLength = option.maxLength;
// if (readonly === true) {
@@ -586,7 +586,7 @@ export default class CustomerCommunication {
div.style.display = 'none';
}
},
createElement('span', span => span.innerText = r('P_WO_NAME_COLON', 'Name:')),
createElement('span', span => span.innerText = r('FLTL_01970', 'Name:')),
createElement('input', input => {
input.type = 'text';
input.className = 'ui-input';
@@ -631,11 +631,11 @@ export default class CustomerCommunication {
// button.style.display = 'none';
// }
button.appendChild(createIcon('fa-solid', 'paper-plane'));
setTooltip(button, r('P_M3_SENDMESSAGE', 'Send Message'));
setTooltip(button, r('FLTL_02692', 'Send Message'));
button.addEventListener('click', () => {
const val = this.text;
if (nullOrEmpty(val?.trim())) {
const p = showAlert(r('P_WO_ERROR', 'Error'), r('P_WO_PLEASEINPUTTHEMESSAGE', 'Please input the message.'), 'warn');
const p = showAlert(r('FLTL_01165', 'Error'), r('FLTL_02233', 'Please input the message.'), 'warn');
if (typeof option.onMasking === 'function') {
option.onMasking(true);
p.then(() => option.onMasking(false));
@@ -678,7 +678,7 @@ export default class CustomerCommunication {
button.style.display = 'none';
}
button.appendChild(createIcon('fa-solid', 'user-edit'));
setTooltip(button, r('P_CU_EDITCONTACTS', 'Edit Contacts'));
setTooltip(button, r('FLTL_01043', 'Edit Contacts'));
button.addEventListener('click', () => {
const editContacts = () => {
const pop = new Popup({
@@ -692,7 +692,7 @@ export default class CustomerCommunication {
div.className = 'ui-popup-move';
div.style.flex = '1 1 auto';
},
createElement('div', div => div.innerText = r('P_CU_EDITCONTACTS', 'Edit Contacts')),
createElement('div', div => div.innerText = r('FLTL_01043', 'Edit Contacts')),
createElement('div', div => {
div.className = 'title-company';
div.style.maxWidth = '540px';
@@ -760,7 +760,7 @@ export default class CustomerCommunication {
});
}
});
var title = r('P_CU_SELECTFROMCUSTOMERRECORD', 'Select from Customer Record');
var title = r('FLTL_02657', 'Select from Customer Record');
sel.show(title, container);
if (typeof option.onOpenSelectCRContacts === 'function') {
@@ -796,7 +796,7 @@ export default class CustomerCommunication {
return false;
}
});
setTooltip(button, r('P_CU_SELECTFROMCUSTOMERRECORD', 'Select from Customer Record'))
setTooltip(button, r('FLTL_02657', 'Select from Customer Record'))
}),
createElement('button', button => {
button.style.flex = '0 0 auto';
@@ -818,7 +818,7 @@ export default class CustomerCommunication {
onSave: item => {
const exists = this._var.gridContact.source.some(s => s.Name === item.Name && s.MobilePhone === item.MobilePhone);
if (exists) {
showAlert(r('P_CR_ADDCONTACT', 'Add Contact'), r('P_WO_CONTACTNAMEANDMOBILEUNIQUECOMBINATION', 'Contact name and contact mobile must be a unique combination.'), 'warn');
showAlert(r('FLTL_00099', 'Add Contact'), r('FLTL_00638', 'Contact name and contact mobile must be a unique combination.'), 'warn');
return false;
}
if (typeof option.onSave === 'function') {
@@ -852,7 +852,7 @@ export default class CustomerCommunication {
});
add.show(container);
});
setTooltip(button, r('P_CR_ADDCONTACT', 'Add Contact'))
setTooltip(button, r('FLTL_00099', 'Add Contact'))
})
)
}),
@@ -862,7 +862,7 @@ export default class CustomerCommunication {
div.style.display = 'none';
}
div.style.fontWeight = 'bold';
div.innerText = r('P_CU_CONTACTSFROMCUSTOMERRECORD', 'Contacts from Customer Record');
div.innerText = r('FLTL_00657', 'Contacts from Customer Record');
}),
createElement('div', div => {
if (nullOrEmpty(option.companyName)) {
@@ -875,7 +875,7 @@ export default class CustomerCommunication {
}),
createElement('div', div => {
div.style.fontWeight = 'bold';
div.innerText = r('P_CU_CONTACTSNOTCUSTOMERRECORD', 'Contacts not on Customer Record');
div.innerText = r('FLTL_00659', 'Contacts not on Customer Record');
}),
createElement('div', div => {
div.className = 'contacts-wo';
@@ -897,7 +897,7 @@ export default class CustomerCommunication {
option.onChanged([...This._var.gridContact.source, ...This._var.gridWo.source]);
}
},
tooltip: item => item.selected ? r('P_CU_OPTEDIN', 'Opted In') : r('P_CU_OPTEDOUT', 'Opted Out')
tooltip: item => item.selected ? r('FLTL_02090', 'Opted In') : r('FLTL_02091', 'Opted Out')
}
};
const iconCol = {
@@ -927,7 +927,7 @@ export default class CustomerCommunication {
key: 'edit',
...buttonCol,
text: 'edit',
tooltip: r('P_WO_EDIT', 'Edit'),
tooltip: r('FLTL_01032', 'Edit'),
events: {
onclick: function () {
const edit = new Contact({
@@ -940,7 +940,7 @@ export default class CustomerCommunication {
This._var.gridContact.source.some(s => s !== this && s.Name === item.Name && s.MobilePhone === item.MobilePhone) ||
This._var.gridWo.source.some(s => s !== this && s.Name === item.Name && s.MobilePhone === item.MobilePhone);
if (exists) {
showAlert(r('P_CR_EDITCONTACT', 'Edit Contact'), r('P_WO_CONTACTNAMEANDMOBILEUNIQUECOMBINATION', 'Contact name and contact mobile must be a unique combination.'), 'warn');
showAlert(r('FLTL_01041', 'Edit Contact'), r('FLTL_00638', 'Contact name and contact mobile must be a unique combination.'), 'warn');
return false;
}
if (typeof option.onSave === 'function') {
@@ -993,15 +993,15 @@ export default class CustomerCommunication {
key: 'delete',
...buttonCol,
text: 'times',
tooltip: r('P_WO_DELETE', 'Delete'),
tooltip: r('FLTL_00791', 'Delete'),
events: {
onclick: function () {
showConfirm(
r('P_CU_REMOVECONTACT', 'Remove Contact'),
r('FLTL_02417', 'Remove Contact'),
createElement('div', null,
createElement('div', div => {
div.style.paddingLeft = '16px';
div.innerText = r('P_CU_REMOVEFROM', 'Remove {name} from').replace('{name}', this.Name);
div.innerText = r('FLTL_02412', 'Remove {name} from').replace('{name}', this.Name);
}),
createElement('div', div => {
div.style.display = 'flex';
@@ -1010,19 +1010,19 @@ export default class CustomerCommunication {
},
createRadiobox({
name: 'remove-type',
label: r('P_CUSTOMERRECORD', 'Customer Record'),
label: r('FLTL_00747', 'Customer Record'),
checked: true,
className: 'radio-customer-record'
}),
createRadiobox({
name: 'remove-type',
label: r('P_WORKORDER', 'Work Order')
label: r('FLTL_03317', 'Work Order')
})
)
),
[
{ key: 'ok', text: r('P_WO_OK', 'OK') },
{ key: 'cancel', text: r('P_WO_CANCEL', 'Cancel') }
{ key: 'ok', text: r('FLTL_02057', 'OK') },
{ key: 'cancel', text: r('FLTL_00499', 'Cancel') }
]
).then(r => {
if (r.result === 'ok') {
@@ -1078,12 +1078,12 @@ export default class CustomerCommunication {
key: 'delete',
...buttonCol,
text: 'times',
tooltip: r('P_WO_DELETE', 'Delete'),
tooltip: r('FLTL_00791', 'Delete'),
events: {
onclick: function () {
showConfirm(r('P_CU_REMOVECONTACT', 'Remove Contact'), r('P_CU_REMOVEFROMWORKORDER', 'You are removing {name} from work order.\n\nDo you want to Continue?').replace('{name}', this.Name), [
{ key: 'continue', text: r('P_JS_CONTINUE', 'Continue') },
{ key: 'cancel', text: r('P_WO_CANCEL', 'Cancel') }
showConfirm(r('FLTL_02417', 'Remove Contact'), r('FLTL_03382', 'You are removing {name} from work order.\n\nDo you want to Continue?').replace('{name}', this.Name), [
{ key: 'continue', text: r('FLTL_00661', 'Continue') },
{ key: 'cancel', text: r('FLTL_00499', 'Cancel') }
]).then(r => {
if (r.result === 'continue') {
if (typeof option.onDelete === 'function') {
@@ -1124,18 +1124,18 @@ export default class CustomerCommunication {
};
if (nullOrEmpty(option.companyName)) {
showConfirm(
r('P_CU_EDITCONTACTS', 'Edit Contacts'),
r('P_CUSTOMER_ADDCOMPANYPROMPT', 'There is no company associated with this work order. Would you like to add one?\n\nIf no company is indicated, contacts must be added as "Work Order Only".'),
r('FLTL_01043', 'Edit Contacts'),
r('FLTL_03008', 'There is no company associated with this work order. Would you like to add one?\n\nIf no company is indicated, contacts must be added as "Work Order Only".'),
[
{ key: 'add', text: r('P_CUSTOMER_ADDCOMPANY', 'Add Company') },
{ key: 'skip', text: r('P_CUSTOMER_SKIPTHISSTEP', 'Skip This Step') }
{ key: 'add', text: r('FLTL_00098', 'Add Company') },
{ key: 'skip', text: r('FLTL_02777', 'Skip This Step') }
]
).then(r => {
if (r.result === 'add') {
if (typeof option.onAddCompany === 'function') {
option.onAddCompany.call(this);
}
} else if (r.key === 'skip') {
} else if (r.result === 'skip') {
editContacts();
}
});
@@ -1147,7 +1147,7 @@ export default class CustomerCommunication {
),
createElement('div', div => {
div.className = 'bar-info';
div.innerText = r('P_CR_CONTACTINFORMATION', 'Contact Information');
div.innerText = r('FLTL_00635', 'Contact Information');
}),
createElement('div', div => {
if (option.contactCollapserVisible === false) {
@@ -1191,12 +1191,12 @@ export default class CustomerCommunication {
button.style.display = 'none';
}
button.appendChild(createIcon('fa-solid', 'pen'));
setTooltip(button, r('P_CU_EDITFOLLOWERS', 'Edit Followers'));
setTooltip(button, r('FLTL_01054', 'Edit Followers'));
button.addEventListener('click', () => {
if (typeof option.onInitFollower === 'function') {
option.onInitFollower(this._var.data.followers).then(data => {
if (typeof data === 'string') {
showAlert(r('P_CUSTOMERRECORD', 'Customer Record'), data, 'warn');
showAlert(r('FLTL_00747', 'Customer Record'), data, 'warn');
return;
}
const add = new Follower({
@@ -1216,7 +1216,7 @@ export default class CustomerCommunication {
}
}
});
var title = this._var.data.followers?.length > 0 ? r('P_CU_EDITFOLLOWERS', 'Edit Followers') : r('P_CR_ADDFOLLOWERS', 'Add Followers');
var title = this._var.data.followers?.length > 0 ? r('FLTL_01054', 'Edit Followers') : r('FLTL_00116', 'Add Followers');
add.show(title, container);
});
}
@@ -1236,7 +1236,7 @@ export default class CustomerCommunication {
'border-radius': '15px',
'padding': '4px'
})
), r('P_CU_COPIED', 'Copied')),
), r('FLTL_00667', 'Copied')),
createElement('div', 'bar-list',
followers,
buttonEditFollower