[IMP] view_form: improve code formatting
bzr revid: rco@openerp.com-20120904143024-g6fmxpkcjmg95zcu
This commit is contained in:
@@ -3573,7 +3573,11 @@ instance.web.form.One2ManyListView = instance.web.ListView.extend({
|
||||
});
|
||||
instance.web.form.One2ManyList = instance.web.ListView.List.extend({
|
||||
pad_table_to: function (count) {
|
||||
this._super(this.view.is_action_enabled('create') ? (count > 0 ? count - 1 : 0) : this.records.length);
|
||||
if (!this.view.is_action_enabled('create')) {
|
||||
this._super(count);
|
||||
} else {
|
||||
this._super(count > 0 ? count - 1 : 0);
|
||||
}
|
||||
|
||||
// magical invocation of wtf does that do
|
||||
if (this.view.o2m.get('effective_readonly')) {
|
||||
@@ -3586,38 +3590,41 @@ instance.web.form.One2ManyList = instance.web.ListView.List.extend({
|
||||
}).length;
|
||||
if (this.options.selectable) { columns++; }
|
||||
if (this.options.deletable) { columns++; }
|
||||
if (this.view.is_action_enabled('create')) {
|
||||
var $cell = $('<td>', {
|
||||
colspan: columns,
|
||||
'class': 'oe_form_field_one2many_list_row_add'
|
||||
}).append(
|
||||
$('<a>', {href: '#'}).text(_t("Add a row"))
|
||||
.mousedown(function () {
|
||||
// FIXME: needs to be an official API somehow
|
||||
if (self.view.editor.is_editing()) {
|
||||
self.view.__ignore_blur = true;
|
||||
}
|
||||
})
|
||||
.click(function (e) {
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
// FIXME: there should also be an API for that one
|
||||
if (self.view.editor.form.__blur_timeout) {
|
||||
clearTimeout(self.view.editor.form.__blur_timeout);
|
||||
self.view.editor.form.__blur_timeout = false;
|
||||
}
|
||||
self.view.ensure_saved().then(function () {
|
||||
self.view.do_add_record();
|
||||
});
|
||||
}));
|
||||
|
||||
var $padding = this.$current.find('tr:not([data-id]):first');
|
||||
var $newrow = $('<tr>').append($cell);
|
||||
if ($padding.length) {
|
||||
$padding.before($newrow);
|
||||
} else {
|
||||
this.$current.append($newrow)
|
||||
}
|
||||
if (!this.view.is_action_enabled('create')) {
|
||||
return;
|
||||
}
|
||||
|
||||
var $cell = $('<td>', {
|
||||
colspan: columns,
|
||||
'class': 'oe_form_field_one2many_list_row_add'
|
||||
}).append(
|
||||
$('<a>', {href: '#'}).text(_t("Add a row"))
|
||||
.mousedown(function () {
|
||||
// FIXME: needs to be an official API somehow
|
||||
if (self.view.editor.is_editing()) {
|
||||
self.view.__ignore_blur = true;
|
||||
}
|
||||
})
|
||||
.click(function (e) {
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
// FIXME: there should also be an API for that one
|
||||
if (self.view.editor.form.__blur_timeout) {
|
||||
clearTimeout(self.view.editor.form.__blur_timeout);
|
||||
self.view.editor.form.__blur_timeout = false;
|
||||
}
|
||||
self.view.ensure_saved().then(function () {
|
||||
self.view.do_add_record();
|
||||
});
|
||||
}));
|
||||
|
||||
var $padding = this.$current.find('tr:not([data-id]):first');
|
||||
var $newrow = $('<tr>').append($cell);
|
||||
if ($padding.length) {
|
||||
$padding.before($newrow);
|
||||
} else {
|
||||
this.$current.append($newrow)
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user