summaryrefslogtreecommitdiff
path: root/addons/web_editor/static/src/js/snippets.editor.js
diff options
context:
space:
mode:
authorqsm-odoo <qsm@odoo.com>2016-08-12 10:58:04 +0200
committerqsm-odoo <qsm@odoo.com>2016-08-12 16:09:57 +0200
commitde0d9fd6661691488fcf4fd546d89042c0c99a4b (patch)
treefeddf1d011f7a70d836a2ae319713fd3149d75a3 /addons/web_editor/static/src/js/snippets.editor.js
parentf368c0184d454981565baaa82ef75506b8c6a82c (diff)
[FIX] web_editor: visibility of customize snippet option button
Commit 57c09e8a8effe0e0ec8f96dd940218027789feaa was supposed to fix the problem but only made it worse in some cases. Since the new option parenting system, the customize button visibility should not be determined on creation as parent and own options are appended on snippet focus. Also, removing the dropdown header if it was alone was a bad idea as this is it which contains the information of options and all the options have not necessarily a <li/> tag in the dropdown. For example, the many2one option has no <li/> in the dropdown and is the only option of the field snippet. So with the previous commit, the dropdown header was removed as there is no <li/> in the dropdown other than this header. So as the header was removed, on snippet focus, there was no way to determine the many2one option exists, so its on_focus method was not called. Now, the dropdown-header is always kept. The visibility of customize button is determine on snippet focus.
Diffstat (limited to 'addons/web_editor/static/src/js/snippets.editor.js')
-rw-r--r--addons/web_editor/static/src/js/snippets.editor.js14
1 files changed, 5 insertions, 9 deletions
diff --git a/addons/web_editor/static/src/js/snippets.editor.js b/addons/web_editor/static/src/js/snippets.editor.js
index 3f7561a8d98..3e01f825b48 100644
--- a/addons/web_editor/static/src/js/snippets.editor.js
+++ b/addons/web_editor/static/src/js/snippets.editor.js
@@ -977,11 +977,7 @@ data.Editor = Class.extend({
self.styles[option].start();
self.styles[option].__order = i++;
});
- if ($ul.children().length > 1) {
- $ul.append($("<li/>", {"class": "divider"}));
- } else {
- $ul.empty();
- }
+ $ul.append($("<li/>", {"class": "divider"}));
var $parents = this.$target.parents();
_.each($parents, function (parent) {
@@ -1000,9 +996,6 @@ data.Editor = Class.extend({
this.$overlay.find(".oe_snippet_move, .oe_snippet_clone").addClass('hidden');
}
- if ($ul.children().length) {
- $styles.removeClass("hidden");
- }
this.$overlay.find('[data-toggle="dropdown"]').dropdown();
},
@@ -1120,7 +1113,9 @@ data.Editor = Class.extend({
var do_action = (focus ? _do_action_focus : _do_action_blur);
// Attach own and parent options on the current overlay
- var $headers = this.$overlay.find(".oe_options ul:first .dropdown-header:data(editor)");
+ var $style_button = this.$overlay.find(".oe_options");
+ var $ul = $style_button.find("ul:first");
+ var $headers = $ul.find(".dropdown-header:data(editor)");
_.each($headers, function (el) {
var $el = $(el);
var styles = _.values($el.data("editor").styles);
@@ -1133,6 +1128,7 @@ data.Editor = Class.extend({
});
// Activate the overlay
+ $style_button.toggleClass("hidden", $ul.children(":not(.dropdown-header):not(.divider):not(.hidden)").length === 0);
this.$overlay.toggleClass("oe_active", !!focus);
function _do_action_focus(style, $dest) {