Просмотр исходного кода

[fixes] data-sidebar in body and de-duplicate for awesome bar

version-14
Rushabh Mehta 9 лет назад
Родитель
Сommit
54d8c4f851
4 измененных файлов: 37 добавлений и 10 удалений
  1. +3
    -1
      frappe/public/js/frappe/ui/page.js
  2. +26
    -7
      frappe/public/js/frappe/ui/toolbar/awesome_bar.js
  3. +7
    -1
      frappe/public/js/frappe/views/container.js
  4. +1
    -1
      frappe/templates/autodoc/base_template.html

+ 3
- 1
frappe/public/js/frappe/ui/page.js Просмотреть файл

@@ -19,6 +19,8 @@ frappe.ui.make_app_page = function(opts) {
return opts.parent.page; return opts.parent.page;
} }


frappe.ui.pages = {};

frappe.ui.Page = Class.extend({ frappe.ui.Page = Class.extend({
init: function(opts) { init: function(opts) {
$.extend(this, opts); $.extend(this, opts);
@@ -29,7 +31,7 @@ frappe.ui.Page = Class.extend({
this.views = {}; this.views = {};


this.make(); this.make();
frappe.ui.pages[frappe.get_route_str()] = this;
}, },


make: function() { make: function() {


+ 26
- 7
frappe/public/js/frappe/ui/toolbar/awesome_bar.js Просмотреть файл

@@ -20,11 +20,25 @@ frappe.search = {
frappe.search.options.sort(function(a, b) { frappe.search.options.sort(function(a, b) {
return (a.match || "").length - (b.match || "").length; }); return (a.match || "").length - (b.match || "").length; });


frappe.search.add_recent("");

frappe.search.add_recent(txt || "");
frappe.search.add_help(); 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) { open: function(event, ui) {
frappe.search.autocomplete_open = event.target; frappe.search.autocomplete_open = event.target;
@@ -110,7 +124,7 @@ frappe.search = {
if(doctype[0]!==":" && !frappe.model.is_table(doctype) if(doctype[0]!==":" && !frappe.model.is_table(doctype)
&& !in_list(frappe.boot.single_types, doctype) && !in_list(frappe.boot.single_types, doctype)
&& !in_list(["DocType", "DocField", "DocPerm", "Page", "Country", && !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( var values = frappe.utils.remove_nulls(frappe.utils.unique(
keys(locals[doctype]).concat(frappe.search.recent[doctype] || []) keys(locals[doctype]).concat(frappe.search.recent[doctype] || [])
@@ -122,7 +136,7 @@ frappe.search = {
value: __(doctype) + " " + match, value: __(doctype) + " " + match,
route: ["Form", doctype, match] route: ["Form", doctype, match]
} }
});
}, true);
} }
} }
}, },
@@ -146,13 +160,18 @@ frappe.search = {
frappe.search.recent[d[0]].push(d[1]); frappe.search.recent[d[0]].push(d[1]);
} }
}, },
find: function(list, txt, process) {
find: function(list, txt, process, prepend) {
$.each(list, function(i, item) { $.each(list, function(i, item) {
_item = __(item).toLowerCase().replace(/-/g, " "); _item = __(item).toLowerCase().replace(/-/g, " ");
if(txt===_item || _item.indexOf(txt) !== -1) { if(txt===_item || _item.indexOf(txt) !== -1) {
var option = process(item); var option = process(item);
option.match = 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);
}
} }
}); });
} }


+ 7
- 1
frappe/public/js/frappe/views/container.js Просмотреть файл

@@ -19,7 +19,13 @@ frappe.views.Container = Class.extend({


$(document).on("page-change", function() { $(document).on("page-change", function() {
// set data-route in body // 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) { $(document).bind('rename', function(event, dt, old_name, new_name) {


+ 1
- 1
frappe/templates/autodoc/base_template.html Просмотреть файл

@@ -64,7 +64,7 @@
{%- if footer is defined -%}{{ footer }}{%- endif -%} {%- if footer is defined -%}{{ footer }}{%- endif -%}


<div class="built-with-frappe text-center"> <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> <h3>By {{ app.publisher }}</h3>
</div> </div>
<div class="text-center"> <div class="text-center">


Загрузка…
Отмена
Сохранить