email address autocomplete 2
This commit is contained in:
@@ -188,6 +188,43 @@ Espo.define('Views.Fields.Email', 'Views.Fields.Base', function (Dep) {
|
||||
Dep.prototype.afterRender.call(this);
|
||||
this.manageButtonsVisibility();
|
||||
this.manageAddButton();
|
||||
|
||||
|
||||
if (this.mode == 'search') {
|
||||
this.$element.autocomplete({
|
||||
serviceUrl: function (q) {
|
||||
return 'EmailAddress/action/searchInAddressBook?limit=5';
|
||||
}.bind(this),
|
||||
paramName: 'q',
|
||||
minChars: 1,
|
||||
autoSelectFirst: true,
|
||||
formatResult: function (suggestion) {
|
||||
return suggestion.name + ' <' + suggestion.id + '>';
|
||||
},
|
||||
transformResult: function (response) {
|
||||
var response = JSON.parse(response);
|
||||
var list = [];
|
||||
response.forEach(function(item) {
|
||||
list.push({
|
||||
id: item.emailAddress,
|
||||
name: item.entityName,
|
||||
emailAddress: item.emailAddress,
|
||||
entityId: item.entityId,
|
||||
entityName: item.entityName,
|
||||
entityType: item.entityType,
|
||||
data: item.emailAddress,
|
||||
value: item.emailAddress
|
||||
});
|
||||
}, this);
|
||||
return {
|
||||
suggestions: list
|
||||
};
|
||||
}.bind(this),
|
||||
onSelect: function (s) {
|
||||
this.$element.val(s.emailAddress);
|
||||
}.bind(this)
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
manageAddButton: function () {
|
||||
|
||||
Reference in New Issue
Block a user