From c4735c677090ff107d0af4200a4d7009f8023904 Mon Sep 17 00:00:00 2001 From: Xavier Morel Date: Wed, 7 Sep 2011 16:31:10 +0200 Subject: [ADD] autogenerated json-rpc2 ID, in a multithreaded server many requests may reach the server simultanously leading to logs which are a pain to decipher bzr revid: xmo@openerp.com-20110907143110-ujmkir821alxjxoo --- addons/web/static/src/js/core.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'addons/web/static/src/js/core.js') diff --git a/addons/web/static/src/js/core.js b/addons/web/static/src/js/core.js index ae2c4d0d657..da2afae3680 100644 --- a/addons/web/static/src/js/core.js +++ b/addons/web/static/src/js/core.js @@ -375,7 +375,7 @@ openerp.web.Session = openerp.web.CallbackEnabled.extend( /** @lends openerp.web jsonrpc: "2.0", method: "call", params: params, - id:null + id: _.uniqueId('browser-client-') }).then(function () {deferred.resolve.apply(deferred, arguments);}, function(error) {deferred.reject(error, $.Event());}); return deferred.fail(function() { -- cgit v1.2.3 From f312876e947a1bf9eb0d85cbbb82d3a6bfb40a3a Mon Sep 17 00:00:00 2001 From: Fabien Meghazi Date: Thu, 8 Sep 2011 16:05:54 +0200 Subject: [IMP] Avoid browsers cache problem with autoloaded addons in debug mode (part 2) bzr revid: fme@openerp.com-20110908140554-h1ya4l9lctwk2hvm --- addons/web/static/src/js/core.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'addons/web/static/src/js/core.js') diff --git a/addons/web/static/src/js/core.js b/addons/web/static/src/js/core.js index da2afae3680..ecf65152e55 100644 --- a/addons/web/static/src/js/core.js +++ b/addons/web/static/src/js/core.js @@ -578,7 +578,7 @@ openerp.web.Session = openerp.web.CallbackEnabled.extend( /** @lends openerp.web do_load_css: function (files) { _.each(files, function (file) { $('head').append($('', { - 'href': file, + 'href': file + (this.debug ? '?debug=' + (new Date().getTime()) : ''), 'rel': 'stylesheet', 'type': 'text/css' })); @@ -590,7 +590,7 @@ openerp.web.Session = openerp.web.CallbackEnabled.extend( /** @lends openerp.web var file = files.shift(); var tag = document.createElement('script'); tag.type = 'text/javascript'; - tag.src = file; + tag.src = file + (this.debug ? '?debug=' + (new Date().getTime()) : ''); tag.onload = tag.onreadystatechange = function() { if ( (tag.readyState && tag.readyState != "loaded" && tag.readyState != "complete") || tag.onload_done ) return; -- cgit v1.2.3 From 6c7c08a62ff46c54c42efc558e36aa29132f2226 Mon Sep 17 00:00:00 2001 From: Fabien Meghazi Date: Mon, 12 Sep 2011 11:07:27 +0200 Subject: [ADD] Add debug url hack for qweb xhr templates bzr revid: fme@openerp.com-20110912090727-hv3bslofmcpj06ld --- addons/web/static/src/js/core.js | 1 + 1 file changed, 1 insertion(+) (limited to 'addons/web/static/src/js/core.js') diff --git a/addons/web/static/src/js/core.js b/addons/web/static/src/js/core.js index ecf65152e55..26a76ca94ff 100644 --- a/addons/web/static/src/js/core.js +++ b/addons/web/static/src/js/core.js @@ -4,6 +4,7 @@ openerp.web.core = function(openerp) { openerp.web.qweb = new QWeb2.Engine(); +openerp.web.qweb.debug = (window.location.search.indexOf('?debug') !== -1); /** * John Resig Class with factory improvement */ -- cgit v1.2.3 From 555f654d8318b812f8005768cbec16592d39d2d3 Mon Sep 17 00:00:00 2001 From: Fabien Meghazi Date: Mon, 12 Sep 2011 11:59:37 +0200 Subject: [ADD] Added openerp.web.Widget#on_inserted bzr revid: fme@openerp.com-20110912095937-iabmo7213rsqt8b8 --- addons/web/static/src/js/core.js | 2 ++ 1 file changed, 2 insertions(+) (limited to 'addons/web/static/src/js/core.js') diff --git a/addons/web/static/src/js/core.js b/addons/web/static/src/js/core.js index 26a76ca94ff..fe08e532bc7 100644 --- a/addons/web/static/src/js/core.js +++ b/addons/web/static/src/js/core.js @@ -861,8 +861,10 @@ openerp.web.Widget = openerp.web.SessionAware.extend({ if (target instanceof openerp.web.Widget) target = target.$element; insertion(target); + this.on_inserted(this.$element, this); return this.start(); }, + on_inserted: function(element, widget) {}, /** * Renders the widget using QWeb, `this.template` must be defined. * The context given to QWeb contains the "widget" key that references `this`. -- cgit v1.2.3 From ba4779e87d941e27d9747aef2d6b8c8363964fd6 Mon Sep 17 00:00:00 2001 From: Fabien Meghazi Date: Mon, 12 Sep 2011 12:08:19 +0200 Subject: [FIX] Corrected url debug for dynamically loaded stylesheets bzr revid: fme@openerp.com-20110912100819-w62t21ktvb9lwycb --- addons/web/static/src/js/core.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'addons/web/static/src/js/core.js') diff --git a/addons/web/static/src/js/core.js b/addons/web/static/src/js/core.js index fe08e532bc7..b5db38d338b 100644 --- a/addons/web/static/src/js/core.js +++ b/addons/web/static/src/js/core.js @@ -577,9 +577,10 @@ openerp.web.Session = openerp.web.CallbackEnabled.extend( /** @lends openerp.web }); }, do_load_css: function (files) { + var self = this; _.each(files, function (file) { $('head').append($('', { - 'href': file + (this.debug ? '?debug=' + (new Date().getTime()) : ''), + 'href': file + (self.debug ? '?debug=' + (new Date().getTime()) : ''), 'rel': 'stylesheet', 'type': 'text/css' })); -- cgit v1.2.3 From bd5ee5973f127811d8719747e5e8100e3fe6ddb8 Mon Sep 17 00:00:00 2001 From: Xavier Morel Date: Mon, 12 Sep 2011 12:35:03 +0200 Subject: [FIX] jsdoc v3 fixes: @constructs needs an explicit name, @lends is mandatory to not make free-floating methods (interpreted as globals) bzr revid: xmo@openerp.com-20110912103503-0gpou4t50i2stycp --- addons/web/static/src/js/core.js | 67 +++++++++++++++++++++++++++------------- 1 file changed, 46 insertions(+), 21 deletions(-) (limited to 'addons/web/static/src/js/core.js') diff --git a/addons/web/static/src/js/core.js b/addons/web/static/src/js/core.js index b5db38d338b..ce69be7f245 100644 --- a/addons/web/static/src/js/core.js +++ b/addons/web/static/src/js/core.js @@ -13,11 +13,17 @@ openerp.web.qweb.debug = (window.location.search.indexOf('?debug') !== -1); fnTest = /xyz/.test(function(){xyz;}) ? /\b_super\b/ : /.*/; // The web Class implementation (does nothing) /** + * Extended version of John Resig's Class pattern + * * @class */ openerp.web.Class = function(){}; - // Create a new Class that inherits from this class + /** + * Subclass an existing class + * + * @param {Object} prop class-level properties (class attributes and instance methods) to set on the new class + */ openerp.web.Class.extend = function(prop) { var _super = this.prototype; @@ -158,7 +164,7 @@ openerp.web.callback = function(obj, method) { * that does nothing and always return undefined). * * @param {Class} claz - * @param {dict} add Additional functions to override. + * @param {Object} add Additional functions to override. * @return {Class} */ openerp.web.generate_null_object_class = function(claz, add) { @@ -189,7 +195,7 @@ openerp.web.KeyNotFound = openerp.web.NotFound.extend( /** @lends openerp.web.Ke /** * Thrown when a key could not be found in a mapping * - * @constructs + * @constructs openerp.web.KeyNotFound * @extends openerp.web.NotFound * @param {String} key the key which could not be found */ @@ -205,7 +211,7 @@ openerp.web.ObjectNotFound = openerp.web.NotFound.extend( /** @lends openerp.web * Thrown when an object path does not designate a valid class or object * in the openerp hierarchy. * - * @constructs + * @constructs openerp.web.ObjectNotFound * @extends openerp.web.NotFound * @param {String} path the invalid object path */ @@ -229,7 +235,7 @@ openerp.web.Registry = openerp.web.Class.extend( /** @lends openerp.web.Registry * object pointed to (e.g. ``"openerp.web.Session"`` for an OpenERP * session object). * - * @constructs + * @constructs openerp.web.Registry * @param {Object} mapping a mapping of keys to object-paths */ init: function (mapping) { @@ -310,7 +316,11 @@ openerp.web.Registry = openerp.web.Class.extend( /** @lends openerp.web.Registry } }); -openerp.web.CallbackEnabled = openerp.web.Class.extend({ +openerp.web.CallbackEnabled = openerp.web.Class.extend(/** @lends openerp.web.CallbackEnabled# */{ + /** + * @constructs openerp.web.CallbackEnabled + * @extends openerp.web.Class + */ init: function() { // Transform on_* method into openerp.web.callbacks for (var name in this) { @@ -327,9 +337,11 @@ openerp.web.CallbackEnabled = openerp.web.Class.extend({ openerp.web.Session = openerp.web.CallbackEnabled.extend( /** @lends openerp.web.Session# */{ /** - * @constructs - * @param server - * @param port + * @constructs openerp.web.Session + * @extends openerp.web.CallbackEnabled + * + * @param {String} [server] JSON-RPC endpoint hostname + * @param {String} [port] JSON-RPC endpoint port */ init: function(server, port) { this._super(); @@ -710,13 +722,18 @@ openerp.web.Session = openerp.web.CallbackEnabled.extend( /** @lends openerp.web } }); -/** - * Utility class that any class is allowed to extend to easy common manipulations. - * - * It provides rpc calls, callback on all methods preceded by "on_" or "do_" and a - * logging facility. - */ -openerp.web.SessionAware = openerp.web.CallbackEnabled.extend({ +openerp.web.SessionAware = openerp.web.CallbackEnabled.extend(/** @lends openerp.web.SessionAware# */{ + /** + * Utility class that any class is allowed to extend to easy common manipulations. + * + * It provides rpc calls, callback on all methods preceded by "on_" or "do_" and a + * logging facility. + * + * @constructs openerp.web.SessionAware + * @extends openerp.web.CallbackEnabled + * + * @param {openerp.web.Session} session + */ init: function(session) { this._super(); this.session = session; @@ -768,7 +785,7 @@ openerp.web.SessionAware = openerp.web.CallbackEnabled.extend({ } }); -openerp.web.Widget = openerp.web.SessionAware.extend({ +openerp.web.Widget = openerp.web.SessionAware.extend(/** @lends openerp.web.Widget# */{ /** * The name of the QWeb template that will be used for rendering. Must be * redefined in subclasses or the default render() method can not be used. @@ -786,7 +803,9 @@ openerp.web.Widget = openerp.web.SessionAware.extend({ /** * Construct the widget and set its parent if a parent is given. * - * @constructs + * @constructs openerp.web.Widget + * @extends openerp.web.SessionAware + * * @param {openerp.web.Widget} parent Binds the current instance to the given Widget instance. * When that widget is destroyed by calling stop(), the current instance will be * destroyed too. Can be null. @@ -945,17 +964,23 @@ openerp.web.Widget = openerp.web.SessionAware.extend({ }); /** + * @class + * @extends openerp.web.Widget * @deprecated * For retro compatibility only, the only difference with is that render() uses - * directly `this` instead of context with a "widget" key. + * directly ``this`` instead of context with a ``widget`` key. */ -openerp.web.OldWidget = openerp.web.Widget.extend({ +openerp.web.OldWidget = openerp.web.Widget.extend(/** @lends openerp.web.OldWidget# */{ render: function (additional) { return openerp.web.qweb.render(this.template, _.extend(_.extend({}, this), additional || {})); } }); -openerp.web.TranslationDataBase = openerp.web.Class.extend({ +openerp.web.TranslationDataBase = openerp.web.Class.extend(/** @lends openerp.web.TranslationDataBase# */{ + /** + * @constructs openerp.web.TranslationDataBase + * @extends openerp.web.Class + */ init: function() { this.db = {}; this.parameters = {"direction": 'ltr', -- cgit v1.2.3 From d1be801b9103d749848d4ef06d979cf54aa18594 Mon Sep 17 00:00:00 2001 From: niv-openerp Date: Mon, 12 Sep 2011 15:56:03 +0200 Subject: [imp] removed a lot of useless notifications bzr revid: nicolas.vanhoren@openerp.com-20110912135603-fai75jzwgbyalnwz --- addons/web/static/src/js/core.js | 3 --- 1 file changed, 3 deletions(-) (limited to 'addons/web/static/src/js/core.js') diff --git a/addons/web/static/src/js/core.js b/addons/web/static/src/js/core.js index ce69be7f245..77b48820e83 100644 --- a/addons/web/static/src/js/core.js +++ b/addons/web/static/src/js/core.js @@ -777,9 +777,6 @@ openerp.web.SessionAware = openerp.web.CallbackEnabled.extend(/** @lends openerp if(body) { $('
').text(v).appendTo($('body'));
                 }
-                if(notify && this.notification) {
-                    this.notification.notify("Logging:",v);
-                }
             }
         }
     }
-- 
cgit v1.2.3