diff options
| author | qsm-odoo <qsm@odoo.com> | 2016-08-05 13:59:05 +0200 |
|---|---|---|
| committer | qsm-odoo <qsm@odoo.com> | 2016-08-19 17:44:27 +0200 |
| commit | ff9a9d703f5582d1d1032e6ee056057bf03da2db (patch) | |
| tree | 528914110fee6180f1c4e57a29d41a60c94d6654 | |
| parent | 3049b154e91c20b9c07c4ea0d3490935c6e0aaed (diff) | |
[FIX] web_editor: properly handle many2one fields
The many2one fields and their search bar were not working anymore since
the loss of some functionnalities with commit b309f3ab543b5195eedc5b06ad08cfa81f43171a.
* The dropdown which regroups a snippet options list is hidden if it
does not contain any option. This was not the case anymore because it
now always contains a dropdown title. This is fixed by simply removing
this title if it is alone in the dropdown.
* Snippet options attached to an element whose parent is not editable
cannot be moved/deleted/duplicated as it is supposed to remain where
it is. This is often the case for many2one fields and the feature was
simply lost in the refactoring.
| -rw-r--r-- | addons/web_editor/static/src/js/snippets.editor.js | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/addons/web_editor/static/src/js/snippets.editor.js b/addons/web_editor/static/src/js/snippets.editor.js index 19f60a25741..3f7561a8d98 100644 --- a/addons/web_editor/static/src/js/snippets.editor.js +++ b/addons/web_editor/static/src/js/snippets.editor.js @@ -827,9 +827,13 @@ data.Editor = Class.extend({ this.load_style_options(); // Initialize move/clone/remove buttons - this.$overlay.on('click', '.oe_snippet_clone', _.bind(this.on_clone, this)); - this.$overlay.on('click', '.oe_snippet_remove', _.bind(this.on_remove, this)); - this._drag_and_drop(); + if (!this.$target.parent().is(':o_editable')) { + this.$overlay.find('.oe_snippet_move, .oe_snippet_clone, .oe_snippet_remove').remove(); + } else { + this.$overlay.on('click', '.oe_snippet_clone', _.bind(this.on_clone, this)); + this.$overlay.on('click', '.oe_snippet_remove', _.bind(this.on_remove, this)); + this._drag_and_drop(); + } }, getName: function () { @@ -973,7 +977,11 @@ data.Editor = Class.extend({ self.styles[option].start(); self.styles[option].__order = i++; }); - $ul.append($("<li/>", {"class": "divider"})); + if ($ul.children().length > 1) { + $ul.append($("<li/>", {"class": "divider"})); + } else { + $ul.empty(); + } var $parents = this.$target.parents(); _.each($parents, function (parent) { |
