summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorqsm-odoo <qsm@odoo.com>2018-09-12 17:21:26 +0200
committerqsm-odoo <qsm@odoo.com>2018-09-13 10:35:42 +0200
commitfd8d6cb393ff4ca077bcfad3b3fa560eed0ba9b2 (patch)
tree022bf6a4f350111b6b62132600e1cc6b711830e4
parent6113a20fa7aac62bbf4e7681538014b0dd4a8703 (diff)
[FIX] website: make theme customization modal multi-faster
Since the recent fixes on multi website, the customization modal is restored but is a lot slower the first time we use it (around 20sec to save an option on my machine). This was because when we change an option, all the others options are sent to the server to be (re-)saved and, on the first time, the multi-website system has to duplicate them all to make them website-specific. Now, we only enable/disable views which are modified by the user.
-rw-r--r--addons/website/static/src/js/widgets/theme.js16
1 files changed, 11 insertions, 5 deletions
diff --git a/addons/website/static/src/js/widgets/theme.js b/addons/website/static/src/js/widgets/theme.js
index 5cef69414ba..16e99de52e7 100644
--- a/addons/website/static/src/js/widgets/theme.js
+++ b/addons/website/static/src/js/widgets/theme.js
@@ -289,7 +289,7 @@ var ThemeCustomizeDialog = Dialog.extend({
this.$modal.addClass('o_theme_customize_loading');
var bodyCustomImageXMLID = 'option_custom_body_image';
- var $inputBodyCustomImage = $inputs.filter('[data-xmlid*="website.' + bodyCustomImageXMLID + '"]');
+ var $inputBodyCustomImage = $inputs.filter('[data-xmlid*="website.' + bodyCustomImageXMLID + '"]:checked');
if (!$inputBodyCustomImage.length) {
return $.when();
}
@@ -439,8 +439,8 @@ var ThemeCustomizeDialog = Dialog.extend({
var $options = $option;
var checked = $option.is(':checked');
- // If it was enabled, enable/disable the related input (see data-enable, data-disable)
- // and retain the ones that actually changed
+ // If it was enabled, enable/disable the related input (see data-enable,
+ // data-disable) and retain the ones that actually changed
if (checked) {
var $inputs;
// Input to enable
@@ -452,10 +452,16 @@ var ThemeCustomizeDialog = Dialog.extend({
$options = $options.add($inputs.filter(':checked'));
$inputs.prop('checked', false);
}
+ var optionNames = _.uniq(_.map($options, function (option) {
+ return option.name;
+ }));
+ $options = this.$inputs.filter(function (i, input) {
+ return _.contains(optionNames, input.name);
+ });
// Look at all options to see if they are enabled or disabled
- var $enable = this.$inputs.filter('[data-xmlid]:checked');
- var $disable = this.$inputs.filter('[data-xmlid]:not(:checked)');
+ var $enable = $options.filter('[data-xmlid]:checked');
+ var $disable = $options.filter('[data-xmlid]:not(:checked)');
this._setActive();