[ADD] push/pop API for views
lp bug: https://launchpad.net/bugs/900225 fixed bzr revid: xmo@openerp.com-20111207104503-gcy0gbin36s4uudh
This commit is contained in:
parent
44bb69e3a1
commit
f3c671cbd8
|
@ -357,11 +357,11 @@ openerp.web.FormView = openerp.web.View.extend( /** @lends openerp.web.FormView#
|
|||
on_button_save: function() {
|
||||
var self = this;
|
||||
return this.do_save().then(function() {
|
||||
self.do_switch_view('page');
|
||||
self.do_prev_view();
|
||||
});
|
||||
},
|
||||
on_button_cancel: function() {
|
||||
return this.do_switch_view('page');
|
||||
return this.do_prev_view();
|
||||
},
|
||||
on_button_new: function() {
|
||||
var self = this;
|
||||
|
@ -383,7 +383,7 @@ openerp.web.FormView = openerp.web.View.extend( /** @lends openerp.web.FormView#
|
|||
return def.promise();
|
||||
},
|
||||
can_be_discarded: function() {
|
||||
return true; // Disabled until the page view and button refactoring is done
|
||||
return true; // FIXME: Disabled until the page view and button refactoring is done
|
||||
return !this.is_dirty() || confirm(_t("Warning, the record has been modified, your changes will be discarded."));
|
||||
},
|
||||
/**
|
||||
|
|
|
@ -388,10 +388,10 @@ openerp.web.ListView = openerp.web.View.extend( /** @lends openerp.web.ListView#
|
|||
* new record.
|
||||
*
|
||||
* @param {Number|void} index the record index (in the current dataset) to switch to
|
||||
* @param {String} [view="form"] the view type to switch to
|
||||
* @param {String} [view="page"] the view type to switch to
|
||||
*/
|
||||
select_record:function (index, view) {
|
||||
view = view || 'form';
|
||||
view = view || 'page';
|
||||
this.dataset.index = index;
|
||||
_.delay(_.bind(function () {
|
||||
this.do_switch_view(view);
|
||||
|
|
|
@ -193,6 +193,8 @@ session.web.ViewManager = session.web.Widget.extend(/** @lends session.web.View
|
|||
this.views = {};
|
||||
this.flags = this.flags || {};
|
||||
this.registry = session.web.views;
|
||||
this.views = [];
|
||||
this.views_history = [];
|
||||
},
|
||||
render: function() {
|
||||
return session.web.qweb.render(this.template, {
|
||||
|
@ -232,11 +234,15 @@ session.web.ViewManager = session.web.Widget.extend(/** @lends session.web.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) {
|
||||
on_mode_switch: function(view_type, no_store) {
|
||||
var self = this,
|
||||
view_promise;
|
||||
if (!no_store) {
|
||||
this.views_history.push(view_type);
|
||||
}
|
||||
this.active_view = view_type;
|
||||
var view = this.views[view_type];
|
||||
if (!view.controller) {
|
||||
|
@ -247,6 +253,7 @@ session.web.ViewManager = session.web.Widget.extend(/** @lends session.web.View
|
|||
controller.set_embedded_view(view.embedded_view);
|
||||
}
|
||||
controller.do_switch_view.add_last(this.on_mode_switch);
|
||||
controller.do_prev_view.add_last(this.on_prev_view);
|
||||
var container = $("#" + this.element_id + '_view_' + view_type);
|
||||
view_promise = controller.appendTo(container);
|
||||
this.views[view_type].controller = controller;
|
||||
|
@ -286,6 +293,11 @@ session.web.ViewManager = session.web.Widget.extend(/** @lends session.web.View
|
|||
});
|
||||
return view_promise;
|
||||
},
|
||||
on_prev_view: function () {
|
||||
this.views_history.pop();
|
||||
var previous_view = this.views_history[this.views_history.length - 1];
|
||||
this.on_mode_switch(previous_view, true);
|
||||
},
|
||||
/**
|
||||
* Sets up the current viewmanager's search view.
|
||||
*
|
||||
|
@ -453,10 +465,10 @@ session.web.ViewManagerAction = session.web.ViewManager.extend(/** @lends oepner
|
|||
|
||||
return manager_ready;
|
||||
},
|
||||
on_mode_switch: function (view_type) {
|
||||
on_mode_switch: function (view_type, no_store) {
|
||||
var self = this;
|
||||
return $.when(
|
||||
this._super(view_type),
|
||||
this._super(view_type, no_store),
|
||||
this.shortcut_check(this.views[view_type])
|
||||
).then(function() {
|
||||
var controller = self.views[self.active_view].controller,
|
||||
|
@ -939,8 +951,16 @@ session.web.View = session.web.Widget.extend(/** @lends session.web.View# */{
|
|||
this.embedded_view = embedded_view;
|
||||
this.options.sidebar = false;
|
||||
},
|
||||
do_switch_view: function(view) {
|
||||
},
|
||||
/**
|
||||
* Switches to a specific view type
|
||||
*
|
||||
* @param {String} view view type to switch to
|
||||
*/
|
||||
do_switch_view: function(view) { },
|
||||
/**
|
||||
* Cancels the switch to the current view, switches to the previous one
|
||||
*/
|
||||
do_prev_view: function () { },
|
||||
do_search: function(view) {
|
||||
},
|
||||
|
||||
|
|
Loading…
Reference in New Issue