From 8c756a32a0c20b8ea8efb556b25eaa1fcaaab7bc Mon Sep 17 00:00:00 2001 From: qsm-odoo Date: Fri, 19 Oct 2018 15:51:10 +0000 Subject: [REF] website: review theme dialog engine Refactor the code to remove useless parts, simplify behaviors and allow more customizations in future tasks. closes odoo/odoo#28167 --- addons/website/static/src/js/widgets/theme.js | 85 +++++++--------------- .../website/static/src/scss/website.edit_mode.scss | 4 - addons/website/static/src/xml/website.editor.xml | 60 +++++++-------- 3 files changed, 56 insertions(+), 93 deletions(-) (limited to 'addons/website/static/src') 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); - } - break; - - case 'MORE': - var collapseID = _.uniqueId('collapse-'); - - $col = $('
', { - class: 'col-12', - }).appendTo($container); - - var string = $item.attr('string'); - if (string) { - var $button = $('