From f0620a9648d7f6ab65489432f49aa4854ee1cfd9 Mon Sep 17 00:00:00 2001 From: qsm-odoo Date: Wed, 20 Jul 2016 14:01:16 +0200 Subject: [FIX] web_editor,website: allow creating pages from edit menu The code for page creation from menu edition dialog was there but invisible to the user because of a wrong qweb template inheritance. Indeed, the edit menu dialog relies on an extension of the link dialog template. But this one is extended in-place in another location and that extension is not considered when the second extension is made because a t-extend always use the base template. The only solution to achieve the same result is to copy the edit menu dialog qweb extension in Javascript. Note: the feature was still available from the link dialog in page edition though because this was not concerned by the wrong qweb extension. However, adding a page by this way would create multiple pages because one was created each time a page name was entered (and not only on save !). So typing "test", then changing its mind and typing "hello", then rechanging to "test", then hitting the save button created the "test, "test-1", "test-2" and "hello" pages. This fix takes advantage of an already present parameter which can determine if a new page should be created or not. However, a code refactoring should be done in master for these classes. --- addons/website/static/src/js/website.contentMenu.js | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'addons/website/static/src/js/website.contentMenu.js') diff --git a/addons/website/static/src/js/website.contentMenu.js b/addons/website/static/src/js/website.contentMenu.js index 54a7e041538..a665a8b3eee 100644 --- a/addons/website/static/src/js/website.contentMenu.js +++ b/addons/website/static/src/js/website.contentMenu.js @@ -307,7 +307,6 @@ var EditMenuDialog = widget.Dialog.extend({ }); var MenuEntryDialog = widget.LinkDialog.extend({ - template: 'website.contentMenu.dialog.add', init: function (editor, data) { data.text = data.name || ''; data.isNewWindow = data.new_window; @@ -316,10 +315,11 @@ var MenuEntryDialog = widget.LinkDialog.extend({ }, start: function () { var self = this; - var result = $.when(this._super.apply(this, arguments)).then(function () { - if (self.data) { - self.bind_data(); - } + + this.$(".link-style").remove(); + this.$("label[for=link-new]").text("Menu Label"); + + return $.when(this._super.apply(this, arguments)).then(function () { var $link_text = self.$('#link-text').focus(); self.$('#link-page').change(function (e) { if ($link_text.val()) { return; } @@ -328,7 +328,6 @@ var MenuEntryDialog = widget.LinkDialog.extend({ $link_text.focus(); }); }); - return result; }, save: function () { var $e = this.$('#link-text'); -- cgit v1.2.3