Move global search in navbar

This gives more places to display menu entries in the dropdown.
And provide more spaces for the menu on small screen.

issue7485
review47621002
This commit is contained in:
Cédric Krier committed 2018-07-26 00:25:00 +02:00
1 parent ade21e9fbc
commit 0629d4bef0
2 files changed
+21 -28

No files matched your search

+2
View File
@@ -53,6 +53,8 @@ this repository contains the full copyright notices and license terms. -->
</a>
</div>
<div class="collapse navbar-collapse" id="main_navbar">
<form class="navbar-form navbar-left" role="search" id="global-search">
</form>
<ul class="nav navbar-nav navbar-right">
<li id="user-preferences"></li>
<li id="user-logout"></li>
+19 -28
View File
@@ -499,6 +499,7 @@ var Sao = {};
jQuery('#user-preferences').children().remove();
jQuery('#user-logout').children().remove();
jQuery('#user-favorites').children().remove();
jQuery('#global-search').children().remove();
jQuery('#menu').children().remove();
session.do_logout().always(Sao.login);
Sao.set_title();
@@ -520,25 +521,17 @@ var Sao = {};
});
};
Sao.favorites_menu = function() {
var clear_menu = function() {
if (menu) {
menu.remove();
}
};
jQuery(window).click(function() {
clear_menu();
Sao.favorites_menu_clear();
});
if (jQuery('#user-favorites').children('.dropdown-menu')
.length !== 0 ) {
clear_menu();
} else {
if (!jQuery('#user-favorites').children('.dropdown-menu').length) {
var name = Sao.main_menu_screen.model_name + '.favorite';
var session = Sao.Session.current_session;
var args = {
'method': 'model.' + name + '.get',
};
var menu = jQuery('<ul/>', {
'class': 'dropdown-menu dropdown-menu-right',
'class': 'dropdown-menu',
'aria-expanded': 'false',
'aria-labelledby': 'user-favorites',
});
@@ -561,7 +554,7 @@ var Sao = {};
Sao.common.ICONFACTORY.get_icon_url(menu_item[2]));
a.append(menu_item[1]);
a.click(function() {
clear_menu();
Sao.favorites_menu_clear();
// ids is not defined to prevent to add suffix
Sao.Action.exec_keyword('tree_open', {
'model': Sao.main_menu_screen.model_name,
@@ -578,7 +571,7 @@ var Sao = {};
}).append(jQuery('<a/>', {
'href': '#'
}).click(function() {
clear_menu();
Sao.favorites_menu_clear();
Sao.Tab.create({
'model': Sao.main_menu_screen.model_name +
'.favorite',
@@ -590,6 +583,9 @@ var Sao = {};
});
}
};
Sao.favorites_menu_clear = function() {
jQuery('#user-favorites').children('.dropdown-menu').remove();
};
Sao.user_menu = function(preferences) {
jQuery('#user-preferences').children().remove();
@@ -659,10 +655,10 @@ var Sao = {};
var view = form.screen.current_view;
view.table.removeClass('table table-bordered table-striped');
view.table.find('thead').hide();
jQuery('#menu').children().remove();
var gs = new Sao.GlobalSearch();
jQuery('#menu').append(gs.el);
jQuery('#global-search').children().remove();
jQuery('#global-search').append(gs.el);
jQuery('#menu').children().remove();
jQuery('#menu').append(
form.screen.screen_container.content_box.detach());
var column = new FavoriteColumn(form.screen.model.fields.favorite);
@@ -729,6 +725,7 @@ var Sao = {};
'params': [e.data.record.id, session.context]
};
Sao.rpc(args, session);
Sao.favorites_menu_clear();
}
});
@@ -788,12 +785,6 @@ var Sao = {};
'class': 'input-group',
}).appendTo(this.el);
this.search_entry = jQuery('<input>', {
'id': 'global-search-entry',
'class': 'form-control mousetrap',
'placeholder': Sao.i18n.gettext('Search...')
}).appendTo(group);
jQuery('<div/>', {
'id': 'user-favorites',
'class': 'input-group-btn',
@@ -809,6 +800,12 @@ var Sao = {};
'aria-hidden': true,
}))).appendTo(group);
this.search_entry = jQuery('<input>', {
'id': 'global-search-entry',
'class': 'form-control mousetrap',
'placeholder': Sao.i18n.gettext('Action')
}).appendTo(group);
var completion = new Sao.common.InputCompletion(
this.el,
this.update.bind(this),
@@ -822,12 +819,6 @@ var Sao = {};
}
}
});
completion.dropdown.on('hide.bs.dropdown', function() {
jQuery('#menu').css('overflow-y', 'auto');
});
completion.dropdown.on('show.bs.dropdown', function() {
jQuery('#menu').css('overflow-y', 'visible');
});
},
format: function(content) {
var el = jQuery('<div/>');