From 2c407a3d63f55ae6efcd2bce25a37eac9d097c61 Mon Sep 17 00:00:00 2001
From: pratu16x7
Date: Thu, 23 Feb 2017 13:15:15 +0530
Subject: [PATCH 01/10] Placeholder graphics, nav results preference, json
fields update
---
frappe/core/doctype/docfield/docfield.json | 2 +-
.../customize_form_field.json | 5 +-
frappe/public/css/desk.css | 18 +++
.../js/frappe/ui/toolbar/awesome_bar.js | 12 +-
.../public/js/frappe/ui/toolbar/search.html | 3 +-
frappe/public/js/frappe/ui/toolbar/search.js | 116 +++++++++++-------
.../js/frappe/ui/toolbar/search_header.html | 4 +-
frappe/public/js/frappe/ui/toolbar/toolbar.js | 5 +-
frappe/public/less/desk.less | 22 ++++
9 files changed, 127 insertions(+), 60 deletions(-)
diff --git a/frappe/core/doctype/docfield/docfield.json b/frappe/core/doctype/docfield/docfield.json
index 2052e4e141..f2f954c810 100644
--- a/frappe/core/doctype/docfield/docfield.json
+++ b/frappe/core/doctype/docfield/docfield.json
@@ -1288,7 +1288,7 @@
"issingle": 0,
"istable": 1,
"max_attachments": 0,
- "modified": "2017-02-17 16:14:33.670631",
+ "modified": "2017-02-22 21:43:00.771400",
"modified_by": "Administrator",
"module": "Core",
"name": "DocField",
diff --git a/frappe/custom/doctype/customize_form_field/customize_form_field.json b/frappe/custom/doctype/customize_form_field/customize_form_field.json
index 56b08933d6..ba6d51ee26 100644
--- a/frappe/custom/doctype/customize_form_field/customize_form_field.json
+++ b/frappe/custom/doctype/customize_form_field/customize_form_field.json
@@ -255,7 +255,7 @@
"bold": 0,
"collapsible": 0,
"columns": 0,
- "depends_on": "eval:([\"Data\", \"Select\", \"Table\", \"Text\", \"Text Editor\", \"Link\", \"Small Text\", \"Long Text\", \"Read Only\", \"Heading\"].indexOf(doc.fieldtype) !== -1)",
+ "depends_on": "eval:([\"Data\", \"Select\", \"Table\", \"Text\", \"Text Editor\", \"Link\", \"Small Text\", \"Long Text\", \"Read Only\", \"Heading\", \"Dynamic Link\"].indexOf(doc.fieldtype) !== -1)",
"fieldname": "in_global_search",
"fieldtype": "Check",
"hidden": 0,
@@ -1104,7 +1104,7 @@
"issingle": 0,
"istable": 1,
"max_attachments": 0,
- "modified": "2017-01-30 02:49:36.834130",
+ "modified": "2017-02-22 21:43:19.748233",
"modified_by": "Administrator",
"module": "Custom",
"name": "Customize Form Field",
@@ -1113,6 +1113,7 @@
"quick_entry": 0,
"read_only": 0,
"read_only_onload": 0,
+ "show_name_in_global_search": 0,
"sort_order": "ASC",
"track_changes": 0,
"track_seen": 0
diff --git a/frappe/public/css/desk.css b/frappe/public/css/desk.css
index 8c049e68d5..242843b35e 100644
--- a/frappe/public/css/desk.css
+++ b/frappe/public/css/desk.css
@@ -694,6 +694,24 @@ fieldset[disabled] .form-control {
.search-dialog .layout-side-section .nav > li > a {
padding-left: 20px;
}
+.search-dialog .results-area .search-intro-placeholder {
+ color: #d4d9dd;
+ height: inherit;
+ display: flex;
+ justify-content: center;
+ align-items: center;
+}
+.search-dialog .results-area .search-intro-placeholder span {
+ text-align: center;
+}
+.search-dialog .results-area .search-intro-placeholder span i{
+ font-size: 120px;
+ display: block;
+}
+.search-dialog .results-area .search-intro-placeholder span p{
+ font-size: 20px;
+ display: block;
+}
.search-dialog .results-area a {
color: #5E64FF;
}
diff --git a/frappe/public/js/frappe/ui/toolbar/awesome_bar.js b/frappe/public/js/frappe/ui/toolbar/awesome_bar.js
index 2f4daf6946..fd1037a0df 100644
--- a/frappe/public/js/frappe/ui/toolbar/awesome_bar.js
+++ b/frappe/public/js/frappe/ui/toolbar/awesome_bar.js
@@ -4,9 +4,11 @@ frappe.provide('frappe.search');
frappe.search.AwesomeBar = Class.extend({
setup: function(element) {
+ var me = this;
+
var $input = $(element);
var input = $input.get(0);
- var me = this;
+
this.search = new frappe.search.UnifiedSearch();
this.global = new frappe.search.GlobalSearch();
this.nav = new frappe.search.NavSearch();
@@ -102,7 +104,7 @@ frappe.search.AwesomeBar = Class.extend({
}
});
awesomplete.list = out;
- }, 200));
+ }, 100));
});
@@ -346,11 +348,11 @@ frappe.search.AwesomeBar = Class.extend({
label: __("Search for '" + txt.bold() + "'"),
value: __("Search for '" + txt + "'"),
match: txt,
- index: 22,
+ index: 19,
default: "Search",
onclick: function() {
me.search.search_dialog.show();
- me.search.setup_search(txt, [me.global, me.nav, me.help]);
+ me.search.setup_search(txt, [me.nav, me.global, me.help]);
}
});
},
@@ -469,7 +471,7 @@ frappe.search.AwesomeBar = Class.extend({
index = result[1];
rendered_label = result[2];
if(target) {
- // include 'making new' option (not working)
+ // include 'making new' option
// if(in_list(frappe.boot.user.can_create, target)) {
// out.push({
// label: rendered_label,
diff --git a/frappe/public/js/frappe/ui/toolbar/search.html b/frappe/public/js/frappe/ui/toolbar/search.html
index b964b1c5f5..67ea7cfe6d 100644
--- a/frappe/public/js/frappe/ui/toolbar/search.html
+++ b/frappe/public/js/frappe/ui/toolbar/search.html
@@ -1,7 +1,6 @@
diff --git a/frappe/public/js/frappe/ui/toolbar/search.js b/frappe/public/js/frappe/ui/toolbar/search.js
index 44e2f62550..ff4377bc58 100644
--- a/frappe/public/js/frappe/ui/toolbar/search.js
+++ b/frappe/public/js/frappe/ui/toolbar/search.js
@@ -3,7 +3,15 @@ frappe.provide('frappe.search');
frappe.search.UnifiedSearch = Class.extend({
setup: function() {
- var d = new frappe.ui.Dialog();
+ var d;
+ if(!frappe.search.dialog) {
+ d = new frappe.ui.Dialog();
+ frappe.search.dialog = d;
+ } else {
+ d = frappe.search.dialog;
+ $(d.body).empty();
+ }
+
$(frappe.render_template("search")).appendTo($(d.body));
$(d.header).html($(frappe.render_template("search_header")));
@@ -12,12 +20,13 @@ frappe.search.UnifiedSearch = Class.extend({
this.search_modal.addClass('search-dialog');
this.input = this.search_modal.find(".search-input");
- this.sidelist = this.search_modal.find(".search-sidelist");
+ this.sidebar = this.search_modal.find(".search-sidebar");
this.results_area = this.search_modal.find(".results-area");
},
- setup_search: function(keywords, search_objects) {
+ setup_search: function(init_keywords, search_objects) {
var me = this;
+ var keywords = init_keywords;
this.search_objects = search_objects;
this.search_types = search_objects.map(function(s) {
return s.search_type;
@@ -29,37 +38,42 @@ frappe.search.UnifiedSearch = Class.extend({
var $this = $(this);
clearTimeout($this.data('timeout'));
- $this.data('timeout', setTimeout(function(){
- var keywords = me.input.val();
+ $this.data('timeout', setTimeout(function() {
+ if(me.input.val() === keywords) return;
+ keywords = me.input.val();
me.reset();
if(keywords.length > 2) {
me.build_results(keywords);
} else {
me.current_type = '';
}
- }, 600));
+ }, 300));
});
this.build_results(keywords);
setTimeout(function() { me.input.select(); }, 500);
},
reset: function() {
- this.sidelist.empty();
+ this.sidebar.empty();
this.results_area.empty();
+ this.results_area.append($('
'));
},
build_results: function(keywords) {
var me = this;
this.summary = $('
');
+ this.sidelist = $('');
this.full_lists = {};
this.current = 0;
this.search_objects[me.current].build_results_object(me, keywords);
},
- render_results: function(results_obj, keywords){
+ render_results: function(results_obj, keywords) {
var me = this;
if(this.current === 0) { this.reset() }
results_obj.sidelist.forEach(function(list_item) {
+ // Don't append to main sidebar here
me.sidelist.append(list_item);
})
this.results_area.find('.results-status').remove();
@@ -80,25 +94,26 @@ frappe.search.UnifiedSearch = Class.extend({
me.results_area.find('.module-section').each(function() {
if(($(this).position().top < 120) && ($(this).position().top + $(this).height() > 120)) {
var types = $(this).attr('data-type').split(',');
- me.sidelist.find('.list-link').removeClass('active');
+ me.sidebar.find('.list-link').removeClass('active');
types.forEach(function(type) {
- me.sidelist.find('*[data-category="'+ type +'"]').addClass('active');
+ me.sidebar.find('*[data-category="'+ type +'"]').addClass('active');
});
}
});
});
- this.sidelist.find('.list-link').on('click', function() {
- me.set_sidelist_link_action($(this));
+ this.sidebar.find('.list-link').on('click', function() {
+ me.set_sidebar_link_action($(this));
});
this.results_area.find('.section-more').on('click', function() {
var type = $(this).attr('data-category');
- me.sidelist.find('*[data-category="'+ type +'"]').trigger('click');
+ me.sidebar.find('*[data-category="'+ type +'"]').trigger('click');
});
+ this.results_area.find('.Help-result a').on('click', frappe.help.show_results);
},
- set_sidelist_link_action: function(link) {
- this.sidelist.find(".list-link").removeClass("active");
- this.sidelist.find(".list-link i").addClass("hide");
+ set_sidebar_link_action: function(link) {
+ this.sidebar.find(".list-link").removeClass("active");
+ this.sidebar.find(".list-link i").addClass("hide");
link.addClass("active");
link.find("i").removeClass("hide");
var type = link.attr('data-category');
@@ -108,6 +123,7 @@ frappe.search.UnifiedSearch = Class.extend({
this.set_back_link();
this.set_list_more_link(type);
+ this.results_area.find('.Help-result a').on('click', frappe.help.show_results);
},
set_back_link: function() {
@@ -120,9 +136,9 @@ frappe.search.UnifiedSearch = Class.extend({
show_summary: function() {
this.current_type = '';
- this.sidelist.find(".list-link i").addClass("hide");
- this.sidelist.find(".list-link").removeClass("active");
- this.sidelist.find(".list-link").first().addClass("active");
+ this.sidebar.find(".list-link i").addClass("hide");
+ this.sidebar.find(".list-link").removeClass("active");
+ this.sidebar.find(".list-link").first().addClass("active");
this.results_area.empty().html(this.summary);
this.bind_events();
},
@@ -166,20 +182,24 @@ frappe.search.UnifiedSearch = Class.extend({
// More searches to go
this.search_objects[this.current].build_results_object(this, keywords);
} else {
- // If there's only one link in sidelist, there's no summary (show its full list)
- if(this.sidelist.find('.list-link').length === 1) {
+ this.sidebar.append(this.sidelist);
+ // If there's only one link in sidebar, there's no summary (show its full list)
+ if(this.sidebar.find('.list-link').length === 1) {
this.bind_events();
- this.sidelist.find('.list-link').trigger('click');
+ this.sidebar.find('.list-link').trigger('click');
this.results_area.find('.all-results-link').hide();
- } else if (this.sidelist.find('.list-link').length === 0) {
+ } else if (this.sidebar.find('.list-link').length === 0) {
this.results_area.html('
'+
'No results found for: '+ "'"+ keywords +"'" +'
');
} else {
+ this.sidebar.find('.search-sidelist').prepend('');
var list_types = this.get_all_list_types();
if(list_types.indexOf(this.current_type) >= 0) {
this.bind_events();
- this.sidelist.find('*[data-category="'+ this.current_type +'"]').trigger('click');
+ this.sidebar.find('*[data-category="'+ this.current_type +'"]').trigger('click');
} else {
this.show_summary();
}
@@ -189,11 +209,11 @@ frappe.search.UnifiedSearch = Class.extend({
get_all_list_types: function() {
var types = [];
- this.sidelist.find('.list-link').each(function() {
+ this.sidebar.find('.list-link').each(function() {
types.push($(this).attr('data-category'));
});
return types;
- }
+ },
});
@@ -244,8 +264,9 @@ frappe.search.GlobalSearch = Class.extend({
},
make_sidelist_item: function(type) {
- var sidelist_item = '';
+ var sidelist_item = '';
return $(__(sidelist_item, [this.search_type, type]));
},
@@ -349,8 +370,8 @@ frappe.search.GlobalSearch = Class.extend({
results_col.append(me.make_result_item(type, result));
});
if(results.length > this.section_length) {
- results_col.append('
');
+ results_col.append('
More...');
}
return results_section;
@@ -394,8 +415,8 @@ frappe.search.GlobalSearch = Class.extend({
results_col.append(me.make_result_item(type, result));
});
if(more) {
- results_col.append('
');
+ results_col.append('
More...');
}
return results_list;
},
@@ -503,14 +524,8 @@ frappe.search.NavSearch = frappe.search.GlobalSearch.extend({
set_types: function() {
var me = this;
this.section_length = 4;
- this.awesome_bar = new frappe.search.AwesomeBar();
- this.nav_results = {
- "Search in ...": me.awesome_bar.make_search_in_list(me.keywords),
- "Lists": me.awesome_bar.get_doctypes(me.keywords),
- "Reports": me.awesome_bar.get_reports(me.keywords),
- "Pages": me.awesome_bar.get_pages(me.keywords),
- "Modules": me.awesome_bar.get_modules(me.keywords)
- }
+
+ this.set_nav_results(me.keywords);
var types = ["Search in ...", "Lists", "Reports", "Pages", "Modules"];
types.forEach(function(type) {
if(me.nav_results[type].length > 0) {
@@ -526,6 +541,18 @@ frappe.search.NavSearch = frappe.search.GlobalSearch.extend({
}
},
+ set_nav_results: function(keywords) {
+ var me = this;
+ this.awesome_bar = new frappe.search.AwesomeBar();
+ this.nav_results = {
+ "Search in ...": me.awesome_bar.make_search_in_list(keywords),
+ "Lists": me.awesome_bar.get_doctypes(keywords),
+ "Reports": me.awesome_bar.get_reports(keywords),
+ "Pages": me.awesome_bar.get_pages(keywords),
+ "Modules": me.awesome_bar.get_modules(keywords)
+ }
+ },
+
get_results: function() {
var me = this;
this.types.forEach(function(type) {
@@ -668,8 +695,8 @@ frappe.search.NavSearch = frappe.search.GlobalSearch.extend({
results_column.append(me.make_result_item(type, result));
});
if(results.length > this.section_length) {
- results_column.append('
');
+ results_column.append('
More...');
}
return results_column;
}
@@ -688,9 +715,9 @@ frappe.search.HelpSearch = frappe.search.GlobalSearch.extend({
make_sidelist: function() {
var sidelist = [];
- var sidelist_item = '';
+ this.search_type +'
';
sidelist.push(sidelist_item);
return sidelist;
},
@@ -726,7 +753,6 @@ frappe.search.HelpSearch = frappe.search.GlobalSearch.extend({
'{2}
' +
'
';
var link = $(__(link_html, [result[2], result[0], result[1]]));
- link.find('a').on('click', frappe.help.show_results);
return link;
},
diff --git a/frappe/public/js/frappe/ui/toolbar/search_header.html b/frappe/public/js/frappe/ui/toolbar/search_header.html
index 0e493f0ec2..dcacb8c453 100644
--- a/frappe/public/js/frappe/ui/toolbar/search_header.html
+++ b/frappe/public/js/frappe/ui/toolbar/search_header.html
@@ -1,7 +1,7 @@
\ No newline at end of file
diff --git a/frappe/public/js/frappe/ui/toolbar/toolbar.js b/frappe/public/js/frappe/ui/toolbar/toolbar.js
index 6cbce74bb4..4fa42cbb61 100644
--- a/frappe/public/js/frappe/ui/toolbar/toolbar.js
+++ b/frappe/public/js/frappe/ui/toolbar/toolbar.js
@@ -16,9 +16,8 @@ frappe.ui.toolbar.Toolbar = Class.extend({
this.awesome_bar.setup("#navbar-search");
this.awesome_bar.setup("#modal-search");
- this.search = new frappe.search.UnifiedSearch();
- this.help = new frappe.search.HelpSearch();
- this.search.setup();
+ this.search = this.awesome_bar.search;
+ this.help = this.awesome_bar.help;
$(document).on("notification-update", function() {
frappe.ui.notifications.update_notifications();
diff --git a/frappe/public/less/desk.less b/frappe/public/less/desk.less
index 300120c7e2..817451c474 100644
--- a/frappe/public/less/desk.less
+++ b/frappe/public/less/desk.less
@@ -574,6 +574,28 @@ textarea.form-control {
}
.results-area {
+ .search-intro-placeholder {
+ color: #d4d9dd;
+ height: inherit;
+ display: flex;
+ justify-content: center;
+ align-items: center;
+
+ span {
+ text-align: center;
+
+ i {
+ font-size: 120px;
+ display: block;
+ }
+
+ p {
+ font-size: 20px;
+ display: block;
+ }
+ }
+ }
+
a {
color: #5E64FF;
}
From ca563331fadeb0e226d689a0e335d06c8504611f Mon Sep 17 00:00:00 2001
From: pratu16x7
Date: Fri, 24 Feb 2017 09:02:36 +0530
Subject: [PATCH 02/10] All results link in sidebar, remove scroll
---
frappe/public/css/desk.css | 5 ++
frappe/public/js/frappe/ui/toolbar/search.js | 88 ++++++++++----------
frappe/public/less/desk.less | 6 ++
3 files changed, 53 insertions(+), 46 deletions(-)
diff --git a/frappe/public/css/desk.css b/frappe/public/css/desk.css
index 242843b35e..fbe4fa7890 100644
--- a/frappe/public/css/desk.css
+++ b/frappe/public/css/desk.css
@@ -764,6 +764,11 @@ fieldset[disabled] .form-control {
margin: 30px 0px;
}
}
+@media (min-width: 600px) {
+ .search-dialog .results-area .back-link {
+ display: none;
+ }
+}
.result p {
margin-top: 0.2em;
}
diff --git a/frappe/public/js/frappe/ui/toolbar/search.js b/frappe/public/js/frappe/ui/toolbar/search.js
index ff4377bc58..a891a388dd 100644
--- a/frappe/public/js/frappe/ui/toolbar/search.js
+++ b/frappe/public/js/frappe/ui/toolbar/search.js
@@ -31,7 +31,7 @@ frappe.search.UnifiedSearch = Class.extend({
this.search_types = search_objects.map(function(s) {
return s.search_type;
});
- this.current_type = '';
+ this.current_type = "All Results";
this.reset();
this.input.val(keywords);
this.input.on("input", function() {
@@ -57,7 +57,7 @@ frappe.search.UnifiedSearch = Class.extend({
this.sidebar.empty();
this.results_area.empty();
this.results_area.append($(''));
+ 'Search for anything
'));
},
build_results: function(keywords) {
@@ -81,25 +81,14 @@ frappe.search.UnifiedSearch = Class.extend({
me.summary.append(section);
});
this.full_lists = Object.assign(this.full_lists, results_obj.lists);
+ this.full_lists["All Results"] = this.summary;
this.render_next_search(keywords);
},
bind_events: function() {
var me = this;
- this.results_area.on('scroll', function() {
- if(me.results_area.find('.all-results-link').length !== 0) {
- return;
- }
- var r = me.results_area.find('.module-section')[1];
- me.results_area.find('.module-section').each(function() {
- if(($(this).position().top < 120) && ($(this).position().top + $(this).height() > 120)) {
- var types = $(this).attr('data-type').split(',');
- me.sidebar.find('.list-link').removeClass('active');
- types.forEach(function(type) {
- me.sidebar.find('*[data-category="'+ type +'"]').addClass('active');
- });
- }
- });
+ this.search_modal.on('keypress', function() {
+ me.input.focus();
});
this.sidebar.find('.list-link').on('click', function() {
me.set_sidebar_link_action($(this));
@@ -107,11 +96,13 @@ frappe.search.UnifiedSearch = Class.extend({
this.results_area.find('.section-more').on('click', function() {
var type = $(this).attr('data-category');
me.sidebar.find('*[data-category="'+ type +'"]').trigger('click');
+ return false;
});
this.results_area.find('.Help-result a').on('click', frappe.help.show_results);
},
set_sidebar_link_action: function(link) {
+ var me = this;
this.sidebar.find(".list-link").removeClass("active");
this.sidebar.find(".list-link i").addClass("hide");
link.addClass("active");
@@ -119,6 +110,12 @@ frappe.search.UnifiedSearch = Class.extend({
var type = link.attr('data-category');
this.results_area.empty().html(this.full_lists[type]);
+ this.results_area.find('.section-more').on('click', function() {
+ var type = $(this).attr('data-category');
+ me.sidebar.find('*[data-category="'+ type +'"]').trigger('click');
+ return false;
+ });
+
this.current_type = type;
this.set_back_link();
@@ -197,12 +194,12 @@ frappe.search.UnifiedSearch = Class.extend({
'data-category="All Results">All Results');
var list_types = this.get_all_list_types();
- if(list_types.indexOf(this.current_type) >= 0) {
- this.bind_events();
- this.sidebar.find('*[data-category="'+ this.current_type +'"]').trigger('click');
- } else {
- this.show_summary();
+ if(list_types.indexOf(this.current_type) === -1) {
+ this.current_type = "All Results";
}
+ this.bind_events();
+ this.sidebar.find('*[data-category="'+ this.current_type +'"]').trigger('click');
+ this.bind_events();
}
}
},
@@ -370,7 +367,7 @@ frappe.search.GlobalSearch = Class.extend({
results_col.append(me.make_result_item(type, result));
});
if(results.length > this.section_length) {
- results_col.append('More...');
}
@@ -415,7 +412,7 @@ frappe.search.GlobalSearch = Class.extend({
results_col.append(me.make_result_item(type, result));
});
if(more) {
- results_col.append(' More...');
}
return results_list;
@@ -526,7 +523,7 @@ frappe.search.NavSearch = frappe.search.GlobalSearch.extend({
this.section_length = 4;
this.set_nav_results(me.keywords);
- var types = ["Search in ...", "Lists", "Reports", "Pages", "Modules"];
+ var types = ["Lists", "Reports", "Pages", "Modules"];
types.forEach(function(type) {
if(me.nav_results[type].length > 0) {
me.types.push(type);
@@ -545,7 +542,6 @@ frappe.search.NavSearch = frappe.search.GlobalSearch.extend({
var me = this;
this.awesome_bar = new frappe.search.AwesomeBar();
this.nav_results = {
- "Search in ...": me.awesome_bar.make_search_in_list(keywords),
"Lists": me.awesome_bar.get_doctypes(keywords),
"Reports": me.awesome_bar.get_reports(keywords),
"Pages": me.awesome_bar.get_pages(keywords),
@@ -590,7 +586,16 @@ frappe.search.NavSearch = frappe.search.GlobalSearch.extend({
this.make_more_list(type, results, more)
},
+ make_path: function(route) {
+ path = '#';
+ route.forEach(function(r) {
+ path += r + '/';
+ });
+ return path.slice(0, -1);
+ },
+
make_result_item: function(type, result) {
+ var me = this;
if(!result.subtypes) {
var link_html = '' +
'
{1}' +
@@ -599,29 +604,19 @@ frappe.search.NavSearch = frappe.search.GlobalSearch.extend({
} else {
var result_div = $('
');
- var button_html = '
'
result.subtypes.forEach(function(s) {
if(["Gantt", "Report", "Calendar"].indexOf(s.type) !== -1) {
- var button = $(__(button_html, [s.type]));
- button.on('click', function() {
- if(s.route_options) {
- frappe.route_options = s.route_options;
- }
- frappe.set_route(s.route);
- return false;
- });
+ var button_html = '
';
+ var button = $(__(button_html, [me.make_path(s.route), s.type]));
result_div.append(button);
} else {
- title_link_html = '
{1}';
- var link = $(__(title_link_html, ['#', result.title + ' ' + s.type]));
- link.on('click', function() {
- if(s.route_options) {
- frappe.route_options = s.route_options;
- }
- frappe.set_route(s.route);
- return false;
- });
+ title_link_html = '
{1}';
+ if(s.type === "List") {
+ var link = $(__(title_link_html, [me.make_path(s.route), result.title]));
+ } else {
+ var link = $(__(title_link_html, [me.make_path(s.route), result.title + ' ' + s.type]));
+ }
result_div.append(link);
}
})
@@ -632,8 +627,9 @@ frappe.search.NavSearch = frappe.search.GlobalSearch.extend({
},
make_result_link: function(type, result, link_html) {
+ var me = this;
if(!result.onclick) {
- var link = $(__(link_html, ['#', result.label]));
+ var link = $(__(link_html, [me.make_path(result.route), result.label]));
link.on('click', function() {
if(result.route_options) {
frappe.route_options = result.route_options;
@@ -695,7 +691,7 @@ frappe.search.NavSearch = frappe.search.GlobalSearch.extend({
results_column.append(me.make_result_item(type, result));
});
if(results.length > this.section_length) {
- results_column.append('
More...');
}
return results_column;
diff --git a/frappe/public/less/desk.less b/frappe/public/less/desk.less
index 817451c474..07500c6a13 100644
--- a/frappe/public/less/desk.less
+++ b/frappe/public/less/desk.less
@@ -668,6 +668,12 @@ textarea.form-control {
margin: 30px 0px;
}
}
+
+ @media (min-width: 600px) {
+ .results-area .back-link {
+ display: none;
+ }
+ }
}
.result {
From dc22a6bb8ff35ef5db20f62138cc8f433d8a673d Mon Sep 17 00:00:00 2001
From: pratu16x7
Date: Fri, 24 Feb 2017 10:06:34 +0530
Subject: [PATCH 03/10] Nav results order fix, black links
---
frappe/public/css/desk.css | 4 +-
.../js/frappe/ui/toolbar/awesome_bar.js | 68 ++++++++-----------
frappe/public/js/frappe/ui/toolbar/search.js | 14 ++--
frappe/public/less/desk.less | 6 +-
4 files changed, 43 insertions(+), 49 deletions(-)
diff --git a/frappe/public/css/desk.css b/frappe/public/css/desk.css
index fbe4fa7890..1280c4f110 100644
--- a/frappe/public/css/desk.css
+++ b/frappe/public/css/desk.css
@@ -712,9 +712,9 @@ fieldset[disabled] .form-control {
font-size: 20px;
display: block;
}
-.search-dialog .results-area a {
+/*.search-dialog .results-area a {
color: #5E64FF;
-}
+}*/
.search-dialog .results-area .single-link a {
color: #36414c;
}
diff --git a/frappe/public/js/frappe/ui/toolbar/awesome_bar.js b/frappe/public/js/frappe/ui/toolbar/awesome_bar.js
index fd1037a0df..7d0eee6d8a 100644
--- a/frappe/public/js/frappe/ui/toolbar/awesome_bar.js
+++ b/frappe/public/js/frappe/ui/toolbar/awesome_bar.js
@@ -58,7 +58,7 @@ frappe.search.AwesomeBar = Class.extend({
sort: function(a, b) {
var a_index = a.split("%%%")[3];
var b_index = b.split("%%%")[3];
- return (a_index - b_index);
+ return (a_index*10 - b_index*10);
}
});
@@ -217,7 +217,7 @@ frappe.search.AwesomeBar = Class.extend({
out.label = match[0].bold();
out.value = match[0];
}
- out.index = 29;
+ out.index = 30;
out.default = "Recent";
return out;
}, true);
@@ -263,9 +263,7 @@ frappe.search.AwesomeBar = Class.extend({
var ilen = item.length;
var tlen = txt.length;
- var match_level1 = 0.5;
- var match_level2 = 0.8;
- var index = ((tlen/ilen) > match_level1) ? 24 : index;
+ var match_level = tlen/ilen;
var rendered_label = "";
var i, j, skips = 0, mismatches = 0;
@@ -273,14 +271,9 @@ frappe.search.AwesomeBar = Class.extend({
return [];
}
if (item.indexOf(txt) !== -1) {
- // prefer single words
- index = (item.indexOf(' ') === -1) ? index-1 : index;
- index = ((tlen/ilen) > match_level2) ? 21 : index;
-
var regEx = new RegExp("("+ txt +")", "ig");
rendered_label = _item.replace(regEx, '$1');
-
- return [_item, index, rendered_label];
+ return [_item, ilen/50, rendered_label];
}
outer: for (i = 0, j = 0; i < tlen; i++) {
var t_ch = txt.charCodeAt(i);
@@ -307,7 +300,7 @@ frappe.search.AwesomeBar = Class.extend({
return [];
}
rendered_label += _item.slice(j);
- return [_item, index + 10, rendered_label];
+ return [_item, 20 + ilen/50, rendered_label];
},
set_specifics: function(txt, end_txt) {
@@ -315,9 +308,6 @@ frappe.search.AwesomeBar = Class.extend({
var results = this.build_options(txt);
results.forEach(function(r) {
if((r.type).toLowerCase().indexOf(end_txt.toLowerCase()) === 0) {
- if(r.index < 25) {
- r.index = 21;
- }
me.options.push(r);
}
});
@@ -348,7 +338,7 @@ frappe.search.AwesomeBar = Class.extend({
label: __("Search for '" + txt.bold() + "'"),
value: __("Search for '" + txt + "'"),
match: txt,
- index: 19,
+ index: 10,
default: "Search",
onclick: function() {
me.search.search_dialog.show();
@@ -369,7 +359,7 @@ frappe.search.AwesomeBar = Class.extend({
label: __('Find {0} in {1}', [txt.bold(), route[1].bold()]),
value: __('Find {0} in {1}', [txt, route[1]]),
route_options: options,
- index: 23,
+ index: 11,
onclick: function() {
cur_list.refresh();
},
@@ -392,7 +382,7 @@ frappe.search.AwesomeBar = Class.extend({
label: formatted_value,
value: __('{0} = {1}', [txt, val]),
match: val,
- index: 24,
+ index: 12,
default: "Calculator",
onclick: function() {
msgprint(formatted_value, "Result");
@@ -410,13 +400,13 @@ frappe.search.AwesomeBar = Class.extend({
if(in_list(txt.split(" "), "in") && (txt.slice(-2) !== "in")) {
parts = txt.split(" in ");
frappe.boot.user.can_read.forEach(function (item) {
- var target = me.fuzzy_search(parts[1], item, 21)[0];
+ var target = me.fuzzy_search(parts[1], item, 13)[0];
if(target) {
out.push({
label: __('Find {0} in {1}', [__(parts[0]).bold(), __(target).bold()]),
value: __('Find {0} in {1}', [__(parts[0]), __(target)]),
route_options: {"name": ["like", "%" + parts[0] + "%"]},
- index: 21,
+ index: 13,
default: "In List",
route: ["List", target]
});
@@ -431,14 +421,15 @@ frappe.search.AwesomeBar = Class.extend({
var out = [];
if(txt.split(" ")[0]==="new") {
frappe.boot.user.can_create.forEach(function (item) {
- var result = me.fuzzy_search(txt.substr(4), item, 21);
+ var result = me.fuzzy_search(txt.substr(4), item, 14);
var target = result[0];
+ var index = result[1];
var rendered_label = result[2];
if(target) {
out.push({
label: rendered_label,
value: __("New {0}", [target]),
- index: 21,
+ index: 14 + index,
type: "New",
prefix: "New",
match: target,
@@ -455,18 +446,18 @@ frappe.search.AwesomeBar = Class.extend({
var out = [];
var result, target, index, rendered_label;
- var option = function(type, route) {
+ var option = function(type, route, order) {
return {
label: rendered_label,
value: __(target),
route: route,
- index: index,
+ index: 15 + index + order,
match: target,
type: type
}
};
frappe.boot.user.can_read.forEach(function (item) {
- result = me.fuzzy_search(txt, item, 25);
+ result = me.fuzzy_search(txt, item, 15);
target = result[0];
index = result[1];
rendered_label = result[2];
@@ -483,24 +474,25 @@ frappe.search.AwesomeBar = Class.extend({
// });
// }
if(in_list(frappe.boot.single_types, target)) {
- out.push(option("", ["Form", target, target]));
+ out.push(option("", ["Form", target, target], 0));
} else if(in_list(frappe.boot.treeviews, target)) {
- out.push(option("Tree", ["Tree", target]));
+ out.push(option("Tree", ["Tree", target], 0));
} else {
- out.push(option("List", ["List", target]));
+ out.push(option("List", ["List", target], 0));
if(frappe.model.can_get_report(target)) {
- out.push(option("Report", ["Report", target]));
+ out.push(option("Report", ["Report", target], 0.001));
}
if(frappe.boot.calendars.indexOf(target) !== -1) {
- out.push(option("Calendar", ["List", target, "Calendar"]));
- out.push(option("Gantt", ["List", target, "Gantt"]));
+ out.push(option("Calendar", ["List", target, "Calendar"], 0.002));
+ out.push(option("Gantt", ["List", target, "Gantt"], 0.003));
}
}
}
});
+ console.log(out);
return out;
},
@@ -508,7 +500,7 @@ frappe.search.AwesomeBar = Class.extend({
var me = this;
var out = [];
Object.keys(frappe.boot.user.all_reports).forEach(function(item) {
- var result = me.fuzzy_search(txt, item, 26);
+ var result = me.fuzzy_search(txt, item, 20);
var target = result[0];
var index = result[1];
var rendered_label = result[2];
@@ -524,7 +516,7 @@ frappe.search.AwesomeBar = Class.extend({
label: rendered_label,
value: __("Report {0}" , [__(target)]),
match: txt,
- index: index,
+ index: 20 + index,
type: "Report",
prefix: "Report",
route: route
@@ -543,7 +535,7 @@ frappe.search.AwesomeBar = Class.extend({
p.name = name;
});
Object.keys(this.pages).forEach(function(item) {
- var result = me.fuzzy_search(txt, item, 27);
+ var result = me.fuzzy_search(txt, item, 21);
var target = result[0];
var index = result[1];
var rendered_label = result[2];
@@ -553,7 +545,7 @@ frappe.search.AwesomeBar = Class.extend({
label: rendered_label,
value: __("Open {0}", [__(target)]),
match: txt,
- index: index,
+ index: 21 + index,
type: "Page",
prefix: "Open",
route: [page.route || page.name]
@@ -567,7 +559,7 @@ frappe.search.AwesomeBar = Class.extend({
label: rendered_label,
value: __("Open {0}", [__(target)]),
route: [target, 'Event'],
- index: 27,
+ index: 21,
type: "Calendar",
prefix: "Open",
match: target
@@ -580,7 +572,7 @@ frappe.search.AwesomeBar = Class.extend({
var me = this;
var out = [];
Object.keys(frappe.modules).forEach(function(item) {
- var result = me.fuzzy_search(txt, item, 28);
+ var result = me.fuzzy_search(txt, item, 22);
var target = result[0];
var index = result[1];
var rendered_label = result[2];
@@ -591,7 +583,7 @@ frappe.search.AwesomeBar = Class.extend({
label: rendered_label,
value: __("Open {0}", [__(target)]),
match: txt,
- index: index,
+ index: 22 + index,
type: "Module",
prefix: "Open"
}
diff --git a/frappe/public/js/frappe/ui/toolbar/search.js b/frappe/public/js/frappe/ui/toolbar/search.js
index a891a388dd..3347399cc1 100644
--- a/frappe/public/js/frappe/ui/toolbar/search.js
+++ b/frappe/public/js/frappe/ui/toolbar/search.js
@@ -73,7 +73,6 @@ frappe.search.UnifiedSearch = Class.extend({
var me = this;
if(this.current === 0) { this.reset() }
results_obj.sidelist.forEach(function(list_item) {
- // Don't append to main sidebar here
me.sidelist.append(list_item);
})
this.results_area.find('.results-status').remove();
@@ -502,7 +501,7 @@ frappe.search.GlobalSearch = Class.extend({
value: __("{0}: {1}", [__(data.doctype), data.name]),
route: ["Form", data.doctype, data.name],
match: data.doctype,
- index: 41,
+ index: 40,
default: "Global",
description: me.get_finds(data.content, keywords).slice(0,86) + '...'
}
@@ -541,11 +540,14 @@ frappe.search.NavSearch = frappe.search.GlobalSearch.extend({
set_nav_results: function(keywords) {
var me = this;
this.awesome_bar = new frappe.search.AwesomeBar();
+ var compare = function(a, b) {
+ return a.index - b.index;
+ }
this.nav_results = {
- "Lists": me.awesome_bar.get_doctypes(keywords),
- "Reports": me.awesome_bar.get_reports(keywords),
- "Pages": me.awesome_bar.get_pages(keywords),
- "Modules": me.awesome_bar.get_modules(keywords)
+ "Lists": me.awesome_bar.get_doctypes(keywords).sort(compare),
+ "Reports": me.awesome_bar.get_reports(keywords).sort(compare),
+ "Pages": me.awesome_bar.get_pages(keywords).sort(compare),
+ "Modules": me.awesome_bar.get_modules(keywords).sort(compare)
}
},
diff --git a/frappe/public/less/desk.less b/frappe/public/less/desk.less
index 07500c6a13..96b2632d6d 100644
--- a/frappe/public/less/desk.less
+++ b/frappe/public/less/desk.less
@@ -596,9 +596,9 @@ textarea.form-control {
}
}
- a {
- color: #5E64FF;
- }
+ // a {
+ // color: #5E64FF;
+ // }
.single-link a {
color: #36414c;
From 25b242885bee9b253d9c0ec8cba3edf08bbaf11e Mon Sep 17 00:00:00 2001
From: pratu16x7
Date: Fri, 24 Feb 2017 10:35:11 +0530
Subject: [PATCH 04/10] Remove list borders and help descriptions
---
frappe/public/css/desk.css | 7 ++--
frappe/public/js/frappe/ui/toolbar/search.js | 38 +++++++++++++++++---
frappe/public/less/desk.less | 10 ++++--
3 files changed, 46 insertions(+), 9 deletions(-)
diff --git a/frappe/public/css/desk.css b/frappe/public/css/desk.css
index 1280c4f110..4fa12ad747 100644
--- a/frappe/public/css/desk.css
+++ b/frappe/public/css/desk.css
@@ -727,13 +727,16 @@ fieldset[disabled] .form-control {
content: '\f0a4';
}
.search-dialog .full-list .result {
- border-bottom: 1px solid #d1d8dd;
- margin-top: 10px;
+ margin-top: 15px;
}
.search-dialog .full-list .result .result-subtype {
float: right;
margin-left: 10px;
}
+.search-dialog .full-list .result-with-subtype {
+ border-bottom: 1px solid #d1d8dd;
+ margin-top: 10px;
+}
.search-dialog .full-list .section-head {
margin-bottom: 25px;
}
diff --git a/frappe/public/js/frappe/ui/toolbar/search.js b/frappe/public/js/frappe/ui/toolbar/search.js
index 3347399cc1..cf8e9c47b3 100644
--- a/frappe/public/js/frappe/ui/toolbar/search.js
+++ b/frappe/public/js/frappe/ui/toolbar/search.js
@@ -320,7 +320,7 @@ frappe.search.GlobalSearch = Class.extend({
make_result_item: function(type, result) {
var link_html = '' +
- '
{1}' +
+ '
{1}' +
'
{2}
' +
'
';
var formatted_result = this.format_result(result);
@@ -341,7 +341,7 @@ frappe.search.GlobalSearch = Class.extend({
if(part.toLowerCase().indexOf(keywords) !== -1) {
var colon_index = part.indexOf(':');
part = '' +
- part.slice(0, colon_index + 1) + '' +
+ me.bold_keywords(part.slice(0, colon_index + 1), keywords) + '' +
me.bold_keywords(part.slice(colon_index + 1), keywords);
content += part + ', ';
}
@@ -605,7 +605,7 @@ frappe.search.NavSearch = frappe.search.GlobalSearch.extend({
return this.make_result_link(type, result, link_html);
} else {
- var result_div = $('');
+ var result_div = $('');
result.subtypes.forEach(function(s) {
if(["Gantt", "Report", "Calendar"].indexOf(s.type) !== -1) {
var button_html = ' ');
+ var results_col = results_section.find('.module-section-column');
+ results.slice(0, this.section_length).forEach(function(result) {
+ results_col.append(me.make_condensed_result_item(type, result));
+ });
+ if(results.length > this.section_length) {
+ results_col.append('More...');
+
+ }
+ return results_section;
+ },
+
+ make_condensed_result_item: function(type, result) {
+ var me = this;
+ var link_html = '';
+ var link = $(__(link_html, [result[2], result[0]]));
+ return link;
+ },
+
make_result_item: function(type, result) {
var me = this;
var link_html = '' +
- '
{1}' +
+ '
{1}' +
'
{2}
' +
'
';
var link = $(__(link_html, [result[2], result[0], result[1]]));
diff --git a/frappe/public/less/desk.less b/frappe/public/less/desk.less
index 96b2632d6d..0239cb2985 100644
--- a/frappe/public/less/desk.less
+++ b/frappe/public/less/desk.less
@@ -619,15 +619,19 @@ textarea.form-control {
.full-list {
.result {
- border-bottom: 1px solid #d1d8dd;
- margin-top: 10px;
+ margin-top: 15px;
- .result-subtype{
+ .result-subtype {
float: right;
margin-left: 10px;
}
}
+ .result-with-subtype {
+ border-bottom: 1px solid #d1d8dd;
+ margin-top: 10px;
+ }
+
.section-head {
margin-bottom: 25px;
}
From 809b2b89889d28b30c3d06ec3992961821a73627 Mon Sep 17 00:00:00 2001
From: pratu16x7
Date: Fri, 24 Feb 2017 10:43:24 +0530
Subject: [PATCH 05/10] [start] keyboard nav
---
frappe/public/js/frappe/ui/toolbar/search.js | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/frappe/public/js/frappe/ui/toolbar/search.js b/frappe/public/js/frappe/ui/toolbar/search.js
index cf8e9c47b3..23540e87dc 100644
--- a/frappe/public/js/frappe/ui/toolbar/search.js
+++ b/frappe/public/js/frappe/ui/toolbar/search.js
@@ -86,9 +86,9 @@ frappe.search.UnifiedSearch = Class.extend({
bind_events: function() {
var me = this;
- this.search_modal.on('keypress', function() {
- me.input.focus();
- });
+ // this.search_modal.on('keypress', function() {
+ // me.input.focus();
+ // });
this.sidebar.find('.list-link').on('click', function() {
me.set_sidebar_link_action($(this));
});
From 80f7c0079cafc60025e67513720db190dbe4f258 Mon Sep 17 00:00:00 2001
From: pratu16x7
Date: Fri, 24 Feb 2017 11:23:07 +0530
Subject: [PATCH 06/10] languagify strings
---
frappe/public/js/frappe/ui/toolbar/search.js | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/frappe/public/js/frappe/ui/toolbar/search.js b/frappe/public/js/frappe/ui/toolbar/search.js
index 23540e87dc..0b24162bef 100644
--- a/frappe/public/js/frappe/ui/toolbar/search.js
+++ b/frappe/public/js/frappe/ui/toolbar/search.js
@@ -57,7 +57,7 @@ frappe.search.UnifiedSearch = Class.extend({
this.sidebar.empty();
this.results_area.empty();
this.results_area.append($('' +
- 'Search for anything
'));
+ ''+__("Search for anything")+'
'));
},
build_results: function(keywords) {
@@ -190,7 +190,7 @@ frappe.search.UnifiedSearch = Class.extend({
'No results found for: '+ "'"+ keywords +"'" +'
');
} else {
this.sidebar.find('.search-sidelist').prepend('');
var list_types = this.get_all_list_types();
if(list_types.indexOf(this.current_type) === -1) {
@@ -367,7 +367,7 @@ frappe.search.GlobalSearch = Class.extend({
});
if(results.length > this.section_length) {
results_col.append('More...');
+ + type + '" style="margin-top:10px">'+__("More...")+'');
}
return results_section;
@@ -412,7 +412,7 @@ frappe.search.GlobalSearch = Class.extend({
});
if(more) {
results_col.append(' More...');
+ '" data-category="'+ type + '" style="margin-top:10px">'+__("More...")+'');
}
return results_list;
},
@@ -694,7 +694,7 @@ frappe.search.NavSearch = frappe.search.GlobalSearch.extend({
});
if(results.length > this.section_length) {
results_column.append('More...');
+ + type + '" style="margin-top:10px">'+__("More...")+'');
}
return results_column;
}
@@ -758,7 +758,7 @@ frappe.search.HelpSearch = frappe.search.GlobalSearch.extend({
});
if(results.length > this.section_length) {
results_col.append('More...');
+ + type + '" style="margin-top:10px">'+__("More...")+'');
}
return results_section;
From db4a083a33b543bb1ddaa6886dc285917dac1a9d Mon Sep 17 00:00:00 2001
From: pratu16x7
Date: Fri, 24 Feb 2017 14:05:18 +0530
Subject: [PATCH 07/10] sidebar fixes
---
frappe/public/css/desk.css | 14 ++++++++++++-
.../js/frappe/ui/toolbar/awesome_bar.js | 1 -
frappe/public/js/frappe/ui/toolbar/search.js | 12 +++--------
frappe/public/less/desk.less | 20 +++++++++++++++++--
4 files changed, 34 insertions(+), 13 deletions(-)
diff --git a/frappe/public/css/desk.css b/frappe/public/css/desk.css
index 4fa12ad747..597dc219b5 100644
--- a/frappe/public/css/desk.css
+++ b/frappe/public/css/desk.css
@@ -687,13 +687,25 @@ fieldset[disabled] .form-control {
padding: 0px;
overflow-y: auto;
}
+.search-dialog .layout-side-section .module-sidebar-nav {
+ margin-top: 0px;
+}
.search-dialog .layout-side-section .help-link {
padding-top: 20px;
text-transform: uppercase;
}
-.search-dialog .layout-side-section .nav > li > a {
+.search-dialog .layout-side-section .nav > li a {
+ display: flex;
+ align-items: center;
+ justify-content: space-between;
padding-left: 20px;
}
+.search-dialog .layout-side-section .nav li a i {
+ visibility: hidden;
+}
+.search-dialog .layout-side-section .nav .active i {
+ visibility: visible;
+}
.search-dialog .results-area .search-intro-placeholder {
color: #d4d9dd;
height: inherit;
diff --git a/frappe/public/js/frappe/ui/toolbar/awesome_bar.js b/frappe/public/js/frappe/ui/toolbar/awesome_bar.js
index 7d0eee6d8a..4fff7fd20a 100644
--- a/frappe/public/js/frappe/ui/toolbar/awesome_bar.js
+++ b/frappe/public/js/frappe/ui/toolbar/awesome_bar.js
@@ -492,7 +492,6 @@ frappe.search.AwesomeBar = Class.extend({
}
});
- console.log(out);
return out;
},
diff --git a/frappe/public/js/frappe/ui/toolbar/search.js b/frappe/public/js/frappe/ui/toolbar/search.js
index 0b24162bef..8a7882243b 100644
--- a/frappe/public/js/frappe/ui/toolbar/search.js
+++ b/frappe/public/js/frappe/ui/toolbar/search.js
@@ -86,9 +86,6 @@ frappe.search.UnifiedSearch = Class.extend({
bind_events: function() {
var me = this;
- // this.search_modal.on('keypress', function() {
- // me.input.focus();
- // });
this.sidebar.find('.list-link').on('click', function() {
me.set_sidebar_link_action($(this));
});
@@ -103,9 +100,7 @@ frappe.search.UnifiedSearch = Class.extend({
set_sidebar_link_action: function(link) {
var me = this;
this.sidebar.find(".list-link").removeClass("active");
- this.sidebar.find(".list-link i").addClass("hide");
link.addClass("active");
- link.find("i").removeClass("hide");
var type = link.attr('data-category');
this.results_area.empty().html(this.full_lists[type]);
@@ -132,7 +127,6 @@ frappe.search.UnifiedSearch = Class.extend({
show_summary: function() {
this.current_type = '';
- this.sidebar.find(".list-link i").addClass("hide");
this.sidebar.find(".list-link").removeClass("active");
this.sidebar.find(".list-link").first().addClass("active");
this.results_area.empty().html(this.summary);
@@ -190,7 +184,7 @@ frappe.search.UnifiedSearch = Class.extend({
'No results found for: '+ "'"+ keywords +"'" +'');
} else {
this.sidebar.find('.search-sidelist').prepend('');
var list_types = this.get_all_list_types();
if(list_types.indexOf(this.current_type) === -1) {
@@ -261,7 +255,7 @@ frappe.search.GlobalSearch = Class.extend({
make_sidelist_item: function(type) {
var sidelist_item = '';
return $(__(sidelist_item, [this.search_type, type]));
},
@@ -716,7 +710,7 @@ frappe.search.HelpSearch = frappe.search.GlobalSearch.extend({
var sidelist = [];
var sidelist_item = '';
+ this.search_type +'';
sidelist.push(sidelist_item);
return sidelist;
},
diff --git a/frappe/public/less/desk.less b/frappe/public/less/desk.less
index 0239cb2985..7414ccb74e 100644
--- a/frappe/public/less/desk.less
+++ b/frappe/public/less/desk.less
@@ -563,13 +563,29 @@ textarea.form-control {
}
.layout-side-section {
+ .module-sidebar-nav {
+ margin-top: 0px;
+ }
.help-link {
padding-top: 20px;
text-transform: uppercase;
}
- .nav > li > a {
- padding-left: 20px;
+ .nav {
+ li a {
+ display: flex;
+ align-items: center;
+ justify-content: space-between;
+ padding-left: 20px;
+
+ i {
+ visibility: hidden;
+ }
+ }
+
+ .active i {
+ visibility: visible;
+ }
}
}
From 16c6c4003dc2bd7a72cd97473d44739e81873501 Mon Sep 17 00:00:00 2001
From: pratu16x7
Date: Fri, 24 Feb 2017 18:02:05 +0530
Subject: [PATCH 08/10] Keyboard nav: sidebar and input focus
---
frappe/public/js/frappe/ui/toolbar/search.js | 36 ++++++++++++++++++++
1 file changed, 36 insertions(+)
diff --git a/frappe/public/js/frappe/ui/toolbar/search.js b/frappe/public/js/frappe/ui/toolbar/search.js
index 8a7882243b..88a546f6f9 100644
--- a/frappe/public/js/frappe/ui/toolbar/search.js
+++ b/frappe/public/js/frappe/ui/toolbar/search.js
@@ -33,6 +33,7 @@ frappe.search.UnifiedSearch = Class.extend({
});
this.current_type = "All Results";
this.reset();
+ this.bind_keyboard_events();
this.input.val(keywords);
this.input.on("input", function() {
var $this = $(this);
@@ -60,6 +61,38 @@ frappe.search.UnifiedSearch = Class.extend({
''+__("Search for anything")+'
'));
},
+ bind_keyboard_events: function() {
+ var me = this;
+ this.search_modal.on('keydown', function(e) {
+ if(me.sidebar.find('.list-link').length > 1) {
+ var list_types = me.get_all_list_types();
+ var current_type_index = list_types.indexOf(me.current_type);
+ // DOWN and UP keys navigate sidebar
+ if(e.which === 40) {
+ if(current_type_index < list_types.length - 1) {
+ next_type = list_types[current_type_index + 1];
+ me.sidebar.find('*[data-category="'+ next_type +'"]').trigger('click');
+ }
+ } else if(e.which === 38) {
+ if(current_type_index > 0) {
+ last_type = list_types[current_type_index - 1];
+ me.sidebar.find('*[data-category="'+ last_type +'"]').trigger('click');
+ }
+ } else if(e.which === 8) {
+ // Backspace key focuses input
+ if(!me.input.is(":focus")) {
+ me.input.focus();
+ }
+ }
+ }
+ });
+ this.search_modal.on('keypress', function(e) {
+ if(!me.input.is(":focus")) {
+ me.input.focus();
+ }
+ });
+ },
+
build_results: function(keywords) {
var me = this;
this.summary = $('');
@@ -103,6 +136,7 @@ frappe.search.UnifiedSearch = Class.extend({
link.addClass("active");
var type = link.attr('data-category');
this.results_area.empty().html(this.full_lists[type]);
+ me.results_area.find('.module-section-link').first().focus();
this.results_area.find('.section-more').on('click', function() {
var type = $(this).attr('data-category');
@@ -147,7 +181,9 @@ frappe.search.UnifiedSearch = Class.extend({
var me = this;
var more_results = more_data[0];
var more = more_data[1];
+ var last_result = this.results_area.find('.module-section-link').last();
this.results_area.find('.list-more').before(more_results);
+ last_result.next().focus();
if(!more) {
this.results_area.find('.list-more').hide();
var no_of_results = this.results_area.find('.result').length;
From 0a361dfd95f859e5dabd0050042a922b8e83afa1 Mon Sep 17 00:00:00 2001
From: pratu16x7
Date: Fri, 24 Feb 2017 18:20:16 +0530
Subject: [PATCH 09/10] Keyboard nav: tab roll on results
---
frappe/public/js/frappe/ui/toolbar/search.js | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)
diff --git a/frappe/public/js/frappe/ui/toolbar/search.js b/frappe/public/js/frappe/ui/toolbar/search.js
index 88a546f6f9..b0229fa93b 100644
--- a/frappe/public/js/frappe/ui/toolbar/search.js
+++ b/frappe/public/js/frappe/ui/toolbar/search.js
@@ -78,6 +78,12 @@ frappe.search.UnifiedSearch = Class.extend({
last_type = list_types[current_type_index - 1];
me.sidebar.find('*[data-category="'+ last_type +'"]').trigger('click');
}
+ } else if (e.which === 9) {
+ // Tab key rolls back after the last result
+ if(me.results_area.find('a').last().is(":focus")) {
+ e.preventDefault();
+ me.results_area.find('.module-section-link').first().focus();
+ }
} else if(e.which === 8) {
// Backspace key focuses input
if(!me.input.is(":focus")) {
@@ -181,9 +187,9 @@ frappe.search.UnifiedSearch = Class.extend({
var me = this;
var more_results = more_data[0];
var more = more_data[1];
- var last_result = this.results_area.find('.module-section-link').last();
+ this.results_area.find('.module-section-link').last().addClass('.current-last');
this.results_area.find('.list-more').before(more_results);
- last_result.next().focus();
+ this.results_area.find('.more_results').last().find('.module-section-link').first().focus();
if(!more) {
this.results_area.find('.list-more').hide();
var no_of_results = this.results_area.find('.result').length;
From 03083b3087e68827edb7b975c853abe389160dd3 Mon Sep 17 00:00:00 2001
From: pratu16x7
Date: Fri, 24 Feb 2017 18:51:19 +0530
Subject: [PATCH 10/10] Keyboard nav: more link
---
frappe/public/js/frappe/ui/toolbar/search.js | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/frappe/public/js/frappe/ui/toolbar/search.js b/frappe/public/js/frappe/ui/toolbar/search.js
index b0229fa93b..26e2d3593b 100644
--- a/frappe/public/js/frappe/ui/toolbar/search.js
+++ b/frappe/public/js/frappe/ui/toolbar/search.js
@@ -189,7 +189,7 @@ frappe.search.UnifiedSearch = Class.extend({
var more = more_data[1];
this.results_area.find('.module-section-link').last().addClass('.current-last');
this.results_area.find('.list-more').before(more_results);
- this.results_area.find('.more_results').last().find('.module-section-link').first().focus();
+ setTimeout(function() { me.results_area.find('.more-results').last().find('.module-section-link').first().focus(); }, 200);
if(!more) {
this.results_area.find('.list-more').hide();
var no_of_results = this.results_area.find('.result').length;