openerp.web.dialog = function(element) {
var result = element.dialog.apply(element, _.rest(_.toArray(arguments)));
- result.dialog("widget").addClass("openerp");
+ result.dialog("widget").addClass("openerp2");
return result;
}
$db_list = $form.find('[name=drop_db]'),
db = $db_list.val();
- if (!confirm("Do you really want to delete the database: " + db + " ?")) {
+ if (!db || !confirm("Do you really want to delete the database: " + db + " ?")) {
return;
}
self.rpc("/web/database/drop", {'fields': fields}, function(result) {
init: function() {
this._super.apply(this, arguments);
this.has_been_loaded = $.Deferred();
+ this.maximum_visible_links = 'auto'; // # of menu to show. 0 = do not crop, 'auto' = algo
},
start: function() {
this._super.apply(this, arguments);
this.$secondary_menus = this.getParent().$element.find('.oe_secondary_menus_container');
this.$secondary_menus.on('click', 'a[data-menu]', this.on_menu_click);
+ $('html').bind('click', this.do_hide_more);
},
do_reload: function() {
var self = this;
});
},
on_loaded: function(data) {
+ var self = this;
this.data = data;
this.renderElement();
+ this.limit_entries();
this.$element.on('click', 'a[data-menu]', this.on_menu_click);
+ this.$element.on('click', 'a.oe_menu_more_link', function() {
+ self.$element.find('.oe_menu_more').toggle();
+ return false;
+ });
this.$secondary_menus.html(QWeb.render("Menu.secondary", { widget : this }));
// Hide second level submenus
this.$secondary_menus.find('.oe_menu_toggler').siblings('.oe_secondary_submenu').hide();
this.has_been_loaded.resolve();
},
+ limit_entries: function() {
+ var maximum_visible_links = this.maximum_visible_links;
+ if (maximum_visible_links === 'auto') {
+ maximum_visible_links = this.auto_limit_entries();
+ }
+ if (maximum_visible_links < this.data.data.children.length) {
+ var $more = $(QWeb.render('Menu.more')),
+ $index = this.$element.find('li').eq(maximum_visible_links - 1);
+ $index.after($more);
+ $more.find('.oe_menu_more').append($index.next().nextAll());
+ }
+ },
+ auto_limit_entries: function() {
+ // TODO: auto detect overflow and bind window on resize
+ var width = $(window).width();
+ return Math.floor(width / 125);
+ },
+ do_hide_more: function() {
+ this.$element.find('.oe_menu_more').hide();
+ },
/**
* Opens a given menu by id, as if a user had browsed to that menu by hand
* except does not trigger any event on the way
}
},
on_menu_click: function(ev, id) {
+ this.do_hide_more();
id = id || 0;
var $clicked_menu, manual = false;
return;
var func = new openerp.web.Model("res.users").get_func("read");
return func(self.session.uid, ["name", "company_id"]).pipe(function(res) {
- // TODO: Only show company if multicompany in use
- self.$element.find('.oe_topbar_name').text(res.name + '/' + res.company_id[1]);
+ // TODO: Show company if multicompany is in use
+ var topbar_name = _.str.sprintf("%s (%s)", res.name, openerp.connection.db, res.company_id[1]);
+ self.$element.find('.oe_topbar_name').text(topbar_name);
+ var avatar_src = _.str.sprintf('%s/web/binary/image?session_id=%s&model=res.users&field=avatar&id=%s', self.session.prefix, self.session.session_id, self.session.uid);
+ $avatar.attr('src', avatar_src);
return self.shortcut_load();
});
};
},
start: function() {
var self = this;
- this.$element.addClass("openerp openerp2");
+ this.$element.addClass("openerp2");
if (jQuery.param != undefined && jQuery.deparam(jQuery.param.querystring()).kitten != undefined) {
this.$element.addClass("kitten-mode-activated");
this.$element.delegate('img.oe-record-edit-link-img', 'hover', function(e) {
start: function() {
var self = this;
- this.am.appendTo(this.$element.addClass('openerp'));
+ this.am.appendTo(this.$element.addClass('openerp openerp2'));
return this.rpc("/web/action/load", { action_id: this.action_id }, function(result) {
var action = result.result;
action.flags = _.extend({