[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.
This commit is contained in:
qsm-odoo
2016-08-19 17:44:27 +02:00
parent 3c98c78fc7
commit 1d54874c13
2 changed files with 41 additions and 0 deletions
@@ -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();
+4
View File
@@ -937,5 +937,9 @@
<div data-js="menu_data"
data-selector="#top_menu > li > a"
data-no-check="true"/>
<div data-js="company_data"
data-selector="img[src='/logo.png'], [data-oe-expression='res_company.partner_id']"
data-no-check="true"/>
</template>
</odoo>