Skip to content

Commit 1906d56

Browse files
committed
[MIG] web_responsive: Migration to 18.0
1 parent 430706c commit 1906d56

File tree

33 files changed

+168
-266
lines changed

33 files changed

+168
-266
lines changed

web_responsive/README.rst

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -61,13 +61,9 @@ This module adds responsiveness to web backend.
6161
**Features for mobile**: \* View type picker dropdown displays
6262
comfortably
6363

64-
- Control panel buttons use icons to save space.
65-
66-
|image6|
67-
6864
- Followers and send button is displayed on mobile. Avatar is hidden.
6965

70-
|image7|
66+
|image6|
7167

7268
- Big inputs on form in edit mode
7369

@@ -79,36 +75,35 @@ comfortably
7975
be more intuitive or accessible by fingers of one hand. F.x. Alt + S
8076
for Save
8177

82-
|image8|
78+
|image7|
8379

8480
- Autofocus on search menu box when opening the app menu
8581

86-
|image9|
82+
|image8|
8783

8884
- When the chatter is on the side part, the document viewer fills that
8985
part for side-by-side reading instead of full screen. You can still
9086
put it on full width preview clicking on the new maximize button.
9187

92-
|image10|
88+
|image9|
9389

9490
- When the user chooses to send a public message the color of the
9591
composer is different from the one when the message is an internal
9692
log.
9793

98-
|image11|
94+
|image10|
9995

10096
.. |image| image:: https://raw.githubusercontent.com/OCA/web/18.0/web_responsive/static/img/redirecthome.gif
10197
.. |image1| image:: https://raw.githubusercontent.com/OCA/web/18.0/web_responsive/static/img/appmenu.gif
10298
.. |image2| image:: https://raw.githubusercontent.com/OCA/web/18.0/web_responsive/static/img/appsearch.gif
10399
.. |image3| image:: https://raw.githubusercontent.com/OCA/web/18.0/web_responsive/static/img/listview.gif
104100
.. |image4| image:: https://raw.githubusercontent.com/OCA/web/18.0/web_responsive/static/img/formview.gif
105101
.. |image5| image:: https://raw.githubusercontent.com/OCA/web/18.0/web_responsive/static/img/listview.gif
106-
.. |image6| image:: https://raw.githubusercontent.com/OCA/web/18.0/web_responsive/static/img/form_buttons.gif
107-
.. |image7| image:: https://raw.githubusercontent.com/OCA/web/18.0/web_responsive/static/img/chatter.png
108-
.. |image8| image:: https://raw.githubusercontent.com/OCA/web/18.0/web_responsive/static/img/shortcuts.gif
109-
.. |image9| image:: https://raw.githubusercontent.com/OCA/web/18.0/web_responsive/static/img/appsearch.gif
110-
.. |image10| image:: https://raw.githubusercontent.com/OCA/web/18.0/web_responsive/static/img/document_viewer.gif
111-
.. |image11| image:: https://raw.githubusercontent.com/OCA/web/18.0/web_responsive/static/img/chatter-colors.png
102+
.. |image6| image:: https://raw.githubusercontent.com/OCA/web/18.0/web_responsive/static/img/chatter.png
103+
.. |image7| image:: https://raw.githubusercontent.com/OCA/web/18.0/web_responsive/static/img/shortcuts.gif
104+
.. |image8| image:: https://raw.githubusercontent.com/OCA/web/18.0/web_responsive/static/img/appsearch.gif
105+
.. |image9| image:: https://raw.githubusercontent.com/OCA/web/18.0/web_responsive/static/img/document_viewer.gif
106+
.. |image10| image:: https://raw.githubusercontent.com/OCA/web/18.0/web_responsive/static/img/chatter-colors.png
112107

113108
**Table of contents**
114109

@@ -179,6 +174,14 @@ Contributors
179174

180175
- Angel Patel <patelangel1414@gmail.com>
181176

177+
- Chau Le <chaulb@trobz.com>
178+
179+
Other credits
180+
-------------
181+
182+
The migration of this module from 17.0 to 18.0 was financially supported
183+
by Trobz.
184+
182185
Maintainers
183186
-----------
184187

web_responsive/__manifest__.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
{
1010
"name": "Web Responsive",
1111
"summary": "Responsive web client, community-supported",
12-
"version": "17.0.1.1.3",
12+
"version": "18.0.1.0.0",
1313
"category": "Website",
1414
"website": "https://github.com/OCA/web",
1515
"author": "LasLabs, Tecnativa, ITerra, Onestein, "
@@ -50,9 +50,6 @@
5050
"/web_responsive/static/src/components/command_palette/*",
5151
"/web_responsive/static/src/views/form/*",
5252
],
53-
"web.assets_tests": [
54-
"/web_responsive/static/tests/test_patch.js",
55-
],
5653
"web.qunit_suite_tests": [
5754
"/web_responsive/static/tests/apps_menu_tests.esm.js",
5855
"/web_responsive/static/tests/apps_menu_search_tests.esm.js",

web_responsive/readme/CONTRIBUTORS.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,5 @@
2121
- Taras Shabaranskyi \<<shabaranskij@gmail.com>\>
2222

2323
- Angel Patel \<<patelangel1414@gmail.com>\>
24+
25+
- Chau Le \<<chaulb@trobz.com>\>

web_responsive/readme/CREDITS.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
The migration of this module from 17.0 to 18.0 was financially supported by Trobz.

web_responsive/readme/DESCRIPTION.md

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,6 @@ their profile settings.
3232
**Features for mobile**: \* View type picker dropdown displays
3333
comfortably
3434

35-
- Control panel buttons use icons to save space.
36-
37-
![image](../static/img/form_buttons.gif)
38-
3935
- Followers and send button is displayed on mobile. Avatar is hidden.
4036

4137
![image](../static/img/chatter.png)

web_responsive/static/description/index.html

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -397,11 +397,8 @@ <h1 class="title">Web Responsive</h1>
397397
<p><strong>Features for mobile</strong>: * View type picker dropdown displays
398398
comfortably</p>
399399
<ul>
400-
<li><p class="first">Control panel buttons use icons to save space.</p>
401-
<p><img alt="image6" src="https://raw.githubusercontent.com/OCA/web/18.0/web_responsive/static/img/form_buttons.gif" /></p>
402-
</li>
403400
<li><p class="first">Followers and send button is displayed on mobile. Avatar is hidden.</p>
404-
<p><img alt="image7" src="https://raw.githubusercontent.com/OCA/web/18.0/web_responsive/static/img/chatter.png" /></p>
401+
<p><img alt="image6" src="https://raw.githubusercontent.com/OCA/web/18.0/web_responsive/static/img/chatter.png" /></p>
405402
</li>
406403
<li><p class="first">Big inputs on form in edit mode</p>
407404
</li>
@@ -413,20 +410,20 @@ <h1 class="title">Web Responsive</h1>
413410
with Firefox Tab switching. Standard Odoo keyboard hotkeys changed to
414411
be more intuitive or accessible by fingers of one hand. F.x. Alt + S
415412
for Save</p>
416-
<p><img alt="image8" src="https://raw.githubusercontent.com/OCA/web/18.0/web_responsive/static/img/shortcuts.gif" /></p>
413+
<p><img alt="image7" src="https://raw.githubusercontent.com/OCA/web/18.0/web_responsive/static/img/shortcuts.gif" /></p>
417414
</li>
418415
<li><p class="first">Autofocus on search menu box when opening the app menu</p>
419-
<p><img alt="image9" src="https://raw.githubusercontent.com/OCA/web/18.0/web_responsive/static/img/appsearch.gif" /></p>
416+
<p><img alt="image8" src="https://raw.githubusercontent.com/OCA/web/18.0/web_responsive/static/img/appsearch.gif" /></p>
420417
</li>
421418
<li><p class="first">When the chatter is on the side part, the document viewer fills that
422419
part for side-by-side reading instead of full screen. You can still
423420
put it on full width preview clicking on the new maximize button.</p>
424-
<p><img alt="image10" src="https://raw.githubusercontent.com/OCA/web/18.0/web_responsive/static/img/document_viewer.gif" /></p>
421+
<p><img alt="image9" src="https://raw.githubusercontent.com/OCA/web/18.0/web_responsive/static/img/document_viewer.gif" /></p>
425422
</li>
426423
<li><p class="first">When the user chooses to send a public message the color of the
427424
composer is different from the one when the message is an internal
428425
log.</p>
429-
<p><img alt="image11" src="https://raw.githubusercontent.com/OCA/web/18.0/web_responsive/static/img/chatter-colors.png" /></p>
426+
<p><img alt="image10" src="https://raw.githubusercontent.com/OCA/web/18.0/web_responsive/static/img/chatter-colors.png" /></p>
430427
</li>
431428
</ul>
432429
<p><strong>Table of contents</strong></p>
@@ -438,7 +435,8 @@ <h1 class="title">Web Responsive</h1>
438435
<li><a class="reference internal" href="#credits" id="toc-entry-4">Credits</a><ul>
439436
<li><a class="reference internal" href="#authors" id="toc-entry-5">Authors</a></li>
440437
<li><a class="reference internal" href="#contributors" id="toc-entry-6">Contributors</a></li>
441-
<li><a class="reference internal" href="#maintainers" id="toc-entry-7">Maintainers</a></li>
438+
<li><a class="reference internal" href="#other-credits" id="toc-entry-7">Other credits</a></li>
439+
<li><a class="reference internal" href="#maintainers" id="toc-entry-8">Maintainers</a></li>
442440
</ul>
443441
</li>
444442
</ul>
@@ -496,10 +494,16 @@ <h2><a class="toc-backref" href="#toc-entry-6">Contributors</a></h2>
496494
<li>David Vidal &lt;<a class="reference external" href="mailto:david.vidal&#64;tecnativa.com">david.vidal&#64;tecnativa.com</a>&gt;</li>
497495
<li>Taras Shabaranskyi &lt;<a class="reference external" href="mailto:shabaranskij&#64;gmail.com">shabaranskij&#64;gmail.com</a>&gt;</li>
498496
<li>Angel Patel &lt;<a class="reference external" href="mailto:patelangel1414&#64;gmail.com">patelangel1414&#64;gmail.com</a>&gt;</li>
497+
<li>Chau Le &lt;<a class="reference external" href="mailto:chaulb&#64;trobz.com">chaulb&#64;trobz.com</a>&gt;</li>
499498
</ul>
500499
</div>
500+
<div class="section" id="other-credits">
501+
<h2><a class="toc-backref" href="#toc-entry-7">Other credits</a></h2>
502+
<p>The migration of this module from 17.0 to 18.0 was financially supported
503+
by Trobz.</p>
504+
</div>
501505
<div class="section" id="maintainers">
502-
<h2><a class="toc-backref" href="#toc-entry-7">Maintainers</a></h2>
506+
<h2><a class="toc-backref" href="#toc-entry-8">Maintainers</a></h2>
503507
<p>This module is maintained by the OCA.</p>
504508
<a class="reference external image-reference" href="https://odoo-community.org">
505509
<img alt="Odoo Community Association" src="https://odoo-community.org/logo.png" />
-205 KB
Binary file not shown.
Lines changed: 62 additions & 80 deletions
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,48 @@
1-
/** @odoo-module **/
21
/* Copyright 2018 Tecnativa - Jairo Llopis
32
* Copyright 2021 ITerra - Sergey Shebanin
43
* Copyright 2023 Onestein - Anjeel Haria
54
* Copyright 2023 Taras Shabaranskyi
65
* License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl). */
76

87
import {Component, onWillStart, useState} from "@odoo/owl";
9-
import {session} from "@web/session";
108
import {useBus, useService} from "@web/core/utils/hooks";
119
import {AppMenuItem} from "@web_responsive/components/apps_menu_item/apps_menu_item.esm";
1210
import {AppsMenuSearchBar} from "@web_responsive/components/menu_searchbar/searchbar.esm";
1311
import {NavBar} from "@web/webclient/navbar/navbar";
1412
import {WebClient} from "@web/webclient/webclient";
13+
import {browser} from "@web/core/browser/browser";
1514
import {patch} from "@web/core/utils/patch";
15+
import {router} from "@web/core/browser/router";
16+
import {session} from "@web/session";
1617
import {useHotkey} from "@web/core/hotkeys/hotkey_hook";
17-
import {browser} from "@web/core/browser/browser";
18+
import {user} from "@web/core/user";
19+
20+
/* global document */
21+
/* global location */
22+
/* global window */
1823

1924
// Patch WebClient to show AppsMenu instead of default app
2025
patch(WebClient.prototype, {
2126
setup() {
2227
super.setup();
28+
2329
useBus(this.env.bus, "APPS_MENU:STATE_CHANGED", ({detail: state}) => {
2430
document.body.classList.toggle("o_apps_menu_opened", state);
2531
});
26-
this.user = useService("user");
2732
onWillStart(async () => {
2833
const is_redirect_home = await this.orm.searchRead(
2934
"res.users",
30-
[["id", "=", this.user.userId]],
35+
[["id", "=", user.userId]],
3136
["is_redirect_home"]
3237
);
33-
this.env.services.user.updateContext({
38+
user.updateContext({
3439
is_redirect_to_home: is_redirect_home[0]?.is_redirect_home,
3540
});
3641
});
3742
this.redirect = false;
3843
},
3944
_loadDefaultApp() {
40-
if (this.env.services.user.context.is_redirect_to_home) {
45+
if (user.context.is_redirect_to_home) {
4146
this.env.bus.trigger("APPS_MENU:STATE_CHANGED", true);
4247
} else {
4348
super._loadDefaultApp();
@@ -52,9 +57,9 @@ export class AppsMenu extends Component {
5257
this.theme = session.apps_menu.theme || "milk";
5358
this.menuService = useService("menu");
5459
browser.localStorage.setItem("redirect_menuId", "");
55-
if (this.env.services.user.context.is_redirect_to_home) {
56-
this.router = useService("router");
57-
const menuId = Number(this.router.current.hash.menu_id || 0);
60+
61+
if (user.context.is_redirect_to_home) {
62+
const menuId = Number(router.current.menu_id || 0);
5863
this.state = useState({open: menuId === 0});
5964
}
6065
useBus(this.env.bus, "ACTION_MANAGER:UI-UPDATED", () => {
@@ -75,98 +80,75 @@ export class AppsMenu extends Component {
7580
const repeatable = {
7681
allowRepeat: true,
7782
};
78-
useHotkey(
79-
"ArrowRight",
80-
() => {
81-
this._onWindowKeydown("next");
82-
},
83-
repeatable
84-
);
85-
useHotkey(
86-
"ArrowLeft",
87-
() => {
88-
this._onWindowKeydown("prev");
89-
},
90-
repeatable
91-
);
92-
useHotkey(
93-
"ArrowDown",
94-
() => {
95-
this._onWindowKeydown("next");
96-
},
97-
repeatable
98-
);
99-
useHotkey(
100-
"ArrowUp",
101-
() => {
102-
this._onWindowKeydown("prev");
103-
},
104-
repeatable
105-
);
83+
84+
const keyActions = [
85+
{key: "ArrowRight", action: "next"},
86+
{key: "ArrowLeft", action: "prev"},
87+
{key: "ArrowDown", action: "next"},
88+
{key: "ArrowUp", action: "prev"},
89+
];
90+
91+
keyActions.forEach(({key, action}) => {
92+
useHotkey(
93+
key,
94+
() => {
95+
this._onWindowKeydown(action);
96+
},
97+
repeatable
98+
);
99+
});
100+
106101
useHotkey("Escape", () => {
107102
this.env.bus.trigger("ACTION_MANAGER:UI-UPDATED");
108103
});
109104
}
110105

111106
_onWindowKeydown(direction) {
112-
const focusableInputElements = document.querySelectorAll(".o-app-menu-item");
107+
const focusableInputElements = Array.from(
108+
document.querySelectorAll(".o-app-menu-item")
109+
);
110+
const currentIndex = focusableInputElements.indexOf(document.activeElement);
111+
113112
if (focusableInputElements.length) {
114-
const focusable = [...focusableInputElements];
115-
const index = focusable.indexOf(document.activeElement);
113+
const lastIndex = focusableInputElements.length - 1;
114+
116115
let nextIndex = 0;
117-
if (direction === "prev" && index >= 0) {
118-
if (index > 0) {
119-
nextIndex = index - 1;
120-
} else {
121-
nextIndex = focusable.length - 1;
122-
}
123-
} else if (direction === "next") {
124-
if (index + 1 < focusable.length) {
125-
nextIndex = index + 1;
126-
} else {
127-
nextIndex = 0;
128-
}
116+
if (direction === "next") {
117+
nextIndex = currentIndex < lastIndex ? currentIndex + 1 : 0;
118+
} else if (direction === "prev") {
119+
nextIndex = currentIndex > 0 ? currentIndex - 1 : lastIndex;
129120
}
121+
130122
focusableInputElements[nextIndex].focus();
131123
}
132124
}
133125

134126
onMenuClick() {
135-
if (!this.env.services.user.context.is_redirect_to_home) {
136-
this.setOpenState(!this.state.open);
137-
} else {
138-
const redirect_menuId =
139-
browser.localStorage.getItem("redirect_menuId") || "";
140-
if (!redirect_menuId) {
141-
this.setOpenState(true);
142-
} else {
143-
this.setOpenState(!this.state.open);
144-
}
145-
const {href, hash} = location;
146-
const menuId = this.router.current.hash.menu_id;
147-
if (menuId && menuId != redirect_menuId) {
148-
console.log(this.router.current.hash.menu_id);
149-
browser.localStorage.setItem(
150-
"redirect_menuId",
151-
this.router.current.hash.menu_id
152-
);
127+
const isRedirect = user.context.is_redirect_to_home;
128+
const redirectMenuId = browser.localStorage.getItem("redirect_menuId") || "";
129+
const {href, hash} = location;
130+
131+
if (isRedirect) {
132+
const shouldOpenState = !redirectMenuId || !this.state.open;
133+
this.setOpenState(shouldOpenState);
134+
135+
const currentMenuId = router.current.menu_id;
136+
if (currentMenuId && currentMenuId !== redirectMenuId) {
137+
browser.localStorage.setItem("redirect_menuId", currentMenuId);
153138
}
154139

155140
if (href.includes(hash)) {
156141
window.history.replaceState(null, "", href.replace(hash, ""));
157142
}
143+
} else {
144+
this.setOpenState(!this.state.open);
158145
}
159146
}
160147
}
161148

162-
Object.assign(AppsMenu, {
163-
template: "web_responsive.AppsMenu",
164-
props: {
165-
slots: {
166-
type: Object,
167-
optional: true,
168-
},
169-
},
170-
});
149+
AppsMenu.template = "web_responsive.AppsMenu";
150+
AppsMenu.props = {
151+
slots: {type: Object, optional: true},
152+
};
171153

172154
Object.assign(NavBar.components, {AppsMenu, AppMenuItem, AppsMenuSearchBar});

0 commit comments

Comments
 (0)