summaryrefslogtreecommitdiff
path: root/addons/website/static/src/js/website.contentMenu.js
diff options
context:
space:
mode:
authorChristophe Matthieu <chm@odoo.com>2015-02-10 17:39:31 +0100
committerChristophe Matthieu <chm@odoo.com>2015-02-11 12:31:52 +0100
commite8526dd01386afdc8ea81fad8237a6ad858f30a7 (patch)
tree97915ab8b060d172ca55abc1733410287116e31a /addons/website/static/src/js/website.contentMenu.js
parent8d34ada28234cc5e87aee72e268087e1bb09cad8 (diff)
[IMP] website: menu editor open a modal to select the menu to edit if more of one menu in the page (like event)
Diffstat (limited to 'addons/website/static/src/js/website.contentMenu.js')
-rw-r--r--addons/website/static/src/js/website.contentMenu.js50
1 files changed, 39 insertions, 11 deletions
diff --git a/addons/website/static/src/js/website.contentMenu.js b/addons/website/static/src/js/website.contentMenu.js
index cf60f1263f6..ab85c061a12 100644
--- a/addons/website/static/src/js/website.contentMenu.js
+++ b/addons/website/static/src/js/website.contentMenu.js
@@ -14,22 +14,34 @@
var $content_item = $(this);
self[$content_item.data('action')]();
});
-
return this._super();
},
edit_menu: function() {
var self = this;
var context = website.get_context();
- openerp.jsonRpc('/web/dataset/call_kw', 'call', {
- model: 'website.menu',
- method: 'get_tree',
- args: [context.website_id],
- kwargs: {
- context: context
- },
- }).then(function (menu) {
- var result = new website.contentMenu.EditMenuDialog(menu).appendTo(document.body);
- return result;
+ var def = $.Deferred();
+ if ($("[data-content_menu_id]").length) {
+ var select = new website.contentMenu.SelectEditMenuDialog();
+ select.appendTo(document.body);
+ select.on('save', this, function (root) {
+ def.resolve(root);
+ });
+ } else {
+ def.resolve(null);
+ }
+
+ def.then(function (root_id) {
+ openerp.jsonRpc('/web/dataset/call_kw', 'call', {
+ model: 'website.menu',
+ method: 'get_tree',
+ args: [context.website_id, root_id],
+ kwargs: {
+ context: context
+ },
+ }).then(function (menu) {
+ var result = new website.contentMenu.EditMenuDialog(menu).appendTo(document.body);
+ return result;
+ });
});
},
new_page: function() {
@@ -105,6 +117,22 @@
}
});
+ website.contentMenu.SelectEditMenuDialog = website.editor.Dialog.extend({
+ template: 'website.contentMenu.dialog.select',
+ init: function () {
+ var self = this;
+ self.roots = [{id: null, name: _t("Top Menu")}];
+ $("[data-content_menu_id]").each(function () {
+ self.roots.push({id: $(this).data("content_menu_id"), name: $(this).attr("name")});
+ });
+ this._super();
+ },
+ save: function () {
+ this.trigger("save", parseInt(this.$el.find("select").val() || null));
+ this._super();
+ }
+ });
+
website.contentMenu.EditMenuDialog = website.editor.Dialog.extend({
template: 'website.contentMenu.dialog.edit',
events: _.extend({}, website.editor.Dialog.prototype.events, {