diff options
| author | Yogesh (OpenERP) <ysa@tinyerp.com> | 2011-11-09 10:31:42 +0530 |
|---|---|---|
| committer | Yogesh (OpenERP) <ysa@tinyerp.com> | 2011-11-09 10:31:42 +0530 |
| commit | eed4414d6db930bebca5d0c690cc70717465eb01 (patch) | |
| tree | af6b162016d13b0b32c1b2aeee579cc757067ece /addons/web/static/src | |
| parent | 5c073850ee307fbbaa2645ba974626280ff1a5a6 (diff) | |
| parent | 66f71407f2c838dd2d88c90ebd0b8d5fe16f7c5d (diff) | |
[MERGE] Merge with trunk upto revision no 1417.
bzr revid: ysa@tinyerp.com-20111109050142-0ugi5ufvhq73ojp9
Diffstat (limited to 'addons/web/static/src')
| -rw-r--r-- | addons/web/static/src/css/base.css | 3 | ||||
| -rw-r--r-- | addons/web/static/src/js/chrome.js | 14 | ||||
| -rw-r--r-- | addons/web/static/src/js/core.js | 65 | ||||
| -rw-r--r-- | addons/web/static/src/js/data.js | 12 | ||||
| -rw-r--r-- | addons/web/static/src/js/search.js | 7 |
5 files changed, 44 insertions, 57 deletions
diff --git a/addons/web/static/src/css/base.css b/addons/web/static/src/css/base.css index 3430dfe196a..94e36d60419 100644 --- a/addons/web/static/src/css/base.css +++ b/addons/web/static/src/css/base.css @@ -1088,7 +1088,7 @@ label.error { list-style: none; } .openerp .oe-view-manager-logs li:before { - content: '→ '; + content: '\2192 '; } .openerp .oe-view-manager-logs a { text-decoration: none; @@ -1448,3 +1448,4 @@ ul.oe-arrow-list li.oe-arrow-list-selected .oe-arrow-list-after { .openerp .oe_view_editor_tree_grid a { display: block; } + diff --git a/addons/web/static/src/js/chrome.js b/addons/web/static/src/js/chrome.js index 22c2b0ba2ea..d85942feead 100644 --- a/addons/web/static/src/js/chrome.js +++ b/addons/web/static/src/js/chrome.js @@ -136,10 +136,10 @@ openerp.web.Dialog = openerp.web.OldWidget.extend(/** @lends openerp.web.Dialog# } }); -openerp.web.CrashManager = openerp.web.SessionAware.extend({ - init: function(parent) { - this._super((parent || {}).session); - this.session.on_rpc_error.add(this.on_rpc_error); +openerp.web.CrashManager = openerp.web.CallbackEnabled.extend({ + init: function() { + this._super(); + openerp.connection.on_rpc_error.add(this.on_rpc_error); }, on_rpc_error: function(error) { this.error = error; @@ -959,17 +959,15 @@ openerp.web.WebClient = openerp.web.Widget.extend(/** @lends openerp.web.WebClie this._super(null, element_id); openerp.webclient = this; - QWeb.add_template("/web/static/src/xml/base.xml"); var params = {}; if(jQuery.param != undefined && jQuery.deparam(jQuery.param.querystring()).kitten != undefined) { this.$element.addClass("kitten-mode-activated"); } this.$element.html(QWeb.render("Interface", params)); - this.notification = new openerp.web.Notification(); - this.session = new openerp.web.Session(); + this.notification = new openerp.web.Notification(this); this.loading = new openerp.web.Loading(this,"oe_loading"); - this.crashmanager = new openerp.web.CrashManager(this); + this.crashmanager = new openerp.web.CrashManager(); this.header = new openerp.web.Header(this); this.login = new openerp.web.Login(this); diff --git a/addons/web/static/src/js/core.js b/addons/web/static/src/js/core.js index 9563abea49a..7b402cae7fd 100644 --- a/addons/web/static/src/js/core.js +++ b/addons/web/static/src/js/core.js @@ -237,8 +237,8 @@ openerp.web.Registry = openerp.web.Class.extend( /** @lends openerp.web.Registry * registry was created. * * An object path is simply a dotted name from the openerp root to the - * object pointed to (e.g. ``"openerp.web.Session"`` for an OpenERP - * session object). + * object pointed to (e.g. ``"openerp.web.Connection"`` for an OpenERP + * connection object). * * @constructs openerp.web.Registry * @param {Object} mapping a mapping of keys to object-paths @@ -338,9 +338,9 @@ openerp.web.CallbackEnabled = openerp.web.Class.extend(/** @lends openerp.web.Ca } }); -openerp.web.Session = openerp.web.CallbackEnabled.extend( /** @lends openerp.web.Session# */{ +openerp.web.Connection = openerp.web.CallbackEnabled.extend( /** @lends openerp.web.Connection# */{ /** - * @constructs openerp.web.Session + * @constructs openerp.web.Connection * @extends openerp.web.CallbackEnabled * * @param {String} [server] JSON-RPC endpoint hostname @@ -364,7 +364,9 @@ openerp.web.Session = openerp.web.CallbackEnabled.extend( /** @lends openerp.web // TODO: session should have an optional name indicating that they'll // be saved to (and revived from) cookies this.name = 'session'; + this.do_load_qweb(['/web/webclient/qweb']); }, + start: function() { this.session_restore(); }, @@ -487,9 +489,11 @@ openerp.web.Session = openerp.web.CallbackEnabled.extend( /** @lends openerp.web self.user_context = result.context; self.db = result.db; self.session_save(); + self.on_session_valid(); return true; }).then(success_callback); }, + login: function() { this.session_login.apply(this, arguments); }, /** * Reloads uid and session_id from local storage, if they exist */ @@ -577,6 +581,7 @@ openerp.web.Session = openerp.web.CallbackEnabled.extend( /** @lends openerp.web self.rpc('/web/webclient/jslist', {"mods": modules}, function(files) { self.do_load_js(file_list.concat(files)); }); + self.rpc('/web/webclient/qweblist', {"mods": modules}, self.do_load_qweb); openerp._modules_loaded = true; }); }); @@ -610,6 +615,12 @@ openerp.web.Session = openerp.web.CallbackEnabled.extend( /** @lends openerp.web this.on_modules_loaded(); } }, + do_load_qweb: function(files) { + var self = this; + _.each(files, function(file) { + openerp.web.qweb.add_template(file); + }); + }, on_modules_loaded: function() { for(var j=0; j<this.module_list.length; j++) { var mod = this.module_list[j]; @@ -716,36 +727,6 @@ openerp.web.Session = openerp.web.CallbackEnabled.extend( /** @lends openerp.web } }); -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; - }, - /** - * Performs a JSON-RPC call - * - * @param {String} url endpoint url - * @param {Object} data RPC parameters - * @param {Function} success RPC call success callback - * @param {Function} error RPC call error callback - * @returns {jQuery.Deferred} deferred object for the RPC call - */ - rpc: function(url, data, success, error) { - return this.session.rpc(url, data, success, error); - } -}); - /** * Base class for all visual components. Provides a lot of functionalities helpful * for the management of a part of the DOM. @@ -756,8 +737,6 @@ openerp.web.SessionAware = openerp.web.CallbackEnabled.extend(/** @lends openerp * destroyed too). * - Insertion in DOM. * - * Widget also extends SessionAware for ease of use. - * * Guide to create implementations of the Widget class: * ============================================== * @@ -798,7 +777,7 @@ openerp.web.SessionAware = openerp.web.CallbackEnabled.extend(/** @lends openerp * * That will kill the widget in a clean way and erase its content from the dom. */ -openerp.web.Widget = openerp.web.SessionAware.extend(/** @lends openerp.web.Widget# */{ +openerp.web.Widget = openerp.web.CallbackEnabled.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. @@ -817,7 +796,7 @@ openerp.web.Widget = openerp.web.SessionAware.extend(/** @lends openerp.web.Widg * Construct the widget and set its parent if a parent is given. * * @constructs openerp.web.Widget - * @extends openerp.web.SessionAware + * @extends openerp.web.CallbackEnabled * * @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 @@ -828,7 +807,8 @@ openerp.web.Widget = openerp.web.SessionAware.extend(/** @lends openerp.web.Widg * for new components this argument should not be provided any more. */ init: function(parent, /** @deprecated */ element_id) { - this._super((parent || {}).session); + this._super(); + this.session = openerp.connection; // if given an element_id, try to get the associated DOM element and save // a reference in this.$element. Else just generate a unique identifier. this.element_id = element_id; @@ -967,7 +947,7 @@ openerp.web.Widget = openerp.web.SessionAware.extend(/** @lends openerp.web.Widg rpc: function(url, data, success, error) { var def = $.Deferred().then(success, error); var self = this; - this._super(url, data). then(function() { + openerp.connection.rpc(url, data). then(function() { if (!self.widget_is_stopped) def.resolve.apply(def, arguments); }, function() { @@ -1047,6 +1027,8 @@ if ($.blockUI) { $.blockUI.defaults.baseZ = 1100; $.blockUI.defaults.message = '<img src="/web/static/src/img/throbber2.gif">'; } + +/** Configure default qweb */ openerp.web._t = new openerp.web.TranslationDataBase().build_translation_function(); openerp.web.qweb = new QWeb2.Engine(); openerp.web.qweb.debug = (window.location.search.indexOf('?debug') !== -1); @@ -1067,6 +1049,9 @@ openerp.web.qweb.format_text_node = function(s) { return tr === ts ? s : tr; } +/** Setup default connection */ +openerp.connection = new openerp.web.Connection(); + }; // vim:et fdc=0 fdl=0 foldnestmax=3 fdm=syntax: diff --git a/addons/web/static/src/js/data.js b/addons/web/static/src/js/data.js index 069506586ad..f4509c82a81 100644 --- a/addons/web/static/src/js/data.js +++ b/addons/web/static/src/js/data.js @@ -32,7 +32,7 @@ openerp.web.DataGroup = openerp.web.Widget.extend( /** @lends openerp.web.DataG * @constructs openerp.web.DataGroup * @extends openerp.web.Widget * - * @param {openerp.web.Session} session Current OpenERP session + * @param {openerp.web.Widget} parent widget * @param {String} model name of the model managed by this DataGroup * @param {Array} domain search domain for this DataGroup * @param {Object} context context of the DataGroup's searches @@ -785,11 +785,15 @@ openerp.web.ProxyDataSet = openerp.web.DataSetSearch.extend({ on_unlink: function(ids) {} }); -openerp.web.Model = openerp.web.SessionAware.extend({ - init: function(session, model_name) { - this._super(session); +openerp.web.Model = openerp.web.CallbackEnabled.extend({ + init: function(_, model_name) { + this._super(); this.model_name = model_name; }, + rpc: function() { + var c = openerp.connection; + return c.rpc.apply(c, arguments); + }, get_func: function(method_name) { var self = this; return function() { diff --git a/addons/web/static/src/js/search.js b/addons/web/static/src/js/search.js index b2402cf95fa..18e035a40b8 100644 --- a/addons/web/static/src/js/search.js +++ b/addons/web/static/src/js/search.js @@ -433,6 +433,7 @@ openerp.web.search.Widget = openerp.web.Widget.extend( /** @lends openerp.web.se * @param view the ancestor view of this widget */ init: function (view) { + this._super(view); this.view = view; }, /** @@ -473,10 +474,8 @@ openerp.web.search.Widget = openerp.web.Widget.extend( /** @lends openerp.web.se this._super(); }, render: function (defaults) { - return QWeb.render( - this.template, _.extend(this, { - defaults: defaults - })); + // FIXME + return this._super(_.extend(this, {defaults: defaults})); } }); openerp.web.search.add_expand_listener = function($root) { |
