diff options
| author | qsm-odoo <qsm@odoo.com> | 2016-08-12 10:58:04 +0200 |
|---|---|---|
| committer | qsm-odoo <qsm@odoo.com> | 2016-08-19 17:44:27 +0200 |
| commit | 9c07b67d10b5910a5a9b257477ed13cb07232baa (patch) | |
| tree | 549ffdf09a5cf50af9cab61ad8301fb2d3d8d164 | |
| parent | 1421c682072f8464cfe685356a02d4dd7abcef1d (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.
| -rw-r--r-- | addons/web_editor/static/src/js/snippets.editor.js | 14 |
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) { |
