summaryrefslogtreecommitdiff
path: root/addons/base/static
diff options
context:
space:
mode:
authorXavier Morel <xmo@openerp.com>2011-06-07 12:55:57 +0200
committerXavier Morel <xmo@openerp.com>2011-06-07 12:55:57 +0200
commit08f6d5d9eecc2e82cb46d591f7dd992a2d66eba6 (patch)
treeb235452edb8aed239d4e5ae9c2bd45fb5db7e393 /addons/base/static
parent8a7a64bcd1e8e96bb7b1604d2f74e3145315246e (diff)
[IMP] switching to form view selecting the correct record while in edition mode with a record being edited
bzr revid: xmo@openerp.com-20110607105557-izu1cm5udiqkktsg
Diffstat (limited to 'addons/base/static')
-rw-r--r--addons/base/static/src/js/list-editable.js42
-rw-r--r--addons/base/static/src/js/list.js2
2 files changed, 37 insertions, 7 deletions
diff --git a/addons/base/static/src/js/list-editable.js b/addons/base/static/src/js/list-editable.js
index c0ad2e7379d..ec9f21f61b7 100644
--- a/addons/base/static/src/js/list-editable.js
+++ b/addons/base/static/src/js/list-editable.js
@@ -8,10 +8,35 @@ openerp.base.list.editable = function (openerp) {
// editability status of list rows
openerp.base.ListView.prototype.defaults.editable = null;
- var old_actual_search = openerp.base.ListView.prototype.do_actual_search;
- var old_add_record = openerp.base.ListView.prototype.do_add_record;
- var old_on_loaded = openerp.base.ListView.prototype.on_loaded;
- _.extend(openerp.base.ListView.prototype, {
+ var old_init = openerp.base.ListView.prototype.init,
+ old_actual_search = openerp.base.ListView.prototype.do_actual_search,
+ old_add_record = openerp.base.ListView.prototype.do_add_record,
+ old_on_loaded = openerp.base.ListView.prototype.on_loaded;
+ // TODO: not sure second @lends on existing item is correct, to check
+ _.extend(openerp.base.ListView.prototype, /** @lends openerp.base.ListView# */{
+ init: function () {
+ var self = this;
+ old_init.apply(this, arguments);
+ $(this.groups).bind({
+ 'edit': function (e, id, dataset) {
+ self.do_edit(dataset.index, id, dataset);
+ }
+ })
+ },
+ /**
+ * Handles the activation of a record in editable mode (making a record
+ * editable), called *after* the record has become editable.
+ *
+ * The default behavior is to setup the listview's dataset to match
+ * whatever dataset was provided by the editing List
+ *
+ * @param {Number} index index of the record in the dataset
+ * @param {Object} id identifier of the record being edited
+ * @param {openerp.base.DataSet} dataset dataset in which the record is available
+ */
+ do_edit: function (index, id, dataset) {
+ _.extend(this.dataset, dataset);
+ },
/**
* Sets editability status for the list, based on defaults, view
* architecture and the provided flag, if any.
@@ -52,7 +77,8 @@ openerp.base.list.editable = function (openerp) {
}
});
- _.extend(openerp.base.ListView.Groups.prototype, {
+ _.extend(openerp.base.ListView.Groups.prototype, /** @lends openerp.base.ListView.Groups# */{
+ passtrough_events: openerp.base.ListView.Groups.prototype.passtrough_events + " edit",
new_record: function () {
// TODO: handle multiple children
this.children[null].new_record();
@@ -60,7 +86,7 @@ openerp.base.list.editable = function (openerp) {
});
var old_list_row_clicked = openerp.base.ListView.List.prototype.row_clicked;
- _.extend(openerp.base.ListView.List.prototype, {
+ _.extend(openerp.base.ListView.List.prototype, /** @lends openerp.base.ListView.List */{
row_clicked: function (event) {
if (!this.options.editable) {
return old_list_row_clicked.call(this, event);
@@ -169,6 +195,7 @@ openerp.base.list.editable = function (openerp) {
return;
}
self.dataset.next();
+ self.edit_record();
});
}, this.options.editable === 'top');
},
@@ -186,6 +213,9 @@ openerp.base.list.editable = function (openerp) {
this.$current.children(
_.sprintf('[data-index=%d]',
this.dataset.index)));
+ $(this).trigger(
+ 'edit',
+ [this.rows[this.dataset.index].data.id.value, this.dataset]);
},
new_record: function () {
this.dataset.index = null;
diff --git a/addons/base/static/src/js/list.js b/addons/base/static/src/js/list.js
index 41ff6e9ec14..dea3feb3970 100644
--- a/addons/base/static/src/js/list.js
+++ b/addons/base/static/src/js/list.js
@@ -392,7 +392,7 @@ openerp.base.ListView = openerp.base.View.extend( /** @lends openerp.base.ListVi
*
* @param {Number} index index of the record in the dataset
* @param {Object} id identifier of the activated record
- * @param {openobject.base.DataSet} dataset dataset in which the record is available (may not be the listview's dataset in case of nested groups)
+ * @param {openerp.base.DataSet} dataset dataset in which the record is available (may not be the listview's dataset in case of nested groups)
*/
do_activate_record: function (index, id, dataset) {
var self = this;