[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 b309f3ab54.

* 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.
This commit is contained in:
qsm-odoo
2016-08-19 17:44:27 +02:00
parent 3049b154e9
commit ff9a9d703f
@@ -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) {