summaryrefslogtreecommitdiff
path: root/addons/base/static/src
diff options
context:
space:
mode:
authorXavier Morel <xmo@openerp.com>2011-05-27 09:44:42 +0200
committerXavier Morel <xmo@openerp.com>2011-05-27 09:44:42 +0200
commitf86bc1c6a398d5ff5da9e517b92bb8cffeb5225d (patch)
tree80ffd580ac41bfaee39c37752655ce550e9410a3 /addons/base/static/src
parentfa284d7c09a5bee5425afb88a4e9d1316887a55f (diff)
[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
Diffstat (limited to 'addons/base/static/src')
-rw-r--r--addons/base/static/src/js/list.js55
-rw-r--r--addons/base/static/src/js/views.js2
2 files changed, 39 insertions, 18 deletions
diff --git a/addons/base/static/src/js/list.js b/addons/base/static/src/js/list.js
index c20e5637693..05fc586a14d 100644
--- a/addons/base/static/src/js/list.js
+++ b/addons/base/static/src/js/list.js
@@ -78,25 +78,10 @@ openerp.base.ListView = openerp.base.View.extend( /** @lends openerp.base.ListVi
self.do_delete(ids);
},
'action': function (e, action_name, id, callback) {
- var action = _.detect(self.columns, function (field) {
- return field.name === action_name;
- });
- if (!action) { return; }
- self.execute_action(
- action, self.dataset, self.session.action_manager,
- id, function () {
- if (callback) {
- callback();
- }
- });
+ self.do_action(action_name, id, callback);
},
'row_link': function (e, index, id, dataset) {
- _.extend(self.dataset, {
- domain: dataset.domain,
- context: dataset.context
- }).read_slice([], null, null, function () {
- self.select_record(index);
- });
+ self.do_activate_record(index, id, dataset);
}
});
},
@@ -359,6 +344,42 @@ openerp.base.ListView = openerp.base.View.extend( /** @lends openerp.base.ListVi
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,
* can be the addition from a remote source, ...)
*
diff --git a/addons/base/static/src/js/views.js b/addons/base/static/src/js/views.js
index bb52009ae40..d4ab23af0d0 100644
--- a/addons/base/static/src/js/views.js
+++ b/addons/base/static/src/js/views.js
@@ -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 {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 {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)
*/
execute_action: function (action_data, dataset, action_manager, record_id, on_no_action) {