bzr revid: nicolas.vanhoren@openerp.com-20110622145153-1j0ntku8qndpij1o
This commit is contained in:
niv-openerp
2011-06-22 16:51:53 +02:00
5 changed files with 53 additions and 42 deletions
+3 -8
View File
@@ -670,15 +670,10 @@ QWeb2.Element = (function() {
this.top("(function(" + value + ") {");
this.bottom("})(dict);");
this.indent();
if (this.children.length === 1) {
var lines = this.children[0].node.data.split(/\r?\n/);
for (var i = 0, ilen = lines.length; i < ilen; i++) {
this.top(lines[i]);
}
} else {
this.engine.tools.exception("'js' code block contains " + this.children.length + " nodes instead of 1");
var lines = this.engine.tools.xml_node_to_string(this.node, true).split(/\r?\n/);
for (var i = 0, ilen = lines.length; i < ilen; i++) {
this.top(lines[i]);
}
// Maybe I could handle the children ?
this.process_children = false;
},
compile_action_debug : function(value) {
+18 -3
View File
@@ -310,9 +310,10 @@ openerp.base.DataSet = openerp.base.Controller.extend( /** @lends openerp.base.
context: this.context
}, callback);
},
unlink: function(ids) {
// to implement in children
this.notification.notify("Unlink", ids);
unlink: function(ids, callback, error_callback) {
var self = this;
return this.call_and_eval("unlink", [ids, this.context], null, 1,
callback, error_callback);
},
call: function (method, args, callback, error_callback) {
return this.rpc('/base/dataset/call', {
@@ -362,9 +363,12 @@ openerp.base.DataSetStatic = openerp.base.DataSet.extend({
set_ids: function (ids) {
this.ids = ids;
this.count = this.ids.length;
this.index = this.index <= this.count - 1 ?
this.index : (this.count > 0 ? this.count - 1 : 0);
},
unlink: function(ids) {
this.on_unlink(ids);
return $.Deferred().resolve({result: true});
},
on_unlink: function(ids) {
this.set_ids(_.without.apply(null, [this.ids].concat(ids)));
@@ -438,6 +442,17 @@ openerp.base.DataSetSearch = openerp.base.DataSet.extend({
this._sort.unshift((reverse ? '-' : '') + field);
return undefined;
},
unlink: function(ids, callback, error_callback) {
var self = this;
return this._super(ids, function(result) {
self.ids = _.without.apply(_, [self.ids].concat(ids));
self.count = self.ids.length;
self.index = self.index <= self.count - 1 ?
self.index : (self.count > 0 ? self.count -1 : 0);
if (callback)
callback(result);
}, error_callback);
}
});
+8 -3
View File
@@ -252,18 +252,23 @@ openerp.base.FormView = openerp.base.View.extend( /** @lends openerp.base.FormV
if (!this.ready) {
return false;
}
var invalid = false;
var values = {};
var invalid = false,
values = {},
first_invalid_field = null;
for (var f in this.fields) {
f = this.fields[f];
if (f.invalid) {
invalid = true;
f.update_dom();
if (!first_invalid_field) {
first_invalid_field = f;
}
} else if (f.touched) {
values[f.name] = f.get_value();
}
}
if (invalid) {
first_invalid_field.focus();
this.on_invalid();
return false;
} else {
@@ -553,7 +558,7 @@ openerp.base.form.WidgetFrame = openerp.base.form.Widget.extend({
var widget_type = node.attrs.widget || type.type || node.tag;
var widget = new (this.view.registry.get_object(widget_type)) (this.view, node);
if (node.tag == 'field') {
if (node.attrs.default_focus == '1') {
if (!this.view.default_focus_field || node.attrs.default_focus == '1') {
this.view.default_focus_field = widget;
}
if (node.attrs.nolabel != '1') {
+1 -19
View File
@@ -336,25 +336,7 @@ openerp.base.ListView = openerp.base.View.extend( /** @lends openerp.base.ListVi
}
var self = this;
return $.when(this.dataset.unlink(ids)).then(function () {
_(self.rows).chain()
.map(function (row, index) {
return {
index: index,
id: row.data.id.value
};})
.filter(function (record) {
return _.contains(ids, record.id);
})
.sort(function (a, b) {
// sort in reverse index order, so we delete from the end
// and don't blow up the following indexes (leading to
// removing the wrong records from the visible list)
return b.index - a.index;
})
.each(function (record) {
self.rows.splice(record.index, 1);
});
// TODO only refresh modified rows
self.reload_content();
});
},
/**
+23 -9
View File
@@ -113,7 +113,8 @@ openerp.base.ViewManager = openerp.base.Controller.extend({
* @returns {jQuery.Deferred} new view loading promise
*/
on_mode_switch: function(view_type) {
var view_promise;
var self = this,
view_promise;
this.active_view = view_type;
var view = this.views[view_type];
if (!view.controller) {
@@ -124,6 +125,16 @@ openerp.base.ViewManager = openerp.base.Controller.extend({
if (view.embedded_view) {
controller.set_embedded_view(view.embedded_view);
}
if (view_type === 'list' && this.flags.search_view === false && this.action && this.action['auto_search']) {
// In case the search view is not instanciated: manually call ListView#search
controller.on_loaded.add({
callback: function () {
controller.do_search([self.action.domain], [self.action.context], []);
},
position: 'last',
unique: true
});
}
view_promise = controller.start();
var self = this;
$.when(view_promise).then(function() {
@@ -132,6 +143,7 @@ openerp.base.ViewManager = openerp.base.Controller.extend({
this.views[view_type].controller = controller;
}
if (this.searchview) {
if (view.controller.searchable === false) {
this.searchview.hide();
@@ -261,16 +273,18 @@ openerp.base.ViewManagerAction = openerp.base.ViewManager.extend({
}
});
// init search view
var searchview_id = this.action.search_view_id && this.action.search_view_id[0];
if (this.flags.search_view !== false) {
// init search view
var searchview_id = this.action.search_view_id && this.action.search_view_id[0];
var searchview_loaded = this.setup_search_view(
searchview_id || false, search_defaults);
var searchview_loaded = this.setup_search_view(
searchview_id || false, search_defaults);
// schedule auto_search
if (searchview_loaded != null && this.action['auto_search']) {
$.when(searchview_loaded, inital_view_loaded)
.then(this.searchview.do_search);
// schedule auto_search
if (searchview_loaded != null && this.action['auto_search']) {
$.when(searchview_loaded, inital_view_loaded)
.then(this.searchview.do_search);
}
}
},
stop: function() {