From 70b415a14b56b8eb2e260abd9070579f7e883b7f Mon Sep 17 00:00:00 2001 From: vlst Date: Tue, 26 Sep 2023 17:47:44 +0200 Subject: [PATCH] [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) --- .../src/app/errors/popups/error_popup.js | 14 ++++++++++--- .../app/navbar/closing_popup/closing_popup.js | 14 +++++-------- .../src/app/utils/alert_popup/alert_popup.js | 14 ------------- .../src/app/utils/alert_popup/alert_popup.xml | 20 ------------------- 4 files changed, 16 insertions(+), 46 deletions(-) delete mode 100644 addons/point_of_sale/static/src/app/utils/alert_popup/alert_popup.js delete mode 100644 addons/point_of_sale/static/src/app/utils/alert_popup/alert_popup.xml diff --git a/addons/point_of_sale/static/src/app/errors/popups/error_popup.js b/addons/point_of_sale/static/src/app/errors/popups/error_popup.js index 6cfad9808ea..ca5bc68ea22 100644 --- a/addons/point_of_sale/static/src/app/errors/popups/error_popup.js +++ b/addons/point_of_sale/static/src/app/errors/popups/error_popup.js @@ -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"); + } } } diff --git a/addons/point_of_sale/static/src/app/navbar/closing_popup/closing_popup.js b/addons/point_of_sale/static/src/app/navbar/closing_popup/closing_popup.js index fdff16f036c..11cf526c0a0 100644 --- a/addons/point_of_sale/static/src/app/navbar/closing_popup/closing_popup.js +++ b/addons/point_of_sale/static/src/app/navbar/closing_popup/closing_popup.js @@ -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"; } diff --git a/addons/point_of_sale/static/src/app/utils/alert_popup/alert_popup.js b/addons/point_of_sale/static/src/app/utils/alert_popup/alert_popup.js deleted file mode 100644 index 06c203754f3..00000000000 --- a/addons/point_of_sale/static/src/app/utils/alert_popup/alert_popup.js +++ /dev/null @@ -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, - }; -} diff --git a/addons/point_of_sale/static/src/app/utils/alert_popup/alert_popup.xml b/addons/point_of_sale/static/src/app/utils/alert_popup/alert_popup.xml deleted file mode 100644 index 0b20ce52eb3..00000000000 --- a/addons/point_of_sale/static/src/app/utils/alert_popup/alert_popup.xml +++ /dev/null @@ -1,20 +0,0 @@ - - - - - -