Modify sort in ModelTree

This commit is contained in:
Ludovic Stephan 2017-03-16 01:21:18 -03:00
parent 3d76079439
commit 770c185bd0

View file

@ -165,24 +165,11 @@ class ModelObject {
/**
* Returns a string value for the model, to use in comparisons
* @see {@link Models.ModelObject.compare|ModelObject.compare}
* @see {@link Models.TreeNode.compare|TreeNode.compare}
*/
comparevalue() {
return this.id.toString();
}
/**
* Compare function between two instances of the model
* by serializing them using comparevalue().
* @abstract
* @param {a} Models.ModelObject
* @param {b} Models.ModelObject
* @see {@link Models.ModelObject.comparevalue|ModelObject.comparevalue}
*/
static compare(a, b) {
return a.comparevalue().localeCompare(b.comparevalue());
}
}
@ -552,7 +539,7 @@ class Article extends ModelObject {
* @see {@link Models.ModelObject.compare|ModelObject.compare}
*/
comparevalue() {
return a.name;
return this.name;
}
// Take care of 'price' type
@ -574,6 +561,13 @@ class TreeNode {
this.parent = null;
this.children = [];
}
static compare(a, b) {
var a_serial = a.content.comparevalue();
var b_serial = b.content.comparevalue();
return a_serial.localeCompare(b_serial)
}
}