bzr revid: al@openerp.com-20130703015109-clb9v3n8yawg5ew8
This commit is contained in:
Antony Lesuisse 2013-07-03 03:51:09 +02:00
parent a415c9c39b
commit d7a782a884
2 changed files with 16 additions and 6 deletions

View File

@ -33,16 +33,24 @@ instance.website.EditorBar = instance.web.Widget.extend({
});
},
save: function () {
var sleep = function (timeout) {
deferred = new $.Deferred();
setTimeout(deferred.resolve, timeout);
return deferred.promise();
}
var self = this;
var defs = [];
$('.oe_dirty').each(function () {
$('.oe_dirty').each(function (i, v) {
var $el = $(this);
var def = self.saveElement($el).then(function () {
$el.removeClass('oe_dirty');
}).fail(function () {
var data = $el.data();
console.error(_.str.sprintf('Could not save %s#%d#%s', data.oeModel, data.oeId, data.oeField));
var def = sleep(i*100).then(function () {
return self.saveElement($el).then(function () {
$el.removeClass('oe_dirty');
}).fail(function () {
var data = $el.data();
console.error(_.str.sprintf('Could not save %s#%d#%s', data.oeModel, data.oeId, data.oeField));
});
});
defs.push(def);
});
return $.when.apply(null, defs).then(function () {
@ -57,6 +65,7 @@ instance.website.EditorBar = instance.web.Widget.extend({
var $w = $el.clone();
$w.removeClass('aloha-editable aloha-editable-highlight oe_dirty');
_.each(['model', 'id', 'field', 'xpath'], function(d) {$w.removeAttr('data-oe-' + d);});
_.each(['contenteditable'], function(d) {$w.removeAttr(d);});
html = $w.wrap('<div>').parent().html();
}
return (new instance.web.DataSet(this, 'ir.ui.view')).call('save', [data.oeModel, data.oeId, data.oeField, html, xpath]);

View File

@ -24,4 +24,5 @@ class contactus(http.Controller):
html = request.registry.get("ir.ui.view").render(cr, uid, "website_crm.thanks", values)
return html
# vim:expandtab:tabstop=4:softtabstop=4:shiftwidth=4: