diff --git a/addons/web/static/src/css/base.css b/addons/web/static/src/css/base.css index be9e873bb77..b0877b0dbd2 100644 --- a/addons/web/static/src/css/base.css +++ b/addons/web/static/src/css/base.css @@ -167,6 +167,24 @@ -webkit-box-shadow: 0 1px 2px rgba(255, 255, 255, 0.3) inset; -box-shadow: 0 1px 2px rgba(255, 255, 255, 0.3) inset; } +.openerp2 .oe_menu_more_container { + position: relative; +} +.openerp2 .oe_menu_more_container .oe_menu_more { + position: absolute; + padding: 0; + background-color: #646060; + z-index: 1; + border: 1px solid black; + border-bottom-left-radius: 5px; + border-bottom-right-radius: 5px; +} +.openerp2 .oe_menu_more_container .oe_menu_more li { + float: none; +} +.openerp2 .oe_menu_more_container .oe_menu_more li a { + white-space: nowrap; +} .openerp2 .oe_secondary_menu_section { font-weight: bold; margin-left: 8px; @@ -250,19 +268,10 @@ border-right: 4px solid transparent; border-top: 4px solid #4c4c4c; } -.openerp2 .oe_user_menu { - float: right; - padding: 0; - margin: 0; -} -.openerp2 .oe_user_menu li { - list-style-type: none; - float: left; -} -.openerp2 .oe_user_menu .oe_dropdown { +.openerp2 .oe_dropdown { position: relative; } -.openerp2 .oe_user_menu .oe_dropdown_toggle:after { +.openerp2 .oe_dropdown_toggle:after { width: 0; height: 0; display: inline-block; @@ -277,6 +286,15 @@ filter: alpha(opacity=50); opacity: 0.5; } +.openerp2 .oe_user_menu { + float: right; + padding: 0; + margin: 0; +} +.openerp2 .oe_user_menu li { + list-style-type: none; + float: left; +} .openerp2 .oe_user_menu .oe_dropdown_options { float: left; background: #333333; diff --git a/addons/web/static/src/css/base.sass b/addons/web/static/src/css/base.sass index 5dead080904..d8251e501fe 100644 --- a/addons/web/static/src/css/base.sass +++ b/addons/web/static/src/css/base.sass @@ -194,6 +194,20 @@ $colour4: #8a89ba font-weight: bold color: white @include box-shadow(0 1px 2px rgba(255,255,255,0.3) inset) + .oe_menu_more_container + position: relative + .oe_menu_more + position: absolute + padding: 0 + background-color: #646060 + z-index: 1 + border: 1px solid black + border-bottom-left-radius: 5px + border-bottom-right-radius: 5px + li + float: none + a + white-space: nowrap .oe_secondary_menu_section font-weight: bold margin-left: 8px @@ -260,6 +274,23 @@ $colour4: #8a89ba border-top: 4px solid #4c4c4c // }}} // UserMenu {{{ + .oe_dropdown + position: relative + + .oe_dropdown_toggle:after + width: 0 + height: 0 + display: inline-block + content: "&darr" + text-indent: -99999px + vertical-align: top + margin-top: 8px + margin-left: 4px + border-left: 4px solid transparent + border-right: 4px solid transparent + border-top: 4px solid white + @include opacity(0.5) + .oe_user_menu float: right padding: 0 @@ -267,22 +298,6 @@ $colour4: #8a89ba li list-style-type: none float: left - .oe_dropdown - position: relative - - .oe_dropdown_toggle:after - width: 0 - height: 0 - display: inline-block - content: "&darr" - text-indent: -99999px - vertical-align: top - margin-top: 8px - margin-left: 4px - border-left: 4px solid transparent - border-right: 4px solid transparent - border-top: 4px solid white - @include opacity(0.5) .oe_dropdown_options float: left diff --git a/addons/web/static/src/js/chrome.js b/addons/web/static/src/js/chrome.js index ec32bd3c6eb..5faa8c59a80 100644 --- a/addons/web/static/src/js/chrome.js +++ b/addons/web/static/src/js/chrome.js @@ -635,11 +635,13 @@ openerp.web.Menu = openerp.web.Widget.extend(/** @lends openerp.web.Menu# */{ 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; @@ -650,14 +652,40 @@ openerp.web.Menu = openerp.web.Widget.extend(/** @lends openerp.web.Menu# */{ }); }, 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) { + 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 @@ -702,6 +730,7 @@ openerp.web.Menu = openerp.web.Widget.extend(/** @lends openerp.web.Menu# */{ } }, on_menu_click: function(ev, id) { + this.do_hide_more(); id = id || 0; var $clicked_menu, manual = false; diff --git a/addons/web/static/src/js/view_form.js b/addons/web/static/src/js/view_form.js index 642f50bcef9..c817e251054 100644 --- a/addons/web/static/src/js/view_form.js +++ b/addons/web/static/src/js/view_form.js @@ -1785,7 +1785,7 @@ openerp.web.form.FieldFloat = openerp.web.form.FieldChar.extend({ this._super(view, node); this.value = 0; if (this.node.attrs.digits) { - this.digits = py.eval(this.node.attrs.digits).toJSON(); + this.digits = py.eval(node.attrs.digits); } else { this.digits = this.field.digits; } diff --git a/addons/web/static/src/js/view_page.js b/addons/web/static/src/js/view_page.js index 8a6a6e7da4b..d284470fdde 100644 --- a/addons/web/static/src/js/view_page.js +++ b/addons/web/static/src/js/view_page.js @@ -63,11 +63,10 @@ openerp.web.page = function (openerp) { return def.promise(); } }); - + openerp.web.FormRenderingEngineReadonly = openerp.web.FormRenderingEngine.extend({ alter_field: function(field) { field.set({"force_readonly": true}); }, }); - }; diff --git a/addons/web/static/src/js/views.js b/addons/web/static/src/js/views.js index 58d11f017f4..54d9b5118e5 100644 --- a/addons/web/static/src/js/views.js +++ b/addons/web/static/src/js/views.js @@ -763,7 +763,7 @@ session.web.ViewManagerAction = session.web.ViewManager.extend(/** @lends oepner _(log_records.reverse()).each(function (record) { var context = {}; if (record.context) { - try { context = py.eval(record.context).toJSON(); } + try { context = py.eval(record.context); } catch (e) { /* TODO: what do I do now? */ } } $(_.str.sprintf('