forked from DGNum/gestioCOF
Modify sort in ModelTree
This commit is contained in:
parent
3d76079439
commit
770c185bd0
1 changed files with 9 additions and 15 deletions
|
@ -165,24 +165,11 @@ class ModelObject {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a string value for the model, to use in comparisons
|
* 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() {
|
comparevalue() {
|
||||||
return this.id.toString();
|
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}
|
* @see {@link Models.ModelObject.compare|ModelObject.compare}
|
||||||
*/
|
*/
|
||||||
comparevalue() {
|
comparevalue() {
|
||||||
return a.name;
|
return this.name;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Take care of 'price' type
|
// Take care of 'price' type
|
||||||
|
@ -574,6 +561,13 @@ class TreeNode {
|
||||||
this.parent = null;
|
this.parent = null;
|
||||||
this.children = [];
|
this.children = [];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static compare(a, b) {
|
||||||
|
var a_serial = a.content.comparevalue();
|
||||||
|
var b_serial = b.content.comparevalue();
|
||||||
|
|
||||||
|
return a_serial.localeCompare(b_serial)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue