[ADD] Added 'home' and 'history_back' client actions

[MOV] Moved client actions from coresetup.js to chrome.js

bzr revid: fme@openerp.com-20120806103330-xt5gjcntaho4qq7k
This commit is contained in:
Fabien Meghazi 2012-08-06 12:33:30 +02:00
parent b950d2c785
commit 8cecaa14f3
2 changed files with 49 additions and 26 deletions

View File

@ -609,6 +609,55 @@ instance.web.Login = instance.web.Widget.extend({
});
instance.web.client_actions.add("login", "instance.web.Login");
/**
* Client action to reload the whole interface.
* If params has an entry 'menu_id', it opens the given menu entry.
*/
instance.web.Reload = instance.web.Widget.extend({
init: function(parent, params) {
this._super(parent);
this.menu_id = (params && params.menu_id) || false;
},
start: function() {
var l = window.location;
var timestamp = new Date().getTime();
var search = "?ts=" + timestamp;
if (l.search) {
search = l.search + "&ts=" + timestamp;
}
var hash = l.hash;
if (this.menu_id) {
hash = "#menu_id=" + this.menu_id;
}
var url = l.protocol + "//" + l.host + l.pathname + search + hash;
window.location = url;
}
});
instance.web.client_actions.add("reload", "instance.web.Reload");
/**
* Client action to go back in breadcrumb history.
* If can't go back in history stack, will go back to home.
*/
instance.web.HistoryBack = instance.web.Widget.extend({
init: function(parent, params) {
if (!parent.history_back()) {
window.location = '/' + (window.location.search || '');
}
}
});
instance.web.client_actions.add("history_back", "instance.web.HistoryBack");
/**
* Client action to go back home.
*/
instance.web.Home = instance.web.Widget.extend({
init: function(parent, params) {
window.location = '/' + (window.location.search || '');
}
});
instance.web.client_actions.add("home", "instance.web.Home");
instance.web.Menu = instance.web.Widget.extend({
template: 'Menu',
init: function() {

View File

@ -672,32 +672,6 @@ instance.connection.on('module_loaded', this, function () {
*/
instance.web.client_actions = new instance.web.Registry();
/**
* Client action to reload the whole interface.
* If params has an entry 'menu_id', it opens the given menu entry.
*/
instance.web.Reload = instance.web.Widget.extend({
init: function(parent, params) {
this._super(parent);
this.menu_id = (params && params.menu_id) || false;
},
start: function() {
var l = window.location;
var timestamp = new Date().getTime();
var search = "?ts=" + timestamp;
if (l.search) {
search = l.search + "&ts=" + timestamp;
}
var hash = l.hash;
if (this.menu_id) {
hash = "#menu_id=" + this.menu_id;
}
var url = l.protocol + "//" + l.host + l.pathname + search + hash;
window.location = url;
}
});
instance.web.client_actions.add("reload", "instance.web.Reload");
};
// vim:et fdc=0 fdl=0 foldnestmax=3 fdm=syntax: