[FIX] Buggy qweb template loading

bzr revid: fme@openerp.com-20131029161128-ko0ocpa0h6kziooh
This commit is contained in:
Fabien Meghazi 2013-10-29 17:11:28 +01:00
parent 07b9cf0f02
commit 4ae5425fb8
8 changed files with 21 additions and 28 deletions

View File

@ -6,7 +6,7 @@
var hash = "#advanced-view-editor";
var website = openerp.website;
website.templates.push('/website/static/src/xml/website.ace.xml');
website.add_template_file('/website/static/src/xml/website.ace.xml');
website.ready().then(function () {
if (window.location.hash.indexOf(hash) >= 0) {

View File

@ -4,7 +4,7 @@
var website = openerp.website;
// $.fn.data automatically parses value, '0'|'1' -> 0|1
website.templates.push('/website/static/src/xml/website.editor.xml');
website.add_template_file('/website/static/src/xml/website.editor.xml');
website.dom_ready.done(function () {
var is_smartphone = $(document.body)[0].clientWidth < 767;

View File

@ -5,10 +5,6 @@
// The following line can be removed in 2017
openerp.website = website;
var templates = website.templates = [
'/website/static/src/xml/website.xml'
];
website.get_context = function (dict) {
var html = document.documentElement;
return _.extend({
@ -18,23 +14,21 @@
};
/* ----- TEMPLATE LOADING ---- */
website.add_template = function(template) {
templates.push(template);
};
website.load_templates = function(templates) {
var dones = _(templates).map(function (t) {
return new $.Deferred(function (d) {
openerp.qweb.add_template(t, function(err) {
if (err) {
d.reject(err);
} else {
d.resolve();
}
});
var templates_def = $.Deferred().resolve();
website.add_template_file = function(template) {
templates_def = templates_def.then(function() {
var def = $.Deferred();
openerp.qweb.add_template(template, function(err) {
if (err) {
def.reject(err);
} else {
def.resolve();
}
});
return def;
});
return $.when.apply(null, dones);
};
website.add_template_file('/website/static/src/xml/website.xml');
website.reload = function () {
location.hash = "scrollTop=" + window.document.body.scrollTop;
if (location.search.indexOf("enable_editor") > -1) {
@ -111,15 +105,14 @@
*/
website.ready = function() {
if (!all_ready) {
var tpl = website.load_templates(templates);
all_ready = dom_ready.then(function () {
all_ready = $.when(dom_ready, templates_def).then(function () {
if ($('html').data('editable')) {
website.id = $('html').data('website-id');
website.session = new openerp.Session();
var modules = ['website'];
return openerp._t.database.load_translations(website.session, modules, website.get_context().lang);
}
}).always(tpl).promise();
}).promise();
}
return all_ready;
};

View File

@ -3,7 +3,7 @@
var website = openerp.website;
website.menu = {};
website.templates.push('/website/static/src/xml/website.menu.xml');
website.add_template_file('/website/static/src/xml/website.menu.xml');
website.menu.EditMenuDialog = website.editor.Dialog.extend({
template: 'website.menu.dialog.edit',

View File

@ -2,7 +2,7 @@
'use strict';
var website = openerp.website;
website.templates.push('/website/static/src/xml/website.seo.xml');
website.add_template_file('/website/static/src/xml/website.seo.xml');
website.EditorBar.include({
events: _.extend({}, website.EditorBar.prototype.events, {

View File

@ -2,7 +2,7 @@
'use strict';
var website = openerp.website;
website.templates.push('/website/static/src/xml/website.snippets.xml');
website.add_template_file('/website/static/src/xml/website.snippets.xml');
website.EditorBar.include({
start: function () {

View File

@ -2,7 +2,7 @@
'use strict';
var website = openerp.website;
website.templates.push('/website/static/src/xml/website.tour.xml');
website.add_template_file('/website/static/src/xml/website.tour.xml');
website.tour = {
render: function render (template, dict) {

View File

@ -2,7 +2,7 @@
'use strict';
var website = openerp.website;
website.templates.push('/website/static/src/xml/website.translator.xml');
website.add_template_file('/website/static/src/xml/website.translator.xml');
var nodialog = 'website_translator_nodialog';
website.EditorBar.include({