Victor Tabuenca (OpenERP) has proposed merging 
lp:~openerp-dev/openerp-web/trunk-trigger-on_mode_switch into lp:openerp-web.

Requested reviews:
  OpenERP R&D Web Team (openerp-dev-web)

For more details, see:
https://code.launchpad.net/~openerp-dev/openerp-web/trunk-trigger-on_mode_switch/+merge/128894
-- 
https://code.launchpad.net/~openerp-dev/openerp-web/trunk-trigger-on_mode_switch/+merge/128894
Your team OpenERP R&D Team is subscribed to branch 
lp:~openerp-dev/openerp-web/trunk-trigger-on_mode_switch.
=== modified file 'addons/web/static/src/js/view_form.js'
--- addons/web/static/src/js/view_form.js	2012-10-09 09:30:35 +0000
+++ addons/web/static/src/js/view_form.js	2012-10-10 09:43:24 +0000
@@ -3380,10 +3380,13 @@
             }
             def.resolve();
         });
-        this.viewmanager.on_mode_switch.add_first(function(n_mode, b, c, d, e) {
+        this.viewmanager.on("switch_mode", self, function(n_mode, b, c, d, e) {
             $.when(self.save_any_view()).then(function() {
-                if(n_mode === "list")
-                    $.async_when().then(function() {self.reload_current_view();});
+                if (n_mode === "list") {
+                    $.async_when().then(function() {
+                        self.reload_current_view();
+                    });
+                }
             });
         });
         this.is_setted.then(function() {

=== modified file 'addons/web/static/src/js/views.js'
--- addons/web/static/src/js/views.js	2012-10-08 10:40:47 +0000
+++ addons/web/static/src/js/views.js	2012-10-10 09:43:24 +0000
@@ -417,7 +417,7 @@
         this._super();
         var self = this;
         this.$el.find('.oe_view_manager_switch a').click(function() {
-            self.on_mode_switch($(this).data('view-type'));
+            self.trigger('switch_mode', $(this).data('view-type'));
         }).tipsy();
         var views_ids = {};
         _.each(this.views_src, function(view) {
@@ -439,16 +439,10 @@
         }
         // If no default view defined, switch to the first one in sequence
         var default_view = this.flags.default_view || this.views_src[0].view_type;
-        return this.on_mode_switch(default_view);
+        this.on('switch_mode', self, self.switch_mode);
+        return this.trigger('switch_mode', default_view);
     },
-    /**
-     * Asks the view manager to switch visualization mode.
-     *
-     * @param {String} view_type type of view to display
-     * @param {Boolean} [no_store=false] don't store the view being switched to on the switch stack
-     * @returns {jQuery.Deferred} new view loading promise
-     */
-    on_mode_switch: function(view_type, no_store, view_options) {
+    switch_mode: function(view_type, no_store, view_options) {
         var self = this;
         var view = this.views[view_type];
         var view_promise;
@@ -552,7 +546,7 @@
     add_breadcrumb: function(on_reverse_breadcrumb) {
         var self = this;
         var views = [this.active_view || this.views_src[0].view_type];
-        this.on_mode_switch.add(function(mode) {
+        this.on('switch_mode', self, function(mode) {
             var last = views.slice(-1)[0];
             if (mode !== last) {
                 if (mode !== 'form') {
@@ -568,7 +562,7 @@
                 var view_to_select = views[index];
                 self.$el.show();
                 if (self.active_view !== view_to_select) {
-                    self.on_mode_switch(view_to_select);
+                    self.trigger('switch_mode', view_to_select);
                 }
             },
             get_title: function() {
@@ -604,12 +598,12 @@
      * consist to switch to the asked view.
      */
     switch_view: function(view_type, no_store, options) {
-        return this.on_mode_switch(view_type, no_store, options);
+        return this.trigger('switch_mode', view_type, no_store, options);
     },
     /**
      * Returns to the view preceding the caller view in this manager's
      * navigation history (the navigation history is appended to via
-     * on_mode_switch)
+     * switch_mode)
      *
      * @param {Object} [options]
      * @param {Boolean} [options.created=false] resource was created
@@ -623,12 +617,12 @@
         if (options.created && current_view === 'form' && previous_view === 'list') {
             // APR special case: "If creation mode from list (and only from a list),
             // after saving, go to page view (don't come back in list)"
-            return this.on_mode_switch('form');
+            return this.trigger('switch_mode', 'form');
         } else if (options.created && !previous_view && this.action && this.action.flags.default_view === 'form') {
             // APR special case: "If creation from dashboard, we have no previous view
-            return this.on_mode_switch('form');
+            return this.trigger('switch_mode', 'form');
         }
-        return this.on_mode_switch(previous_view, true);
+        return this.trigger('switch_mode', previous_view, true);
     },
     /**
      * Sets up the current viewmanager's search view.
@@ -897,7 +891,7 @@
         }, action || {});
         this.do_action(action);
     },
-    on_mode_switch: function (view_type, no_store, options) {
+    switch_mode: function (view_type, no_store, options) {
         var self = this;
 
         return $.when(this._super.apply(this, arguments)).then(function () {
@@ -932,7 +926,7 @@
         if (state.view_type && state.view_type !== this.active_view) {
             defs.push(
                 this.views[this.active_view].deferred.pipe(function() {
-                    return self.on_mode_switch(state.view_type, true);
+                    return self.trigger('switch_mode', state.view_type, true)
                 })
             );
         } 

=== modified file 'addons/web_kanban/static/src/js/kanban.js'
--- addons/web_kanban/static/src/js/kanban.js	2012-10-02 09:40:33 +0000
+++ addons/web_kanban/static/src/js/kanban.js	2012-10-10 09:43:24 +0000
@@ -194,7 +194,7 @@
         });
         var am = instance.webclient.action_manager;
         var form = am.dialog_widget.views.form.controller;
-        form.on_button_cancel.add_last(am.dialog.on_close);
+        form.on("on_button_cancel", self, am.dialog.on_close);
         form.on_created.add_last(function(r) {
             (new instance.web.DataSet(self, self.group_by_field.relation)).name_get([r.result]).then(function(new_record) {
                 am.dialog.on_close();
@@ -672,7 +672,7 @@
         });
         var am = instance.webclient.action_manager;
         var form = am.dialog_widget.views.form.controller;
-        form.on_button_cancel.add_last(am.dialog.on_close);
+        form.on("on_button_cancel", self, am.dialog.on_close);
         form.on_saved.add_last(function() {
             am.dialog.on_close();
             self.view.do_reload();

=== modified file 'addons/web_view_editor/static/src/js/view_editor.js'
--- addons/web_view_editor/static/src/js/view_editor.js	2012-10-03 10:34:28 +0000
+++ addons/web_view_editor/static/src/js/view_editor.js	2012-10-10 09:43:24 +0000
@@ -1014,9 +1014,7 @@
         var action_manager = new instance.web.ActionManager(self);
         $.when(action_manager.do_action(action)).then(function() {
             var controller = action_manager.dialog_widget.views['form'].controller;
-            controller.on_button_cancel.add_last(function(){
-                action_manager.destroy()
-            });
+            controller.on("on_button_cancel",self,action_manager.destroy);
             controller.do_save.add_last(function(){
                 action_manager.destroy();
                 var value =controller.fields.name.get('value');

_______________________________________________
Mailing list: https://launchpad.net/~openerp-dev-gtk
Post to     : [email protected]
Unsubscribe : https://launchpad.net/~openerp-dev-gtk
More help   : https://help.launchpad.net/ListHelp

Reply via email to