summaryrefslogtreecommitdiff
path: root/addons/website/static/src
diff options
context:
space:
mode:
authorFabien Meghazi <fme@openerp.com>2013-06-26 01:07:34 +0200
committerFabien Meghazi <fme@openerp.com>2013-06-26 01:07:34 +0200
commit110b0d1052280be256325c0e5b9b3a52626e59ea (patch)
treeef28d199e50bd2d5a55044bb1a6de9abc2982ae5 /addons/website/static/src
parent0352478bd6b3e735048427018af74d0ba6f7b7c5 (diff)
[ADD] Save to db
bzr revid: fme@openerp.com-20130625230734-6i0vxc89gkshrp8t
Diffstat (limited to 'addons/website/static/src')
-rw-r--r--addons/website/static/src/js/website_editor.js35
1 files changed, 32 insertions, 3 deletions
diff --git a/addons/website/static/src/js/website_editor.js b/addons/website/static/src/js/website_editor.js
index 54f01cf96a6..270e28593ef 100644
--- a/addons/website/static/src/js/website_editor.js
+++ b/addons/website/static/src/js/website_editor.js
@@ -1,14 +1,43 @@
(function() {
- // Init headless webclient (TODO: check embedded mode)
- var $web = $('<div style="width: 300px; height: 300px; position: absolute; bottom: 0; right: 0;"/>').appendTo($('body'));
+ // Init headless webclient
+ // TODO: check embedded mode or how to put it cleanly in a dom ready callback
+ var $web = $('<div style="display: none;"/>').appendTo('body');
var s = new openerp.init(['web']);
var wc = new s.web.WebClient();
+ // TODO: disable blockUI
wc.appendTo($web);
+ var instance = openerp.instances[wc.session.name];
+
+ setTimeout(function () {
+ // HACKY HACK YUCK YUCK !!
+ // TODO: Need modification to webclient. Webclient shall trigger an event when it's ready.
+ if (instance.web.notification) {
+ instance.web.notification.$el.appendTo('body');
+ } else {
+ console.log("too late");
+ }
+ }, 2000);
$(function() {
- $('.editable').css('outline', '1px solid red').attr('contentEditable', 'true').click(function (e) {
+ $('.editable').css('outline', '1px dotted red').attr('contentEditable', 'true').click(function (e) {
e.stopPropagation();
e.preventDefault();
});
+ $('body').on("keypress", ".editable", function(e) {
+ if (e.which == 13) {
+ var $el = $(e.currentTarget);
+ var data = $el.data();
+ var update = {};
+ // TODO: Are we going to use a meta-data flag in order to know if the field shall be text or html ?
+ update[data.field] = $el.text();
+ (new instance.web.DataSet(this, data.model)).write(data.id, update).done(function() {
+ $el.blur();
+ instance.webclient.do_notify('Save', _.str.sprintf('%s#%d#%s saved', data.model, data.id, data.field));
+ }).fail(function () {
+ console.error('fail');
+ });
+ e.preventDefault();
+ }
+ });
});
})();