diff options
| author | Christophe Simonis <chs@odoo.com> | 2019-08-08 11:52:13 +0200 |
|---|---|---|
| committer | Christophe Simonis <chs@odoo.com> | 2019-08-08 11:52:13 +0200 |
| commit | b792ba7d9a80e856e3c69c2852e6d44b78d0e13f (patch) | |
| tree | a3ee5b7ef9f9317866deeb2b3e5964020c87b8fb /addons/website/static/src/js | |
| parent | 22e0f88bce5bf162a6c67e915a3c27b101f74f2b (diff) | |
| parent | 752b2553c6fad061ebf23e13585f7b7489b20840 (diff) | |
[MERGE] forward port branch saas-12.3 up to 752b2553c6f
Diffstat (limited to 'addons/website/static/src/js')
| -rw-r--r-- | addons/website/static/src/js/widgets/theme.js | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/addons/website/static/src/js/widgets/theme.js b/addons/website/static/src/js/widgets/theme.js index d5a2997031d..fcdc8c5ad3b 100644 --- a/addons/website/static/src/js/widgets/theme.js +++ b/addons/website/static/src/js/widgets/theme.js @@ -547,6 +547,34 @@ var ThemeCustomizeDialog = Dialog.extend({ _setActive: function () { var self = this; + // First enforce that all input groups have only one element checked as + // it is supposed to be (it might not be the case on initialization, for + // exemple if we had data-xmlid="A" and data-xmlid="A,B" and if A and B + // are active, the 2 related inputs would be checked). + var $radioXMLInputs = this.$inputs.filter('[type="radio"][data-xmlid]'); + var optionNames = _.uniq(_.map($radioXMLInputs, function (option) { + return option.name; + })); + _.each(optionNames, function (optionName) { + var $inputs = $radioXMLInputs.filter('[name="' + optionName + '"]:checked'); + if ($inputs.length > 1) { + $inputs.prop('checked', false); + + var maxNbXMLIDs = -1; + var $maxInput = null; + _.each($inputs, function (input) { + var $input = $(input); + var xmlID = $input.data('xmlid'); + var nbXMLIDs = xmlID ? xmlID.split(',').length : 0; + if (nbXMLIDs >= maxNbXMLIDs) { + maxNbXMLIDs = nbXMLIDs; + $maxInput = $input; + } + }); + $maxInput.prop('checked', true); + } + }); + // Look at all options to see if they are enabled or disabled var $enable = this.$inputs.filter(':checked'); |
