Sort child notes alphabetically
This commit is contained in:
parent
54c0fbdd16
commit
e18cdcc4a7
|
@ -1356,9 +1356,29 @@ Zotero.Item.prototype.getNotes = function(){
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
|
|
||||||
var sql = "SELECT itemID FROM itemNotes NATURAL JOIN items "
|
// DEBUG: Not just using itemNoteTitles just in case something went wrong
|
||||||
+ "WHERE sourceItemID=" + this.getID() + " ORDER BY dateAdded";
|
// during migration and there's no titles row
|
||||||
return Zotero.DB.columnQuery(sql);
|
//
|
||||||
|
// TODO: move titles into itemNotes table
|
||||||
|
var sql = "SELECT N.itemID, title FROM itemNotes N NATURAL JOIN items "
|
||||||
|
+ "LEFT JOIN itemNoteTitles USING (itemID) WHERE sourceItemID=" + this.getID();
|
||||||
|
var notes = Zotero.DB.query(sql);
|
||||||
|
if (!notes) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Sort by title
|
||||||
|
var collation = Zotero.getLocaleCollation();
|
||||||
|
var f = function (a, b) {
|
||||||
|
return collation.compareString(1, a.title, b.title);
|
||||||
|
}
|
||||||
|
|
||||||
|
var noteIDs = [];
|
||||||
|
notes.sort(f);
|
||||||
|
for each(var note in notes) {
|
||||||
|
noteIDs.push(note.itemID);
|
||||||
|
}
|
||||||
|
return noteIDs;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -362,7 +362,7 @@ Zotero.ItemTreeView.prototype.notify = function(action, type, ids)
|
||||||
sort = ids[i];
|
sort = ids[i];
|
||||||
}
|
}
|
||||||
// If not moved from under one item to another
|
// If not moved from under one item to another
|
||||||
else if (parentIndex == -1 || !sourceItemID) {
|
else if (!(sourceItemID && parentIndex != -1 && this._itemRowMap[sourceItemID] != parentIndex)) {
|
||||||
sort = ids[i];
|
sort = ids[i];
|
||||||
}
|
}
|
||||||
madeChanges = true;
|
madeChanges = true;
|
||||||
|
@ -738,6 +738,14 @@ Zotero.ItemTreeView.prototype.sort = function(itemID)
|
||||||
this._needsSort = false;
|
this._needsSort = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Single child item sort -- just toggle parent open and closed
|
||||||
|
if (itemID && this._getItemAtRow(this._itemRowMap[itemID]).ref.getSource()) {
|
||||||
|
var parentIndex = this.getParentIndex(this._itemRowMap[itemID]);
|
||||||
|
this.toggleOpenState(parentIndex);
|
||||||
|
this.toggleOpenState(parentIndex);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
var columnField = this.getSortField();
|
var columnField = this.getSortField();
|
||||||
var order = this.getSortDirection() == 'ascending';
|
var order = this.getSortDirection() == 'ascending';
|
||||||
|
|
||||||
|
@ -930,9 +938,9 @@ Zotero.ItemTreeView.prototype.sort = function(itemID)
|
||||||
this._refreshHashMap();
|
this._refreshHashMap();
|
||||||
|
|
||||||
// Reopen closed containers
|
// Reopen closed containers
|
||||||
for(var i = 0; i < openRows.length; i++)
|
for (var i = 0; i < openRows.length; i++) {
|
||||||
this.toggleOpenState(this._itemRowMap[openRows[i]]);
|
this.toggleOpenState(this._itemRowMap[openRows[i]]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
Loading…
Reference in New Issue
Block a user