3
0
Fork 0

[MIG] web_responsive: Migration to 13.0

17.0
Alexandre Díaz 2019-09-30 17:32:35 +02:00 committed by Taras Shabaranskyi
parent a98c3ad854
commit ef1461287b
9 changed files with 131 additions and 116 deletions

View File

@ -14,13 +14,13 @@ Web Responsive
:target: http://www.gnu.org/licenses/lgpl-3.0-standalone.html :target: http://www.gnu.org/licenses/lgpl-3.0-standalone.html
:alt: License: LGPL-3 :alt: License: LGPL-3
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fweb-lightgray.png?logo=github .. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fweb-lightgray.png?logo=github
:target: https://github.com/OCA/web/tree/12.0/web_responsive :target: https://github.com/OCA/web/tree/13.0/web_responsive
:alt: OCA/web :alt: OCA/web
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png .. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/web-12-0/web-12-0-web_responsive :target: https://translation.odoo-community.org/projects/web-13-0/web-13-0-web_responsive
:alt: Translate me on Weblate :alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png .. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png
:target: https://runbot.odoo-community.org/runbot/162/12.0 :target: https://runbot.odoo-community.org/runbot/162/13.0
:alt: Try me on Runbot :alt: Try me on Runbot
|badge1| |badge2| |badge3| |badge4| |badge5| |badge1| |badge2| |badge3| |badge4| |badge5|
@ -85,23 +85,23 @@ Features for computers:
* Sticky chatter topbar * Sticky chatter topbar
.. image:: https://raw.githubusercontent.com/OCA/web/12.0/web_responsive/static/img/chatter_topbar.gif .. image:: https://raw.githubusercontent.com/OCA/web/13.0/web_responsive/static/img/chatter_topbar.gif
* AppMenu waits for action finished to show the view * AppMenu waits for action finished to show the view
.. image:: https://raw.githubusercontent.com/OCA/web/12.0/web_responsive/static/img/appmenu.gif .. image:: https://raw.githubusercontent.com/OCA/web/13.0/web_responsive/static/img/appmenu.gif
* Sticky header & footer in list view * Sticky header & footer in list view
.. image:: https://raw.githubusercontent.com/OCA/web/12.0/web_responsive/static/img/listview.gif .. image:: https://raw.githubusercontent.com/OCA/web/13.0/web_responsive/static/img/listview.gif
* Sticky statusbar in form view * Sticky statusbar in form view
.. image:: https://raw.githubusercontent.com/OCA/web/12.0/web_responsive/static/img/formview.gif .. image:: https://raw.githubusercontent.com/OCA/web/13.0/web_responsive/static/img/formview.gif
* Followers and send button is displayed on mobile. Avatar is hidden. * Followers and send button is displayed on mobile. Avatar is hidden.
.. image:: https://raw.githubusercontent.com/OCA/web/12.0/web_responsive/static/img/chatter.gif .. image:: https://raw.githubusercontent.com/OCA/web/13.0/web_responsive/static/img/chatter.gif
**Table of contents** **Table of contents**
@ -113,7 +113,6 @@ Usage
The following keyboard shortcuts are implemented: The following keyboard shortcuts are implemented:
* Toggle app drawer - ``Alt + Shift + H``
* Navigate app search results - Arrow keys * Navigate app search results - Arrow keys
* Choose app result - ``Enter`` * Choose app result - ``Enter``
* ``Esc`` to close app drawer * ``Esc`` to close app drawer
@ -134,7 +133,7 @@ Bug Tracker
Bugs are tracked on `GitHub Issues <https://github.com/OCA/web/issues>`_. Bugs are tracked on `GitHub Issues <https://github.com/OCA/web/issues>`_.
In case of trouble, please check there if your issue has already been reported. In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us smashing it by providing a detailed and welcomed If you spotted it first, help us smashing it by providing a detailed and welcomed
`feedback <https://github.com/OCA/web/issues/new?body=module:%20web_responsive%0Aversion:%2012.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_. `feedback <https://github.com/OCA/web/issues/new?body=module:%20web_responsive%0Aversion:%2013.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
Do not contact contributors directly about support or help with technical issues. Do not contact contributors directly about support or help with technical issues.
@ -146,7 +145,6 @@ Authors
* LasLabs * LasLabs
* Tecnativa * Tecnativa
* Alexandre Díaz
Contributors Contributors
~~~~~~~~~~~~ ~~~~~~~~~~~~
@ -171,6 +169,6 @@ OCA, or the Odoo Community Association, is a nonprofit organization whose
mission is to support the collaborative development of Odoo features and mission is to support the collaborative development of Odoo features and
promote its widespread use. promote its widespread use.
This module is part of the `OCA/web <https://github.com/OCA/web/tree/12.0/web_responsive>`_ project on GitHub. This module is part of the `OCA/web <https://github.com/OCA/web/tree/13.0/web_responsive>`_ project on GitHub.
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

View File

@ -1,14 +1,14 @@
# Copyright 2016-2017 LasLabs Inc. # Copyright 2016-2017 LasLabs Inc.
# Copyright 2018 Alexandre Díaz # Copyright 2018-2019 Alexandre Díaz
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl.html). # License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl.html).
{ {
"name": "Web Responsive", "name": "Web Responsive",
"summary": "Responsive web client, community-supported", "summary": "Responsive web client, community-supported",
"version": "12.0.1.3.0", "version": "13.0.1.0.0",
"category": "Website", "category": "Website",
"website": "https://github.com/OCA/web", "website": "https://github.com/OCA/web",
"author": "LasLabs, Tecnativa, Alexandre Díaz, " "author": "LasLabs, Tecnativa, "
"Odoo Community Association (OCA)", "Odoo Community Association (OCA)",
"license": "LGPL-3", "license": "LGPL-3",
"installable": True, "installable": True,

View File

@ -1,4 +1,4 @@
# Copyright 2018 Alexandre Díaz # Copyright 2018-2019 Alexandre Díaz
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from odoo import models, fields from odoo import models, fields
@ -10,7 +10,7 @@ class ResUsers(models.Model):
chatter_position = fields.Selection([ chatter_position = fields.Selection([
('normal', 'Normal'), ('normal', 'Normal'),
('sided', 'Sided'), ('sided', 'Sided'),
], string="Chatter Position", default='normal') ], string="Chatter Position", default='sided')
def __init__(self, pool, cr): def __init__(self, pool, cr):
""" Override of __init__ to add access rights. """ Override of __init__ to add access rights.

View File

@ -1,6 +1,5 @@
The following keyboard shortcuts are implemented: The following keyboard shortcuts are implemented:
* Toggle app drawer - ``Alt + Shift + H``
* Navigate app search results - Arrow keys * Navigate app search results - Arrow keys
* Choose app result - ``Enter`` * Choose app result - ``Enter``
* ``Esc`` to close app drawer * ``Esc`` to close app drawer

View File

@ -367,7 +367,7 @@ ul.auto-toc {
!! This file is generated by oca-gen-addon-readme !! !! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !! !! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! --> !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
<p><a class="reference external" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external" href="http://www.gnu.org/licenses/lgpl-3.0-standalone.html"><img alt="License: LGPL-3" src="https://img.shields.io/badge/licence-LGPL--3-blue.png" /></a> <a class="reference external" href="https://github.com/OCA/web/tree/12.0/web_responsive"><img alt="OCA/web" src="https://img.shields.io/badge/github-OCA%2Fweb-lightgray.png?logo=github" /></a> <a class="reference external" href="https://translation.odoo-community.org/projects/web-12-0/web-12-0-web_responsive"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external" href="https://runbot.odoo-community.org/runbot/162/12.0"><img alt="Try me on Runbot" src="https://img.shields.io/badge/runbot-Try%20me-875A7B.png" /></a></p> <p><a class="reference external" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external" href="http://www.gnu.org/licenses/lgpl-3.0-standalone.html"><img alt="License: LGPL-3" src="https://img.shields.io/badge/licence-LGPL--3-blue.png" /></a> <a class="reference external" href="https://github.com/OCA/web/tree/13.0/web_responsive"><img alt="OCA/web" src="https://img.shields.io/badge/github-OCA%2Fweb-lightgray.png?logo=github" /></a> <a class="reference external" href="https://translation.odoo-community.org/projects/web-13-0/web-13-0-web_responsive"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external" href="https://runbot.odoo-community.org/runbot/162/13.0"><img alt="Try me on Runbot" src="https://img.shields.io/badge/runbot-Try%20me-875A7B.png" /></a></p>
<p>This module adds responsiveness to web backend.</p> <p>This module adds responsiveness to web backend.</p>
<p>Features for all devices:</p> <p>Features for all devices:</p>
<ul> <ul>
@ -416,19 +416,19 @@ See <a class="reference external" href="https://github.com/odoo/odoo/issues/3006
<img alt="https://user-images.githubusercontent.com/973709/48417428-ac5a5f00-e74a-11e8-8839-5bc538c54c1d.png" src="https://user-images.githubusercontent.com/973709/48417428-ac5a5f00-e74a-11e8-8839-5bc538c54c1d.png" /> <img alt="https://user-images.githubusercontent.com/973709/48417428-ac5a5f00-e74a-11e8-8839-5bc538c54c1d.png" src="https://user-images.githubusercontent.com/973709/48417428-ac5a5f00-e74a-11e8-8839-5bc538c54c1d.png" />
</li> </li>
<li><p class="first">Sticky chatter topbar</p> <li><p class="first">Sticky chatter topbar</p>
<img alt="https://raw.githubusercontent.com/OCA/web/12.0/web_responsive/static/img/chatter_topbar.gif" src="https://raw.githubusercontent.com/OCA/web/12.0/web_responsive/static/img/chatter_topbar.gif" /> <img alt="https://raw.githubusercontent.com/OCA/web/13.0/web_responsive/static/img/chatter_topbar.gif" src="https://raw.githubusercontent.com/OCA/web/13.0/web_responsive/static/img/chatter_topbar.gif" />
</li> </li>
<li><p class="first">AppMenu waits for action finished to show the view</p> <li><p class="first">AppMenu waits for action finished to show the view</p>
<img alt="https://raw.githubusercontent.com/OCA/web/12.0/web_responsive/static/img/appmenu.gif" src="https://raw.githubusercontent.com/OCA/web/12.0/web_responsive/static/img/appmenu.gif" /> <img alt="https://raw.githubusercontent.com/OCA/web/13.0/web_responsive/static/img/appmenu.gif" src="https://raw.githubusercontent.com/OCA/web/13.0/web_responsive/static/img/appmenu.gif" />
</li> </li>
<li><p class="first">Sticky header &amp; footer in list view</p> <li><p class="first">Sticky header &amp; footer in list view</p>
<img alt="https://raw.githubusercontent.com/OCA/web/12.0/web_responsive/static/img/listview.gif" src="https://raw.githubusercontent.com/OCA/web/12.0/web_responsive/static/img/listview.gif" /> <img alt="https://raw.githubusercontent.com/OCA/web/13.0/web_responsive/static/img/listview.gif" src="https://raw.githubusercontent.com/OCA/web/13.0/web_responsive/static/img/listview.gif" />
</li> </li>
<li><p class="first">Sticky statusbar in form view</p> <li><p class="first">Sticky statusbar in form view</p>
<img alt="https://raw.githubusercontent.com/OCA/web/12.0/web_responsive/static/img/formview.gif" src="https://raw.githubusercontent.com/OCA/web/12.0/web_responsive/static/img/formview.gif" /> <img alt="https://raw.githubusercontent.com/OCA/web/13.0/web_responsive/static/img/formview.gif" src="https://raw.githubusercontent.com/OCA/web/13.0/web_responsive/static/img/formview.gif" />
</li> </li>
<li><p class="first">Followers and send button is displayed on mobile. Avatar is hidden.</p> <li><p class="first">Followers and send button is displayed on mobile. Avatar is hidden.</p>
<img alt="https://raw.githubusercontent.com/OCA/web/12.0/web_responsive/static/img/chatter.gif" src="https://raw.githubusercontent.com/OCA/web/12.0/web_responsive/static/img/chatter.gif" /> <img alt="https://raw.githubusercontent.com/OCA/web/13.0/web_responsive/static/img/chatter.gif" src="https://raw.githubusercontent.com/OCA/web/13.0/web_responsive/static/img/chatter.gif" />
</li> </li>
</ul> </ul>
<p><strong>Table of contents</strong></p> <p><strong>Table of contents</strong></p>
@ -449,7 +449,6 @@ See <a class="reference external" href="https://github.com/odoo/odoo/issues/3006
<h1><a class="toc-backref" href="#id1">Usage</a></h1> <h1><a class="toc-backref" href="#id1">Usage</a></h1>
<p>The following keyboard shortcuts are implemented:</p> <p>The following keyboard shortcuts are implemented:</p>
<ul class="simple"> <ul class="simple">
<li>Toggle app drawer - <tt class="docutils literal">Alt + Shift + H</tt></li>
<li>Navigate app search results - Arrow keys</li> <li>Navigate app search results - Arrow keys</li>
<li>Choose app result - <tt class="docutils literal">Enter</tt></li> <li>Choose app result - <tt class="docutils literal">Enter</tt></li>
<li><tt class="docutils literal">Esc</tt> to close app drawer</li> <li><tt class="docutils literal">Esc</tt> to close app drawer</li>
@ -471,7 +470,7 @@ new size. This is Odoos own limitation.</li>
<p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/web/issues">GitHub Issues</a>. <p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/web/issues">GitHub Issues</a>.
In case of trouble, please check there if your issue has already been reported. In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us smashing it by providing a detailed and welcomed If you spotted it first, help us smashing it by providing a detailed and welcomed
<a class="reference external" href="https://github.com/OCA/web/issues/new?body=module:%20web_responsive%0Aversion:%2012.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p> <a class="reference external" href="https://github.com/OCA/web/issues/new?body=module:%20web_responsive%0Aversion:%2013.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
<p>Do not contact contributors directly about support or help with technical issues.</p> <p>Do not contact contributors directly about support or help with technical issues.</p>
</div> </div>
<div class="section" id="credits"> <div class="section" id="credits">
@ -481,7 +480,6 @@ If you spotted it first, help us smashing it by providing a detailed and welcome
<ul class="simple"> <ul class="simple">
<li>LasLabs</li> <li>LasLabs</li>
<li>Tecnativa</li> <li>Tecnativa</li>
<li>Alexandre Díaz</li>
</ul> </ul>
</div> </div>
<div class="section" id="contributors"> <div class="section" id="contributors">
@ -502,7 +500,7 @@ If you spotted it first, help us smashing it by providing a detailed and welcome
<p>OCA, or the Odoo Community Association, is a nonprofit organization whose <p>OCA, or the Odoo Community Association, is a nonprofit organization whose
mission is to support the collaborative development of Odoo features and mission is to support the collaborative development of Odoo features and
promote its widespread use.</p> promote its widespread use.</p>
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/web/tree/12.0/web_responsive">OCA/web</a> project on GitHub.</p> <p>This module is part of the <a class="reference external" href="https://github.com/OCA/web/tree/13.0/web_responsive">OCA/web</a> project on GitHub.</p>
<p>You are welcome to contribute. To learn how please visit <a class="reference external" href="https://odoo-community.org/page/Contribute">https://odoo-community.org/page/Contribute</a>.</p> <p>You are welcome to contribute. To learn how please visit <a class="reference external" href="https://odoo-community.org/page/Contribute">https://odoo-community.org/page/Contribute</a>.</p>
</div> </div>
</div> </div>

View File

@ -207,12 +207,12 @@
} }
// Scroll all but top bar // Scroll all but top bar
html .o_web_client .o_main .o_main_content { html .o_web_client .o_action_manager .o_action {
@include media-breakpoint-down(sm) { @include media-breakpoint-down(sm) {
overflow: auto; overflow: auto;
.o_content { .o_content {
overflow: initial; overflow: visible;
} }
} }
@ -330,13 +330,10 @@ html .o_web_client .o_main .o_main_content {
.o_form_sheet { .o_form_sheet {
max-width: calc(100% - 32px); max-width: calc(100% - 32px);
overflow-x: auto; overflow-x: auto;
}
.oe_button_box { .oe_chatter {
.o_dropdown_more { padding-top: 0;
padding: 0.1em;
width: min-content;
}
}
} }
// Sticky statusbar // Sticky statusbar
@ -365,8 +362,16 @@ html .o_web_client .o_main .o_main_content {
@include media-breakpoint-down(sm) { @include media-breakpoint-down(sm) {
min-width: auto; min-width: auto;
// More buttons border
.oe_button_box {
.o_dropdown_more {
button:last-child {
border-right: 1px solid gray('400');
}
}
}
// Avoid overflow on forms with title and/or button box // Avoid overflow on forms with title and/or button box
.oe_button_box,
.oe_title, .oe_title,
{ {
max-width: 100%; max-width: 100%;
@ -432,6 +437,8 @@ html .o_web_client .o_main .o_main_content {
} }
.o_chatter { .o_chatter {
padding-top: initial;
// Display send button on small screens // Display send button on small screens
.o_thread_composer { .o_thread_composer {
padding-left: $o-mail-thread-avatar-size*0.5; padding-left: $o-mail-thread-avatar-size*0.5;
@ -497,22 +504,7 @@ html .o_web_client .o_main .o_main_content {
position: sticky; position: sticky;
background-color: $o-view-background-color; background-color: $o-view-background-color;
z-index: 1; z-index: 1;
overflow-x: auto;
.o_chatter_topbar {
margin-top: 0;
flex-wrap: wrap;
height: auto;
button:last-of-type {
flex: 1 0 auto;
text-align: left;
}
.o_topbar_right_area {
order: -10;
flex: 0 1 100%;
border-bottom-color: transparent;
}
}
.o_attachments_previews { .o_attachments_previews {
overflow: auto; overflow: auto;
@ -526,25 +518,25 @@ html .o_web_client .o_main .o_main_content {
} }
// Sticky Header & Footer in List View // Sticky Header & Footer in List View
.table-responsive { .o_list_view {
overflow-x: initial; .table-responsive {
.o_list_table {
.o_list_view { // th & td are here for compatibility with chrome
// th & td are here for compatibility with chrome thead, thead tr:nth-child(1) th {
thead, thead tr:nth-child(1) th { position: sticky;
position: sticky; top: 0;
top: 0; z-index: 1;
z-index: 1; }
} thead tr:nth-child(1) th {
thead tr:nth-child(1) th { background-color: $o-list-footer-bg-color;
background-color: $o-list-footer-bg-color; }
} tfoot, tfoot tr:nth-child(1) td {
tfoot, tfoot tr:nth-child(1) td { position: sticky;
position: sticky; bottom: 0;
bottom: 0; }
} tfoot tr:nth-child(1) td {
tfoot tr:nth-child(1) td { background-color: $o-list-footer-bg-color;
background-color: $o-list-footer-bg-color; }
} }
} }
} }

View File

@ -4,16 +4,17 @@
odoo.define('web_responsive', function (require) { odoo.define('web_responsive', function (require) {
'use strict'; 'use strict';
var ActionManager = require('web.ActionManager'); const ActionManager = require('web.ActionManager');
var AbstractWebClient = require("web.AbstractWebClient"); const AbstractWebClient = require("web.AbstractWebClient");
var AppsMenu = require("web.AppsMenu"); const AppsMenu = require("web.AppsMenu");
var BasicController = require('web.BasicController'); const BasicController = require('web.BasicController');
var config = require("web.config"); const config = require("web.config");
var core = require("web.core"); const core = require("web.core");
var FormRenderer = require('web.FormRenderer'); const FormRenderer = require('web.FormRenderer');
var Menu = require("web.Menu"); const Menu = require("web.Menu");
var RelationalFields = require('web.relational_fields'); const RelationalFields = require('web.relational_fields');
var Chatter = require('mail.Chatter'); const Chatter = require('mail.Chatter');
const ListRenderer = require('web.ListRenderer');
/* /*
* Helper function to know if are waiting * Helper function to know if are waiting
@ -97,7 +98,7 @@ odoo.define('web_responsive', function (require) {
init: function (parent, menuData) { init: function (parent, menuData) {
this._super.apply(this, arguments); this._super.apply(this, arguments);
// Keep base64 icon for main menus // Keep base64 icon for main menus
for (var n in this._apps) { for (let n in this._apps) {
this._apps[n].web_icon_data = this._apps[n].web_icon_data =
menuData.children[n].web_icon_data; menuData.children[n].web_icon_data;
} }
@ -108,7 +109,7 @@ odoo.define('web_responsive', function (require) {
{} {}
); );
// Search only after timeout, for fast typers // Search only after timeout, for fast typers
this._search_def = $.Deferred(); this._search_def = false;
}, },
/** /**
@ -141,7 +142,7 @@ odoo.define('web_responsive', function (require) {
* Menu definition, plus extra needed keys. * Menu definition, plus extra needed keys.
*/ */
_menuInfo: function (key) { _menuInfo: function (key) {
var original = this._searchableMenus[key]; const original = this._searchableMenus[key];
return _.extend({ return _.extend({
action_id: parseInt(original.action.split(',')[1], 10), action_id: parseInt(original.action.split(',')[1], 10),
}, original); }, original);
@ -169,17 +170,17 @@ odoo.define('web_responsive', function (require) {
* Schedule a search on current menu items. * Schedule a search on current menu items.
*/ */
_searchMenusSchedule: function () { _searchMenusSchedule: function () {
this._search_def.reject(); this._search_def = new Promise((resolve) => {
this._search_def = $.Deferred(); setTimeout(resolve, 50);
setTimeout(this._search_def.resolve.bind(this._search_def), 50); });
this._search_def.done(this._searchMenus.bind(this)); this._search_def.then(this._searchMenus.bind(this));
}, },
/** /**
* Search among available menu items, and render that search. * Search among available menu items, and render that search.
*/ */
_searchMenus: function () { _searchMenus: function () {
var query = this.$search_input.val(); const query = this.$search_input.val();
if (query === "") { if (query === "") {
this.$search_container.removeClass("has-results"); this.$search_container.removeClass("has-results");
this.$search_results.empty(); this.$search_results.empty();
@ -216,7 +217,7 @@ odoo.define('web_responsive', function (require) {
_searchResultChosen: function (event) { _searchResultChosen: function (event) {
event.preventDefault(); event.preventDefault();
event.stopPropagation(); event.stopPropagation();
var $result = $(event.currentTarget), const $result = $(event.currentTarget),
text = $result.text().trim(), text = $result.text().trim(),
data = $result.data(), data = $result.data(),
suffix = ~text.indexOf("/") ? "/" : ""; suffix = ~text.indexOf("/") ? "/" : "";
@ -227,7 +228,7 @@ odoo.define('web_responsive', function (require) {
previous_menu_id: data.parentId, previous_menu_id: data.parentId,
}); });
// Find app that owns the chosen menu // Find app that owns the chosen menu
var app = _.find(this._apps, function (_app) { const app = _.find(this._apps, function (_app) {
return text.indexOf(_app.name + suffix) === 0; return text.indexOf(_app.name + suffix) === 0;
}); });
// Update navbar menus // Update navbar menus
@ -241,9 +242,9 @@ odoo.define('web_responsive', function (require) {
*/ */
_searchResultsNavigate: function (event) { _searchResultsNavigate: function (event) {
// Find current results and active element (1st by default) // Find current results and active element (1st by default)
var all = this.$search_results.find(".o-menu-search-result"), const all = this.$search_results.find(".o-menu-search-result"),
pre_focused = all.filter(".active") || $(all[0]), pre_focused = all.filter(".active") || $(all[0]);
offset = all.index(pre_focused), let offset = all.index(pre_focused),
key = event.key; key = event.key;
// Keyboard navigation only supports search results // Keyboard navigation only supports search results
if (!all.length) { if (!all.length) {
@ -277,7 +278,7 @@ odoo.define('web_responsive', function (require) {
offset -= all.length; offset -= all.length;
} }
// Switch active element // Switch active element
var new_focused = $(all[offset]); const new_focused = $(all[offset]);
pre_focused.removeClass("active"); pre_focused.removeClass("active");
new_focused.addClass("active"); new_focused.addClass("active");
this.$search_results.scrollTo(new_focused, { this.$search_results.scrollTo(new_focused, {
@ -298,14 +299,17 @@ odoo.define('web_responsive', function (require) {
BasicController.include({ BasicController.include({
/** /**
* Close the AppDrawer if the data set is dirty and a discard dialog is opened * Close the AppDrawer if the data set is dirty and a discard dialog
* is opened
* *
* @override * @override
*/ */
canBeDiscarded: function (recordID) { canBeDiscarded: function (recordID) {
if (this.model.isDirty(recordID || this.handle)) { if (this.model.isDirty(recordID || this.handle)) {
$('.o_menu_apps .dropdown:has(.dropdown-menu.show) > a').dropdown('toggle'); $('.o_menu_apps .dropdown:has(.dropdown-menu.show) > a')
$('.o_menu_sections li.show .dropdown-toggle').dropdown('toggle'); .dropdown('toggle');
$('.o_menu_sections li.show .dropdown-toggle')
.dropdown('toggle');
} }
return this._super.apply(this, arguments); return this._super.apply(this, arguments);
}, },
@ -382,13 +386,38 @@ odoo.define('web_responsive', function (require) {
_setState: function () { _setState: function () {
this._super.apply(this, arguments); this._super.apply(this, arguments);
if (config.device.isMobile) { if (config.device.isMobile) {
_.map(this.status_information, function (value) { _.map(this.status_information, (value) => {
value.fold = true; value.fold = true;
}); });
} }
}, },
}); });
// Sticky Column Selector
ListRenderer.include({
_renderView: function () {
const self = this;
return this._super.apply(this, arguments).then(() => {
const $col_selector = self.$el.find(
'.o_optional_columns_dropdown_toggle');
if ($col_selector.length !== 0) {
const $th = self.$el.find('thead>tr:first>th:last');
$col_selector.appendTo($th);
}
});
},
_onToggleOptionalColumnDropdown: function (ev) {
// FIXME: For some strange reason the 'stopPropagation' call
// in the main method don't work. Invoking here the same method
// does the expected behavior... O_O!
// This prevents the action of sorting the column from being
// launched.
ev.stopPropagation();
this._super.apply(this, arguments);
},
});
// Responsive view "action" buttons // Responsive view "action" buttons
FormRenderer.include({ FormRenderer.include({
@ -398,7 +427,7 @@ odoo.define('web_responsive', function (require) {
* @override * @override
*/ */
_renderHeaderButtons: function () { _renderHeaderButtons: function () {
var $buttons = this._super.apply(this, arguments); const $buttons = this._super.apply(this, arguments);
if ( if (
!config.device.isMobile || !config.device.isMobile ||
!$buttons.is(":has(>:not(.o_invisible_modifier))") !$buttons.is(":has(>:not(.o_invisible_modifier))")
@ -408,7 +437,7 @@ odoo.define('web_responsive', function (require) {
// $buttons must be appended by JS because all events are bound // $buttons must be appended by JS because all events are bound
$buttons.addClass("dropdown-menu"); $buttons.addClass("dropdown-menu");
var $dropdown = $(core.qweb.render( const $dropdown = $(core.qweb.render(
'web_responsive.MenuStatusbarButtons' 'web_responsive.MenuStatusbarButtons'
)); ));
$buttons.addClass("dropdown-menu").appendTo($dropdown); $buttons.addClass("dropdown-menu").appendTo($dropdown);
@ -442,26 +471,25 @@ odoo.define('web_responsive', function (require) {
* The executed action * The executed action
*/ */
_hideMenusByAction: function (action) { _hideMenusByAction: function (action) {
var uniq_sel = '[data-action-id='+action.id+']'; const uniq_sel = '[data-action-id='+action.id+']';
// Need close AppDrawer? // Need close AppDrawer?
var menu_apps_dropdown = document.querySelector( const menu_apps_dropdown = document.querySelector(
'.o_menu_apps .dropdown'); '.o_menu_apps .dropdown');
$(menu_apps_dropdown).has('.dropdown-menu.show') $(menu_apps_dropdown).has('.dropdown-menu.show')
.has(uniq_sel).find('> a').dropdown('toggle'); .has(uniq_sel).find('> a').dropdown('toggle');
// Need close Sections Menu? // Need close Sections Menu?
// TODO: Change to 'hide' in modern Bootstrap >4.1 const menu_sections = document.querySelector(
var menu_sections = document.querySelector(
'.o_menu_sections li.show'); '.o_menu_sections li.show');
$(menu_sections).has(uniq_sel).find('.dropdown-toggle') $(menu_sections).has(uniq_sel).find('.dropdown-toggle')
.dropdown('toggle'); .dropdown('toggle');
// Need close Mobile? // Need close Mobile?
var menu_sections_mobile = document.querySelector( const menu_sections_mobile = document.querySelector(
'.o_menu_sections.show'); '.o_menu_sections.show');
$(menu_sections_mobile).has(uniq_sel).collapse('hide'); $(menu_sections_mobile).has(uniq_sel).hide();
}, },
_handleAction: function (action) { _handleAction: function (action) {
return this._super.apply(this, arguments).always( return this._super.apply(this, arguments).finally(
$.proxy(this, '_hideMenusByAction', action)); $.proxy(this, '_hideMenusByAction', action));
}, },
}); });
@ -498,7 +526,7 @@ odoo.define('web_responsive', function (require) {
* Altered event object * Altered event object
*/ */
_shiftPressed: function (keyEvent) { _shiftPressed: function (keyEvent) {
var alt = keyEvent.altKey || keyEvent.key === "Alt", const alt = keyEvent.altKey || keyEvent.key === "Alt",
newEvent = _.extend({}, keyEvent), newEvent = _.extend({}, keyEvent),
shift = keyEvent.shiftKey || keyEvent.key === "Shift"; shift = keyEvent.shiftKey || keyEvent.key === "Shift";
// Mock event to make it seem like Alt is not pressed // Mock event to make it seem like Alt is not pressed

View File

@ -9,8 +9,8 @@ class TestResUsers(common.TransactionCase):
def test_chatter_position_wr(self): def test_chatter_position_wr(self):
user_public = self.env.ref('base.public_user') user_public = self.env.ref('base.public_user')
self.assertEqual(user_public.chatter_position, 'normal')
user_public.sudo(user_public).write({
'chatter_position': 'sided',
})
self.assertEqual(user_public.chatter_position, 'sided') self.assertEqual(user_public.chatter_position, 'sided')
user_public.sudo(user_public).write({
'chatter_position': 'normal',
})
self.assertEqual(user_public.chatter_position, 'normal')

View File

@ -11,8 +11,8 @@
inherit_id="web.webclient_bootstrap" inherit_id="web.webclient_bootstrap"
name="App Drawer - Web Client" name="App Drawer - Web Client"
> >
<xpath expr="//*[hasclass('o_main')]" position="attributes"> <xpath expr="//t[@t-set='body_classname']" position="attributes">
<attribute name="t-attf-class">o_main o_chatter_position_{{ request.env.user.chatter_position or 'normal' }}</attribute> <attribute name="t-value" add="+ ' o_chatter_position_' + (request.env.user.chatter_position or 'normal')" separator=" " />
</xpath> </xpath>
</template> </template>