summaryrefslogtreecommitdiff
path: root/addons/web_editor/static/src/js/snippets.editor.js
diff options
context:
space:
mode:
authorqsm-odoo <qsm@odoo.com>2016-08-05 13:59:05 +0200
committerqsm-odoo <qsm@odoo.com>2016-08-05 15:13:54 +0200
commit57c09e8a8effe0e0ec8f96dd940218027789feaa (patch)
treecf7f0a918d5a5ad38beae7cce20c9027dbd2a3c5 /addons/web_editor/static/src/js/snippets.editor.js
parent0a3cd5b0a7bcfff056ebaa31951a9e849d25e397 (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.
Diffstat (limited to 'addons/web_editor/static/src/js/snippets.editor.js')
-rw-r--r--addons/web_editor/static/src/js/snippets.editor.js16
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) {