Merge pull request #2727 from RobertSchouten/composer
communication composer recipient lookup improvements
This commit is contained in:
commit
b2aeaf222f
2 changed files with 20 additions and 18 deletions
|
|
@ -16,8 +16,9 @@ def get_contact_list(txt):
|
|||
return filter(None, frappe.db.sql_list('select email from tabUser where email like %s',
|
||||
('%' + txt + '%')))
|
||||
try:
|
||||
out = filter(None, frappe.db.sql_list("""select email_id from `tabContact`
|
||||
where `email_id` like %(txt)s order by
|
||||
out = filter(None, frappe.db.sql_list("""select distinct email_id from `tabContact`
|
||||
where email_id like %(txt)s or concat(first_name, " ", last_name) like %(txt)s order by
|
||||
if (locate( %(_txt)s, concat(first_name, " ", last_name)), locate( %(_txt)s, concat(first_name, " ", last_name)), 99999),
|
||||
if (locate( %(_txt)s, email_id), locate( %(_txt)s, email_id), 99999)""",
|
||||
{'txt': "%%%s%%" % frappe.db.escape(txt),
|
||||
'_txt': txt.replace("%", "")
|
||||
|
|
|
|||
|
|
@ -88,7 +88,7 @@ frappe.views.CommunicationComposer = Class.extend({
|
|||
if(frappe.boot.email_accounts && frappe.boot.email_accounts.length > 1) {
|
||||
fields = [
|
||||
{label: __("From"), fieldtype: "Select", reqd: 1, fieldname: "sender",
|
||||
options: frappe.boot.email_accounts.map(function(d) { return e.email_id; }) }
|
||||
options: frappe.boot.email_accounts.map(function(e) { return e.email_id; }) }
|
||||
].concat(fields);
|
||||
}
|
||||
|
||||
|
|
@ -566,28 +566,29 @@ frappe.views.CommunicationComposer = Class.extend({
|
|||
item: function(item, input) {
|
||||
return $('<li>').text(item.value).get(0);
|
||||
},
|
||||
filter: function(text, input) {
|
||||
return Awesomplete.FILTER_CONTAINS(text, input.match(/[^,]*$/)[0]);
|
||||
},
|
||||
filter: function(text, input) { return true },
|
||||
replace: function(text) {
|
||||
var before = this.input.value.match(/^.+,\s*|/)[0];
|
||||
this.input.value = before + text + ", ";
|
||||
}
|
||||
});
|
||||
|
||||
var delay_timer;
|
||||
var $input = $(input);
|
||||
$input.on("input", function(e) {
|
||||
var term = e.target.value;
|
||||
frappe.call({
|
||||
method:'frappe.email.get_contact_list',
|
||||
args: {
|
||||
'txt': extractLast(term) || '%'
|
||||
},
|
||||
quiet: true,
|
||||
callback: function(r) {
|
||||
awesomplete.list = r.message;
|
||||
}
|
||||
});
|
||||
clearTimeout(delay_timer);
|
||||
delay_timer = setTimeout(function() {
|
||||
var term = e.target.value;
|
||||
frappe.call({
|
||||
method:'frappe.email.get_contact_list',
|
||||
args: {
|
||||
'txt': extractLast(term) || '%'
|
||||
},
|
||||
quiet: true,
|
||||
callback: function(r) {
|
||||
awesomplete.list = r.message || [];
|
||||
}
|
||||
});
|
||||
},250);
|
||||
});
|
||||
}
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue