[fixes] data-sidebar in body and de-duplicate for awesome bar
This commit is contained in:
parent
afe991cd94
commit
54d8c4f851
4 changed files with 37 additions and 10 deletions
|
|
@ -19,6 +19,8 @@ frappe.ui.make_app_page = function(opts) {
|
|||
return opts.parent.page;
|
||||
}
|
||||
|
||||
frappe.ui.pages = {};
|
||||
|
||||
frappe.ui.Page = Class.extend({
|
||||
init: function(opts) {
|
||||
$.extend(this, opts);
|
||||
|
|
@ -29,7 +31,7 @@ frappe.ui.Page = Class.extend({
|
|||
this.views = {};
|
||||
|
||||
this.make();
|
||||
|
||||
frappe.ui.pages[frappe.get_route_str()] = this;
|
||||
},
|
||||
|
||||
make: function() {
|
||||
|
|
|
|||
|
|
@ -20,11 +20,25 @@ frappe.search = {
|
|||
frappe.search.options.sort(function(a, b) {
|
||||
return (a.match || "").length - (b.match || "").length; });
|
||||
|
||||
frappe.search.add_recent("");
|
||||
|
||||
frappe.search.add_recent(txt || "");
|
||||
frappe.search.add_help();
|
||||
|
||||
response(frappe.search.options);
|
||||
// de-duplicate
|
||||
var out = [], routes = [];
|
||||
frappe.search.options.forEach(function(option) {
|
||||
if(option.route) {
|
||||
var str_route = (typeof option.route==='string') ?
|
||||
option.route : option.route.join('/');
|
||||
if(routes.indexOf(str_route)===-1) {
|
||||
out.push(option);
|
||||
routes.push(str_route);
|
||||
}
|
||||
} else {
|
||||
out.push(option);
|
||||
}
|
||||
});
|
||||
|
||||
response(out);
|
||||
},
|
||||
open: function(event, ui) {
|
||||
frappe.search.autocomplete_open = event.target;
|
||||
|
|
@ -110,7 +124,7 @@ frappe.search = {
|
|||
if(doctype[0]!==":" && !frappe.model.is_table(doctype)
|
||||
&& !in_list(frappe.boot.single_types, doctype)
|
||||
&& !in_list(["DocType", "DocField", "DocPerm", "Page", "Country",
|
||||
"Currency", "Page Role", "Print Format"], doctype)) {
|
||||
"Currency", "Page Role", "Print Format", "Report"], doctype)) {
|
||||
|
||||
var values = frappe.utils.remove_nulls(frappe.utils.unique(
|
||||
keys(locals[doctype]).concat(frappe.search.recent[doctype] || [])
|
||||
|
|
@ -122,7 +136,7 @@ frappe.search = {
|
|||
value: __(doctype) + " " + match,
|
||||
route: ["Form", doctype, match]
|
||||
}
|
||||
});
|
||||
}, true);
|
||||
}
|
||||
}
|
||||
},
|
||||
|
|
@ -146,13 +160,18 @@ frappe.search = {
|
|||
frappe.search.recent[d[0]].push(d[1]);
|
||||
}
|
||||
},
|
||||
find: function(list, txt, process) {
|
||||
find: function(list, txt, process, prepend) {
|
||||
$.each(list, function(i, item) {
|
||||
_item = __(item).toLowerCase().replace(/-/g, " ");
|
||||
if(txt===_item || _item.indexOf(txt) !== -1) {
|
||||
var option = process(item);
|
||||
option.match = item;
|
||||
frappe.search.options.push(option);
|
||||
|
||||
if(prepend) {
|
||||
frappe.search.options = [option].concat(frappe.search.options);
|
||||
} else {
|
||||
frappe.search.options.push(option);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,7 +19,13 @@ frappe.views.Container = Class.extend({
|
|||
|
||||
$(document).on("page-change", function() {
|
||||
// set data-route in body
|
||||
$("body").attr("data-route", frappe.get_route_str());
|
||||
var route_str = frappe.get_route_str();
|
||||
$("body").attr("data-route", route_str);
|
||||
var has_sidebar = false;
|
||||
if(frappe.ui.pages[route_str] && !frappe.ui.pages[route_str].single_column) {
|
||||
has_sidebar = true;
|
||||
}
|
||||
$("body").attr("data-sidebar", has_sidebar ? 1 : 0);
|
||||
});
|
||||
|
||||
$(document).bind('rename', function(event, dt, old_name, new_name) {
|
||||
|
|
|
|||
|
|
@ -64,7 +64,7 @@
|
|||
{%- if footer is defined -%}{{ footer }}{%- endif -%}
|
||||
|
||||
<div class="built-with-frappe text-center">
|
||||
<img class="frappe-bird-grey" src="{{ docs_base_url }}/assets/img/frappe-bird-grey.svg">
|
||||
<img class="frappe-bird" src="{{ docs_base_url }}/assets/img/frappe-bird-grey.svg">
|
||||
<h3>By {{ app.publisher }}</h3>
|
||||
</div>
|
||||
<div class="text-center">
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue