Addresses #672, allow child items to exist in collections by themselves for sorting and outlines
- Makes sort=note work as expected when combineChildItems is disabled - Fix for standalone notes and attachments not displaying when combineChildItems is disabled
This commit is contained in:
parent
cc0583bc5f
commit
ee23bb6bcb
|
@ -154,8 +154,8 @@ function ChromeExtensionHandler() {
|
||||||
// items were selected
|
// items were selected
|
||||||
includeAllChildItems = false;
|
includeAllChildItems = false;
|
||||||
}
|
}
|
||||||
// If combining children, add matching parents
|
// If combining children or standalone note/attachment, add matching parents
|
||||||
else if (combineChildItems) {
|
else if (combineChildItems || !results[i].isRegularItem()) {
|
||||||
itemsHash[results[i].getID()] = items.length;
|
itemsHash[results[i].getID()] = items.length;
|
||||||
items.push(results[i].toArray(2));
|
items.push(results[i].toArray(2));
|
||||||
// Flag item as a search match
|
// Flag item as a search match
|
||||||
|
@ -290,10 +290,45 @@ function ChromeExtensionHandler() {
|
||||||
|
|
||||||
// Multidimensional sort
|
// Multidimensional sort
|
||||||
do {
|
do {
|
||||||
var cmp = collation.compareString(0,
|
// Note and attachment sorting when combineChildItems is false
|
||||||
a[sorts[index].field],
|
if (!combineChildItems && sorts[index].field == 'note') {
|
||||||
b[sorts[index].field]
|
if (a.itemType == 'note' || a.itemType == 'attachment') {
|
||||||
);
|
var valA = a.note;
|
||||||
|
}
|
||||||
|
else if (a.reportChildren) {
|
||||||
|
var valA = a.reportChildren.notes[0].note;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
var valA = '';
|
||||||
|
}
|
||||||
|
|
||||||
|
if (b.itemType == 'note' || b.itemType == 'attachment') {
|
||||||
|
var valB = b.note;
|
||||||
|
}
|
||||||
|
else if (b.reportChildren) {
|
||||||
|
var valB = b.reportChildren.notes[0].note;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
var valB = '';
|
||||||
|
}
|
||||||
|
|
||||||
|
// Put items without notes last
|
||||||
|
if (valA == '' && valB != '') {
|
||||||
|
var cmp = 1;
|
||||||
|
}
|
||||||
|
else if (valA != '' && valB == '') {
|
||||||
|
var cmp = -1;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
var cmp = collation.compareString(0, valA, valB);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
var cmp = collation.compareString(0,
|
||||||
|
a[sorts[index].field],
|
||||||
|
b[sorts[index].field]
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
if (cmp == 0) {
|
if (cmp == 0) {
|
||||||
continue;
|
continue;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user