From e43790f7f2e04782f9d52851ec48edaadabcf5b6 Mon Sep 17 00:00:00 2001 From: niv-openerp Date: Wed, 28 Sep 2011 17:16:13 +0200 Subject: [PATCH] [imp] refactoring to improve the way the components are destroyed bzr revid: nicolas.vanhoren@openerp.com-20110928151613-8suxvi1rzn9t40gd --- addons/web/static/src/js/chrome.js | 3 ++- addons/web/static/src/js/data.js | 17 ++++++----------- addons/web/static/src/js/view_form.js | 6 +----- addons/web/static/src/js/views.js | 6 +++--- addons/web_calendar/static/src/js/calendar.js | 1 + addons/web_dashboard/static/src/js/dashboard.js | 2 +- addons/web_graph/__openerp__.py | 2 +- 7 files changed, 15 insertions(+), 22 deletions(-) diff --git a/addons/web/static/src/js/chrome.js b/addons/web/static/src/js/chrome.js index 86b48b1be2d..e6a850cd799 100644 --- a/addons/web/static/src/js/chrome.js +++ b/addons/web/static/src/js/chrome.js @@ -129,6 +129,7 @@ openerp.web.Dialog = openerp.web.OldWidget.extend(/** @lends openerp.web.Dialog# // Destroy widget this.close(); this.$dialog.dialog('destroy'); + this._super(); } }); @@ -253,7 +254,7 @@ openerp.web.Database = openerp.web.Widget.extend(/** @lends openerp.web.Database .removeClass("database_block") .end() .empty(); - + this._super(); }, /** * Converts a .serializeArray() result into a dict. Does not bother folding diff --git a/addons/web/static/src/js/data.js b/addons/web/static/src/js/data.js index 00281628e75..1652ee62cb9 100644 --- a/addons/web/static/src/js/data.js +++ b/addons/web/static/src/js/data.js @@ -233,6 +233,7 @@ openerp.web.StaticDataGroup = openerp.web.GrouplessDataGroup.extend( /** @lends }); openerp.web.DataSet = openerp.web.Widget.extend( /** @lends openerp.web.DataSet# */{ + identifier_prefix: "dataset", /** * DateaManagement interface between views and the collection of selected * OpenERP records (represents the view's state?) @@ -242,16 +243,12 @@ openerp.web.DataSet = openerp.web.Widget.extend( /** @lends openerp.web.DataSet * * @param {String} model the OpenERP model this dataset will manage */ - init: function(source_controller, model, context) { - // we don't want the dataset to be a child of anything! - this._super(null); - this.session = source_controller ? source_controller.session : undefined; + init: function(parent, model, context) { + this._super(parent); this.model = model; this.context = context || {}; this.index = null; }, - start: function() { - }, previous: function () { this.index -= 1; if (this.index < 0) { @@ -549,13 +546,11 @@ openerp.web.DataSetSearch = openerp.web.DataSet.extend(/** @lends openerp.web.D sort: this.sort(), offset: offset, limit: options.limit || false - }, function (result) { + }).pipe(function (result) { self.ids = result.ids; self.offset = offset; - if (callback) { - callback(result.records); - } - }); + return result.records; + }).then(callback); }, get_domain: function (other_domain) { if (other_domain) { diff --git a/addons/web/static/src/js/view_form.js b/addons/web/static/src/js/view_form.js index 4d761ab6585..e21d0541a81 100644 --- a/addons/web/static/src/js/view_form.js +++ b/addons/web/static/src/js/view_form.js @@ -72,6 +72,7 @@ openerp.web.FormView = openerp.web.View.extend( /** @lends openerp.web.FormView# _.each(this.widgets, function(w) { w.stop(); }); + this._super(); }, on_loaded: function(data) { var self = this; @@ -656,11 +657,6 @@ openerp.web.form.Widget = openerp.web.Widget.extend(/** @lends openerp.web.form. start: function() { this.$element = $('#' + this.element_id); }, - stop: function() { - if (this.$element) { - this.$element.remove(); - } - }, process_modifiers: function() { var compute_domain = openerp.web.form.compute_domain; for (var a in this.modifiers) { diff --git a/addons/web/static/src/js/views.js b/addons/web/static/src/js/views.js index 93265fdc5f1..42e1a5b8e0d 100644 --- a/addons/web/static/src/js/views.js +++ b/addons/web/static/src/js/views.js @@ -163,7 +163,7 @@ db.web.ViewManager = db.web.Widget.extend(/** @lends db.web.ViewManager# */{ */ init: function(parent, dataset, views) { this._super(parent); - this.model = dataset.model; + this.model = dataset ? dataset.model : undefined; this.dataset = dataset; this.searchview = null; this.active_view = null; @@ -184,7 +184,6 @@ db.web.ViewManager = db.web.Widget.extend(/** @lends db.web.ViewManager# */{ start: function() { this._super(); var self = this; - this.dataset.start(); this.$element.find('.oe_vm_switch button').click(function() { self.on_mode_switch($(this).data('view-type')); }); @@ -332,6 +331,7 @@ db.web.ViewManagerAction = db.web.ViewManager.extend(/** @lends oepnerp.web.View // dataset initialization will take the session from ``this``, so if we // do not have it yet (and we don't, because we've not called our own // ``_super()``) rpc requests will blow up. + this._super(parent, null, action.views); this.session = parent.session; this.action = action; var dataset = new db.web.DataSetSearch(this, action.res_model, action.context, action.domain); @@ -339,7 +339,7 @@ db.web.ViewManagerAction = db.web.ViewManager.extend(/** @lends oepnerp.web.View dataset.ids.push(action.res_id); dataset.index = 0; } - this._super(parent, dataset, action.views); + this.dataset = dataset; this.flags = this.action.flags || {}; if (action.res_model == 'board.board' && action.views.length == 1 && action.views) { // Not elegant but allows to avoid form chrome (pager, save/new diff --git a/addons/web_calendar/static/src/js/calendar.js b/addons/web_calendar/static/src/js/calendar.js index e590280b933..5de601e0921 100644 --- a/addons/web_calendar/static/src/js/calendar.js +++ b/addons/web_calendar/static/src/js/calendar.js @@ -35,6 +35,7 @@ openerp.web_calendar.CalendarView = openerp.web.View.extend({ }, stop: function() { scheduler.clearAll(); + this._super(); }, on_loaded: function(data) { this.fields_view = data; diff --git a/addons/web_dashboard/static/src/js/dashboard.js b/addons/web_dashboard/static/src/js/dashboard.js index 008d03d1548..4672492821d 100644 --- a/addons/web_dashboard/static/src/js/dashboard.js +++ b/addons/web_dashboard/static/src/js/dashboard.js @@ -301,7 +301,7 @@ openerp.web_dashboard.ConfigOverview = openerp.web.View.extend({ .then(this.on_records_loaded); }, on_records_loaded: function (read_response, progress_response) { - var records = read_response[0].records, + var records = read_response, progress = progress_response[0]; var grouped_todos = _(records).chain() diff --git a/addons/web_graph/__openerp__.py b/addons/web_graph/__openerp__.py index 4a1c4a6576f..03839744480 100644 --- a/addons/web_graph/__openerp__.py +++ b/addons/web_graph/__openerp__.py @@ -3,7 +3,7 @@ "version": "2.0", "depends": ['web'], "js": [ - "static/lib/dhtmlxGraph/codebase/dhtmlxchart.js", + "static/lib/dhtmlxGraph/codebase/dhtmlxchart_debug.js", "static/src/js/graph.js"], "css": ["static/lib/dhtmlxGraph/codebase/dhtmlxchart.css"], "active": True