From 5db605f08124e0d8623b7158569566c3571d9bb1 Mon Sep 17 00:00:00 2001 From: QS5ELkMu Date: Thu, 2 Aug 2018 08:07:07 +0200 Subject: [PATCH] [IMP][11.0][web_responsive] Suggested changes (#978) * [IMP] Chatter Position * [IMP] Clean unused stuff * [IMP] FieldStatus hidden-xs * [IMP] Improvements suggested in #540 * [WIP] Suggested changes * [WIP] Improve FieldStatus-Responsive * [IMP] Statusbar Buttons & FieldStatus * [IMP] Statusbar Buttons Style * [IMP] Button 'Task' style --- web_responsive/models/__init__.py | 1 - web_responsive/models/ir_http.py | 16 ------ .../static/src/js/web_responsive.js | 46 +++++++++++++++++ web_responsive/static/src/less/form_view.less | 33 +++++++++++++ web_responsive/static/src/xml/form_view.xml | 49 +++++++++++++++++++ web_responsive/views/web.xml | 2 +- 6 files changed, 129 insertions(+), 18 deletions(-) delete mode 100644 web_responsive/models/ir_http.py diff --git a/web_responsive/models/__init__.py b/web_responsive/models/__init__.py index 190e5f763696..e674b2be94d8 100644 --- a/web_responsive/models/__init__.py +++ b/web_responsive/models/__init__.py @@ -2,4 +2,3 @@ # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). from . import inherited_res_users -from . import ir_http diff --git a/web_responsive/models/ir_http.py b/web_responsive/models/ir_http.py deleted file mode 100644 index f5dad08766c9..000000000000 --- a/web_responsive/models/ir_http.py +++ /dev/null @@ -1,16 +0,0 @@ -# Copyright 2018 Alexandre Díaz -# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). - -from odoo import models -from odoo.http import request - - -class Http(models.AbstractModel): - _inherit = 'ir.http' - - def session_info(self): - res = super(Http, self).session_info() - res.update({ - 'chatter_position': request.env.user.chatter_position or 'normal', - }) - return res diff --git a/web_responsive/static/src/js/web_responsive.js b/web_responsive/static/src/js/web_responsive.js index bbc8617512fb..fc9d7d0d864a 100644 --- a/web_responsive/static/src/js/web_responsive.js +++ b/web_responsive/static/src/js/web_responsive.js @@ -10,6 +10,10 @@ odoo.define('web_responsive', function(require) { var core = require('web.core'); var config = require('web.config'); var ViewManager = require('web.ViewManager'); + var RelationalFields = require('web.relational_fields'); + var FormRenderer = require('web.FormRenderer'); + + var qweb = core.qweb; Menu.include({ @@ -306,11 +310,53 @@ odoo.define('web_responsive', function(require) { }, }); + // FieldStatus (responsive fold) + RelationalFields.FieldStatus.include({ + _renderQWebValues: function () { + return { + selections: this.status_information, // Needed to preserve order + has_folded: _.filter(this.status_information, {'selected': false}).length > 0, + clickable: !!this.attrs.clickable, + }; + }, + + _render: function () { + // FIXME: Odoo framework creates view values & render qweb in the + // same method. This cause a "double render" process to use + // new custom values. + this._super.apply(this, arguments); + this.$el.html(qweb.render("FieldStatus.content", this._renderQWebValues())); + } + }); + + // Responsive view "action" buttons + FormRenderer.include({ + _renderHeaderButtons: function (node) { + var self = this; + var $buttons = this._super(node); + + var $container = $(qweb.render('web_responsive.MenuStatusbarButtons')); + $container.find('.o_statusbar_buttons_base').append($buttons); + + var $dropdownMenu = $container.find('.dropdown-menu'); + _.each(node.children, function (child) { + if (child.tag === 'button') { + $dropdownMenu.append($('
  • ').append(self._renderHeaderButton(child))); + } + }); + + return $container; + } + }); + + return { 'AppDrawer': AppDrawer, 'SearchView': SearchView, 'Menu': Menu, 'ViewManager': ViewManager, + 'FieldStatus': RelationalFields.FieldStatus, + 'FormRenderer': FormRenderer, }; }); diff --git a/web_responsive/static/src/less/form_view.less b/web_responsive/static/src/less/form_view.less index 1f58a8438789..f367c322adf8 100644 --- a/web_responsive/static/src/less/form_view.less +++ b/web_responsive/static/src/less/form_view.less @@ -92,6 +92,39 @@ position: sticky; top: 0; z-index: 1; + + .o-status-more > li > button { + border: 0; + } + + .o_statusbar_buttons_container { + .o_statusbar_buttons_dropdown { + height: 100%; + + >#dropdownMenuHeader { + height: 100%; + border-top: 0; + border-bottom: 0; + border-radius: 0; + } + >.dropdown-menu > li > button { + width: 100%; + border-radius: 0; + border: 0; + } + } + + .o_statusbar_buttons_base > .o_statusbar_buttons { + .o-flex-flow(row, wrap); + >.btn { + @o-statusbar-buttons-vmargin: 4px; + min-height: @odoo-statusbar-height - 2 * @o-statusbar-buttons-vmargin; + margin: @o-statusbar-buttons-vmargin 3px @o-statusbar-buttons-vmargin 0; + padding-top: 2px; + padding-bottom: 2px; + } + } + } } } diff --git a/web_responsive/static/src/xml/form_view.xml b/web_responsive/static/src/xml/form_view.xml index bca8904c95b6..51537b9994d9 100644 --- a/web_responsive/static/src/xml/form_view.xml +++ b/web_responsive/static/src/xml/form_view.xml @@ -1,6 +1,7 @@ @@ -12,4 +13,52 @@ + + + + + + + + + + + + + + + + + + + + + + + + + +
    + + +
    +
    + diff --git a/web_responsive/views/web.xml b/web_responsive/views/web.xml index 8da49e2bd0ac..0f57c0a3a79c 100644 --- a/web_responsive/views/web.xml +++ b/web_responsive/views/web.xml @@ -96,7 +96,7 @@ - o_main o_chatter_position_{{ json.loads(session_info)['chatter_position'] }} + o_main o_chatter_position_{{ request.env.user.chatter_position or 'normal' }}