[REF] point_of_sale, pos_hr: remove HeaderButton

The HeaderButton component is used once and is mostly presentational,
this commit inlines it into the navbar.

closes odoo/odoo#122035

Related: odoo/enterprise#41336
Signed-off-by: Monnom David (moda) <moda@odoo.com>
This commit is contained in:
Samuel Degueldre
2023-05-24 14:27:59 +02:00
parent 6f18cffb60
commit c7ce04a8ed
8 changed files with 16 additions and 45 deletions
@@ -5,13 +5,13 @@ import { useService } from "@web/core/utils/hooks";
import { CashierName } from "@point_of_sale/js/ChromeWidgets/CashierName";
import { CustomerFacingDisplayButton } from "@point_of_sale/js/ChromeWidgets/CustomerFacingDisplayButton";
import { HeaderButton } from "@point_of_sale/js/ChromeWidgets/HeaderButton";
import { ProxyStatus } from "@point_of_sale/js/ChromeWidgets/ProxyStatus";
import { SaleDetailsButton } from "@point_of_sale/js/ChromeWidgets/SaleDetailsButton";
import { SyncNotification } from "@point_of_sale/js/ChromeWidgets/SyncNotification";
import { CashMovePopup } from "./cash_move_popup/cash_move_popup";
import { TicketScreen } from "@point_of_sale/js/Screens/TicketScreen/TicketScreen";
import { Component, useState, useExternalListener } from "@odoo/owl";
import { ClosePosPopup } from "@point_of_sale/js/Popups/ClosePosPopup";
export class Navbar extends Component {
static template = "point_of_sale.Navbar";
@@ -19,7 +19,6 @@ export class Navbar extends Component {
// FIXME POSREF remove some of these components
CashierName,
CustomerFacingDisplayButton,
HeaderButton,
ProxyStatus,
SaleDetailsButton,
SyncNotification,
@@ -97,4 +96,9 @@ export class Navbar extends Component {
openMenu() {
this.state.isMenuOpened = true;
}
async closeSession() {
const info = await this.pos.globalState.getClosePosInfo();
this.popup.add(ClosePosPopup, { info, keepBehind: true });
}
}
@@ -37,9 +37,11 @@
Backend
</span>
</li>
<div class="close-button">
<HeaderButton/>
</div>
<li class="menu-item navbar-button close-button" t-on-click="closeSession">
<span>
Close Session
</span>
</li>
<li t-if="this.env.debug" t-on-click="() => debug.toggleWidget()" class="menu-item navbar-button">
<span>Debug Window</span>
</li>
@@ -1,23 +0,0 @@
/** @odoo-module */
import { useService } from "@web/core/utils/hooks";
import { ClosePosPopup } from "@point_of_sale/js/Popups/ClosePosPopup";
import { Component } from "@odoo/owl";
import { usePos } from "@point_of_sale/app/pos_hook";
// Previously HeaderButtonWidget
// This is the close session button
export class HeaderButton extends Component {
static template = "HeaderButton";
setup() {
super.setup(...arguments);
this.pos = usePos();
this.popup = useService("popup");
}
async onClick() {
const info = await this.pos.globalState.getClosePosInfo();
this.popup.add(ClosePosPopup, { info: info, keepBehind: true });
}
}
@@ -1,12 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<templates id="template" xml:space="preserve">
<t t-name="HeaderButton" owl="1">
<li class="menu-item navbar-button header-button" t-on-click="onClick">
<span>
Close Session
</span>
</li>
</t>
</templates>
@@ -309,7 +309,7 @@ steps = steps.concat([
},
{
content: "open closing the Point of Sale frontend popup",
trigger: ".header-button",
trigger: ".close-button",
},
{
content: "close the Point of Sale frontend",
@@ -255,7 +255,7 @@ class Do {
clickCloseButton() {
return [
{
trigger: ".header-button",
trigger: ".close-button",
},
];
}
@@ -415,7 +415,7 @@ class Check {
},
{
content: "Click close session button",
trigger: ".header-button",
trigger: ".close-button",
},
{
content: "Check closing details",
@@ -319,7 +319,7 @@ steps = steps.concat([
},
{
content: "confirm closing the frontend",
trigger: ".header-button",
trigger: ".close-button",
run: function () {}, //it's a check,
},
]);
+1 -1
View File
@@ -8,7 +8,7 @@
</attribute>
</xpath>
<xpath expr="//div[hasclass('close-button')]" position="attributes">
<xpath expr="//li[hasclass('close-button')]" position="attributes">
<attribute name="t-if">
!pos.globalState.config.module_pos_hr or pos.globalState.get_cashier().role === 'manager' or pos.globalState.get_cashier_user_id() === pos.globalState.user.id
</attribute>