[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.
This commit is contained in:
qsm-odoo
2018-09-13 10:35:42 +02:00
parent 6113a20fa7
commit fd8d6cb393
+11 -5
View File
@@ -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();