mirror of
https://github.com/zadam/trilium.git
synced 2025-03-01 14:22:32 +01:00
fix order by note content size, closes #3488
This commit is contained in:
parent
161b45aa12
commit
218f526a92
5
package-lock.json
generated
5
package-lock.json
generated
@ -1,12 +1,11 @@
|
|||||||
{
|
{
|
||||||
"name": "trilium",
|
"name": "trilium",
|
||||||
"version": "0.58.2-beta",
|
"version": "0.58.3-beta",
|
||||||
"lockfileVersion": 2,
|
"lockfileVersion": 2,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "trilium",
|
"version": "0.58.3-beta",
|
||||||
"version": "0.58.2-beta",
|
|
||||||
"hasInstallScript": true,
|
"hasInstallScript": true,
|
||||||
"license": "AGPL-3.0-only",
|
"license": "AGPL-3.0-only",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
@ -48,14 +48,13 @@ class OrderByAndLimitExp extends Expression {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// if both are numbers then parse them for numerical comparison
|
// if both are numbers then parse them for numerical comparison
|
||||||
// beware that isNaN will return false for empty string and null
|
if (this.isNumber(valA) && this.isNumber(valB)) {
|
||||||
if (valA.trim() !== "" && valB.trim() !== "" && !isNaN(valA) && !isNaN(valB)) {
|
|
||||||
valA = parseFloat(valA);
|
valA = parseFloat(valA);
|
||||||
valB = parseFloat(valB);
|
valB = parseFloat(valB);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!valA && !valB) {
|
if (!valA && !valB) {
|
||||||
// the attribute is not defined in either note so continue to next order definition
|
// the attribute value is empty/zero in both notes so continue to the next order definition
|
||||||
continue;
|
continue;
|
||||||
} else if (!valB || valA < valB) {
|
} else if (!valB || valA < valB) {
|
||||||
return smaller;
|
return smaller;
|
||||||
@ -77,6 +76,17 @@ class OrderByAndLimitExp extends Expression {
|
|||||||
|
|
||||||
return noteSet;
|
return noteSet;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
isNumber(x) {
|
||||||
|
if (typeof x === 'number') {
|
||||||
|
return true;
|
||||||
|
} else if (typeof x === 'string') {
|
||||||
|
// isNaN will return false for blank string
|
||||||
|
return x.trim() !== "" && !isNaN(x);
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = OrderByAndLimitExp;
|
module.exports = OrderByAndLimitExp;
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Search string is lower cased for case insensitive comparison. But when retrieving properties
|
* Search string is lower cased for case-insensitive comparison. But when retrieving properties
|
||||||
* we need case sensitive form so we have this translation object.
|
* we need case-sensitive form, so we have this translation object.
|
||||||
*/
|
*/
|
||||||
const PROP_MAPPING = {
|
const PROP_MAPPING = {
|
||||||
"noteid": "noteId",
|
"noteid": "noteId",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user