From aee1ab9cf9283aeb87d2b636c48f2b6ca8d9bf52 Mon Sep 17 00:00:00 2001 From: pratu16x7 Date: Mon, 27 Feb 2017 12:22:38 +0530 Subject: [PATCH] [fix] awesomebar new option with/without new keyword --- .../js/frappe/ui/toolbar/awesome_bar.js | 23 ++++++++++--------- frappe/public/js/frappe/ui/toolbar/search.js | 2 +- 2 files changed, 13 insertions(+), 12 deletions(-) diff --git a/frappe/public/js/frappe/ui/toolbar/awesome_bar.js b/frappe/public/js/frappe/ui/toolbar/awesome_bar.js index 4fff7fd20a..9142095dd6 100644 --- a/frappe/public/js/frappe/ui/toolbar/awesome_bar.js +++ b/frappe/public/js/frappe/ui/toolbar/awesome_bar.js @@ -133,7 +133,6 @@ frappe.search.AwesomeBar = Class.extend({ } if(item.onclick) { - // frappe.new_doc(item.match, true); item.onclick(item.match); } else { var previous_hash = window.location.hash; @@ -463,16 +462,18 @@ frappe.search.AwesomeBar = Class.extend({ rendered_label = result[2]; if(target) { // include 'making new' option - // if(in_list(frappe.boot.user.can_create, target)) { - // out.push({ - // label: rendered_label, - // value: __("New {0}", [target]), - // index: index, - // type: "New", - // prefix: "New", - // onclick: function() { frappe.new_doc(target, true); } - // }); - // } + if(in_list(frappe.boot.user.can_create, target)) { + var match = target; + out.push({ + label: rendered_label, + value: __("New {0}", [target]), + index: 15 + index + 0.004, + type: "New", + prefix: "New", + match: target, + onclick: function() { frappe.new_doc(match, true); } + }); + } if(in_list(frappe.boot.single_types, target)) { out.push(option("", ["Form", target, target], 0)); diff --git a/frappe/public/js/frappe/ui/toolbar/search.js b/frappe/public/js/frappe/ui/toolbar/search.js index 26e2d3593b..b110404cb4 100644 --- a/frappe/public/js/frappe/ui/toolbar/search.js +++ b/frappe/public/js/frappe/ui/toolbar/search.js @@ -648,7 +648,7 @@ frappe.search.NavSearch = frappe.search.GlobalSearch.extend({ '>{1}'; var button = $(__(button_html, [me.make_path(s.route), s.type])); result_div.append(button); - } else { + } else if (s.type !== "New") { title_link_html = '{1}'; if(s.type === "List") { var link = $(__(title_link_html, [me.make_path(s.route), result.title]));