Commit a882ef32 authored by Tristan Cavelier's avatar Tristan Cavelier Committed by Sebastien Robin

Fix bug: sort and limit did not modify the list.

parent b0c669ec
...@@ -761,14 +761,15 @@ var JIO = ...@@ -761,14 +761,15 @@ var JIO =
} }
// check for sorting // check for sorting
if (!priv.sorted && typeof priv.job.sort !== 'undefined') { if (!priv.sorted && typeof priv.job.sort !== 'undefined') {
that.sortDocumentArray({documentarray:priv.res.return_value}); that.sortDocumentArray(priv.res.return_value);
} }
// check for limiting // check for limiting
if (!priv.limited && if (!priv.limited &&
typeof priv.job.limit !== 'undefined' && typeof priv.job.limit !== 'undefined' &&
typeof priv.job.limit.begin !== 'undefined' && typeof priv.job.limit.begin !== 'undefined' &&
typeof priv.job.limit.end !== 'undefined') { typeof priv.job.limit.end !== 'undefined') {
that.limitDocumentArray({documentarray:priv.res.return_value}); priv.res.return_value =
that.limitDocumentArray(priv.res.return_value);
} }
}; };
priv.fail_removeDocument = function () { priv.fail_removeDocument = function () {
...@@ -936,11 +937,10 @@ var JIO = ...@@ -936,11 +937,10 @@ var JIO =
/** /**
* Sorts a document list using sort parameters set in the job. * Sorts a document list using sort parameters set in the job.
* @method sortDocumentArray * @method sortDocumentArray
* @param {object} o * @param {array} documentarray The array we want to sort.
* - o.documentarray {array} the array we want to sort.
*/ */
that.sortDocumentArray = function (o) { that.sortDocumentArray = function (documentarray) {
o.documentarray.sort(function (row1,row2) { documentarray.sort(function (row1,row2) {
var k, res; var k, res;
for (k in priv.job.sort) { for (k in priv.job.sort) {
var sign = (priv.job.sort[k] === 'descending' ? -1 : 1); var sign = (priv.job.sort[k] === 'descending' ? -1 : 1);
...@@ -961,17 +961,16 @@ var JIO = ...@@ -961,17 +961,16 @@ var JIO =
}; };
/** /**
* Limits the document list. Get only the document between * Limits the document list. Clones only the document list between
* begin and end set in limit object in the job.
* @method limitDocumentArray * @method limitDocumentArray
* @param {object} o * @param {array} documentarray The array we wont to limit
* - o.documentarray {array} the array we wont to limit
* @return {array} The new document list * @return {array} The new document list
*/ */
that.limitDocumentArray = function (o) { that.limitDocumentArray = function (documentarray) {
o.documentarray = o.documentarray.slice(priv.job.limit.begin,
priv.job.limit.end);
that.limitDone(); that.limitDone();
return o.documentarray; return documentarray.slice(priv.job.limit.begin,
priv.job.limit.end);
}; };
/** /**
......
This diff is collapsed.
...@@ -758,14 +758,15 @@ var JIO = ...@@ -758,14 +758,15 @@ var JIO =
} }
// check for sorting // check for sorting
if (!priv.sorted && typeof priv.job.sort !== 'undefined') { if (!priv.sorted && typeof priv.job.sort !== 'undefined') {
that.sortDocumentArray({documentarray:priv.res.return_value}); that.sortDocumentArray(priv.res.return_value);
} }
// check for limiting // check for limiting
if (!priv.limited && if (!priv.limited &&
typeof priv.job.limit !== 'undefined' && typeof priv.job.limit !== 'undefined' &&
typeof priv.job.limit.begin !== 'undefined' && typeof priv.job.limit.begin !== 'undefined' &&
typeof priv.job.limit.end !== 'undefined') { typeof priv.job.limit.end !== 'undefined') {
that.limitDocumentArray({documentarray:priv.res.return_value}); priv.res.return_value =
that.limitDocumentArray(priv.res.return_value);
} }
}; };
priv.fail_removeDocument = function () { priv.fail_removeDocument = function () {
...@@ -933,11 +934,10 @@ var JIO = ...@@ -933,11 +934,10 @@ var JIO =
/** /**
* Sorts a document list using sort parameters set in the job. * Sorts a document list using sort parameters set in the job.
* @method sortDocumentArray * @method sortDocumentArray
* @param {object} o * @param {array} documentarray The array we want to sort.
* - o.documentarray {array} the array we want to sort.
*/ */
that.sortDocumentArray = function (o) { that.sortDocumentArray = function (documentarray) {
o.documentarray.sort(function (row1,row2) { documentarray.sort(function (row1,row2) {
var k, res; var k, res;
for (k in priv.job.sort) { for (k in priv.job.sort) {
var sign = (priv.job.sort[k] === 'descending' ? -1 : 1); var sign = (priv.job.sort[k] === 'descending' ? -1 : 1);
...@@ -958,17 +958,16 @@ var JIO = ...@@ -958,17 +958,16 @@ var JIO =
}; };
/** /**
* Limits the document list. Get only the document between * Limits the document list. Clones only the document list between
* begin and end set in limit object in the job.
* @method limitDocumentArray * @method limitDocumentArray
* @param {object} o * @param {array} documentarray The array we wont to limit
* - o.documentarray {array} the array we wont to limit
* @return {array} The new document list * @return {array} The new document list
*/ */
that.limitDocumentArray = function (o) { that.limitDocumentArray = function (documentarray) {
o.documentarray = o.documentarray.slice(priv.job.limit.begin,
priv.job.limit.end);
that.limitDone(); that.limitDone();
return o.documentarray; return documentarray.slice(priv.job.limit.begin,
priv.job.limit.end);
}; };
/** /**
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment