[IMP] extract handlers for ListView.Groups events into separate method, so they're not a pain to override
bzr revid: xmo@openerp.com-20110527074442-2wjw9aya7m8t0tlp
This commit is contained in:
parent
fa284d7c09
commit
f86bc1c6a3
|
@ -78,25 +78,10 @@ openerp.base.ListView = openerp.base.View.extend( /** @lends openerp.base.ListVi
|
||||||
self.do_delete(ids);
|
self.do_delete(ids);
|
||||||
},
|
},
|
||||||
'action': function (e, action_name, id, callback) {
|
'action': function (e, action_name, id, callback) {
|
||||||
var action = _.detect(self.columns, function (field) {
|
self.do_action(action_name, id, callback);
|
||||||
return field.name === action_name;
|
|
||||||
});
|
|
||||||
if (!action) { return; }
|
|
||||||
self.execute_action(
|
|
||||||
action, self.dataset, self.session.action_manager,
|
|
||||||
id, function () {
|
|
||||||
if (callback) {
|
|
||||||
callback();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
},
|
},
|
||||||
'row_link': function (e, index, id, dataset) {
|
'row_link': function (e, index, id, dataset) {
|
||||||
_.extend(self.dataset, {
|
self.do_activate_record(index, id, dataset);
|
||||||
domain: dataset.domain,
|
|
||||||
context: dataset.context
|
|
||||||
}).read_slice([], null, null, function () {
|
|
||||||
self.select_record(index);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
@ -358,6 +343,42 @@ openerp.base.ListView = openerp.base.View.extend( /** @lends openerp.base.ListVi
|
||||||
}
|
}
|
||||||
this.compute_aggregates(records);
|
this.compute_aggregates(records);
|
||||||
},
|
},
|
||||||
|
/**
|
||||||
|
* Handles action button signals on a record
|
||||||
|
*
|
||||||
|
* @param {String} name action name
|
||||||
|
* @param {Object} id id of the record the action should be called on
|
||||||
|
* @param {Function} callback should be called after the action is executed, if non-null
|
||||||
|
*/
|
||||||
|
do_action: function (name, id, callback) {
|
||||||
|
var action = _.detect(this.columns, function (field) {
|
||||||
|
return field.name === name;
|
||||||
|
});
|
||||||
|
if (!action) { return; }
|
||||||
|
this.execute_action(
|
||||||
|
action, this.dataset, this.session.action_manager,
|
||||||
|
id, function () {
|
||||||
|
if (callback) {
|
||||||
|
callback();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
},
|
||||||
|
/**
|
||||||
|
* Handles the activation of a record (clicking on it)
|
||||||
|
*
|
||||||
|
* @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)
|
||||||
|
*/
|
||||||
|
do_activate_record: function (index, id, dataset) {
|
||||||
|
var self = this;
|
||||||
|
_.extend(this.dataset, {
|
||||||
|
domain: dataset.domain,
|
||||||
|
context: dataset.context
|
||||||
|
}).read_slice([], 0, false, function () {
|
||||||
|
self.select_record(index);
|
||||||
|
});
|
||||||
|
},
|
||||||
/**
|
/**
|
||||||
* Handles signal for the addition of a new record (can be a creation,
|
* Handles signal for the addition of a new record (can be a creation,
|
||||||
* can be the addition from a remote source, ...)
|
* can be the addition from a remote source, ...)
|
||||||
|
|
|
@ -356,7 +356,7 @@ openerp.base.View = openerp.base.Controller.extend({
|
||||||
* @param {Object} [action_data.context=null] additional action context, to add to the current context
|
* @param {Object} [action_data.context=null] additional action context, to add to the current context
|
||||||
* @param {openerp.base.DataSet} dataset a dataset object used to communicate with the server
|
* @param {openerp.base.DataSet} dataset a dataset object used to communicate with the server
|
||||||
* @param {openerp.base.ActionManager} action_manager object able to actually execute the action, if any is fetched
|
* @param {openerp.base.ActionManager} action_manager object able to actually execute the action, if any is fetched
|
||||||
* @param {Number} [record_id] the identifier of the object on which the action is to be applied
|
* @param {Object} [record_id] the identifier of the object on which the action is to be applied
|
||||||
* @param {Function} on_no_action callback to execute if the action does not generate any result (no new action)
|
* @param {Function} on_no_action callback to execute if the action does not generate any result (no new action)
|
||||||
*/
|
*/
|
||||||
execute_action: function (action_data, dataset, action_manager, record_id, on_no_action) {
|
execute_action: function (action_data, dataset, action_manager, record_id, on_no_action) {
|
||||||
|
|
Loading…
Reference in New Issue