[MERGE] a few trunk improvements

bzr revid: xmo@openerp.com-20110517100105-6ad5urt4gwydlbl8
This commit is contained in:
Xavier Morel
2011-05-17 12:01:05 +02:00
4 changed files with 29 additions and 15 deletions
+5 -2
View File
@@ -44,8 +44,11 @@
// The dummy class constructor
function Class() {
// All construction is actually done in the init method
if ( !initializing && this.init )
this.init.apply(this, arguments);
if ( !initializing && this.init ) {
var ret = this.init.apply(this, arguments);
if (ret) { return ret; }
}
return this;
}
// Populate our constructed prototype object
+6 -6
View File
@@ -321,7 +321,7 @@ openerp.base.form.compute_domain = function(expr, fields) {
var ex = expr[i];
if (ex.length == 1) {
var top = stack.pop();
switch (ex[0]) {
switch (ex) {
case '|':
stack.push(stack.pop() || top);
continue;
@@ -332,7 +332,7 @@ openerp.base.form.compute_domain = function(expr, fields) {
stack.push(!top);
continue;
default:
throw new Error('Unknown domain operator ' + ex[0]);
throw new Error('Unknown domain operator ' + ex);
}
}
@@ -362,17 +362,17 @@ openerp.base.form.compute_domain = function(expr, fields) {
stack.push(field >= val);
break;
case 'in':
stack.push(_.indexOf(val, field) > -1);
stack.push(_(val).contains(field));
break;
case 'not in':
stack.push(_.indexOf(val, field) == -1);
stack.push(!_(val).contains(field));
break;
default:
this.log("Unsupported operator in attrs :", op);
}
}
return _.indexOf(stack, false) == -1;
}
return _.all(stack);
};
openerp.base.form.Widget = openerp.base.Controller.extend({
init: function(view, node) {
+12 -2
View File
@@ -24,6 +24,7 @@ openerp.base.ActionManager = openerp.base.Controller.extend({
sidebar : true,
search_view : true,
new_window : false,
views_switcher : true,
toolbar : true,
pager : true
}, action.flags || {});
@@ -46,6 +47,7 @@ openerp.base.ActionManager = openerp.base.Controller.extend({
viewmanager.start();
this.dialog_stack.push(viewmanager);
} else if (action.flags.new_window) {
action.flags.new_window = false;
this.rpc("/base/session/save_session_action", { the_action : action}, function(key) {
var url = window.location.protocol + "//" + window.location.host +
window.location.pathname + "?" + jQuery.param({ s_action : "" + key });
@@ -79,6 +81,7 @@ openerp.base.ViewManager = openerp.base.Controller.extend({
this.active_view = null;
this.views_src = views;
this.views = {};
this.flags = this.flags || {};
},
/**
* @returns {jQuery.Deferred} initial view loading promise
@@ -93,6 +96,9 @@ openerp.base.ViewManager = openerp.base.Controller.extend({
_.each(this.views_src, function(view) {
self.views[view[1]] = { view_id: view[0], controller: null };
});
if (this.flags.views_switcher === false) {
this.$element.find('.oe_vm_switch').hide();
}
// switch to the first one in sequence
return this.on_mode_switch(this.views_src[0][1]);
},
@@ -116,7 +122,7 @@ openerp.base.ViewManager = openerp.base.Controller.extend({
this.views[view_type].controller = controller;
}
if(this.searchview) {
if (this.searchview) {
if (view.controller.searchable === false) {
this.searchview.hide();
} else {
@@ -152,6 +158,9 @@ openerp.base.ViewManager = openerp.base.Controller.extend({
this.searchview.stop();
}
this.searchview = new openerp.base.SearchView(this, this.session, this.element_id + "_search", this.dataset, view_id, search_defaults);
if (this.flags.search_view === false) {
this.searchview.hide();
}
this.searchview.on_search.add(function(domains, contexts, groupbys) {
self.views[self.active_view].controller.do_search.call(
self, domains.concat(self.domains()),
@@ -201,7 +210,8 @@ openerp.base.ViewManagerAction = openerp.base.ViewManager.extend({
}
this._super(session, element_id, dataset, action.views);
this.action = action;
if (action.flags.sidebar) {
this.flags = this.action.flags || {};
if (this.flags.sidebar) {
this.sidebar = new openerp.base.Sidebar(null, this);
}
},
@@ -55,10 +55,11 @@ openerp.base.form.Action = openerp.base.form.Widget.extend({
on_load_action: function(result) {
var action = result.action;
action.search_view = false;
action.no_sidebar = true;
action.search_view_id = false;
action.flags = {
search_view : false,
sidebar : false,
views_switcher : false
}
var node_attrs = this.node.attrs;
var get_column = ['first', 'second', 'third'];
var board_element = this.board.element.find('[id=column-'+get_column[this.child_index]+']');
@@ -101,4 +102,4 @@ openerp.base.form.Vpaned = openerp.base.form.Widget.extend({
openerp.base.form.widgets.add('hpaned', 'openerp.base.form.Board');
openerp.base.form.widgets.add('vpaned', 'openerp.base.form.Vpaned');
openerp.base.form.widgets.add('action', 'openerp.base.form.Action');
}
}