summaryrefslogtreecommitdiff
path: root/addons/web_editor
diff options
context:
space:
mode:
authorfja-odoo <fja@odoo.com>2019-10-31 17:36:53 +0000
committerfja-odoo <fja@odoo.com>2019-12-06 17:59:59 +0000
commit92fdbec889ec5791b9c4abc949ddeeff8ffecaed (patch)
tree8be3c3efc8e2382e1acabdc4179a535c641683a8 /addons/web_editor
parent6564c36c74a62716436de5231dbf12a4c984ce14 (diff)
[IMP] website, web_editor: add new chart snippet
Introducing a new snippet called Chart. This snippet uses the lib https://www.chartjs.org/ 6 types of graph are possible: Bar vertical Bar horizontal Line Pie Doughnut Radar task-2092267 closes odoo/odoo#40051 Signed-off-by: Quentin Smetz (qsm) <qsm@odoo.com>
Diffstat (limited to 'addons/web_editor')
-rw-r--r--addons/web_editor/static/src/js/wysiwyg/widgets/color_palette.js26
-rw-r--r--addons/web_editor/static/src/scss/wysiwyg_snippets.scss41
2 files changed, 62 insertions, 5 deletions
diff --git a/addons/web_editor/static/src/js/wysiwyg/widgets/color_palette.js b/addons/web_editor/static/src/js/wysiwyg/widgets/color_palette.js
index 04a21c79378..a4881e1b139 100644
--- a/addons/web_editor/static/src/js/wysiwyg/widgets/color_palette.js
+++ b/addons/web_editor/static/src/js/wysiwyg/widgets/color_palette.js
@@ -158,17 +158,33 @@ const ColorPaletteWidget = Widget.extend({
return ColorpickerDialog.normalizeCSSColor(el.style.backgroundColor);
})
));
+ this.trigger_up('get_custom_colors', {
+ onSuccess: (colors) => {
+ colors.forEach(color => {
+ this._addCustomColor(existingColors, color);
+ });
+ },
+ });
_.each(this.options.$editable.find('[style*="color"]'), el => {
for (const colorProp of ['color', 'backgroundColor']) {
- const color = ColorpickerDialog.normalizeCSSColor(el.style[colorProp]);
- if (color && !existingColors.has(color)) {
- this._addCustomColorButton(color);
- existingColors.add(color);
- }
+ this._addCustomColor(existingColors, el.style[colorProp]);
}
});
},
/**
+ * Add the color to the custom color section if it is not in the existingColors.
+ *
+ * @param {string[]} existingColors Colors currently in the colorpicker
+ * @param {string} color Color to add to the cuustom colors
+ */
+ _addCustomColor: function (existingColors, color) {
+ const normColor = ColorpickerDialog.normalizeCSSColor(color);
+ if (color && !existingColors.has(normColor)) {
+ this._addCustomColorButton(normColor);
+ existingColors.add(normColor);
+ }
+ },
+ /**
* Add a custom button in the coresponding section.
*
* @private
diff --git a/addons/web_editor/static/src/scss/wysiwyg_snippets.scss b/addons/web_editor/static/src/scss/wysiwyg_snippets.scss
index 019fb32fd3f..6f76811a704 100644
--- a/addons/web_editor/static/src/scss/wysiwyg_snippets.scss
+++ b/addons/web_editor/static/src/scss/wysiwyg_snippets.scss
@@ -408,6 +408,47 @@ body.editor_enable.editor_has_snippets {
}
}
+ // Chart Snippet
+ we-matrix {
+ overflow-y: auto;
+
+ table {
+ table-layout: fixed;
+ width: 100%;
+
+ td, th {
+ text-align: center;
+ we-button {
+ display: inline-block;
+ color: white;
+ height: 100%;
+
+ &.o_we_matrix_remove_col, &.o_we_matrix_remove_row {
+ display: none;
+ }
+ }
+ input {
+ border: 1px solid var(--o-we-bg-color-dark);
+ background-color: var(--o-we-bg-color-dark);
+ color: var(--o-we-color);
+ font-size: 12px;
+ width: 100%;
+ }
+ &:last-child {
+ width: 28px;
+ }
+ }
+ &.o_we_matrix_five_col {
+ width: auto;
+ td, th {
+ input {
+ width: 43px;
+ }
+ }
+ }
+ }
+ }
+
//----------------------------------------------------------------------
// Layout Utils
//----------------------------------------------------------------------