diff --git a/addons/website/controllers/main.py b/addons/website/controllers/main.py index 3705620a7c6..e68d208fb52 100644 --- a/addons/website/controllers/main.py +++ b/addons/website/controllers/main.py @@ -362,15 +362,17 @@ class Website(Home): return [enable, disable] @http.route(['/website/theme_customize'], type='json', auth="public", website=True) - def theme_customize(self, enable, disable, get_bundle=False): + def theme_customize(self, enable=None, disable=None, get_bundle=False): """ enable or Disable lists of ``xml_id`` of the inherit templates """ def set_active(xml_ids, active): if xml_ids: real_ids = self.get_view_ids(xml_ids) request.env['ir.ui.view'].browse(real_ids).write({'active': active}) - set_active(disable, False) - set_active(enable, True) + if disable: + set_active(disable, False) + if enable: + set_active(enable, True) if get_bundle: context = dict(request.context) diff --git a/addons/website/static/src/js/widgets/theme.js b/addons/website/static/src/js/widgets/theme.js index c48bab3c74f..68a1c6bc50b 100644 --- a/addons/website/static/src/js/widgets/theme.js +++ b/addons/website/static/src/js/widgets/theme.js @@ -154,72 +154,45 @@ var ThemeCustomizeDialog = Dialog.extend({ switch (item.tagName) { case 'OPT': - var colorPalette = $item.data('colorPalette') === 'user'; - var icon = $item.data('icon'); + var widgetName = $item.data('widget'); // Build the options template - var $multiChoiceLabel = $(core.qweb.render('website.theme_customize_modal_option', { + var $option = $(core.qweb.render('website.theme_customize_modal_option', { name: optionsName, id: $item.attr('id') || _.uniqueId('o_theme_customize_input_id_'), string: $item.attr('string'), - icon: icon, - color: $item.data('color'), + icon: $item.data('icon'), font: $item.data('font'), - colorPalette: colorPalette, - xmlid: $item.data('xmlid'), enable: $item.data('enable'), disable: $item.data('disable'), reload: $item.data('reload'), + + widget: widgetName, })); - $multiChoiceLabel.find('.o_theme_customize_color[data-color="primary"]').addClass('d-none').removeClass('d-flex'); - $multiChoiceLabel.find('.o_theme_customize_color[data-color="secondary"]').addClass('d-none').removeClass('d-flex'); + if (widgetName) { + var $widget = $(core.qweb.render('website.theme_customize_' + widgetName)); + $option.append($widget); + } if ($container.hasClass('form-row')) { - $col = $('
', {class: (icon ? 'col-4' : (colorPalette ? 'col-12' : 'col-6'))}); - $col.append($multiChoiceLabel); + $col = $('
', { + class: _.str.sprintf('col-%s', $item.data('col') || 6), + }); + $col.append($option); $container.append($col); } else { - $container.append($multiChoiceLabel); + $container.append($option); } break; - case 'MORE': - var collapseID = _.uniqueId('collapse-'); - - $col = $('
', { - class: 'col-12', - }).appendTo($container); - - var string = $item.attr('string'); - if (string) { - var $button = $('