diff --git a/addons/base/static/src/base.html b/addons/base/static/src/base.html index 93e95d32534..74ce3c267b6 100644 --- a/addons/base/static/src/base.html +++ b/addons/base/static/src/base.html @@ -24,10 +24,10 @@ + - diff --git a/addons/base/static/src/js/form.js b/addons/base/static/src/js/form.js index fbe9e054365..45db4d0f9ec 100644 --- a/addons/base/static/src/js/form.js +++ b/addons/base/static/src/js/form.js @@ -2,7 +2,7 @@ openerp.base.form = function (openerp) { openerp.base.views.add('form', 'openerp.base.FormView'); -openerp.base.FormView = openerp.base.Controller.extend( /** @lends openerp.base.FormView# */{ +openerp.base.FormView = openerp.base.View.extend( /** @lends openerp.base.FormView# */{ /** * Indicates that this view is not searchable, and thus that no search * view should be displayed (if there is one active). @@ -365,7 +365,8 @@ openerp.base.form.compute_domain = function(expr, fields) { } } return _.indexOf(stack, false) == -1; -}, +} + openerp.base.form.Widget = openerp.base.Controller.extend({ init: function(view, node) { this.view = view; @@ -532,7 +533,7 @@ openerp.base.form.WidgetButton = openerp.base.form.Widget.extend({ on_confirmed: function() { var self = this; - this.execute_action( + this.view.execute_action( this.node.attrs, this.view.dataset, this.session.action_manager, this.view.datarecord.id, function (result) { self.log("Button returned", result); @@ -540,9 +541,6 @@ openerp.base.form.WidgetButton = openerp.base.form.Widget.extend({ }); } }); -// let WidgetButton execute actions -_.extend(openerp.base.form.WidgetButton.prototype, - openerp.base.ActionExecutor); openerp.base.form.WidgetLabel = openerp.base.form.Widget.extend({ init: function(view, node) { diff --git a/addons/base/static/src/js/list.js b/addons/base/static/src/js/list.js index 775eaa19df3..b8f9b498578 100644 --- a/addons/base/static/src/js/list.js +++ b/addons/base/static/src/js/list.js @@ -1,7 +1,6 @@ openerp.base.list = function (openerp) { openerp.base.views.add('list', 'openerp.base.ListView'); -openerp.base.ListView = openerp.base.Controller.extend( - /** @lends openerp.base.ListView# */ { +openerp.base.ListView = openerp.base.View.extend( /** @lends openerp.base.ListView# */ { defaults: { // records can be selected one by one 'selectable': true, @@ -361,10 +360,7 @@ openerp.base.ListView = openerp.base.Controller.extend( } // TODO: implement reorder (drag and drop rows) }); -_.extend(openerp.base.ListView.prototype, openerp.base.ActionExecutor); - -openerp.base.ListView.List = Class.extend( - /** @lends openerp.base.ListView.List# */{ +openerp.base.ListView.List = Class.extend( /** @lends openerp.base.ListView.List# */{ /** * List display for the ListView, handles basic DOM events and transforms * them in the relevant higher-level events, to which the list view (or @@ -476,8 +472,7 @@ openerp.base.ListView.List = Class.extend( // drag and drop // editable? }); -openerp.base.ListView.Groups = Class.extend( - /** @lends openerp.base.ListView.Groups# */{ +openerp.base.ListView.Groups = Class.extend( /** @lends openerp.base.ListView.Groups# */{ /** * Grouped display for the ListView. Handles basic DOM events and interacts * with the :js:class:`~openerp.base.DataGroup` bound to it. @@ -525,9 +520,6 @@ openerp.base.ListView.Groups = Class.extend( return this.make_level(this.datagroup); } }); -openerp.base.TreeView = openerp.base.Controller.extend({ -}); - }; // vim:et fdc=0 fdl=0 foldnestmax=3 fdm=syntax: diff --git a/addons/base/static/src/js/views.js b/addons/base/static/src/js/views.js index 1dd89e0d1d8..dee28dfafa9 100644 --- a/addons/base/static/src/js/views.js +++ b/addons/base/static/src/js/views.js @@ -70,63 +70,6 @@ openerp.base.ActionManager = openerp.base.Controller.extend({ } }); -/** - * Mixin for action-executing objects, provides handling of OpenERP actions to - * all clients. - * - * Mix into existing classes via ``_.extend`` of the class's prototype. - * - * @class - */ -openerp.base.ActionExecutor = -/** - * @lends openerp.base.ActionExecutor# - */ { - /** - * Fetches and executes the action identified by ``action_data``. - * - * @param {Object} action_data the action descriptor data - * @param {String} action_data.name the action name, used to uniquely identify the action to find and execute it - * @param {String} [action_data.special=null] special action handlers (currently: only ``'cancel'``) - * @param {String} [action_data.type='workflow'] the action type, if present, one of ``'object'``, ``'action'`` or ``'workflow'`` - * @param {Object} [action_data.context=null] additional action context, to add to the current context - * @param {openerp.base.DataSet} dataset a dataset object used to communicate with the server - * @param {openerp.base.ActionManager} action_manager object able to actually execute the action, if any is fetched - * @param {Number} [record_id] the identifier of the object on which the action is to be applied - * @param {Function} on_no_action callback to execute if the action does not generate any result (no new action) - */ - execute_action: function (action_data, dataset, action_manager, record_id, on_no_action) { - var handler = function (r) { - if (r.result && r.result.constructor == Object) { - action_manager.do_action(r.result); - } else { - on_no_action(r.result); - } - }; - - if (action_data.special) { - handler({ - result : { type: 'ir.actions.act_window_close' } - }); - } else { - var context = _.extend({}, dataset.context, action_data.context || {}); - switch(action_data.type) { - case 'object': - return dataset.call(action_data.name, [record_id], [context], handler); - case 'action': - return this.rpc('/base/action/load', { action_id: parseInt(action_data.name, 10) }, handler); - default: - return dataset.exec_workflow(record_id, action_data.name, handler); - } - } - } -}; - -/** - * Registry for all the main views - */ -openerp.base.views = new openerp.base.Registry(); - openerp.base.ViewManager = openerp.base.Controller.extend({ init: function(session, element_id, dataset, views) { this._super(session, element_id); @@ -367,64 +310,51 @@ openerp.base.Sidebar = openerp.base.BaseWidget.extend({ } }); -openerp.base.views.add('calendar', 'openerp.base.CalendarView'); -openerp.base.CalendarView = openerp.base.Controller.extend({ - start: function () { - this._super(); - this.$element.append('Calendar view'); - }, - do_show: function () { - this.$element.show(); - }, - do_hide: function () { - this.$element.hide(); +openerp.base.View = openerp.base.Controller.extend({ + /** + * Fetches and executes the action identified by ``action_data``. + * + * @param {Object} action_data the action descriptor data + * @param {String} action_data.name the action name, used to uniquely identify the action to find and execute it + * @param {String} [action_data.special=null] special action handlers (currently: only ``'cancel'``) + * @param {String} [action_data.type='workflow'] the action type, if present, one of ``'object'``, ``'action'`` or ``'workflow'`` + * @param {Object} [action_data.context=null] additional action context, to add to the current context + * @param {openerp.base.DataSet} dataset a dataset object used to communicate with the server + * @param {openerp.base.ActionManager} action_manager object able to actually execute the action, if any is fetched + * @param {Number} [record_id] the identifier of the object on which the action is to be applied + * @param {Function} on_no_action callback to execute if the action does not generate any result (no new action) + */ + execute_action: function (action_data, dataset, action_manager, record_id, on_no_action) { + var handler = function (r) { + if (r.result && r.result.constructor == Object) { + action_manager.do_action(r.result); + } else { + on_no_action(r.result); + } + }; + + if (action_data.special) { + handler({ + result : { type: 'ir.actions.act_window_close' } + }); + } else { + var context = _.extend({}, dataset.context, action_data.context || {}); + switch(action_data.type) { + case 'object': + return dataset.call(action_data.name, [record_id], [context], handler); + case 'action': + return this.rpc('/base/action/load', { action_id: parseInt(action_data.name, 10) }, handler); + default: + return dataset.exec_workflow(record_id, action_data.name, handler); + } + } } }); -openerp.base.views.add('gantt', 'openerp.base.GanttView'); -openerp.base.GanttView = openerp.base.Controller.extend({ - start: function () { - this._super(); - this.$element.append('Gantt view'); - }, - do_show: function () { - this.$element.show(); - }, - do_hide: function () { - this.$element.hide(); - } -}); - -openerp.base.views.add('tree', 'openerp.base.TreeView'); -openerp.base.TreeView = openerp.base.Controller.extend({ /** - * Genuine tree view (the one displayed as a tree, not the list) + * Registry for all the main views */ - start: function () { - this._super(); - this.$element.append('Tree view'); - }, - do_show: function () { - this.$element.show(); - }, - do_hide: function () { - this.$element.hide(); - } -}); - -openerp.base.views.add('graph', 'openerp.base.GraphView'); -openerp.base.GraphView = openerp.base.Controller.extend({ - start: function () { - this._super(); - this.$element.append('Graph view'); - }, - do_show: function () { - this.$element.show(); - }, - do_hide: function () { - this.$element.hide(); - } -}); +openerp.base.views = new openerp.base.Registry(); openerp.base.ProcessView = openerp.base.Controller.extend({ }); diff --git a/addons/web_chat/__openerp__.py b/addons/web_chat/__openerp__.py index 3d5358702c2..6bd08f81e6a 100644 --- a/addons/web_chat/__openerp__.py +++ b/addons/web_chat/__openerp__.py @@ -10,5 +10,6 @@ 'static/src/js/web_chat.js' ], "css": [], +# 'active': True, 'active': False, }