From eebacd38b9dffb36907e20cf29760ac35637c719 Mon Sep 17 00:00:00 2001 From: niv-openerp Date: Mon, 11 Feb 2013 14:47:23 +0100 Subject: [PATCH] even nicer bzr revid: nicolas.vanhoren@openerp.com-20130211134723-3fuvud3zfzqrhg17 --- addons/live_support/live_support.py | 5 ++- addons/live_support/loader.js | 1 + .../static/ext/static/js/livesupport.js | 6 +++- addons/live_support/web_page.html | 35 ++++++++++++++++--- 4 files changed, 41 insertions(+), 6 deletions(-) diff --git a/addons/live_support/live_support.py b/addons/live_support/live_support.py index f9ec6fc98b7..78c2b2b8a78 100644 --- a/addons/live_support/live_support.py +++ b/addons/live_support/live_support.py @@ -60,7 +60,9 @@ class ImportController(openerp.addons.web.http.Controller): req.session._login = "anonymous" req.session._password = "anonymous" script = req.session.model('live_support.channel').read(channel, ["script"])["script"] - return req.make_response(env.get_template("web_page.html").render({"script": script}), + info = req.session.model('live_support.channel').get_info_for_chat_src(channel) + info["script"] = script + return req.make_response(env.get_template("web_page.html").render(info), headers=[('Content-Type', "text/html")]) @openerp.addons.web.http.jsonrequest @@ -135,6 +137,7 @@ class live_support_channel(osv.osv): 'buttonText': chan.button_text, 'inputPlaceholder': chan.input_placeholder, 'defaultMessage': chan.default_message, + "channelName": chan.name, } def join(self, cr, uid, ids, context=None): diff --git a/addons/live_support/loader.js b/addons/live_support/loader.js index ac1f6a044e6..7d1062793d1 100644 --- a/addons/live_support/loader.js +++ b/addons/live_support/loader.js @@ -15,5 +15,6 @@ require.config({ buttonText: {{buttonText | json}}, inputPlaceholder: {{inputPlaceholder | json}}, defaultMessage: {{(defaultMessage or None) | json}}, + auto: window.oe_live_support_auto || false, }); }); diff --git a/addons/live_support/static/ext/static/js/livesupport.js b/addons/live_support/static/ext/static/js/livesupport.js index 8d17cfc6982..a9e30efeeb0 100644 --- a/addons/live_support/static/ext/static/js/livesupport.js +++ b/addons/live_support/static/ext/static/js/livesupport.js @@ -14,6 +14,7 @@ define(["nova", "jquery", "underscore", "oeclient", "require"], function(nova, $ buttonText: "Chat with one of our collaborators", inputPlaceholder: "How may I help you?", defaultMessage: null, + auto: false, }); defaultInputPlaceholder = options.inputPlaceholder; var templates_def = $.ajax({ @@ -37,7 +38,10 @@ define(["nova", "jquery", "underscore", "oeclient", "require"], function(nova, $ connection.connector.call("/live_support/available", {db: db, channel: channel}).then(function(activated) { if (! activated) return; - new livesupport.ChatButton(null, channel, options).appendTo($("body")); + var button = new livesupport.ChatButton(null, channel, options); + button.appendTo($("body")); + if (options.auto) + button.click(); }); }); }; diff --git a/addons/live_support/web_page.html b/addons/live_support/web_page.html index 6cf0739962f..58012fc1691 100644 --- a/addons/live_support/web_page.html +++ b/addons/live_support/web_page.html @@ -1,6 +1,9 @@ + {{script}}
- OpenERP Live Support +

OpenERP7.0

+
{{channelName}}
\ No newline at end of file