summaryrefslogtreecommitdiff
path: root/addons/web/static/src/js/data.js
diff options
context:
space:
mode:
authorXavier Morel <xmo@openerp.com>2012-02-06 10:46:48 +0100
committerXavier Morel <xmo@openerp.com>2012-02-06 10:46:48 +0100
commitae273f2414e64f78c7e9adc70d18e1d8abe9b561 (patch)
tree4d1a6e1b1f67d62391b5099e5e391136378a97f7 /addons/web/static/src/js/data.js
parentb21eb64306a5427e1b393c8505c751007c72a912 (diff)
[IMP] move DataSetSearch#sort to DataSet#sort
bzr revid: xmo@openerp.com-20120206094648-1pq0y6oczk8uzzw6
Diffstat (limited to 'addons/web/static/src/js/data.js')
-rw-r--r--addons/web/static/src/js/data.js52
1 files changed, 26 insertions, 26 deletions
diff --git a/addons/web/static/src/js/data.js b/addons/web/static/src/js/data.js
index b596b1eb250..6cfe20984be 100644
--- a/addons/web/static/src/js/data.js
+++ b/addons/web/static/src/js/data.js
@@ -248,6 +248,7 @@ openerp.web.DataSet = openerp.web.OldWidget.extend( /** @lends openerp.web.Data
this.model = model;
this.context = context || {};
this.index = null;
+ this._sort = [];
},
previous: function () {
this.index -= 1;
@@ -496,6 +497,31 @@ openerp.web.DataSet = openerp.web.OldWidget.extend( /** @lends openerp.web.Data
return new openerp.web.CompoundContext(this.context, request_context);
}
return this.context;
+ },
+ /**
+ * Reads or changes sort criteria on the dataset.
+ *
+ * If not provided with any argument, serializes the sort criteria to
+ * an SQL-like form usable by OpenERP's ORM.
+ *
+ * If given a field, will set that field as first sorting criteria or,
+ * if the field is already the first sorting criteria, will reverse it.
+ *
+ * @param {String} [field] field to sort on, reverses it (toggle from ASC to DESC) if already the main sort criteria
+ * @param {Boolean} [force_reverse=false] forces inserting the field as DESC
+ * @returns {String|undefined}
+ */
+ sort: function (field, force_reverse) {
+ if (!field) {
+ return openerp.web.serialize_sort(this._sort);
+ }
+ var reverse = force_reverse || (this._sort[0] === field);
+ this._sort.splice.apply(
+ this._sort, [0, this._sort.length].concat(
+ _.without(this._sort, field, '-' + field)));
+
+ this._sort.unshift((reverse ? '-' : '') + field);
+ return undefined;
}
});
openerp.web.DataSetStatic = openerp.web.DataSet.extend({
@@ -541,7 +567,6 @@ openerp.web.DataSetSearch = openerp.web.DataSet.extend(/** @lends openerp.web.D
init: function(parent, model, context, domain) {
this._super(parent, model, context);
this.domain = domain || [];
- this._sort = [];
this.offset = 0;
// subset records[offset:offset+limit]
// is it necessary ?
@@ -583,31 +608,6 @@ openerp.web.DataSetSearch = openerp.web.DataSet.extend(/** @lends openerp.web.D
}
return this.domain;
},
- /**
- * Reads or changes sort criteria on the dataset.
- *
- * If not provided with any argument, serializes the sort criteria to
- * an SQL-like form usable by OpenERP's ORM.
- *
- * If given a field, will set that field as first sorting criteria or,
- * if the field is already the first sorting criteria, will reverse it.
- *
- * @param {String} [field] field to sort on, reverses it (toggle from ASC to DESC) if already the main sort criteria
- * @param {Boolean} [force_reverse=false] forces inserting the field as DESC
- * @returns {String|undefined}
- */
- sort: function (field, force_reverse) {
- if (!field) {
- return openerp.web.serialize_sort(this._sort);
- }
- var reverse = force_reverse || (this._sort[0] === field);
- this._sort.splice.apply(
- this._sort, [0, this._sort.length].concat(
- _.without(this._sort, field, '-' + field)));
-
- this._sort.unshift((reverse ? '-' : '') + field);
- return undefined;
- },
unlink: function(ids, callback, error_callback) {
var self = this;
return this._super(ids, function(result) {