minor logging improvement
bzr revid: al@openerp.com-20110409230727-dl78pjg6wvoo7g3e
This commit is contained in:
parent
39c554b192
commit
24a68e4061
|
@ -76,6 +76,10 @@
|
|||
|
||||
/** @lends openerp */
|
||||
var openerp = this.openerp = {
|
||||
/**
|
||||
* Debug flag turns on logging
|
||||
*/
|
||||
debug: true,
|
||||
// element_ids registry linked to all controllers on the page
|
||||
// TODO rename to elements, or keep gtk naming?
|
||||
screen: {},
|
||||
|
|
|
@ -193,8 +193,6 @@ openerp.base.BasicController = Class.extend( /** @lends openerp.base.BasicContro
|
|||
// try to call deferred methods on this return value.
|
||||
return $.Deferred().done().promise();
|
||||
},
|
||||
on_ready: function() {
|
||||
},
|
||||
stop: function() {
|
||||
},
|
||||
log: function() {
|
||||
|
@ -206,20 +204,60 @@ openerp.base.BasicController = Class.extend( /** @lends openerp.base.BasicContro
|
|||
this.on_log.apply(this,args);
|
||||
},
|
||||
on_log: function() {
|
||||
if(true || window.openerp.debug || (window.location.search.indexOf('?debug') !== -1)) {
|
||||
if(window.openerp.debug || (window.location.search.indexOf('?debug') !== -1)) {
|
||||
var notify = false;
|
||||
var body = false;
|
||||
if(window.console) {
|
||||
console.log(arguments);
|
||||
} else {
|
||||
$.each(arguments, function(i,v) {
|
||||
v = v==null ? "null" : v;
|
||||
$('<pre></pre>').text(v.toString()).appendTo($('body'));
|
||||
});
|
||||
body = true;
|
||||
}
|
||||
var a = Array.prototype.slice.call(arguments, 0);
|
||||
for(var i = 0; i < a.length; i++) {
|
||||
var v = a[i]==null ? "null" : a[i].toString();
|
||||
if(i==0) {
|
||||
notify = v.match(/^not/);
|
||||
body = v.match(/^bod/);
|
||||
}
|
||||
if(body) {
|
||||
$('<pre></pre>').text(v).appendTo($('body'));
|
||||
}
|
||||
if(notify && this.notification) {
|
||||
this.notification.notify("Logging:",v);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
openerp.base.Notification = openerp.base.BasicController.extend({
|
||||
init: function(element_id) {
|
||||
this._super(element_id);
|
||||
this.$element.notify({
|
||||
speed: 500,
|
||||
expires: 1500
|
||||
});
|
||||
},
|
||||
notify: function(title, text) {
|
||||
this.$element.notify('create', {
|
||||
title: title,
|
||||
text: text
|
||||
});
|
||||
},
|
||||
// TODO remove to avoid default as attribute
|
||||
'default': function(title, text) {
|
||||
this.notify(title,text);
|
||||
},
|
||||
// TODO change into warn to avoid alert
|
||||
alert: function(title, text) {
|
||||
this.$element.notify('create', 'oe_notification_alert', {
|
||||
title: title,
|
||||
text: text
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
openerp.base.Session = openerp.base.BasicController.extend( /** @lends openerp.base.Session# */{
|
||||
/**
|
||||
* @constructs
|
||||
|
@ -447,17 +485,40 @@ openerp.base.Session = openerp.base.BasicController.extend( /** @lends openerp.b
|
|||
});
|
||||
|
||||
openerp.base.Controller = openerp.base.BasicController.extend( /** @lends openerp.base.Controller# */{
|
||||
/**
|
||||
* Controller manifest used to declare standard controller attributes
|
||||
*/
|
||||
controller_manifest: {
|
||||
register: [ "FormView.widget.char" ],
|
||||
template: "",
|
||||
elementpost: false,
|
||||
},
|
||||
/**
|
||||
* @constructs
|
||||
* @extends openerp.base.BasicController
|
||||
*/
|
||||
init: function(session, element_id) {
|
||||
init: function(parent_or_session, element_id) {
|
||||
this._super(element_id);
|
||||
this.session = session;
|
||||
// TODO migrate for backward compat
|
||||
if(parent_or_session) {
|
||||
if(parent_or_session.session) {
|
||||
this.parent = parent_or_session;
|
||||
} else {
|
||||
this.session = parent_or_session;
|
||||
}
|
||||
|
||||
}
|
||||
},
|
||||
on_log: function() {
|
||||
if(this.session)
|
||||
this.session.log.apply(this.session,arguments);
|
||||
/**
|
||||
* Controller registry,
|
||||
*/
|
||||
controller_registry: {
|
||||
},
|
||||
/**
|
||||
* Add a new child controller
|
||||
*/
|
||||
controller_add: function(key,element_id) {
|
||||
var obj = "";
|
||||
},
|
||||
/**
|
||||
* Performs a JSON-RPC call
|
||||
|
@ -495,10 +556,6 @@ openerp.base.CrashManager = openerp.base.Controller.extend({
|
|||
}
|
||||
});
|
||||
|
||||
openerp.base.Database = openerp.base.Controller.extend({
|
||||
// Non Session Controller to manage databases
|
||||
});
|
||||
|
||||
openerp.base.Loading = openerp.base.Controller.extend({
|
||||
init: function(session, element_id) {
|
||||
this._super(session, element_id);
|
||||
|
@ -518,26 +575,7 @@ openerp.base.Loading = openerp.base.Controller.extend({
|
|||
}
|
||||
});
|
||||
|
||||
openerp.base.Notification = openerp.base.Controller.extend({
|
||||
init: function(session, element_id) {
|
||||
this._super(session, element_id);
|
||||
this.$element.notify({
|
||||
speed: 500,
|
||||
expires: 1500
|
||||
});
|
||||
},
|
||||
'default': function(title, text) {
|
||||
this.$element.notify('create', {
|
||||
title: title,
|
||||
text: text
|
||||
});
|
||||
},
|
||||
alert: function(title, text) {
|
||||
this.$element.notify('create', 'oe_notification_alert', {
|
||||
title: title,
|
||||
text: text
|
||||
});
|
||||
}
|
||||
openerp.base.Database = openerp.base.Controller.extend({
|
||||
});
|
||||
|
||||
openerp.base.Login = openerp.base.Controller.extend({
|
||||
|
@ -630,7 +668,6 @@ openerp.base.Menu = openerp.base.Controller.extend({
|
|||
});
|
||||
|
||||
this.$element.add(this.$secondary_menu).find("a").click(this.on_menu_click);
|
||||
this.on_ready();
|
||||
},
|
||||
on_menu_click: function(ev, id) {
|
||||
id = id || 0;
|
||||
|
@ -703,7 +740,7 @@ openerp.base.WebClient = openerp.base.Controller.extend({
|
|||
this.crashmanager = new openerp.base.CrashManager(this.session);
|
||||
|
||||
// Do you autorize this ?
|
||||
openerp.base.Controller.prototype.notification = new openerp.base.Notification(this.session, "oe_notification");
|
||||
openerp.base.Controller.prototype.notification = new openerp.base.Notification("oe_notification");
|
||||
|
||||
this.header = new openerp.base.Header(this.session, "oe_header");
|
||||
this.login = new openerp.base.Login(this.session, "oe_login");
|
||||
|
@ -739,6 +776,7 @@ openerp.base.webclient = function(element_id) {
|
|||
client.start();
|
||||
return client;
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
// vim:et fdc=0 fdl=0 foldnestmax=3 fdm=syntax:
|
||||
|
|
Loading…
Reference in New Issue