summaryrefslogtreecommitdiff
path: root/addons/web_editor
diff options
context:
space:
mode:
authorqsm-odoo <qsm@odoo.com>2016-08-29 16:15:11 +0200
committerqsm-odoo <qsm@odoo.com>2016-08-29 18:50:51 +0200
commit88d8a2ca8e417c90c7a0eb005fd063599efbc2f4 (patch)
tree63e976a9db3cf33a4f7afc6016bba5271bb36317 /addons/web_editor
parentca01e7d7c50380fa4cb1fc13f13c146c9170b1ee (diff)
[FIX] web_editor: hide header in customize dropdown when it has no content
In some snippets, the parent hierarchy has many elements. So, when selecting a deep child of one of those, the customize dropdown had many dropdown headers showing the parent hierarchy but without any option for many of them. Commit de0d9fd6661691488fcf4fd546d89042c0c99a4b already fixed the case where the dropdown only contains dropdown headers. This commit is an adaptation to hide these headers one by one.
Diffstat (limited to 'addons/web_editor')
-rw-r--r--addons/web_editor/static/src/js/snippets.editor.js11
1 files changed, 9 insertions, 2 deletions
diff --git a/addons/web_editor/static/src/js/snippets.editor.js b/addons/web_editor/static/src/js/snippets.editor.js
index bfaeec3975a..020c93cdc17 100644
--- a/addons/web_editor/static/src/js/snippets.editor.js
+++ b/addons/web_editor/static/src/js/snippets.editor.js
@@ -1122,22 +1122,29 @@ data.Editor = Class.extend({
if ($el.data("editor") !== this) {
styles = _.filter(styles, function (option) { return !option.preventChildPropagation; });
}
+
+ var count = 0;
_.each(_.sortBy(styles, "__order").reverse(), function (style) {
- do_action(style, $el);
+ if (do_action(style, $el)) {
+ count++;
+ }
});
+ $el.toggleClass("hidden", count === 0);
}).bind(this));
// Activate the overlay
- $style_button.toggleClass("hidden", $ul.children(":not(.dropdown-header):not(.divider):not(.hidden)").length === 0);
+ $style_button.toggleClass("hidden", $ul.children(":not(.divider):not(.hidden)").length === 0);
this.$overlay.toggleClass("oe_active", !!focus);
function _do_action_focus(style, $dest) {
style.$el.insertAfter($dest);
style.on_focus();
+ return (style.$el.length > 0);
}
function _do_action_blur(style, $dest) {
style.$el.detach();
style.on_blur();
+ return false;
}
},
});