[REF] point_of_sale: remove AlertPopup

The AlertPopup component is identical to the ErrorPopup component,
aside from the fact that the ErrorPopup also plays a sound. We
thus add a new prop to the ErrorPopup that allows the consumer
to decide to have the sound played or not and replace all occurences of the
AlertPopup with ErrorPopup.

closes odoo/odoo#136700

Task: 3522638
Related: odoo/enterprise#47987
Signed-off-by: Robin Heinz (rhe) <rhe@odoo.com>
This commit is contained in:
vlst
2023-09-28 03:19:03 +00:00
parent 64c6f731cb
commit 70b415a14b
4 changed files with 16 additions and 46 deletions
@@ -5,14 +5,20 @@ import { _t } from "@web/core/l10n/translation";
import { useService } from "@web/core/utils/hooks";
import { onMounted } from "@odoo/owl";
// formerly ErrorPopupWidget
export class ErrorPopup extends AbstractAwaitablePopup {
static template = "point_of_sale.ErrorPopup";
static props = {
confirmText: String,
title: String,
body: String,
cancelKey: Boolean,
sound: Boolean,
};
static defaultProps = {
confirmText: _t("Ok"),
title: _t("Error"),
body: "",
cancelKey: false,
sound: true,
};
setup() {
@@ -21,6 +27,8 @@ export class ErrorPopup extends AbstractAwaitablePopup {
this.sound = useService("sound");
}
onMounted() {
this.sound.play("error");
if (this.sound) {
this.sound.play("error");
}
}
}
@@ -6,7 +6,6 @@ import { ConfirmPopup } from "@point_of_sale/app/utils/confirm_popup/confirm_pop
import { MoneyDetailsPopup } from "@point_of_sale/app/utils/money_details_popup/money_details_popup";
import { useService } from "@web/core/utils/hooks";
import { useState } from "@odoo/owl";
import { AlertPopup } from "@point_of_sale/app/utils/alert_popup/alert_popup";
import { ErrorPopup } from "@point_of_sale/app/errors/popups/error_popup";
import { ConnectionLostError } from "@web/core/network/rpc_service";
import { identifyError } from "@point_of_sale/app/errors/error_handlers";
@@ -26,7 +25,6 @@ export class ClosePosPopup extends AbstractAwaitablePopup {
"other_payment_methods",
"is_manager",
"amount_authorized_diff",
"state",
// TODO: set the props for all popups
"id",
"keepBehind",
@@ -229,13 +227,11 @@ export class ClosePosPopup extends AbstractAwaitablePopup {
}
}
async handleClosingError(response) {
const body = response.message;
if (response.type == "alert") {
await this.popup.add(AlertPopup, { title: response.title || "", body });
} else {
await this.popup.add(ErrorPopup, { title: "Error", body });
}
await this.popup.add(ErrorPopup, {
title: response.title || "Error",
body: response.message,
sound: response.type !== "alert",
});
if (response.redirect) {
window.location = "/web#action=point_of_sale.action_client_pos_menu";
}
@@ -1,14 +0,0 @@
/** @odoo-module */
import { AbstractAwaitablePopup } from "@point_of_sale/app/popup/abstract_awaitable_popup";
import { _t } from "@web/core/l10n/translation";
export class AlertPopup extends AbstractAwaitablePopup {
static template = "point_of_sale.AlertPopup";
static defaultProps = {
confirmText: _t("Ok"),
title: "",
body: "",
cancelKey: false,
};
}
@@ -1,20 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<templates id="template" xml:space="preserve">
<t t-name="point_of_sale.AlertPopup">
<div class="popup">
<div class="modal-header">
<h4 class="title modal-title">
<t t-esc="props.title" />
</h4>
</div>
<p class="modal-body">
<t t-esc="props.body" />
</p>
<div class="footer modal-footer">
<div class="button cancel btn btn-lg btn-primary" t-on-click="confirm">
<t t-esc="props.confirmText" />
</div>
</div>
</div>
</t>
</templates>