sync
This commit is contained in:
@ -1,4 +1,4 @@
|
||||
import { Dropdown, createElement, createCheckbox, createPopup, showAlert } from "../../ui";
|
||||
import { Grid, Dropdown, createElement, createCheckbox, createPopup, showAlert } from "../../ui";
|
||||
import { isEmail, nullOrEmpty, r } from "../../utility";
|
||||
|
||||
class Contact {
|
||||
@ -185,4 +185,64 @@ class Contact {
|
||||
}
|
||||
}
|
||||
|
||||
export default Contact;
|
||||
class CustomerRecordContact {
|
||||
#option;
|
||||
#grid;
|
||||
|
||||
constructor(option = {}) {
|
||||
this.#option = option;
|
||||
}
|
||||
|
||||
async show(title, parent = document.body) {
|
||||
const tabIndex = Math.max.apply(null, [...document.querySelectorAll('[tabindex]')].map(e => e.tabIndex ?? 0)) + 3;
|
||||
|
||||
const gridContainer = createElement('div', 'selcontact-grid');
|
||||
const popup = createPopup(
|
||||
title,
|
||||
createElement('div', 'selcontact-wrapper',
|
||||
gridContainer
|
||||
),
|
||||
{
|
||||
text: r('ok', 'OK'),
|
||||
key: 'ok',
|
||||
trigger: () => {
|
||||
if (typeof this.#option.onOk === 'function') {
|
||||
return this.#option.onOk.call(this, this.#grid.source.filter(f => f.selected));
|
||||
}
|
||||
}
|
||||
},
|
||||
{ text: r('cancel', 'Cancel'), key: 'cancel' }
|
||||
);
|
||||
const result = await popup.show(parent);
|
||||
// grid
|
||||
const grid = new Grid(gridContainer);
|
||||
grid.columns = [
|
||||
{
|
||||
key: 'selected',
|
||||
type: Grid.ColumnTypes.Checkbox,
|
||||
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 }
|
||||
];
|
||||
grid.init();
|
||||
grid.source = this.#option.contacts.sort(function (a, b) { return ((b.Text || b.Email) ? 1 : 0) - ((a.Text || a.Email) ? 1 : 0) });
|
||||
this.#grid = grid;
|
||||
return result;
|
||||
}
|
||||
|
||||
set source(contacts) {
|
||||
this.#option.contacts = contacts;
|
||||
const grid = this.#grid;
|
||||
if (grid != null) {
|
||||
this.#grid.source = contacts;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export { Contact, CustomerRecordContact };
|
Reference in New Issue
Block a user