mirror of https://github.com/OCA/web.git
[IMP] web_responsive: Redirect to home after login
Redirect to the home page after login will occur only if the user has enabled the 'Redirect to Home' configuration in their user profile settingspull/2864/head
parent
618d6740e8
commit
c7d59e83b8
|
@ -32,36 +32,42 @@ This module adds responsiveness to web backend.
|
|||
|
||||
**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|
|
||||
|
||||
- Quick menu search inside the app menu
|
||||
- New navigation with the fullscreen app menu
|
||||
|
||||
|image1|
|
||||
|
||||
- Sticky header & footer in list view
|
||||
- Quick menu search inside the app menu
|
||||
|
||||
|image2|
|
||||
|
||||
- Sticky statusbar in form view
|
||||
- Sticky header & footer in list view
|
||||
|
||||
|image3|
|
||||
|
||||
- Bigger checkboxes in list view
|
||||
- Sticky statusbar in form view
|
||||
|
||||
|image4|
|
||||
|
||||
- Bigger checkboxes in list view
|
||||
|
||||
|image5|
|
||||
|
||||
**Features for mobile**: \* View type picker dropdown displays
|
||||
comfortably
|
||||
|
||||
- Control panel buttons use icons to save space.
|
||||
|
||||
|image5|
|
||||
|image6|
|
||||
|
||||
- Followers and send button is displayed on mobile. Avatar is hidden.
|
||||
|
||||
|image6|
|
||||
|image7|
|
||||
|
||||
- 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
|
||||
for Save
|
||||
|
||||
|image7|
|
||||
|image8|
|
||||
|
||||
- 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
|
||||
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.
|
||||
|
||||
|image9|
|
||||
|image10|
|
||||
|
||||
- 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
|
||||
log.
|
||||
|
||||
|image10|
|
||||
|image11|
|
||||
|
||||
.. |image| image:: https://raw.githubusercontent.com/OCA/web/17.0/web_responsive/static/img/appmenu.gif
|
||||
.. |image1| image:: https://raw.githubusercontent.com/OCA/web/17.0/web_responsive/static/img/appsearch.gif
|
||||
.. |image2| image:: https://raw.githubusercontent.com/OCA/web/17.0/web_responsive/static/img/listview.gif
|
||||
.. |image3| image:: https://raw.githubusercontent.com/OCA/web/17.0/web_responsive/static/img/formview.gif
|
||||
.. |image4| image:: https://raw.githubusercontent.com/OCA/web/17.0/web_responsive/static/img/listview.gif
|
||||
.. |image5| image:: https://raw.githubusercontent.com/OCA/web/17.0/web_responsive/static/img/form_buttons.gif
|
||||
.. |image6| image:: https://raw.githubusercontent.com/OCA/web/17.0/web_responsive/static/img/chatter.png
|
||||
.. |image7| image:: https://raw.githubusercontent.com/OCA/web/17.0/web_responsive/static/img/shortcuts.gif
|
||||
.. |image8| image:: https://raw.githubusercontent.com/OCA/web/17.0/web_responsive/static/img/appsearch.gif
|
||||
.. |image9| image:: https://raw.githubusercontent.com/OCA/web/17.0/web_responsive/static/img/document_viewer.gif
|
||||
.. |image10| image:: https://raw.githubusercontent.com/OCA/web/17.0/web_responsive/static/img/chatter-colors.png
|
||||
.. |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/appmenu.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/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/listview.gif
|
||||
.. |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/chatter.png
|
||||
.. |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/appsearch.gif
|
||||
.. |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**
|
||||
|
||||
|
@ -170,6 +177,8 @@ Contributors
|
|||
|
||||
- Taras Shabaranskyi <shabaranskij@gmail.com>
|
||||
|
||||
- Angel Patel <patelangel1414@gmail.com>
|
||||
|
||||
Maintainers
|
||||
-----------
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
# Copyright 2023 Taras Shabaranskyi
|
||||
# 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):
|
||||
|
@ -24,3 +24,19 @@ class ResUsers(models.Model):
|
|||
default="milk",
|
||||
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
|
||||
|
|
|
@ -19,3 +19,5 @@
|
|||
- David Vidal \<<david.vidal@tecnativa.com>\>
|
||||
|
||||
- Taras Shabaranskyi \<<shabaranskij@gmail.com>\>
|
||||
|
||||
- Angel Patel \<<patelangel1414@gmail.com>\>
|
||||
|
|
|
@ -2,6 +2,13 @@ This module adds responsiveness to web backend.
|
|||
|
||||
**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.
|
||||
|
||||

|
||||
|
||||
- New navigation with the fullscreen app menu
|
||||
|
||||

|
||||
|
|
|
@ -8,10 +8,11 @@
|
|||
|
||||
/*
|
||||
:Author: David Goodger (goodger@python.org)
|
||||
:Id: $Id: html4css1.css 8954 2022-01-20 10:10:25Z milde $
|
||||
:Id: $Id: html4css1.css 9511 2024-01-13 09:50:07Z milde $
|
||||
:Copyright: This stylesheet has been placed in the public domain.
|
||||
|
||||
Default cascading style sheet for the HTML output of Docutils.
|
||||
Despite the name, some widely supported CSS2 features are used.
|
||||
|
||||
See https://docutils.sourceforge.io/docs/howto/html-stylesheets.html for how to
|
||||
customize this style sheet.
|
||||
|
@ -274,7 +275,7 @@ pre.literal-block, pre.doctest-block, pre.math, pre.code {
|
|||
margin-left: 2em ;
|
||||
margin-right: 2em }
|
||||
|
||||
pre.code .ln { color: grey; } /* line numbers */
|
||||
pre.code .ln { color: gray; } /* line numbers */
|
||||
pre.code, code { background-color: #eeeeee }
|
||||
pre.code .comment, code .comment { color: #5C6576 }
|
||||
pre.code .keyword, code .keyword { color: #3B0D06; font-weight: bold }
|
||||
|
@ -300,7 +301,7 @@ span.option {
|
|||
span.pre {
|
||||
white-space: pre }
|
||||
|
||||
span.problematic {
|
||||
span.problematic, pre.problematic {
|
||||
color: red }
|
||||
|
||||
span.section-subtitle {
|
||||
|
@ -372,30 +373,35 @@ ul.auto-toc {
|
|||
<p>This module adds responsiveness to web backend.</p>
|
||||
<p><strong>Features for all devices</strong>:</p>
|
||||
<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>
|
||||
<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><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><p class="first">Sticky header & 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><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><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>
|
||||
</ul>
|
||||
<p><strong>Features for mobile</strong>: * View type picker dropdown displays
|
||||
comfortably</p>
|
||||
<ul>
|
||||
<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><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><p class="first">Big inputs on form in edit mode</p>
|
||||
</li>
|
||||
|
@ -407,20 +413,20 @@ comfortably</p>
|
|||
with Firefox Tab switching. Standard Odoo keyboard hotkeys changed to
|
||||
be more intuitive or accessible by fingers of one hand. F.x. Alt + S
|
||||
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><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><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
|
||||
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><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
|
||||
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>
|
||||
</ul>
|
||||
<p><strong>Table of contents</strong></p>
|
||||
|
@ -489,12 +495,15 @@ If you spotted it first, help us to smash it by providing a detailed and welcome
|
|||
<li>Sergey Shebanin <<a class="reference external" href="mailto:sergey@shebanin.ru">sergey@shebanin.ru</a>></li>
|
||||
<li>David Vidal <<a class="reference external" href="mailto:david.vidal@tecnativa.com">david.vidal@tecnativa.com</a>></li>
|
||||
<li>Taras Shabaranskyi <<a class="reference external" href="mailto:shabaranskij@gmail.com">shabaranskij@gmail.com</a>></li>
|
||||
<li>Angel Patel <<a class="reference external" href="mailto:patelangel1414@gmail.com">patelangel1414@gmail.com</a>></li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="section" id="maintainers">
|
||||
<h2><a class="toc-backref" href="#toc-entry-7">Maintainers</a></h2>
|
||||
<p>This module is maintained by the OCA.</p>
|
||||
<a class="reference external image-reference" href="https://odoo-community.org"><img alt="Odoo Community Association" src="https://odoo-community.org/logo.png" /></a>
|
||||
<a class="reference external image-reference" href="https://odoo-community.org">
|
||||
<img alt="Odoo Community Association" src="https://odoo-community.org/logo.png" />
|
||||
</a>
|
||||
<p>OCA, or the Odoo Community Association, is a nonprofit organization whose
|
||||
mission is to support the collaborative development of Odoo features and
|
||||
promote its widespread use.</p>
|
||||
|
|
Binary file not shown.
After Width: | Height: | Size: 3.7 MiB |
|
@ -5,7 +5,7 @@
|
|||
* Copyright 2023 Taras Shabaranskyi
|
||||
* 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 {useBus, useService} from "@web/core/utils/hooks";
|
||||
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 {patch} from "@web/core/utils/patch";
|
||||
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.prototype, {
|
||||
|
@ -22,6 +23,25 @@ patch(WebClient.prototype, {
|
|||
useBus(this.env.bus, "APPS_MENU:STATE_CHANGED", ({detail: 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.theme = session.apps_menu.theme || "milk";
|
||||
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", () => {
|
||||
this.setOpenState(false);
|
||||
});
|
||||
|
@ -106,7 +132,30 @@ export class AppsMenu extends Component {
|
|||
}
|
||||
|
||||
onMenuClick() {
|
||||
this.setOpenState(!this.state.open);
|
||||
if (!this.env.services.user.context.is_redirect_to_home) {
|
||||
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, ""));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -2,3 +2,4 @@
|
|||
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl.html).
|
||||
|
||||
from . import test_ir_http
|
||||
from . import test_res_users
|
||||
|
|
|
@ -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)
|
|
@ -61,4 +61,17 @@
|
|||
]"
|
||||
/>
|
||||
</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>
|
||||
|
|
Loading…
Reference in New Issue