From c9d6612ff77ac199e95fd470cad09fd35a305423 Mon Sep 17 00:00:00 2001 From: Prateeksha Singh Date: Wed, 5 Apr 2017 23:55:26 +0530 Subject: [PATCH] [fix] include singles despite can_search, unscrub (#3019) --- .../js/frappe/ui/toolbar/awesome_bar.js | 2 +- .../js/frappe/ui/toolbar/search_utils.js | 50 +++++++++---------- 2 files changed, 26 insertions(+), 26 deletions(-) diff --git a/frappe/public/js/frappe/ui/toolbar/awesome_bar.js b/frappe/public/js/frappe/ui/toolbar/awesome_bar.js index 339aeee48d..4f69253aa2 100644 --- a/frappe/public/js/frappe/ui/toolbar/awesome_bar.js +++ b/frappe/public/js/frappe/ui/toolbar/awesome_bar.js @@ -149,7 +149,7 @@ frappe.search.AwesomeBar = Class.extend({ var me = this; var results = this.build_options(txt); results.forEach(function(r) { - if((r.type).toLowerCase().indexOf(end_txt.toLowerCase()) === 0) { + if(r.type && (r.type).toLowerCase().indexOf(end_txt.toLowerCase()) === 0) { me.options.push(r); } }); diff --git a/frappe/public/js/frappe/ui/toolbar/search_utils.js b/frappe/public/js/frappe/ui/toolbar/search_utils.js index b4af96e3ad..5e227944ca 100644 --- a/frappe/public/js/frappe/ui/toolbar/search_utils.js +++ b/frappe/public/js/frappe/ui/toolbar/search_utils.js @@ -139,40 +139,40 @@ frappe.search.utils = { } }; frappe.boot.user.can_read.forEach(function(item) { - if(frappe.boot.user.can_search.includes(item)) { level = me.fuzzy_search(keywords, item); if(level) { target = item; - // include 'making new' option - if(in_list(frappe.boot.user.can_create, item)) { - var match = item; - out.push({ - type: "New", - label: __("New {0}", [__(me.bolden_match_part(item, keywords))]), - value: __("New {0}", [__(item)]), - index: level + 0.01, - match: item, - onclick: function() { frappe.new_doc(match, true); } - }); - } if(in_list(frappe.boot.single_types, item)) { out.push(option("", ["Form", item, item], 0.05)); - } else if(in_list(frappe.boot.treeviews, item)) { - out.push(option("Tree", ["Tree", item], 0.05)); - - } else { - out.push(option("List", ["List", item], 0.05)); - if(frappe.model.can_get_report(item)) { - out.push(option("Report", ["Report", item], 0.04)); + } else if(frappe.boot.user.can_search.includes(item)) { + // include 'making new' option + if(in_list(frappe.boot.user.can_create, item)) { + var match = item; + out.push({ + type: "New", + label: __("New {0}", [__(me.bolden_match_part(item, keywords))]), + value: __("New {0}", [__(item)]), + index: level + 0.01, + match: item, + onclick: function() { frappe.new_doc(match, true); } + }); } - if(frappe.boot.calendars.indexOf(item) !== -1) { - out.push(option("Calendar", ["List", item, "Calendar"], 0.03)); - out.push(option("Gantt", ["List", item, "Gantt"], 0.02)); + if(in_list(frappe.boot.treeviews, item)) { + out.push(option("Tree", ["Tree", item], 0.05)); + + } else { + out.push(option("List", ["List", item], 0.05)); + if(frappe.model.can_get_report(item)) { + out.push(option("Report", ["Report", item], 0.04)); + } + if(frappe.boot.calendars.indexOf(item) !== -1) { + out.push(option("Calendar", ["List", item, "Calendar"], 0.03)); + out.push(option("Gantt", ["List", item, "Gantt"], 0.02)); + } } } } - } }); return out; }, @@ -216,7 +216,7 @@ frappe.search.utils = { out.push({ type: "Page", prefix: "Open ", - label: __(me.bolden_match_part(item, keywords)), + label: __(me.bolden_match_part(me.unscrub_and_titlecase(item), keywords)), value: __("Open {0}", [__(item)]), match: item, index: level,