Test version that can send messages
bzr revid: nicolas.vanhoren@openerp.com-20130128143524-cm02ppafma96tkol
This commit is contained in:
parent
a52b59c68f
commit
490361b83e
|
@ -16,8 +16,23 @@ define(["nova", "jquery", "underscore", "oeclient", "require"], function(nova, $
|
|||
}).then(function(content) {
|
||||
return templateEngine.loadFileContent(content);
|
||||
}).then(function() {
|
||||
console.log("starting client");
|
||||
connection = new oeclient.Connection(new oeclient.JsonpRPCConnector(server_url), db, login, password);
|
||||
console.log("hello");
|
||||
connection.getModel("res.users").search_read([["login", "in", ["demo", "admin"]]]).then(function(result) {
|
||||
var admin, demo;
|
||||
if (result[0].login === "admin") {
|
||||
admin = result[0];
|
||||
demo = result[1];
|
||||
} else {
|
||||
admin = result[1];
|
||||
demo = result[0];
|
||||
}
|
||||
admin = new livesupport.ImUser(null, admin);
|
||||
demo = new livesupport.ImUser(null, demo);
|
||||
var manager = new livesupport.ConversationManager(null);
|
||||
manager.set_me(admin);
|
||||
manager.activate_user(demo);
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
|
@ -49,7 +64,7 @@ define(["nova", "jquery", "underscore", "oeclient", "require"], function(nova, $
|
|||
|
||||
livesupport.ConversationManager = nova.Class.$extend({
|
||||
__include__: [nova.DynamicProperties],
|
||||
init: function(parent) {
|
||||
__init__: function(parent) {
|
||||
nova.DynamicProperties.__init__.call(this, parent);
|
||||
this.set("right_offset", 0);
|
||||
this.conversations = [];
|
||||
|
@ -137,8 +152,8 @@ define(["nova", "jquery", "underscore", "oeclient", "require"], function(nova, $
|
|||
"click .oe_im_chatview_close": "destroy",
|
||||
"click .oe_im_chatview_header": "show_hide",
|
||||
},
|
||||
init: function(parent, user, me) {
|
||||
this._super(parent);
|
||||
__init__: function(parent, user, me) {
|
||||
this.$super(parent);
|
||||
this.me = me;
|
||||
this.user = user;
|
||||
this.user.add_watcher();
|
||||
|
@ -184,7 +199,7 @@ define(["nova", "jquery", "underscore", "oeclient", "require"], function(nova, $
|
|||
var mes = this.$("input").val();
|
||||
this.$("input").val("");
|
||||
var send_it = _.bind(function() {
|
||||
var model = new connection.getModel("im.message");
|
||||
var model = connection.getModel("im.message");
|
||||
return model.call("post", [mes, this.user.get('id')], {context: {}});
|
||||
}, this);
|
||||
var tries = 0;
|
||||
|
|
|
@ -149,6 +149,25 @@ define(["underscore", "jquery", "nova"], function(_, $, nova) {
|
|||
]);
|
||||
}, this));
|
||||
},
|
||||
search_read: function(domain, fields, offset, limit, order, context) {
|
||||
return this.call("search", [domain || [], offset || 0, limit || false, order || false, context || {}]).then(_.bind(function(record_ids) {
|
||||
if (! record_ids) {
|
||||
return [];
|
||||
}
|
||||
return this.call("read", [record_ids, fields || [], context || {}]).then(function(records) {
|
||||
var index = {};
|
||||
_.each(records, function(r) {
|
||||
index[r.id] = r;
|
||||
});
|
||||
var res = [];
|
||||
_.each(record_ids, function(id) {
|
||||
if (index[id])
|
||||
res.push(index[id]);
|
||||
});
|
||||
return res;
|
||||
});
|
||||
}, this));
|
||||
},
|
||||
});
|
||||
|
||||
return oeclient;
|
||||
|
|
Loading…
Reference in New Issue