浏览代码

Merge pull request #2727 from RobertSchouten/composer

communication composer recipient lookup improvements
version-14
Makarand Bauskar 8 年前
committed by GitHub
父节点
当前提交
b2aeaf222f
共有 2 个文件被更改,包括 20 次插入18 次删除
  1. +3
    -2
      frappe/email/__init__.py
  2. +17
    -16
      frappe/public/js/frappe/views/communication.js

+ 3
- 2
frappe/email/__init__.py 查看文件

@@ -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("%", "")


+ 17
- 16
frappe/public/js/frappe/views/communication.js 查看文件

@@ -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);
});
}
});

正在加载...
取消
保存