Bases of the group chat work
bzr revid: nicolas.vanhoren@openerp.com-20130902151404-gyy9ydjqu5xucpf5
This commit is contained in:
parent
1f9d21552b
commit
b4b74f9a20
|
@ -222,6 +222,13 @@ class im_session(osv.osv):
|
||||||
}, context=context)
|
}, context=context)
|
||||||
return self.read(cr, uid, session_id, context=context)
|
return self.read(cr, uid, session_id, context=context)
|
||||||
|
|
||||||
|
def add_to_session(self, cr, uid, session_id, user_id, uuid=None, context=None):
|
||||||
|
my_id = self.pool.get("im.user").get_my_id(cr, uid, uuid, context=context)
|
||||||
|
session = self.read(cr, uid, session_id, context=context)
|
||||||
|
if my_id not in session.get("user_ids"):
|
||||||
|
raise Exception("Not allowed to modify a session when you are not in it.")
|
||||||
|
self.write(cr, uid, session_id, {"user_ids": [(4, user_id)]}, context=context)
|
||||||
|
|
||||||
class im_user(osv.osv):
|
class im_user(osv.osv):
|
||||||
_name = "im.user"
|
_name = "im.user"
|
||||||
|
|
||||||
|
|
|
@ -70,7 +70,15 @@
|
||||||
|
|
||||||
var self = this;
|
var self = this;
|
||||||
|
|
||||||
return this.c_manager.start_polling();
|
return this.c_manager.start_polling().then(function() {
|
||||||
|
self.c_manager.on("new_conversation", self, function(conv) {
|
||||||
|
conv.$el.droppable({
|
||||||
|
drop: function(event, ui) {
|
||||||
|
self.add_user(conv, ui.draggable.data("user"));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
},
|
},
|
||||||
calc_box: function() {
|
calc_box: function() {
|
||||||
var $topbar = instance.client.$(".oe_topbar");
|
var $topbar = instance.client.$(".oe_topbar");
|
||||||
|
@ -133,6 +141,9 @@
|
||||||
self.c_manager.activate_session(session.id, true);
|
self.c_manager.activate_session(session.id, true);
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
add_user: function(conversation, user) {
|
||||||
|
conversation.add_user(user);
|
||||||
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
instance.im.UserWidget = instance.web.Widget.extend({
|
instance.im.UserWidget = instance.web.Widget.extend({
|
||||||
|
@ -146,6 +157,8 @@
|
||||||
this.user.add_watcher();
|
this.user.add_watcher();
|
||||||
},
|
},
|
||||||
start: function() {
|
start: function() {
|
||||||
|
this.$el.data("user", this.user);
|
||||||
|
this.$el.draggable({helper: "clone"});
|
||||||
var change_status = function() {
|
var change_status = function() {
|
||||||
this.$(".oe_im_user_online").toggle(this.user.get("im_status") === true);
|
this.$(".oe_im_user_online").toggle(this.user.get("im_status") === true);
|
||||||
};
|
};
|
||||||
|
|
|
@ -223,6 +223,7 @@ function declare($, _, openerp) {
|
||||||
});
|
});
|
||||||
this.conversations.push(conv);
|
this.conversations.push(conv);
|
||||||
this.calc_positions();
|
this.calc_positions();
|
||||||
|
this.trigger("new_conversation", conv);
|
||||||
}, this));
|
}, this));
|
||||||
}
|
}
|
||||||
if (focus) {
|
if (focus) {
|
||||||
|
@ -393,6 +394,19 @@ function declare($, _, openerp) {
|
||||||
_go_bottom: function() {
|
_go_bottom: function() {
|
||||||
this.$(".oe_im_chatview_content").scrollTop($(this.$(".oe_im_chatview_content").children()[0]).height());
|
this.$(".oe_im_chatview_content").scrollTop($(this.$(".oe_im_chatview_content").children()[0]).height());
|
||||||
},
|
},
|
||||||
|
add_user: function(user) {
|
||||||
|
if (user === this.me || _.contains(this.users, user))
|
||||||
|
return;
|
||||||
|
im_common.connection.model("im.session").call("add_to_session",
|
||||||
|
[this.session_id, user.get("id"), this.c_manager.me.get("uuid")]).then(_.bind(function() {
|
||||||
|
if (_.contains(this.others, user)) {
|
||||||
|
this.others = _.without(this.others, user);
|
||||||
|
} else {
|
||||||
|
user.add_watcher();
|
||||||
|
}
|
||||||
|
this.users.push(user);
|
||||||
|
}, this));
|
||||||
|
},
|
||||||
focus: function() {
|
focus: function() {
|
||||||
this.$(".oe_im_chatview_input").focus();
|
this.$(".oe_im_chatview_input").focus();
|
||||||
if (! this.shown)
|
if (! this.shown)
|
||||||
|
|
Loading…
Reference in New Issue