summaryrefslogtreecommitdiff
path: root/addons
diff options
context:
space:
mode:
authorqsm-odoo <qsm@odoo.com>2018-09-26 16:56:45 +0200
committerqsm-odoo <qsm@odoo.com>2018-09-26 21:08:35 +0200
commit5c9d313007a4300a05d6b049d7b69c8e61491555 (patch)
tree2721f0bbb82e8ffb4f23a11c747dc26db7ceef0e /addons
parent67ac1b541db7e812cd41c1251bec37d38ac97548 (diff)
[FIX] website: better allow color extensions in the future
Diffstat (limited to 'addons')
-rw-r--r--addons/website/static/src/js/widgets/theme.js20
-rw-r--r--addons/website/static/src/scss/options/colors/user_color_palette.scss4
-rw-r--r--addons/website/static/src/scss/options/colors/user_color_palette_body.scss4
-rw-r--r--addons/website/static/src/scss/options/colors/user_color_palette_footer.scss4
-rw-r--r--addons/website/static/src/scss/options/colors/user_color_palette_menu.scss4
-rw-r--r--addons/website/static/src/scss/options/colors/user_color_palette_typo.scss10
-rw-r--r--addons/website/static/src/scss/options/colors/user_theme_color_palette.scss22
-rw-r--r--addons/website/static/src/scss/primary_variables.scss9
-rw-r--r--addons/website/static/src/xml/website.editor.xml4
-rw-r--r--addons/website/views/website_templates.xml5
10 files changed, 26 insertions, 60 deletions
diff --git a/addons/website/static/src/js/widgets/theme.js b/addons/website/static/src/js/widgets/theme.js
index 9fc2f0e1c21..416f9eaba8d 100644
--- a/addons/website/static/src/js/widgets/theme.js
+++ b/addons/website/static/src/js/widgets/theme.js
@@ -504,13 +504,8 @@ var ThemeCustomizeDialog = Dialog.extend({
}).then(function (data) {
var files = data.scss[0][1];
var file = _.find(files, function (file) {
- switch (colorType) {
- case 'theme':
- return file.url === '/website/static/src/scss/options/colors/user_theme_color_palette.scss';
- case 'typo':
- return file.url === '/website/static/src/scss/options/colors/user_color_palette_typo.scss';
- }
- return file.url === '/website/static/src/scss/options/colors/user_color_palette_' + colorName + '.scss';
+ var baseURL = '/website/static/src/scss/options/colors/';
+ return file.url === _.str.sprintf('%suser_%scolor_palette.scss', baseURL, (colorType ? (colorType + '_') : ''));
});
var colors = {};
@@ -524,7 +519,16 @@ var ThemeCustomizeDialog = Dialog.extend({
var updatedFileContent = file.arch;
_.each(colors, function (colorValue, colorName) {
- updatedFileContent = updatedFileContent.replace(new RegExp(colorName + ': (?:null|#[a-fA-F0-9]{6}),'), colorName + ': ' + colorValue + ',');
+ var pattern = _.str.sprintf("'%s': %%s,\n", colorName);
+ var regex = new RegExp(_.str.sprintf(pattern, ".+"));
+ var replacement = _.str.sprintf(pattern, colorValue);
+ if (regex.test(updatedFileContent)) {
+ updatedFileContent = updatedFileContent
+ .replace(regex, replacement);
+ } else {
+ updatedFileContent = updatedFileContent
+ .replace(/( *)(.*hook.*)/, _.str.sprintf('$1%s$1$2', replacement));
+ }
});
return self._rpc({
diff --git a/addons/website/static/src/scss/options/colors/user_color_palette.scss b/addons/website/static/src/scss/options/colors/user_color_palette.scss
new file mode 100644
index 00000000000..7abaee4af3b
--- /dev/null
+++ b/addons/website/static/src/scss/options/colors/user_color_palette.scss
@@ -0,0 +1,4 @@
+
+$o-user-color-palette: map-merge($o-user-color-palette, o-map-omit((
+ // -- hook --
+)));
diff --git a/addons/website/static/src/scss/options/colors/user_color_palette_body.scss b/addons/website/static/src/scss/options/colors/user_color_palette_body.scss
deleted file mode 100644
index b8687ea4887..00000000000
--- a/addons/website/static/src/scss/options/colors/user_color_palette_body.scss
+++ /dev/null
@@ -1,4 +0,0 @@
-
-$o-user-color-palette: map-merge((
- body: null,
-), o-map-omit($o-user-color-palette));
diff --git a/addons/website/static/src/scss/options/colors/user_color_palette_footer.scss b/addons/website/static/src/scss/options/colors/user_color_palette_footer.scss
deleted file mode 100644
index 1fb027d61e1..00000000000
--- a/addons/website/static/src/scss/options/colors/user_color_palette_footer.scss
+++ /dev/null
@@ -1,4 +0,0 @@
-
-$o-user-color-palette: map-merge((
- footer: null,
-), o-map-omit($o-user-color-palette));
diff --git a/addons/website/static/src/scss/options/colors/user_color_palette_menu.scss b/addons/website/static/src/scss/options/colors/user_color_palette_menu.scss
deleted file mode 100644
index a9d967cb81b..00000000000
--- a/addons/website/static/src/scss/options/colors/user_color_palette_menu.scss
+++ /dev/null
@@ -1,4 +0,0 @@
-
-$o-user-color-palette: map-merge((
- menu: null,
-), o-map-omit($o-user-color-palette)); \ No newline at end of file
diff --git a/addons/website/static/src/scss/options/colors/user_color_palette_typo.scss b/addons/website/static/src/scss/options/colors/user_color_palette_typo.scss
deleted file mode 100644
index 0ef3d41868c..00000000000
--- a/addons/website/static/src/scss/options/colors/user_color_palette_typo.scss
+++ /dev/null
@@ -1,10 +0,0 @@
-
-$o-user-color-palette: map-merge((
- text: null,
- h1: null,
- h2: null,
- h3: null,
- h4: null,
- h5: null,
- h6: null,
-), o-map-omit($o-user-color-palette));
diff --git a/addons/website/static/src/scss/options/colors/user_theme_color_palette.scss b/addons/website/static/src/scss/options/colors/user_theme_color_palette.scss
index 88c0847ae04..300db091acb 100644
--- a/addons/website/static/src/scss/options/colors/user_theme_color_palette.scss
+++ b/addons/website/static/src/scss/options/colors/user_theme_color_palette.scss
@@ -1,20 +1,4 @@
-$o-user-theme-color-palette: map-merge((
- // Theme colors
- alpha: null,
- beta: null,
- gamma: null,
- epsilon: null,
- delta: null,
-
- // Depending on the theme, alpha and beta may not be equal to
- // primary and secondary
- primary: null,
- secondary: null,
-
- // BS state colors
- success: null,
- info: null,
- warning: null,
- danger: null,
-), o-map-omit($o-user-theme-color-palette));
+$o-user-theme-color-palette: map-merge($o-user-theme-color-palette, o-map-omit((
+ // -- hook --
+)));
diff --git a/addons/website/static/src/scss/primary_variables.scss b/addons/website/static/src/scss/primary_variables.scss
index fb8059b6382..6e3f9a5f39a 100644
--- a/addons/website/static/src/scss/primary_variables.scss
+++ b/addons/website/static/src/scss/primary_variables.scss
@@ -22,12 +22,13 @@ $-palettes: ();
}
$o-color-palettes: $-palettes;
-// By default, all user color palette values are null. Each null value is automatically replaced
-// with corresponsing color of color palette 1.
+// By default, all user color palette values are null. Each null value is
+// automatically replaced with corresponsing color of chosen color palette.
$o-user-color-palette: () !default;
-// By default, all user theme color palette values are null. Each null value is automatically
-// replaced with corresponsing color of theme color palette 1.
+// By default, all user theme color palette values are null. Each null value
+// is automatically replaced with corresponsing color of chosen theme color
+// palette.
$o-user-theme-color-palette: () !default;
//------------------------------------------------------------------------------
diff --git a/addons/website/static/src/xml/website.editor.xml b/addons/website/static/src/xml/website.editor.xml
index 46174daaf72..b3f823314f9 100644
--- a/addons/website/static/src/xml/website.editor.xml
+++ b/addons/website/static/src/xml/website.editor.xml
@@ -44,9 +44,7 @@
<div>
<h6>Text colors</h6>
<t t-foreach="{'text': _t('Text'), 'h1': _t('Headings 1'), 'h2': _t('Headings 2'), 'h3': _t('Headings 3'), 'h4': _t('Headings 4'), 'h5': _t('Headings 5'), 'h6': _t('Headings 6')}" t-as="color">
- <t t-call="website.theme_customize_color_palette_button">
- <t t-set="color_type" t-value="'typo'"/>
- </t>
+ <t t-call="website.theme_customize_color_palette_button"/>
</t>
</div>
<div>
diff --git a/addons/website/views/website_templates.xml b/addons/website/views/website_templates.xml
index 07263647023..82940d1f1c6 100644
--- a/addons/website/views/website_templates.xml
+++ b/addons/website/views/website_templates.xml
@@ -4,10 +4,7 @@
<template id="_assets_primary_variables" inherit_id="web._assets_primary_variables">
<xpath expr="//link[last()]" position="after">
<link rel="stylesheet" type="text/scss" href="/website/static/src/scss/primary_variables.scss"/>
- <link rel="stylesheet" type="text/scss" href="/website/static/src/scss/options/colors/user_color_palette_body.scss"/>
- <link rel="stylesheet" type="text/scss" href="/website/static/src/scss/options/colors/user_color_palette_footer.scss"/>
- <link rel="stylesheet" type="text/scss" href="/website/static/src/scss/options/colors/user_color_palette_menu.scss"/>
- <link rel="stylesheet" type="text/scss" href="/website/static/src/scss/options/colors/user_color_palette_typo.scss"/>
+ <link rel="stylesheet" type="text/scss" href="/website/static/src/scss/options/colors/user_color_palette.scss"/>
<link rel="stylesheet" type="text/scss" href="/website/static/src/scss/options/colors/user_theme_color_palette.scss"/>
</xpath>
</template>