From 3751379f1e9a4c215fb6eb898b4ccc67659b9ace Mon Sep 17 00:00:00 2001 From: stephanchrst Date: Tue, 10 May 2022 21:51:50 +0700 Subject: initial commit 2 --- .../static/src/js/website_sale_payment.js | 48 ++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 addons/website_sale/static/src/js/website_sale_payment.js (limited to 'addons/website_sale/static/src/js/website_sale_payment.js') diff --git a/addons/website_sale/static/src/js/website_sale_payment.js b/addons/website_sale/static/src/js/website_sale_payment.js new file mode 100644 index 00000000..4d6abd98 --- /dev/null +++ b/addons/website_sale/static/src/js/website_sale_payment.js @@ -0,0 +1,48 @@ +odoo.define('website_sale.payment', function (require) { +'use strict'; + +var publicWidget = require('web.public.widget'); + +publicWidget.registry.WebsiteSalePayment = publicWidget.Widget.extend({ + selector: '#wrapwrap:has(#checkbox_cgv)', + events: { + 'change #checkbox_cgv': '_onCGVCheckboxClick', + }, + + /** + * @override + */ + start: function () { + this.$checkbox = this.$('#checkbox_cgv'); + this.$payButton = $('button#o_payment_form_pay'); + this.$checkbox.trigger('change'); + return this._super.apply(this, arguments); + }, + + //-------------------------------------------------------------------------- + // Private + //-------------------------------------------------------------------------- + + /** + * @private + */ + _adaptPayButton: function () { + var disabledReasons = this.$payButton.data('disabled_reasons') || {}; + disabledReasons.cgv = !this.$checkbox.prop('checked'); + this.$payButton.data('disabled_reasons', disabledReasons); + + this.$payButton.prop('disabled', _.contains(disabledReasons, true)); + }, + + //-------------------------------------------------------------------------- + // Handlers + //-------------------------------------------------------------------------- + + /** + * @private + */ + _onCGVCheckboxClick: function () { + this._adaptPayButton(); + }, +}); +}); -- cgit v1.2.3