Merge lp:~openerp-dev/openobject-addons/trunk-livechat-support into lp:openobject-addons

Proposed by Vidhin Mehta (OpenERP)
Status: Work in progress
Proposed branch: lp:~openerp-dev/openobject-addons/trunk-livechat-support
Merge into: lp:openobject-addons
Diff against target: 676 lines (+498/-9) (has conflicts)
13 files modified
im/__openerp__.py (+3/-1)
im/im.py (+21/-0)
im/im_demo.xml (+38/-0)
im/im_shortcut_view.xml (+48/-0)
im/security/im_security.xml (+12/-0)
im/static/src/js/im.js (+89/-1)
im/static/src/js/im_common.js (+20/-2)
im/static/src/xml/im_common.xml (+3/-0)
im_livechat/im_livechat.py (+20/-0)
im_livechat/static/ext/static/css/livesupport.css (+54/-0)
im_livechat/static/ext/static/js/livechat.xml (+56/-3)
im_livechat/static/ext/static/js/livesupport.js (+134/-1)
im_livechat/web_page.html (+0/-1)
Text conflict in im/static/src/js/im_common.js
Text conflict in im/static/src/xml/im_common.xml
To merge this branch: bzr merge lp:~openerp-dev/openobject-addons/trunk-livechat-support
Reviewer Review Type Date Requested Status
OpenERP Core Team Pending
Review via email: mp+183820@code.launchpad.net
To post a comment you must log in.
8866. By Ishwar Malvi(OpenERP)

[MERGE]with trunk and resolve conflicts.

8867. By Ishwar Malvi(OpenERP)

[IMP]improved code.

8868. By Ishwar Malvi(OpenERP)

[IMP]added im_feedback object to store feedback and reason and improved code.

Unmerged revisions

8868. By Ishwar Malvi(OpenERP)

[IMP]added im_feedback object to store feedback and reason and improved code.

8867. By Ishwar Malvi(OpenERP)

[IMP]improved code.

8866. By Ishwar Malvi(OpenERP)

[MERGE]with trunk and resolve conflicts.

8865. By Ishwar Malvi(OpenERP)

[IMP]improved code.

8864. By Ishwar Malvi(OpenERP)

[MERGE] with trunk and resolve conflicts.

8863. By Ishwar Malvi(OpenERP)

[IMP]replaced im_partners object with im_chat_session to maintain individual session chat

8862. By Ishwar Malvi(OpenERP)

[IMP]modify code to resolve conflicts.

8861. By Kunal Chavda

[MERGE]with latest trunk.

8860. By Ishwar Malvi(OpenERP)

[IMP]improved code.

8859. By Ishwar Malvi(OpenERP)

[IMP]improve code.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'im/__openerp__.py'
2--- im/__openerp__.py 2013-08-20 14:15:38 +0000
3+++ im/__openerp__.py 2013-09-05 08:44:12 +0000
4@@ -16,8 +16,10 @@
5 'data': [
6 'security/ir.model.access.csv',
7 'security/im_security.xml',
8+ 'im_shortcut_view.xml'
9 ],
10- 'depends' : ['base', 'web'],
11+ 'demo': ['im_demo.xml'],
12+ 'depends' : ['base', 'web', 'portal_anonymous'],
13 'js': [
14 'static/src/js/im_common.js',
15 'static/src/js/im.js',
16
17=== modified file 'im/im.py'
18--- im/im.py 2013-09-04 13:17:53 +0000
19+++ im/im.py 2013-09-05 08:44:12 +0000
20@@ -191,6 +191,27 @@
21 'to_id': [(6, 0, to_ids)], 'session_id': to_session_id, 'technical': technical}, context=context)
22 notify_channel(cr, "im_channel", {'type': 'message', 'receivers': [my_id] + to_ids})
23 return False
24+
25+class im_premsgs(osv.osv):
26+ _name= "im.premsgs"
27+
28+ _columns = {
29+ 'user_id': fields.many2one("res.users", string="User", select=True, ondelete='cascade'),
30+ 'hashtag': fields.char(string="Message", size=10, required=True),
31+ 'note': fields.text('Note'),
32+ }
33+
34+ def get_premessages(self, cr, uid, ids, context):
35+ res={}
36+ user = self.pool.get("im.user").browse(cr, uid, ids).user_id.id
37+ if user == openerp.SUPERUSER_ID:
38+ id = self.search(cr, uid, ['|','|',('user_id','=', None),('user_id','=', user),('user_id','!=', user)])
39+ else:
40+ id = self.search(cr, uid, ['|',('user_id','=', None),('user_id','=', user)])
41+ for data in self.browse(cr, uid, id):
42+ res[data.hashtag] = data.note
43+ return res
44+
45
46 class im_session(osv.osv):
47 _name = 'im.session'
48
49=== added file 'im/im_demo.xml'
50--- im/im_demo.xml 1970-01-01 00:00:00 +0000
51+++ im/im_demo.xml 2013-09-05 08:44:12 +0000
52@@ -0,0 +1,38 @@
53+<?xml version="1.0"?>
54+<openerp>
55+ <data>
56+
57+ <!-- Resource: im.premsgs -->
58+
59+ <record id="im_premsgs_1" model="im.premsgs">
60+ <field name="hashtag">#gm</field>
61+ <field name="note">good morning</field>
62+ </record>
63+
64+ <record id="im_premsgs_2" model="im.premsgs">
65+ <field name="hashtag">#gn</field>
66+ <field name="note">good night</field>
67+ </record>
68+
69+ <record id="im_premsgs_3" model="im.premsgs">
70+ <field name="hashtag">#u</field>
71+ <field name="note">you</field>
72+ </record>
73+
74+ <record id="im_premsgs_4" model="im.premsgs">
75+ <field name="hashtag">#ur</field>
76+ <field name="note">your</field>
77+ </record>
78+
79+ <record id="im_premsgs_5" model="im.premsgs">
80+ <field name="hashtag">#abt</field>
81+ <field name="note">about</field>
82+ </record>
83+
84+ <record id="im_premsgs_6" model="im.premsgs">
85+ <field name="hashtag">#bt</field>
86+ <field name="note">but</field>
87+ </record>
88+ </data>
89+</openerp>
90+
91\ No newline at end of file
92
93=== added file 'im/im_shortcut_view.xml'
94--- im/im_shortcut_view.xml 1970-01-01 00:00:00 +0000
95+++ im/im_shortcut_view.xml 2013-09-05 08:44:12 +0000
96@@ -0,0 +1,48 @@
97+<?xml version="1.0" encoding="UTF-8" ?>
98+<openerp>
99+ <data>
100+
101+ <menuitem id="im" name="Instant Messaging" parent="mail.mail_feeds_main"/>
102+ <!-- Search View-->
103+ <!-- im premsgs -->
104+ <record model="ir.ui.view" id="view_im_premsgs_search">
105+ <field name="name">im.premsgs.search</field>
106+ <field name="model">im.premsgs</field>
107+ <field name="arch" type="xml">
108+ <search string="Im Shortcuts">
109+ <field name="hashtag" string="Shortcut"/>
110+ <group expand="0" string="Group By...">
111+ <filter string="User" name="user_id" context="{'group_by':'user_id'}"/>
112+ </group>
113+ </search>
114+ </field>
115+ </record>
116+
117+ <!-- Tree View -->
118+ <!-- im premsgs -->
119+ <record model="ir.ui.view" id="view_im_premsgs_tree">
120+ <field name="name">im.premsgs.tree</field>
121+ <field name="model">im.premsgs</field>
122+ <field name="arch" type="xml">
123+ <tree string="Im Shortcuts" editable="top">
124+ <field name="hashtag"/>
125+ <field name="note"/>
126+ <field name="user_id"/>
127+ </tree>
128+ </field>
129+ </record>
130+
131+ <!-- Action -->
132+ <!-- im premsgs -->
133+ <record model="ir.actions.act_window" id="action_im_premsgs">
134+ <field name="name">Im Shortcuts</field>
135+ <field name="res_model">im.premsgs</field>
136+ <field name="view_type">tree</field>
137+ <field name="view_mode">list</field>
138+ <field name="search_view_id" ref="view_im_premsgs_search"/>
139+ </record>
140+
141+ <menuitem name="Shortcuts" parent="im" id="im_shortcuts" action="action_im_premsgs"/>
142+
143+ </data>
144+</openerp>
145\ No newline at end of file
146
147=== modified file 'im/security/im_security.xml'
148--- im/security/im_security.xml 2013-09-02 12:23:11 +0000
149+++ im/security/im_security.xml 2013-09-05 08:44:12 +0000
150@@ -22,5 +22,17 @@
151 <field name="perm_create" eval="1"/>
152 <field name="perm_unlink" eval="1"/>
153 </record>
154+
155+ <record id="premsgs_rule_1" model="ir.rule">
156+ <field name="name">Can create, read and modify message shortcuts of his/her and unassigned </field>
157+ <field name="model_id" ref="model_im_premsgs"/>
158+ <field name="groups" eval="[(6,0,[ref('base.group_user')])]"/>
159+ <field name="domain_force">["|", ('user_id', '=', user.id),('user_id', '=', False)]</field>
160+ <field name="perm_unlink" eval="0"/>
161+ <field name="perm_write" eval="1"/>
162+ <field name="perm_read" eval="1"/>
163+ <field name="perm_create" eval="1"/>
164+ </record>
165+
166 </data>
167 </openerp>
168
169=== modified file 'im/static/src/js/im.js'
170--- im/static/src/js/im.js 2013-09-02 17:36:59 +0000
171+++ im/static/src/js/im.js 2013-09-05 08:44:12 +0000
172@@ -169,9 +169,97 @@
173 this._super();
174 },
175 });
176+
177+ im_common.Conversation.include({
178+ events: {
179+ "keyup input": "keydown",
180+ "click .oe_im_chatview_close": "destroy",
181+ "click .oe_im_chatview_header": "show_hide",
182+ "keydown input": "convertmsg",
183+ },
184+ split: function (val) {
185+ return val.split(/ \s*/);
186+ },
187+ extractLast: function (term) {
188+ return this.split(term).pop();
189+ },
190+ convertmsg : function(e) {
191+ var self = this;
192+ self.mes = this.$("input").val();
193+ var model = new instance.web.Model("im.premsgs");
194+ model.call("get_premessages", [this.c_manager.me.get('id')], {context : new instance.web.CompoundContext()
195+ }).then(function(res) {
196+ var meslist = self.mes.split(' ');
197+ self.availmsgs = _.keys(res);
198+ _.each(meslist, function(mesval, meskey) {
199+ if(_.contains(self.availmsgs, mesval)){
200+ meslist[meskey] = res[mesval];
201+ }
202+ self.mes = meslist.join(" ");
203+ });
204+ });
205+ $(".oe_im_chatview_footer input").bind("keydown", function(event) {
206+ if (event.keyCode === $.ui.keyCode.TAB && $(this).data("ui-autocomplete").menu.active) {
207+ event.preventDefault();
208+ }
209+ }).autocomplete({
210+ minLength: 1,
211+ source: function(request, response) {
212+ if(self.extractLast(request.term).match('#')){
213+ response($.ui.autocomplete.filter(self.availmsgs, self.extractLast(request.term)));
214+ } else {
215+ $( ".oe_im_chatview_footer input" ).blur().focus();
216+ return false;
217+ }
218+ },
219+ focus: function() {
220+ return false;
221+ },
222+ select: function(event, ui) {
223+ var terms = self.split(this.value);
224+ terms.pop();
225+ terms.push(ui.item.value);
226+ terms.push("");
227+ this.value = terms.join(" ");
228+ return false;
229+ }
230+ });
231+ var position = $(".oe_im_chatview_footer input").autocomplete( "option", "position" );
232+ $(".oe_im_chatview_footer input").autocomplete( "option", "position", { my : "right top", at: "right bottom" } );
233+ },
234+ _add_bubble: function(user, item, date) {
235+ var items = [item];
236+ if (user === this.last_user) {
237+ this.last_bubble.remove();
238+ items = this.last_items.concat(items);
239+ }
240+ this.last_user = user;
241+ this.last_items = items;
242+ var zpad = function(str, size) {
243+ str = "" + str;
244+ return new Array(size - str.length + 1).join('0') + str;
245+ };
246+ date = "" + zpad(date.getHours(), 2) + ":" + zpad(date.getMinutes(), 2);
247+
248+ this.last_bubble = $(QWeb.render("im_common.conversation_bubble", {"user": user, "time": date}));
249+ var self = this;
250+ _.each(items, function(item){
251+ if (item == '#offline'){
252+ self.last_bubble.find('.oe_im_chatview_bubble_list').append("<div class='oe_im_chatview_bubble_item'><font color='grey'>Visitor has left conversation.</font></div>");
253+ } else {
254+ self.last_bubble.find('.oe_im_chatview_bubble_list').append("<div class='oe_im_chatview_bubble_item'>" + item + "</div>");
255+ }
256+ });
257+ $(this.$(".oe_im_chatview_content").children()[0]).append(this.last_bubble);
258+ this._go_bottom();
259+ },
260+ _go_bottom: function() {
261+ this.$(".oe_im_chatview_content").scrollTop($(this.$(".oe_im_chatview_content").children()[0]).height());
262+ },
263+ });
264
265 im_common.technical_messages_handlers.force_kitten = function() {
266 openerp.webclient.to_kitten();
267 };
268
269-})();
270\ No newline at end of file
271+})();
272
273=== modified file 'im/static/src/js/im_common.js'
274--- im/static/src/js/im_common.js 2013-09-04 13:17:53 +0000
275+++ im/static/src/js/im_common.js 2013-09-05 08:44:12 +0000
276@@ -307,7 +307,7 @@
277 this.set("bottom_position", 0);
278 this.shown = true;
279 this.set("pending", 0);
280- this.inputPlaceholder = this.options.defaultInputPlaceholder;
281+ this.inputPlaceholder = this.options.inputPlaceholder;
282 this.set("users", []);
283 this.set("disconnected", false);
284 this.others = [];
285@@ -412,11 +412,20 @@
286 if(e && e.which !== 13) {
287 return;
288 }
289- var mes = this.$("input").val();
290+ if(typeof this.mes == 'undefined'){
291+ var mes = this.$("input").val();
292+ }else{
293+ var mes = this.mes;
294+ }
295 if (! mes.trim()) {
296 return;
297 }
298 this.$("input").val("");
299+ var url=/((?:http:|ftp:|https:)\/\/[\w\-_]+(?:\.[\w\-_]+)+(?:[\w\-\.,@?^=%&:/~\+#]*[\w\-\@?^=%&/~\+#])?)/gi;
300+ if (mes.match(url))
301+ mes = mes.replace(url, function(link) {
302+ return '<a style="color:blue; text-decoration:underline;" href="'+ link +'">'+ link +'</a>';
303+ });
304 this.send_message(mes);
305 },
306 send_message: function(message, technical) {
307@@ -446,8 +455,17 @@
308 return new Array(size - str.length + 1).join('0') + str;
309 };
310 date = "" + zpad(date.getHours(), 2) + ":" + zpad(date.getMinutes(), 2);
311+<<<<<<< TREE
312 var to_show = _.map(items, im_common.escape_keep_url);
313 this.last_bubble = $(openerp.qweb.render("im_common.conversation_bubble", {"items": to_show, "user": user, "time": date}));
314+=======
315+
316+ this.last_bubble = $(openerp.qweb.render("im_common.conversation_bubble",{"user": user, "time": date}));
317+ var self = this;
318+ _.each(items, function(item){
319+ self.last_bubble.find('.oe_im_chatview_bubble_list').append("<div class='oe_im_chatview_bubble_item'>" + item + "</div>");
320+ });
321+>>>>>>> MERGE-SOURCE
322 $(this.$(".oe_im_chatview_content").children()[0]).append(this.last_bubble);
323 this._go_bottom();
324 },
325
326=== modified file 'im/static/src/xml/im_common.xml'
327--- im/static/src/xml/im_common.xml 2013-09-03 13:59:40 +0000
328+++ im/static/src/xml/im_common.xml 2013-09-05 08:44:12 +0000
329@@ -32,9 +32,12 @@
330 </div>
331 <div class="oe_im_chatview_from"><t t-esc="user.get('name')"/></div>
332 <div class="oe_im_chatview_bubble_list">
333+<<<<<<< TREE
334 <t t-foreach="items" t-as="item">
335 <div class="oe_im_chatview_bubble_item"><t t-raw="item"/></div>
336 </t>
337+=======
338+>>>>>>> MERGE-SOURCE
339 </div>
340 <div class="oe_im_chatview_time"><t t-esc="time"/></div>
341 </div>
342
343=== modified file 'im_livechat/im_livechat.py'
344--- im_livechat/im_livechat.py 2013-09-02 17:29:23 +0000
345+++ im_livechat/im_livechat.py 2013-09-05 08:44:12 +0000
346@@ -24,6 +24,8 @@
347 import json
348 import random
349 import jinja2
350+import datetime
351+from openerp.tools.misc import DEFAULT_SERVER_DATETIME_FORMAT
352 from openerp.osv import osv, fields
353 from openerp import tools
354 import openerp.addons.web.http as http
355@@ -212,3 +214,21 @@
356 _columns = {
357 'channel_id': fields.many2one("im.user", "Channel"),
358 }
359+
360+class im_feedback(osv.osv):
361+ _name = "im.feedback"
362+
363+ _columns = {
364+ 'session_id': fields.many2one("im.session", string="Session", ondelete='cascade'),
365+ 'feedback': fields.selection([('10','Good'),('5','Ok'),('1','Bad')], 'Feedback', help='Feedback from user'),
366+ 'reason': fields.text('Reason')
367+ }
368+
369+ def post(self, cr, uid, to_session_id, feedback=None, reason=None, context=None):
370+ last_session = self.search(cr, openerp.SUPERUSER_ID, [('session_id', '=', to_session_id),('feedback', '!=', None)])
371+ if reason == None and not last_session:
372+ self.create(cr, openerp.SUPERUSER_ID, {'session_id': to_session_id, 'feedback': feedback}, context=context)
373+ else:
374+ if last_session:
375+ self.write(cr, openerp.SUPERUSER_ID, last_session[0], {'feedback': feedback, 'reason': reason});
376+
377\ No newline at end of file
378
379=== added directory 'im_livechat/static/ext/static/css'
380=== added file 'im_livechat/static/ext/static/css/livesupport.css'
381--- im_livechat/static/ext/static/css/livesupport.css 1970-01-01 00:00:00 +0000
382+++ im_livechat/static/ext/static/css/livesupport.css 2013-09-05 08:44:12 +0000
383@@ -0,0 +1,54 @@
384+/* feedback */
385+
386+.oe_im_feedback_notify {
387+ margin-top: 80px;
388+ color: #FFFFFF;
389+}
390+.oe_im_feedback_notify a{
391+ cursor: pointer;
392+ text-decoration: underline;
393+ margin-left:15px;
394+}
395+.oe_im_feedback {
396+ margin-left: 35px;
397+ margin-top: 15px;
398+}
399+.oe_im_feedback a {
400+ margin-left: 10px;
401+ cursor: pointer;
402+}
403+
404+/* feedback reason*/
405+
406+.oe_im_feedback_reason_lbl {
407+ margin-top: 100px;
408+ color: #FFFFFF;
409+ width: 100%;
410+ font-size: 9pt;
411+ padding-left: 10px;
412+}
413+.oe_im_feedback_reason_txt {
414+ padding: 30px;
415+}
416+.oe_im_feedback_reason_txt textarea {
417+ width: 180px;
418+ height: 55px;
419+}
420+.oe_im_feedback_error_msg {
421+ color: #DD0000;
422+ visibility: hidden;
423+}
424+.oe_im_feedback_reason_btn {
425+ padding-left: 65px;
426+ padding-bottom: 50px;
427+}
428+ /* conversations */
429+.oe_im_chatview_close_inner {
430+ margin-top: -19px;
431+ margin-right: 5px;
432+}
433+.oe_im_chatview_close_inner button {
434+ float: right;
435+ border: 0;
436+ background: transparent;
437+}
438
439=== modified file 'im_livechat/static/ext/static/js/livechat.xml'
440--- im_livechat/static/ext/static/js/livechat.xml 2013-08-19 14:21:39 +0000
441+++ im_livechat/static/ext/static/js/livechat.xml 2013-09-05 08:44:12 +0000
442@@ -1,7 +1,60 @@
443 <?xml version="1.0" encoding="UTF-8"?>
444
445 <templates>
446-<t t-name="chatButton">
447- <t t-esc="widget.text"/>
448-</t>
449+
450+ <t t-name="im_common.conversation_livechat">
451+ <div class="oe_im_chatview_header">
452+ <span class="oe_im_chatview_users"/>
453+ <scan class="oe_im_chatview_nbr_messages" />
454+ </div>
455+ <div class="oe_im_chatview_close_inner">
456+ <button class="oe_im_chatview_close">×</button>
457+ </div>
458+ <div class="oe_im_chatview_disconnected">
459+ All users are offline. They will receive your messages on their next connection.
460+ </div>
461+ <div class="oe_im_chatview_content">
462+ <div id="bubble_list"></div>
463+ </div>
464+ <div class="oe_im_chatview_footer">
465+ <input class="oe_im_chatview_input" t-att-placeholder="widget.inputPlaceholder" />
466+ </div>
467+ </t>
468+
469+ <t t-name="conversation_feedback">
470+ <div id="feedback">
471+ <div class="oe_im_feedback_notify">
472+ Please take a second to rate my reply...
473+ </div>
474+ <div class="oe_im_feedback">
475+ <a id="feed" value="10" name="good" title="It was Good."><img src='/im_livechat/static/src/img/good.png'/></a>
476+ <a id="feed" value="5" name="ok" title="It was OK."><img src='/im_livechat/static/src/img/ok.png'/></a>
477+ <a id="feed" value="1" name="bad" title="It was bad."><img src='/im_livechat/static/src/img/bad.png'/></a>
478+ </div>
479+ <div class="oe_im_feedback_notify">
480+ <a id="back_to_chat">or back to chat</a>
481+ </div>
482+ </div>
483+ </t>
484+
485+
486+ <t t-name="feedback_reason">
487+ <div id="feedback_reason">
488+ <div class="oe_im_feedback_reason_lbl">
489+ Please give me reason for your feedback...
490+ </div>
491+ <div class="oe_im_feedback_reason_txt">
492+ <textarea id="reason"></textarea>
493+ <div class="oe_im_feedback_error_msg">*Please fill the reason details</div>
494+ </div>
495+ <div class="oe_im_feedback_reason_btn">
496+ <input type="button" value="Send" id="reason_submit" />
497+ <input type="button" value="Cancel" id="reason_submit" />
498+ </div>
499+ </div>
500+ </t>
501+
502+ <t t-name="chatButton">
503+ <t t-esc="widget.text"/>
504+ </t>
505 </templates>
506\ No newline at end of file
507
508=== modified file 'im_livechat/static/ext/static/js/livesupport.js'
509--- im_livechat/static/ext/static/js/livesupport.js 2013-09-02 16:15:17 +0000
510+++ im_livechat/static/ext/static/js/livesupport.js 2013-09-05 08:44:12 +0000
511@@ -30,6 +30,7 @@
512 return im_common.connection.session_authenticate(db, login, password).then(function() {
513 var defs = [];
514 defs.push(add_css("/im/static/src/css/im_common.css"));
515+ defs.push(add_css("/im_livechat/static/ext/static/css/livesupport.css"));
516 defs.push(add_css("/im_livechat/static/ext/static/lib/jquery-achtung/src/ui.achtung.css"));
517 defs.push(im_common.connection.rpc('/web/proxy/load', {path: '/im_livechat/static/ext/static/js/livechat.xml'}).then(function(xml) {
518 openerp.qweb.add_template(xml);
519@@ -117,6 +118,138 @@
520 });
521 }
522 });
523-
524+
525+ im_common.Conversation.include({
526+ events: {
527+ "keydown input": "keydown",
528+ "click .oe_im_chatview_close": "click_close",
529+ "click #back_to_chat": "back_to_chat",
530+ "click a#feed": "feedback",
531+ "click .oe_im_chatview_header": "show_hide",
532+ "click #reason_submit": "submit_reason"
533+ },
534+ start: function() {
535+ var self = this;
536+ self.$().append(openerp.qweb.render("im_common.conversation_livechat", {widget: self}));
537+ this.$().hide();
538+
539+ var change_status = function() {
540+ var disconnected = _.every(this.get("users"), function(u) { return u.get("im_status") === false; });
541+ self.set("disconnected", disconnected);
542+ this.$(".oe_im_chatview_users").html(openerp.qweb.render("im_common.conversation.header",
543+ {widget: self, to_url: _.bind(im_common.connection.url, im_common.connection)}));
544+ };
545+ this.on("change:users", this, function(unused, ev) {
546+ _.each(ev.oldValue, function(user) {
547+ user.off("change:im_status", self, change_status);
548+ });
549+ _.each(ev.newValue, function(user) {
550+ user.on("change:im_status", self, change_status);
551+ });
552+ change_status.call(self);
553+ _.each(ev.oldValue, function(user) {
554+ if (! _.contains(ev.newValue, user)) {
555+ user.remove_watcher();
556+ }
557+ });
558+ _.each(ev.newValue, function(user) {
559+ if (! _.contains(ev.oldValue, user)) {
560+ user.add_watcher();
561+ }
562+ });
563+ });
564+ this.on("change:disconnected", this, function() {
565+ self.$().toggleClass("oe_im_chatview_disconnected_status", this.get("disconnected"));
566+ self._go_bottom();
567+ });
568+
569+ self.on("change:right_position", self, self.calc_pos);
570+ self.on("change:bottom_position", self, self.calc_pos);
571+ self.full_height = self.$().height();
572+ self.calc_pos();
573+ self.on("change:pending", self, _.bind(function() {
574+ if (self.get("pending") === 0) {
575+ self.$(".oe_im_chatview_nbr_messages").text("");
576+ } else {
577+ self.$(".oe_im_chatview_nbr_messages").text("(" + self.get("pending") + ")");
578+ }
579+ }, self));
580+
581+ return this.refresh_users().then(function() {
582+ self.$().show();
583+ });
584+ },
585+ click_close: function(e) {
586+ if (! this.shown)
587+ this.show_hide();
588+ $(this.$(".oe_im_chatview_close_inner")).hide();
589+ $(this.$(".oe_im_chatview_footer")).hide();
590+ $(this.$("#bubble_list")).hide();
591+ this.leave_chat = openerp.qweb.render("conversation_feedback");
592+ if ($(this.$("div#feedback")).length > 0){
593+ $(this.$(".oe_im_chatview_content #feedback")).replaceWith(this.leave_chat);
594+ }else{
595+ $(this.$(".oe_im_chatview_content")).append(this.leave_chat);
596+ }
597+ },
598+ back_to_chat: function(e) {
599+ $(this.$("#feedback")).hide();
600+ $(this.$(".oe_im_chatview_close_inner")).show();
601+ $(this.$(".oe_im_chatview_footer")).show();
602+ $(this.$("#bubble_list")).show();
603+ },
604+ feedback: function(e) {
605+ var self = this;
606+ var $el_anchor = $(e.currentTarget).attr('name');;
607+ var $el_anchor_rate = $(e.currentTarget).attr('value');
608+ var model = im_common.connection.model("im.feedback");
609+ // To Insert End-user Feedback to DB
610+ model.call("post", [this.session_id, $el_anchor_rate]);
611+ if($el_anchor == "good"){
612+ this.send_notification();
613+ } else {
614+ this.send_reason();
615+ }
616+ self.$el_anchor_rate = $el_anchor_rate;
617+ },
618+ send_reason: function(e){
619+ $(this.$(".oe_im_chatview_close")).hide();
620+ $(this.$(".oe_im_chatview_footer")).hide();
621+ $(this.$("#bubble_list")).hide();
622+ this.send_reason = openerp.qweb.render("feedback_reason");
623+ $(this.$(".oe_im_chatview_content")).replaceWith(this.send_reason);
624+ },
625+ submit_reason: function(e){
626+ var self = this;
627+ var $el_input = $(e.currentTarget);
628+ var feed_reason = $(this.$("#feedback_reason textarea")).val();
629+ if ($el_input.val() == "Send"){
630+ if(feed_reason){
631+ // To Insert End-user Feedback Reason to DB
632+ var sub_reason = _.bind(function(){
633+ var model = im_common.connection.model("im.feedback");
634+ return model.call("post", [this.session_id, self.$el_anchor_rate, $(this.$("#feedback_reason textarea")).val()]);
635+ }, this);
636+ }else{
637+ $('.oe_im_feedback_error_msg').css('visibility', 'visible');
638+ }
639+ sub_reason().then(function(){
640+ self.send_notification();
641+ });
642+ } else {
643+ this.send_notification();
644+ }
645+ },
646+ send_notification: function() {
647+ var self = this;
648+ var off_mes = _.bind(function() {
649+ var model = im_common.connection.model("im.message");
650+ return model.call("post", ["#offline", this.session_id], {uuid: this.c_manager.me.get("uuid"), context: {}});
651+ }, this);
652+ off_mes().then(function() {
653+ self.destroy();
654+ });
655+ },
656+ });
657 return livesupport;
658 });
659
660=== added file 'im_livechat/static/src/img/bad.png'
661Binary files im_livechat/static/src/img/bad.png 1970-01-01 00:00:00 +0000 and im_livechat/static/src/img/bad.png 2013-09-05 08:44:12 +0000 differ
662=== added file 'im_livechat/static/src/img/good.png'
663Binary files im_livechat/static/src/img/good.png 1970-01-01 00:00:00 +0000 and im_livechat/static/src/img/good.png 2013-09-05 08:44:12 +0000 differ
664=== added file 'im_livechat/static/src/img/ok.png'
665Binary files im_livechat/static/src/img/ok.png 1970-01-01 00:00:00 +0000 and im_livechat/static/src/img/ok.png 2013-09-05 08:44:12 +0000 differ
666=== modified file 'im_livechat/web_page.html'
667--- im_livechat/web_page.html 2013-03-15 11:21:53 +0000
668+++ im_livechat/web_page.html 2013-09-05 08:44:12 +0000
669@@ -41,7 +41,6 @@
670 margin-top: -150px;
671 color: white;
672 text-shadow: 0 1px 0 rgba(34, 52, 72, 0.2);
673- z-index: 10;
674 text-align: center;
675 }
676 .main h1 {

Subscribers

People subscribed via source and target branches

to all changes: