[FIX] website: restore some website rpc since new views
The website is not ready. It is still too young to understand what the beautiful `_rpc` function can bring to its life. Someday it will, but for now, it can at least rely on the `rpc.query` function or to the 'Ace' menu which now understands the beauty of `_rpc`. --- -> Replace website `_rpc` calls with deprecated `rpc.query` as the website is not structured enough yet to handle 'trigger_up' events. -> As the `_rpc` calls cannot be replaced for the ace editor because it is also used and tested in the backend, promote the 'Ace' menu (which instantiate the ace editor) to be a `ServiceProvider` so that the `_rpc` method works in this particular case.
This commit is contained in:
@@ -3,18 +3,23 @@ odoo.define('website.ace', function (require) {
|
||||
|
||||
var Widget = require('web.Widget');
|
||||
var website = require('website.website');
|
||||
var mixins = require('web.mixins');
|
||||
|
||||
var ViewEditor = require('web_editor.ace');
|
||||
|
||||
var hash = "#advanced-view-editor";
|
||||
|
||||
var Ace = Widget.extend({
|
||||
var Ace = Widget.extend(mixins.ServiceProvider, {
|
||||
events: {
|
||||
"click a[data-action=ace]": function (e) {
|
||||
e.preventDefault();
|
||||
this.launchAce();
|
||||
},
|
||||
},
|
||||
init: function () {
|
||||
mixins.ServiceProvider.init.apply(this, arguments);
|
||||
this._super.apply(this, arguments);
|
||||
},
|
||||
start: function () {
|
||||
if (window.location.hash.substr(0, hash.length) === hash) {
|
||||
this.launchAce();
|
||||
|
||||
@@ -6,6 +6,7 @@ var ajax = require('web.ajax');
|
||||
var Class = require('web.Class');
|
||||
var Dialog = require('web.Dialog');
|
||||
var mixins = require('web.mixins');
|
||||
var rpc = require("web.rpc");
|
||||
var Widget = require('web.Widget');
|
||||
var base = require('web_editor.base');
|
||||
var website = require('website.website');
|
||||
@@ -490,22 +491,21 @@ var Configurator = Dialog.extend({
|
||||
def.resolve(null);
|
||||
} else {
|
||||
var fields = ['website_meta_title', 'website_meta_description', 'website_meta_keywords'];
|
||||
this._rpc({
|
||||
model: obj.model,
|
||||
method: 'read',
|
||||
args: [[obj.id], fields, base.get_context()],
|
||||
})
|
||||
.then(function (data) {
|
||||
if (data.length) {
|
||||
var meta = data[0];
|
||||
meta.model = obj.model;
|
||||
def.resolve(meta);
|
||||
} else {
|
||||
def.resolve(null);
|
||||
}
|
||||
}).fail(function () {
|
||||
def.reject();
|
||||
});
|
||||
rpc.query({
|
||||
model: obj.model,
|
||||
method: 'read',
|
||||
args: [[obj.id], fields, base.get_context()],
|
||||
}).then(function (data) {
|
||||
if (data.length) {
|
||||
var meta = data[0];
|
||||
meta.model = obj.model;
|
||||
def.resolve(meta);
|
||||
} else {
|
||||
def.resolve(null);
|
||||
}
|
||||
}).fail(function () {
|
||||
def.reject();
|
||||
});
|
||||
}
|
||||
return def;
|
||||
},
|
||||
@@ -514,11 +514,11 @@ var Configurator = Dialog.extend({
|
||||
if (!obj) {
|
||||
return $.Deferred().reject();
|
||||
} else {
|
||||
return this._rpc({
|
||||
model: obj.model,
|
||||
method: 'write',
|
||||
args: [[obj.id], data, base.get_context()],
|
||||
});
|
||||
return rpc.query({
|
||||
model: obj.model,
|
||||
method: 'write',
|
||||
args: [[obj.id], data, base.get_context()],
|
||||
});
|
||||
}
|
||||
},
|
||||
titleChanged: function () {
|
||||
|
||||
Reference in New Issue
Block a user