From 34f2b5c1d726cb8dd9c34799ab596ca185e0a848 Mon Sep 17 00:00:00 2001 From: "Valentin Vallaeys (vava)" Date: Thu, 3 Nov 2022 07:34:24 +0000 Subject: [PATCH] [IMP] payment: function to build confirmation dialog allowing overrides The confirmation dialog to delete a token from a portal user is the same whatever the linked records. This part of the code is now moved to a separate function `_buildConfirmationDialog` in order to allow overrides of the method in particular cases (e.g. Subscriptions). task-3048269 closes odoo/odoo#105289 X-original-commit: 51d6b724f061af44bc07c342dfa9a34b4d1a2101 Related: odoo/enterprise#33741 Signed-off-by: Vallaeys Valentin (vava) --- addons/payment/static/src/js/manage_form.js | 85 ++++++++++++--------- 1 file changed, 49 insertions(+), 36 deletions(-) diff --git a/addons/payment/static/src/js/manage_form.js b/addons/payment/static/src/js/manage_form.js index 80875d221b7..8cdb1a9e75c 100644 --- a/addons/payment/static/src/js/manage_form.js +++ b/addons/payment/static/src/js/manage_form.js @@ -68,6 +68,53 @@ odoo.define('payment.manage_form', require => { }); }, + /** + * Build the confirmation dialog based on the linked records' information. + * + * @private + * @param {Array} linkedRecordsInfo - The list of information about linked records. + * @param confirmCallback - The callback method called when the user clicks on the + * confirmation button. + * @return {object} + */ + _buildConfirmationDialog: function (linkedRecordsInfo, confirmCallback) { + const $dialogContentMessage = $( + '', {text: _t("Are you sure you want to delete this payment method?")} + ); + if (linkedRecordsInfo.length > 0) { // List the documents linked to the token. + $dialogContentMessage.append($('
')); + $dialogContentMessage.append($( + '', {text: _t("It is currently linked to the following documents:")} + )); + const $documentInfoList = $('