[REF] point_of_sale, pos*: remove BackendButton component

pos*: point_of_sale, pos_hr, pos_restaurant, pos_sale

This component is purely presentational and contains no code, it's also
only used once (it was actually used a second time in pos_hr only
because the way the xpath was written would replace the existing
instance with a new one with an added t-if, we can just use an attribute
xpath instead).

Existing xpaths have been adapted such that the burger menu's dropdown
structure is better semantically (an unordered list containing list
items, instead of containing list elements inside of random divs)

Part-of: odoo/odoo#122035
This commit is contained in:
Samuel Degueldre
2023-05-24 14:27:59 +02:00
parent ebe526241f
commit 6f18cffb60
7 changed files with 23 additions and 47 deletions
@@ -9,7 +9,6 @@ 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 { BackendButton } from "@point_of_sale/js/ChromeWidgets/BackendButton";
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";
@@ -24,7 +23,6 @@ export class Navbar extends Component {
ProxyStatus,
SaleDetailsButton,
SyncNotification,
BackendButton,
};
static props = {
showCashMoveButton: Boolean,
@@ -32,11 +32,13 @@
<span>Cash In/Out</span>
</li>
<CustomerFacingDisplayButton t-if="CustomerFacingDisplayButtonIsShown"/>
<div class="end-nav-button">
<BackendButton/>
<div class="close-button">
<HeaderButton/>
</div>
<li class="menu-item navbar-button backend-button" t-on-click="() => pos.closePos()">
<span>
Backend
</span>
</li>
<div class="close-button">
<HeaderButton/>
</div>
<li t-if="this.env.debug" t-on-click="() => debug.toggleWidget()" class="menu-item navbar-button">
<span>Debug Window</span>
@@ -1,17 +0,0 @@
/** @odoo-module */
import { useService } from "@web/core/utils/hooks";
import { Component } from "@odoo/owl";
export class BackendButton extends Component {
static template = "BackendButton";
setup() {
super.setup(...arguments);
this.pos = useService("pos");
}
async onClick() {
this.pos.closePos();
}
}
@@ -1,12 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<templates id="template" xml:space="preserve">
<t t-name="BackendButton" owl="1">
<li class="menu-item navbar-button" t-on-click="onClick">
<span>
Backend
</span>
</li>
</t>
</templates>
+14 -9
View File
@@ -2,15 +2,20 @@
<templates id="template" xml:space="preserve">
<t t-name="pos_hr.Navbar" t-inherit="point_of_sale.Navbar" t-inherit-mode="extension" owl="1">
<xpath expr="//div[hasclass('end-nav-button')]" position="replace">
<div class="end-nav-button">
<BackendButton t-if="!pos.globalState.config.module_pos_hr"/>
<BackendButton t-elif="(pos.globalState.get_cashier().role === 'manager' || pos.globalState.get_cashier_user_id() === pos.globalState.user.id)"/>
<HeaderLockButton t-if="pos.globalState.config.module_pos_hr" />
<div class="close-button" t-if="!pos.globalState.config.module_pos_hr || pos.globalState.get_cashier().role === 'manager' || pos.globalState.get_cashier_user_id() === pos.globalState.user.id">
<HeaderButton/>
</div>
</div>
<xpath expr="//li[hasclass('backend-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>
</xpath>
<xpath expr="//div[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>
</xpath>
<xpath expr="//li[hasclass('backend-button')]" position="after">
<HeaderLockButton t-if="pos.globalState.config.module_pos_hr" />
</xpath>
</t>
@@ -2,7 +2,7 @@
<templates id="template" xml:space="preserve">
<t t-name="pos_restaurant.Navbar" t-inherit="point_of_sale.Navbar" t-inherit-mode="extension">
<xpath expr="//div[hasclass('end-nav-button')]" position="before">
<xpath expr="//li[hasclass('backend-button')]" position="before">
<li t-if="pos.mainScreen.component.name == 'FloorScreen'" class="menu-item navbar-button edit-button" t-on-click="toggleEditMode">
<span>Edit Plan</span>
</li>
+1 -1
View File
@@ -2,7 +2,7 @@
<templates id="template" xml:space="preserve">
<t t-name="pos_six.Navbar" t-inherit="point_of_sale.Navbar" t-inherit-mode="extension" owl="1">
<xpath expr="//div[hasclass('end-nav-button')]" position="before">
<xpath expr="//li[hasclass('backend-button')]" position="before">
<BalanceButton t-if="pos.globalState.payment_methods.some((pm) => pm.use_payment_terminal === 'six')" />
</xpath>
</t>