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

@@ -29,9 +29,9 @@ export class Contact {
});
const preferences = new Dropdown({ tabIndex: tabIndex + 2 });
preferences.source = [
{ value: '0', text: r('P_CR_TEXT', 'Text') },
{ value: '1', text: r('P_CR_EMAIL', 'Email') },
{ value: '2', text: r('P_CR_PHONE', 'Phone') }
{ value: '0', text: r('FLTL_02915', 'Text') },
{ value: '1', text: r('FLTL_01089', 'Email') },
{ value: '2', text: r('FLTL_02194', 'Phone') }
];
const contactEmail = createElement('input', input => {
input.type = 'email';
@@ -57,7 +57,7 @@ export class Contact {
const buttons = [];
if (this._var.option.company) {
buttons.push({
text: c == null ? r('P_WO_ADDCONTACTRECORD', 'Add Contact Record') : r('P_WO_EDITCONTACTRECORD', 'Edit Contact Record'),
text: c == null ? r('FLTL_00100', 'Add Contact Record') : r('FLTL_01042', 'Edit Contact Record'),
// tabIndex: tabIndex + 7,
trigger: () => {
const item = this.prepare();
@@ -73,7 +73,7 @@ export class Contact {
}
buttons.push(
{
text: r('P_WO_WORKORDERONLY', 'Work Order Only'),
text: r('FLTL_03348', 'Work Order Only'),
// tabIndex: tabIndex + 8,
trigger: () => {
const item = this.prepare();
@@ -88,39 +88,39 @@ export class Contact {
}
},
{
text: r('P_WO_CANCEL', 'Cancel'),
text: r('FLTL_00499', 'Cancel'),
// tabIndex: tabIndex + 9
}
);
const popup = new Popup({
onMasking: this._var.option.onMasking,
title: c == null ? r('P_CR_ADDCONTACT', 'Add Contact') : r('P_CR_EDITCONTACT', 'Edit Contact'),
title: c == null ? r('FLTL_00099', 'Add Contact') : r('FLTL_01041', 'Edit Contact'),
content: createElement('div', wrapper => {
wrapper.className = 'setting-wrapper';
wrapper.style.width = '500px';
},
createElement('div', 'setting-item',
createElement('span', 'setting-label setting-required', r('P_CR_CONTACTNAME_COLON', 'Contact Name:')),
createElement('span', 'setting-label setting-required', r('FLTL_00640', 'Contact Name:')),
contactName
),
createElement('div', 'setting-item',
createElement('span', 'setting-label', r('P_CR_CONTACTPREFERENCES_COLON', 'Contact Preferences:')),
createElement('span', 'setting-label', r('FLTL_00643', 'Contact Preferences:')),
preferences.create()
),
createElement('div', 'setting-item',
createElement('span', 'setting-label', r('P_CR_EMAILADDRESS_COLON', 'Email Address:')),
createElement('span', 'setting-label', r('FLTL_01092', 'Email Address:')),
contactEmail
),
createElement('div', 'setting-item',
createElement('span', 'setting-label', r('P_WO_MOBILE_COLON', 'Mobile:')),
createElement('span', 'setting-label', r('FLTL_01932', 'Mobile:')),
contactMobile
),
createElement('div', 'setting-item',
createElement('span', 'setting-label', r('P_CR_OPTOUT_COLON', 'Opt Out:')),
createElement('span', 'setting-label', r('FLTL_02089', 'Opt Out:')),
checkOpt
),
createElement('div', 'setting-item',
createElement('span', 'setting-label', r('P_CR_NOTES_COLON', 'Notes:')),
createElement('span', 'setting-label', r('FLTL_02017', 'Notes:')),
contactNotes
)
),
@@ -156,24 +156,24 @@ export class Contact {
const phone = this._var.refs.contactMobile.value;
const opt = this._var.refs.checkOpt.querySelector('input').checked;
const notes = this._var.refs.contactNotes.value;
const title = this._var.option.contact == null ? r('P_CR_ADDCONTACT', 'Add Contact') : r('P_CR_EDITCONTACT', 'Edit Contact');
const title = this._var.option.contact == null ? r('FLTL_00099', 'Add Contact') : r('FLTL_01041', 'Edit Contact');
if (nullOrEmpty(name)) {
showAlert(title, r('P_CR_CONTACTNAMECANNOTBEEMPTY', 'Contact Name cannot be empty.'), 'warn')
showAlert(title, r('FLTL_00639', 'Contact Name cannot be empty.'), 'warn')
.then(() => this._var.refs.contactName.focus());
return null;
}
if ((pref == 0 || pref == 2) && nullOrEmpty(phone)) {
showAlert(title, r('P_CR_MOBILECANNOTBEEMPTY', 'Mobile cannot be empty.'), 'warn')
showAlert(title, r('FLTL_01929', 'Mobile cannot be empty.'), 'warn')
.then(() => this._var.refs.contactMobile.focus());
return null;
}
if (pref == 1 && nullOrEmpty(email)) {
showAlert(title, r('P_CU_EMAILCANNOTBEEMPTY', 'Email cannot be empty.'), 'warn')
showAlert(title, r('FLTL_01094', 'Email cannot be empty.'), 'warn')
.then(() => this._var.refs.contactEmail.focus());
return null;
}
if (!nullOrEmpty(email) && !isEmail(email)) {
showAlert(title, r('P_CR_EMAILISNOTAVALIDEMAILADDRESS', 'The email address is invalid.'), 'warn')
showAlert(title, r('FLTL_02952', 'The email address is invalid.'), 'warn')
.then(() => this._var.refs.contactEmail.focus());
return null;
}
@@ -223,7 +223,7 @@ export class CustomerRecordContact {
),
buttons: [
{
text: r('P_WO_OK', 'OK'),
text: r('FLTL_02057', 'OK'),
key: 'ok',
trigger: () => {
if (typeof this._var.option.onOk === 'function') {
@@ -231,7 +231,7 @@ export class CustomerRecordContact {
}
}
},
{ text: r('P_WO_CANCEL', 'Cancel'), key: 'cancel' }
{ text: r('FLTL_00499', 'Cancel'), key: 'cancel' }
]
});
const result = await popup.show(parent);
@@ -244,12 +244,12 @@ export class CustomerRecordContact {
width: 40,
// enabled: item => !nullOrEmpty(item.ID)
},
{ key: 'Name', caption: r("P_CR_CONTACTNAME", "Contact Name"), width: 100 },
{ key: 'Email', caption: r("P_CR_CONTACTEMAIL", "Contact Email"), css: { 'width': 180, 'text-align': 'left' } },
{ key: 'MobilePhoneDisplayText', caption: r("P_CR_CONTACTMOBILE", "Contact Mobile"), width: 130 },
{ key: 'ContactPreferenceStr', caption: r("P_CR_CONTACTPREFERENCES", "Contact Preferences"), width: 100 },
{ key: 'OptOut', caption: r("P_CR_OPTOUT", "Opt Out"), type: Grid.ColumnTypes.Checkbox, width: 70, enabled: false, align: 'center' },
{ key: 'Notes', caption: r("P_CR_NOTES", "Notes"), width: 120 }
{ key: 'Name', caption: r('FLTL_00637', 'Contact Name'), width: 100 },
{ key: 'Email', caption: r('FLTL_00633', 'Contact Email'), css: { 'width': 180, 'text-align': 'left' } },
{ key: 'MobilePhoneDisplayText', caption: r('FLTL_00636', 'Contact Mobile'), width: 130 },
{ key: 'ContactPreferenceStr', caption: r('FLTL_00642', 'Contact Preferences'), width: 100 },
{ key: 'OptOut', caption: r('FLTL_02084', 'Opt Out'), type: Grid.ColumnTypes.Checkbox, width: 70, enabled: false, align: 'center' },
{ key: 'Notes', caption: r('FLTL_02012', 'Notes'), width: 120 }
];
grid.init();
grid.source = this._var.option.contacts.sort(function (a, b) { return ((b.Text || b.Email) ? 1 : 0) - ((a.Text || a.Email) ? 1 : 0) });