Merge PR #2864 into 17.0

Signed-off-by pedrobaeza
pull/2890/head
OCA-git-bot 2024-07-17 11:35:39 +00:00
commit c4d889bf91
10 changed files with 171 additions and 36 deletions

View File

@ -32,36 +32,42 @@ This module adds responsiveness to web backend.
**Features for all devices**: **Features for all devices**:
- New navigation with the fullscreen app menu - Redirect to the dashboard after logging in. Users will only be
redirected to the home page after login if they have enabled the
'Redirect to Home' option in their profile settings.
|image| |image|
- Quick menu search inside the app menu - New navigation with the fullscreen app menu
|image1| |image1|
- Sticky header & footer in list view - Quick menu search inside the app menu
|image2| |image2|
- Sticky statusbar in form view - Sticky header & footer in list view
|image3| |image3|
- Bigger checkboxes in list view - Sticky statusbar in form view
|image4| |image4|
- Bigger checkboxes in list view
|image5|
**Features for mobile**: \* View type picker dropdown displays **Features for mobile**: \* View type picker dropdown displays
comfortably comfortably
- Control panel buttons use icons to save space. - Control panel buttons use icons to save space.
|image5| |image6|
- Followers and send button is displayed on mobile. Avatar is hidden. - Followers and send button is displayed on mobile. Avatar is hidden.
|image6| |image7|
- Big inputs on form in edit mode - Big inputs on form in edit mode
@ -73,35 +79,36 @@ comfortably
be more intuitive or accessible by fingers of one hand. F.x. Alt + S be more intuitive or accessible by fingers of one hand. F.x. Alt + S
for Save for Save
|image7| |image8|
- Autofocus on search menu box when opening the app menu - Autofocus on search menu box when opening the app menu
|image8| |image9|
- When the chatter is on the side part, the document viewer fills that - When the chatter is on the side part, the document viewer fills that
part for side-by-side reading instead of full screen. You can still part for side-by-side reading instead of full screen. You can still
put it on full width preview clicking on the new maximize button. put it on full width preview clicking on the new maximize button.
|image9| |image10|
- When the user chooses to send a public message the color of the - When the user chooses to send a public message the color of the
composer is different from the one when the message is an internal composer is different from the one when the message is an internal
log. log.
|image10| |image11|
.. |image| image:: https://raw.githubusercontent.com/OCA/web/17.0/web_responsive/static/img/appmenu.gif .. |image| image:: https://raw.githubusercontent.com/OCA/web/17.0/web_responsive/static/img/redirecthome.gif
.. |image1| image:: https://raw.githubusercontent.com/OCA/web/17.0/web_responsive/static/img/appsearch.gif .. |image1| image:: https://raw.githubusercontent.com/OCA/web/17.0/web_responsive/static/img/appmenu.gif
.. |image2| image:: https://raw.githubusercontent.com/OCA/web/17.0/web_responsive/static/img/listview.gif .. |image2| image:: https://raw.githubusercontent.com/OCA/web/17.0/web_responsive/static/img/appsearch.gif
.. |image3| image:: https://raw.githubusercontent.com/OCA/web/17.0/web_responsive/static/img/formview.gif .. |image3| image:: https://raw.githubusercontent.com/OCA/web/17.0/web_responsive/static/img/listview.gif
.. |image4| image:: https://raw.githubusercontent.com/OCA/web/17.0/web_responsive/static/img/listview.gif .. |image4| image:: https://raw.githubusercontent.com/OCA/web/17.0/web_responsive/static/img/formview.gif
.. |image5| image:: https://raw.githubusercontent.com/OCA/web/17.0/web_responsive/static/img/form_buttons.gif .. |image5| image:: https://raw.githubusercontent.com/OCA/web/17.0/web_responsive/static/img/listview.gif
.. |image6| image:: https://raw.githubusercontent.com/OCA/web/17.0/web_responsive/static/img/chatter.png .. |image6| image:: https://raw.githubusercontent.com/OCA/web/17.0/web_responsive/static/img/form_buttons.gif
.. |image7| image:: https://raw.githubusercontent.com/OCA/web/17.0/web_responsive/static/img/shortcuts.gif .. |image7| image:: https://raw.githubusercontent.com/OCA/web/17.0/web_responsive/static/img/chatter.png
.. |image8| image:: https://raw.githubusercontent.com/OCA/web/17.0/web_responsive/static/img/appsearch.gif .. |image8| image:: https://raw.githubusercontent.com/OCA/web/17.0/web_responsive/static/img/shortcuts.gif
.. |image9| image:: https://raw.githubusercontent.com/OCA/web/17.0/web_responsive/static/img/document_viewer.gif .. |image9| image:: https://raw.githubusercontent.com/OCA/web/17.0/web_responsive/static/img/appsearch.gif
.. |image10| image:: https://raw.githubusercontent.com/OCA/web/17.0/web_responsive/static/img/chatter-colors.png .. |image10| image:: https://raw.githubusercontent.com/OCA/web/17.0/web_responsive/static/img/document_viewer.gif
.. |image11| image:: https://raw.githubusercontent.com/OCA/web/17.0/web_responsive/static/img/chatter-colors.png
**Table of contents** **Table of contents**
@ -170,6 +177,8 @@ Contributors
- Taras Shabaranskyi <shabaranskij@gmail.com> - Taras Shabaranskyi <shabaranskij@gmail.com>
- Angel Patel <patelangel1414@gmail.com>
Maintainers Maintainers
----------- -----------

View File

@ -1,7 +1,7 @@
# Copyright 2023 Taras Shabaranskyi # Copyright 2023 Taras Shabaranskyi
# 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).
from odoo import fields, models from odoo import api, fields, models
class ResUsers(models.Model): class ResUsers(models.Model):
@ -24,3 +24,19 @@ class ResUsers(models.Model):
default="milk", default="milk",
required=True, required=True,
) )
is_redirect_home = fields.Boolean(
string="Redirect to Home",
help="Redirect to dashboard after signing in",
compute="_compute_redirect_home",
store=True,
readonly=False,
)
@api.depends("action_id")
def _compute_redirect_home(self):
"""
Set is_redirect_home to False
when action_id has a value.
:return:
"""
self.filtered("action_id").is_redirect_home = False

View File

@ -19,3 +19,5 @@
- David Vidal \<<david.vidal@tecnativa.com>\> - David Vidal \<<david.vidal@tecnativa.com>\>
- Taras Shabaranskyi \<<shabaranskij@gmail.com>\> - Taras Shabaranskyi \<<shabaranskij@gmail.com>\>
- Angel Patel \<<patelangel1414@gmail.com>\>

View File

@ -2,6 +2,13 @@ This module adds responsiveness to web backend.
**Features for all devices**: **Features for all devices**:
- Redirect to the dashboard after logging in.
Users will only be redirected to the home page after login
if they have enabled the 'Redirect to Home' option in
their profile settings.
![image](../static/img/redirecthome.gif)
- New navigation with the fullscreen app menu - New navigation with the fullscreen app menu
![image](../static/img/appmenu.gif) ![image](../static/img/appmenu.gif)

View File

@ -373,30 +373,35 @@ ul.auto-toc {
<p>This module adds responsiveness to web backend.</p> <p>This module adds responsiveness to web backend.</p>
<p><strong>Features for all devices</strong>:</p> <p><strong>Features for all devices</strong>:</p>
<ul> <ul>
<li><p class="first">Redirect to the dashboard after logging in. Users will only be
redirected to the home page after login if they have enabled the
Redirect to Home option in their profile settings.</p>
<p><img alt="image" src="https://raw.githubusercontent.com/OCA/web/17.0/web_responsive/static/img/redirecthome.gif" /></p>
</li>
<li><p class="first">New navigation with the fullscreen app menu</p> <li><p class="first">New navigation with the fullscreen app menu</p>
<p><img alt="image" src="https://raw.githubusercontent.com/OCA/web/17.0/web_responsive/static/img/appmenu.gif" /></p> <p><img alt="image1" src="https://raw.githubusercontent.com/OCA/web/17.0/web_responsive/static/img/appmenu.gif" /></p>
</li> </li>
<li><p class="first">Quick menu search inside the app menu</p> <li><p class="first">Quick menu search inside the app menu</p>
<p><img alt="image1" src="https://raw.githubusercontent.com/OCA/web/17.0/web_responsive/static/img/appsearch.gif" /></p> <p><img alt="image2" src="https://raw.githubusercontent.com/OCA/web/17.0/web_responsive/static/img/appsearch.gif" /></p>
</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>
<p><img alt="image2" src="https://raw.githubusercontent.com/OCA/web/17.0/web_responsive/static/img/listview.gif" /></p> <p><img alt="image3" src="https://raw.githubusercontent.com/OCA/web/17.0/web_responsive/static/img/listview.gif" /></p>
</li> </li>
<li><p class="first">Sticky statusbar in form view</p> <li><p class="first">Sticky statusbar in form view</p>
<p><img alt="image3" src="https://raw.githubusercontent.com/OCA/web/17.0/web_responsive/static/img/formview.gif" /></p> <p><img alt="image4" src="https://raw.githubusercontent.com/OCA/web/17.0/web_responsive/static/img/formview.gif" /></p>
</li> </li>
<li><p class="first">Bigger checkboxes in list view</p> <li><p class="first">Bigger checkboxes in list view</p>
<p><img alt="image4" src="https://raw.githubusercontent.com/OCA/web/17.0/web_responsive/static/img/listview.gif" /></p> <p><img alt="image5" src="https://raw.githubusercontent.com/OCA/web/17.0/web_responsive/static/img/listview.gif" /></p>
</li> </li>
</ul> </ul>
<p><strong>Features for mobile</strong>: * View type picker dropdown displays <p><strong>Features for mobile</strong>: * View type picker dropdown displays
comfortably</p> comfortably</p>
<ul> <ul>
<li><p class="first">Control panel buttons use icons to save space.</p> <li><p class="first">Control panel buttons use icons to save space.</p>
<p><img alt="image5" src="https://raw.githubusercontent.com/OCA/web/17.0/web_responsive/static/img/form_buttons.gif" /></p> <p><img alt="image6" src="https://raw.githubusercontent.com/OCA/web/17.0/web_responsive/static/img/form_buttons.gif" /></p>
</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>
<p><img alt="image6" src="https://raw.githubusercontent.com/OCA/web/17.0/web_responsive/static/img/chatter.png" /></p> <p><img alt="image7" src="https://raw.githubusercontent.com/OCA/web/17.0/web_responsive/static/img/chatter.png" /></p>
</li> </li>
<li><p class="first">Big inputs on form in edit mode</p> <li><p class="first">Big inputs on form in edit mode</p>
</li> </li>
@ -408,20 +413,20 @@ comfortably</p>
with Firefox Tab switching. Standard Odoo keyboard hotkeys changed to with Firefox Tab switching. Standard Odoo keyboard hotkeys changed to
be more intuitive or accessible by fingers of one hand. F.x. Alt + S be more intuitive or accessible by fingers of one hand. F.x. Alt + S
for Save</p> for Save</p>
<p><img alt="image7" src="https://raw.githubusercontent.com/OCA/web/17.0/web_responsive/static/img/shortcuts.gif" /></p> <p><img alt="image8" src="https://raw.githubusercontent.com/OCA/web/17.0/web_responsive/static/img/shortcuts.gif" /></p>
</li> </li>
<li><p class="first">Autofocus on search menu box when opening the app menu</p> <li><p class="first">Autofocus on search menu box when opening the app menu</p>
<p><img alt="image8" src="https://raw.githubusercontent.com/OCA/web/17.0/web_responsive/static/img/appsearch.gif" /></p> <p><img alt="image9" src="https://raw.githubusercontent.com/OCA/web/17.0/web_responsive/static/img/appsearch.gif" /></p>
</li> </li>
<li><p class="first">When the chatter is on the side part, the document viewer fills that <li><p class="first">When the chatter is on the side part, the document viewer fills that
part for side-by-side reading instead of full screen. You can still part for side-by-side reading instead of full screen. You can still
put it on full width preview clicking on the new maximize button.</p> put it on full width preview clicking on the new maximize button.</p>
<p><img alt="image9" src="https://raw.githubusercontent.com/OCA/web/17.0/web_responsive/static/img/document_viewer.gif" /></p> <p><img alt="image10" src="https://raw.githubusercontent.com/OCA/web/17.0/web_responsive/static/img/document_viewer.gif" /></p>
</li> </li>
<li><p class="first">When the user chooses to send a public message the color of the <li><p class="first">When the user chooses to send a public message the color of the
composer is different from the one when the message is an internal composer is different from the one when the message is an internal
log.</p> log.</p>
<p><img alt="image10" src="https://raw.githubusercontent.com/OCA/web/17.0/web_responsive/static/img/chatter-colors.png" /></p> <p><img alt="image11" src="https://raw.githubusercontent.com/OCA/web/17.0/web_responsive/static/img/chatter-colors.png" /></p>
</li> </li>
</ul> </ul>
<p><strong>Table of contents</strong></p> <p><strong>Table of contents</strong></p>
@ -490,6 +495,7 @@ If you spotted it first, help us to smash it by providing a detailed and welcome
<li>Sergey Shebanin &lt;<a class="reference external" href="mailto:sergey&#64;shebanin.ru">sergey&#64;shebanin.ru</a>&gt;</li> <li>Sergey Shebanin &lt;<a class="reference external" href="mailto:sergey&#64;shebanin.ru">sergey&#64;shebanin.ru</a>&gt;</li>
<li>David Vidal &lt;<a class="reference external" href="mailto:david.vidal&#64;tecnativa.com">david.vidal&#64;tecnativa.com</a>&gt;</li> <li>David Vidal &lt;<a class="reference external" href="mailto:david.vidal&#64;tecnativa.com">david.vidal&#64;tecnativa.com</a>&gt;</li>
<li>Taras Shabaranskyi &lt;<a class="reference external" href="mailto:shabaranskij&#64;gmail.com">shabaranskij&#64;gmail.com</a>&gt;</li> <li>Taras Shabaranskyi &lt;<a class="reference external" href="mailto:shabaranskij&#64;gmail.com">shabaranskij&#64;gmail.com</a>&gt;</li>
<li>Angel Patel &lt;<a class="reference external" href="mailto:patelangel1414&#64;gmail.com">patelangel1414&#64;gmail.com</a>&gt;</li>
</ul> </ul>
</div> </div>
<div class="section" id="maintainers"> <div class="section" id="maintainers">

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.7 MiB

View File

@ -5,7 +5,7 @@
* Copyright 2023 Taras Shabaranskyi * Copyright 2023 Taras Shabaranskyi
* License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl). */ * License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl). */
import {Component, useState} from "@odoo/owl"; import {Component, onWillStart, useState} from "@odoo/owl";
import {session} from "@web/session"; import {session} from "@web/session";
import {useBus, useService} from "@web/core/utils/hooks"; import {useBus, useService} from "@web/core/utils/hooks";
import {AppMenuItem} from "@web_responsive/components/apps_menu_item/apps_menu_item.esm"; import {AppMenuItem} from "@web_responsive/components/apps_menu_item/apps_menu_item.esm";
@ -14,6 +14,7 @@ import {NavBar} from "@web/webclient/navbar/navbar";
import {WebClient} from "@web/webclient/webclient"; import {WebClient} from "@web/webclient/webclient";
import {patch} from "@web/core/utils/patch"; import {patch} from "@web/core/utils/patch";
import {useHotkey} from "@web/core/hotkeys/hotkey_hook"; import {useHotkey} from "@web/core/hotkeys/hotkey_hook";
import {browser} from "@web/core/browser/browser";
// Patch WebClient to show AppsMenu instead of default app // Patch WebClient to show AppsMenu instead of default app
patch(WebClient.prototype, { patch(WebClient.prototype, {
@ -22,6 +23,25 @@ patch(WebClient.prototype, {
useBus(this.env.bus, "APPS_MENU:STATE_CHANGED", ({detail: state}) => { useBus(this.env.bus, "APPS_MENU:STATE_CHANGED", ({detail: state}) => {
document.body.classList.toggle("o_apps_menu_opened", state); document.body.classList.toggle("o_apps_menu_opened", state);
}); });
this.user = useService("user");
onWillStart(async () => {
const is_redirect_home = await this.orm.searchRead(
"res.users",
[["id", "=", this.user.userId]],
["is_redirect_home"]
);
this.env.services.user.updateContext({
is_redirect_to_home: is_redirect_home[0].is_redirect_home,
});
});
this.redirect = false;
},
_loadDefaultApp() {
if (this.env.services.user.context.is_redirect_to_home) {
this.env.bus.trigger("APPS_MENU:STATE_CHANGED", true);
} else {
super._loadDefaultApp();
}
}, },
}); });
@ -31,6 +51,12 @@ export class AppsMenu extends Component {
this.state = useState({open: false}); this.state = useState({open: false});
this.theme = session.apps_menu.theme || "milk"; this.theme = session.apps_menu.theme || "milk";
this.menuService = useService("menu"); this.menuService = useService("menu");
browser.localStorage.setItem("redirect_menuId", "");
if (this.env.services.user.context.is_redirect_to_home) {
this.router = useService("router");
const menuId = Number(this.router.current.hash.menu_id || 0);
this.state = useState({open: menuId === 0});
}
useBus(this.env.bus, "ACTION_MANAGER:UI-UPDATED", () => { useBus(this.env.bus, "ACTION_MANAGER:UI-UPDATED", () => {
this.setOpenState(false); this.setOpenState(false);
}); });
@ -106,7 +132,30 @@ export class AppsMenu extends Component {
} }
onMenuClick() { onMenuClick() {
if (!this.env.services.user.context.is_redirect_to_home) {
this.setOpenState(!this.state.open); this.setOpenState(!this.state.open);
} else {
const redirect_menuId =
browser.localStorage.getItem("redirect_menuId") || "";
if (!redirect_menuId) {
this.setOpenState(true);
} else {
this.setOpenState(!this.state.open);
}
const {href, hash} = location;
const menuId = this.router.current.hash.menu_id;
if (menuId && menuId != redirect_menuId) {
console.log(this.router.current.hash.menu_id);
browser.localStorage.setItem(
"redirect_menuId",
this.router.current.hash.menu_id
);
}
if (href.includes(hash)) {
window.history.replaceState(null, "", href.replace(hash, ""));
}
}
} }
} }

View File

@ -2,3 +2,4 @@
# 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).
from . import test_ir_http from . import test_ir_http
from . import test_res_users

View File

@ -0,0 +1,32 @@
# Copyright 2023 Taras Shabaranskyi
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl.html).
from odoo.tests.common import TransactionCase
class TestResUsers(TransactionCase):
def test_compute_redirect_home(self):
record = self.env["res.users"].create(
{
"action_id": False,
"is_redirect_home": False,
"name": "Jeant",
"login": "jeant@mail.com",
"password": "jeant@mail.com",
}
)
record._compute_redirect_home()
self.assertFalse(record.is_redirect_home)
action_obj = self.env["ir.actions.actions"]
record.action_id = action_obj.create(
{"name": "Test Action", "type": "ir.actions.act_window"}
)
record._compute_redirect_home()
self.assertFalse(record.is_redirect_home)
record.action_id = False
record.is_redirect_home = True
record._compute_redirect_home()
self.assertTrue(record.is_redirect_home)

View File

@ -61,4 +61,17 @@
]" ]"
/> />
</record> </record>
<record id="view_users_form_web_responsive" model="ir.ui.view">
<field name="name">res.users.form.web.responsive</field>
<field name="model">res.users</field>
<field name="inherit_id" ref="base.view_users_form" />
<field name="arch" type="xml">
<data>
<field name="action_id" position="after">
<field name="is_redirect_home" invisible="action_id" />
</field>
</data>
</field>
</record>
</odoo> </odoo>