diff options
| author | qsm-odoo <qsm@odoo.com> | 2016-08-09 10:58:17 +0200 |
|---|---|---|
| committer | qsm-odoo <qsm@odoo.com> | 2016-08-19 17:44:27 +0200 |
| commit | 1d54874c13e974317bf211ea5af7c1b7d130dbcd (patch) | |
| tree | e58ece44ee5a4e6fe9af54c51b470c5ccd77eb43 /addons/website/static/src/js/website.snippets.editor.js | |
| parent | 3c98c78fc75da13398826ed2ecb5b126c4f57fd1 (diff) | |
[IMP] website: propose edition of company data in frontend
When clicking on the logo or the company adress in the website edit
mode, the user can now choose to be redirected to the form view of
the company so that it can edit the data.
Diffstat (limited to 'addons/website/static/src/js/website.snippets.editor.js')
| -rw-r--r-- | addons/website/static/src/js/website.snippets.editor.js | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/addons/website/static/src/js/website.snippets.editor.js b/addons/website/static/src/js/website.snippets.editor.js index 0a735f34263..bc2dbf3b658 100644 --- a/addons/website/static/src/js/website.snippets.editor.js +++ b/addons/website/static/src/js/website.snippets.editor.js @@ -1,8 +1,10 @@ odoo.define('website.snippets.editor', function (require) { 'use strict'; +var ajax = require("web.ajax"); var core = require("web.core"); var Dialog = require("web.Dialog"); +var Model = require("web.Model"); var editor = require("web_editor.editor"); var options = require('web_editor.snippets.options'); var snippet_editor = require('web_editor.snippet.editor'); @@ -51,6 +53,41 @@ options.registry.menu_data = options.Class.extend({ }, }); +options.registry.company_data = options.Class.extend({ + start: function () { + this._super.apply(this, arguments); + + var proto = options.registry.company_data.prototype; + + if (proto.__link_deferred === undefined) { + proto.__link_deferred = $.Deferred(); + return ajax.jsonRpc("/web/session/get_session_info", "call").then(function (session) { + return (new Model("res.users")).get_func("read")(session.uid, ["company_id"]).then(function (res) { + proto.__link_deferred.resolve( + "/web#action=base.action_res_company_form&view_type=form&id=" + (res && res[0] && res[0].company_id[0] || 1) + ); + }); + }); + } + }, + + on_focus: function () { + this._super.apply(this, arguments); + + var proto = options.registry.company_data.prototype; + + Dialog.confirm(null, _t("Do you want to edit the company data ?"), { + confirm_callback: function () { + editor.editor_bar.save_without_reload().then(function () { + proto.__link_deferred.then(function (link) { + window.location.href = link; + }); + }); + }, + }); + }, +}); + options.registry.slider = options.Class.extend({ drop_and_build_snippet: function () { this.id = "myCarousel" + new Date().getTime(); |
