From 5ffce116a6f8d4775cffe4daef09674db6c159d0 Mon Sep 17 00:00:00 2001 From: Benjamin Vray Date: Thu, 31 Dec 2020 09:12:58 +0000 Subject: [PATCH] [IMP] website_payment, *: new snippet make a donation *= website, website_sale, web_editor This commit add a new snippet donation for the website builder. PR-63133 task-2398403 Part-of: odoo/odoo#63133 --- .../static/src/js/editor/snippets.options.js | 12 +- .../static/src/scss/wysiwyg_snippets.scss | 1 + addons/website/controllers/main.py | 8 + .../src/img/snippets_thumbs/s_donation.svg | 39 +++ .../img/snippets_thumbs/s_donation_button.svg | 18 ++ .../static/src/scss/primary_variables.scss | 15 + addons/website/views/snippets/snippets.xml | 6 +- addons/website_payment/__manifest__.py | 7 + .../static/shapes/s_donation_gift.svg | 87 +++++ .../static/src/snippets/s_donation/000.js | 114 +++++++ .../static/src/snippets/s_donation/000.scss | 56 ++++ .../static/src/snippets/s_donation/000.xml | 40 +++ .../static/src/snippets/s_donation/options.js | 303 ++++++++++++++++++ .../views/snippets/s_donation.xml | 94 ++++++ .../views/snippets/snippets.xml | 17 + addons/website_sale/controllers/main.py | 7 + 16 files changed, 817 insertions(+), 7 deletions(-) create mode 100644 addons/website/static/src/img/snippets_thumbs/s_donation.svg create mode 100644 addons/website/static/src/img/snippets_thumbs/s_donation_button.svg create mode 100644 addons/website_payment/static/shapes/s_donation_gift.svg create mode 100644 addons/website_payment/static/src/snippets/s_donation/000.js create mode 100644 addons/website_payment/static/src/snippets/s_donation/000.scss create mode 100644 addons/website_payment/static/src/snippets/s_donation/000.xml create mode 100644 addons/website_payment/static/src/snippets/s_donation/options.js create mode 100644 addons/website_payment/views/snippets/s_donation.xml create mode 100644 addons/website_payment/views/snippets/snippets.xml diff --git a/addons/web_editor/static/src/js/editor/snippets.options.js b/addons/web_editor/static/src/js/editor/snippets.options.js index 5d41c04cc4c..e05cd78553b 100644 --- a/addons/web_editor/static/src/js/editor/snippets.options.js +++ b/addons/web_editor/static/src/js/editor/snippets.options.js @@ -1956,11 +1956,11 @@ const ListUserValueWidget = UserValueWidget.extend({ /** * @private * @param {string || integer} id - * @param {string} [text] + * @param {string} [value] * @param {Object} [recordData] key, values that will be added to the * element's dataset */ - _addItemToTable(id, text = _t("Item"), recordData) { + _addItemToTable(id, value = this.el.dataset.defaultValue || _t("Item"), recordData) { const trEl = document.createElement('tr'); if (!this.el.dataset.unsortable) { const draggableEl = document.createElement('we-button'); @@ -1971,9 +1971,9 @@ const ListUserValueWidget = UserValueWidget.extend({ trEl.appendChild(draggableTdEl); } const inputEl = document.createElement('input'); - inputEl.type = 'text'; - if (text) { - inputEl.value = text; + inputEl.type = this.el.dataset.inputType || 'text'; + if (value) { + inputEl.value = value; } if (id) { inputEl.name = id; @@ -2033,7 +2033,7 @@ const ListUserValueWidget = UserValueWidget.extend({ * @private */ _notifyCurrentState() { - const values = [...this.listTable.querySelectorAll('input')].map(el => { + const values = [...this.listTable.querySelectorAll('.o_we_list_record_name input')].map(el => { const id = this.isCustom ? el.value : el.name; const idInt = parseInt(id); return Object.assign({ diff --git a/addons/web_editor/static/src/scss/wysiwyg_snippets.scss b/addons/web_editor/static/src/scss/wysiwyg_snippets.scss index d71b02d1ea0..59dcd9af1f0 100644 --- a/addons/web_editor/static/src/scss/wysiwyg_snippets.scss +++ b/addons/web_editor/static/src/scss/wysiwyg_snippets.scss @@ -1360,6 +1360,7 @@ body.editor_enable.editor_has_snippets { margin-bottom: $o-we-sidebar-content-field-spacing / 2; table { + @include o-input-number-no-arrows(); table-layout: auto; width: 100%; diff --git a/addons/website/controllers/main.py b/addons/website/controllers/main.py index 0a940466aa8..29b7aaf778c 100644 --- a/addons/website/controllers/main.py +++ b/addons/website/controllers/main.py @@ -340,6 +340,14 @@ class Website(Home): t['numOfElFetch'] = attribs.get('data-number-of-elements-fetch') return templates + @http.route('/website/get_current_currency', type='json', auth="public", website=True) + def get_current_currency(self, **kwargs): + return { + 'id': request.website.company_id.currency_id.id, + 'symbol': request.website.company_id.currency_id.symbol, + 'position': request.website.company_id.currency_id.position, + } + # ------------------------------------------------------ # Edit # ------------------------------------------------------ diff --git a/addons/website/static/src/img/snippets_thumbs/s_donation.svg b/addons/website/static/src/img/snippets_thumbs/s_donation.svg new file mode 100644 index 00000000000..8995ab98e44 --- /dev/null +++ b/addons/website/static/src/img/snippets_thumbs/s_donation.svg @@ -0,0 +1,39 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/addons/website/static/src/img/snippets_thumbs/s_donation_button.svg b/addons/website/static/src/img/snippets_thumbs/s_donation_button.svg new file mode 100644 index 00000000000..f30edf1b8cb --- /dev/null +++ b/addons/website/static/src/img/snippets_thumbs/s_donation_button.svg @@ -0,0 +1,18 @@ + + + + + + + + + + + + + + + + diff --git a/addons/website/static/src/scss/primary_variables.scss b/addons/website/static/src/scss/primary_variables.scss index 2b85ef6056b..dba19881c71 100644 --- a/addons/website/static/src/scss/primary_variables.scss +++ b/addons/website/static/src/scss/primary_variables.scss @@ -2057,3 +2057,18 @@ $o-theme-font-configs: ( background-image: $-gradient; } }; + +@mixin o-input-number-no-arrows() { + // Remove arrows/spinners from input type number + // => Chrome, Safari, Edge, Opera + input::-webkit-outer-spin-button, + input::-webkit-inner-spin-button { + -webkit-appearance: none; + margin: 0; + } + + // => Firefox + input[type=number] { + -moz-appearance: textfield; + } +}; diff --git a/addons/website/views/snippets/snippets.xml b/addons/website/views/snippets/snippets.xml index b833c016c45..7b98ce1e6ff 100644 --- a/addons/website/views/snippets/snippets.xml +++ b/addons/website/views/snippets/snippets.xml @@ -123,6 +123,7 @@ + @@ -152,6 +153,7 @@ cite + @@ -167,9 +169,11 @@ + + @@ -525,7 +529,7 @@ t-att-data-selector="so_snippet_addition_selector" data-drop-in=":not(p).oe_structure:not(.oe_structure_solo), :not(.o_mega_menu):not(p)[data-oe-type=html], :not(p).oe_structure.oe_structure_solo:not(:has(> section, > div))"/> - blockquote, .s_card:not(.s_timeline_card), .s_alert, .o_facebook_page, .s_share, .s_rating, .s_hr, .s_google_map, .s_map, .s_countdown, .s_chart, .s_text_highlight, .s_progress_bar, .s_badge, .s_embed_code + blockquote, .s_card:not(.s_timeline_card), .s_alert, .o_facebook_page, .s_share, .s_rating, .s_hr, .s_google_map, .s_map, .s_countdown, .s_chart, .s_text_highlight, .s_progress_bar, .s_badge, .s_embed_code, .s_donation
+ + + + + + + + + + gift1 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +