Closes #839, Sort child attachments by title

With pref sortChildAttachmentsChronologically defaulting to false
This commit is contained in:
Dan Stillman 2008-01-25 03:49:02 +00:00
parent fa298cab5b
commit aecd897ae1
3 changed files with 30 additions and 6 deletions

View File

@ -1789,9 +1789,34 @@ Zotero.Item.prototype.getAttachments = function(){
return []; return [];
} }
var sql = "SELECT itemID FROM itemAttachments NATURAL JOIN items " var sql = "SELECT A.itemID, value AS title FROM itemAttachments A "
+ "WHERE sourceItemID=" + this.getID() + " ORDER BY dateAdded"; + "NATURAL JOIN items I LEFT JOIN itemData ID USING (itemID) "
return Zotero.DB.columnQuery(sql); + "LEFT JOIN itemDataValues IDV "
+ "ON (fieldID=110 AND ID.valueID=IDV.valueID) "
+ "WHERE sourceItemID=?";
if (Zotero.Prefs.get('sortAttachmentsChronologically')) {
sql += " ORDER BY dateAdded";
return Zotero.DB.columnQuery(sql, this.getID());
}
var attachments = Zotero.DB.query(sql, this.getID());
if (!attachments) {
return false;
}
// Sort by title
var collation = Zotero.getLocaleCollation();
var f = function (a, b) {
return collation.compareString(1, a.title, b.title);
}
var attachmentIDs = [];
attachments.sort(f);
for each(var attachment in attachments) {
attachmentIDs.push(attachment.itemID);
}
return attachmentIDs;
} }
@ -3153,7 +3178,7 @@ Zotero.Notes = new function(){
/* /*
* Constructor for Collection object * Constructor for Collection object
* *
* Generally should be called from Zotero.Collection rather than directly * Generally should be called from Zotero.Collections rather than directly
*/ */
Zotero.Collection = function(){ Zotero.Collection = function(){
this._init(); this._init();

View File

@ -1597,8 +1597,6 @@ Zotero.Date = new function(){
/** /**
* Figure out the date order from the output of toLocaleDateString() * Figure out the date order from the output of toLocaleDateString()
* *
* Note: Currently unused
*
* Returns a string with y, m, and d (e.g. 'ymd', 'mdy') * Returns a string with y, m, and d (e.g. 'ymd', 'mdy')
*/ */
function getLocaleDateOrder(){ function getLocaleDateOrder(){

View File

@ -27,6 +27,7 @@ pref("extensions.zotero.attachmentRenameFormatString", '{%c - }{%y - }{%t{50}}')
pref("extensions.zotero.capitalizeTitles", true); pref("extensions.zotero.capitalizeTitles", true);
pref("extensions.zotero.launchNonNativeFiles", false); pref("extensions.zotero.launchNonNativeFiles", false);
pref("extensions.zotero.sortNotesChronologically", false); pref("extensions.zotero.sortNotesChronologically", false);
pref("extensions.zotero.sortAttachmentsChronologically", false);
pref("extensions.zotero.lastCreatorFieldMode",0); pref("extensions.zotero.lastCreatorFieldMode",0);
pref("extensions.zotero.lastAbstractExpand",0); pref("extensions.zotero.lastAbstractExpand",0);