diff options
| author | qsm-odoo <qsm@odoo.com> | 2016-08-05 17:41:23 +0200 |
|---|---|---|
| committer | qsm-odoo <qsm@odoo.com> | 2016-08-19 17:44:27 +0200 |
| commit | 3c98c78fc75da13398826ed2ecb5b126c4f57fd1 (patch) | |
| tree | 4e643df2b67066abd933d901ab90f1bc198d7d4b /addons/website/static/src/js/website.snippets.editor.js | |
| parent | 0ab08050b9a2333a1f0793a524b56173cb3c3e3f (diff) | |
[IMP] website: allow to navigate through menus in edit mode
Now, when clicking on a menu item while being in edit mode, a modal
opens asking if we want to go to that page, edit that page, edit the
menu or do nothing (it only allowed to edit the menu item before).
Diffstat (limited to 'addons/website/static/src/js/website.snippets.editor.js')
| -rw-r--r-- | addons/website/static/src/js/website.snippets.editor.js | 42 |
1 files changed, 41 insertions, 1 deletions
diff --git a/addons/website/static/src/js/website.snippets.editor.js b/addons/website/static/src/js/website.snippets.editor.js index 6bf0e805fec..0a735f34263 100644 --- a/addons/website/static/src/js/website.snippets.editor.js +++ b/addons/website/static/src/js/website.snippets.editor.js @@ -1,9 +1,14 @@ odoo.define('website.snippets.editor', function (require) { 'use strict'; -var animation = require('web_editor.snippets.animation'); +var core = require("web.core"); +var Dialog = require("web.Dialog"); +var editor = require("web_editor.editor"); var options = require('web_editor.snippets.options'); var snippet_editor = require('web_editor.snippet.editor'); +var website = require('website.website'); + +var _t = core._t; snippet_editor.Class.include({ _get_snippet_url: function () { @@ -11,6 +16,41 @@ snippet_editor.Class.include({ } }); +options.registry.menu_data = options.Class.extend({ + start: function () { + this._super.apply(this, arguments); + this.link = this.$target.attr("href"); + }, + + on_focus: function () { + this._super.apply(this, arguments); + + (new Dialog(null, { + title: _t("Confirmation"), + $content: $(core.qweb.render("website.leaving_current_page_edition")), + buttons: [ + {text: _t("Continue") + " *", classes: "btn-primary", click: save_editor_then_go_to.bind(null, this.link)}, + {text: _t("Continue & Edit") + " *", classes: "btn-primary", click: save_editor_then_go_to.bind(null, this.link + "?enable_editor=1")}, + {text: _t("Edit the menu") + " *", classes: "btn-primary", click: function () { + var self = this; + website.topBar.content_menu.edit_menu(function () { + return editor.editor_bar.save_without_reload(); + }).then(function (dialog) { + self.close(); + }); + }}, + {text: _t("Stay on this page"), close: true} + ] + })).open(); + + function save_editor_then_go_to(url) { + editor.editor_bar.save_without_reload().then(function () { + window.location.href = url; + }); + } + }, +}); + options.registry.slider = options.Class.extend({ drop_and_build_snippet: function () { this.id = "myCarousel" + new Date().getTime(); |
