From fe31d4c7896c51f5db58b88c140039bc6df4e400 Mon Sep 17 00:00:00 2001 From: Dan Stillman Date: Mon, 16 Apr 2007 22:06:49 +0000 Subject: [PATCH] - Fixed tag selector still displaying all tags for collections and saved searches - Added asTempTable parameter to Zotero.Search.search() to save results to a temporary table -- avoids large inserts with post-search filters - Added proper collation sort support for tags --- chrome/content/zotero/xpcom/data_access.js | 106 ++++++++++---------- chrome/content/zotero/xpcom/itemTreeView.js | 6 +- chrome/content/zotero/xpcom/search.js | 95 ++++++++++++------ chrome/content/zotero/xpcom/zotero.js | 10 ++ 4 files changed, 127 insertions(+), 90 deletions(-) diff --git a/chrome/content/zotero/xpcom/data_access.js b/chrome/content/zotero/xpcom/data_access.js index 8e1c88d43..16bff5205 100644 --- a/chrome/content/zotero/xpcom/data_access.js +++ b/chrome/content/zotero/xpcom/data_access.js @@ -1780,9 +1780,18 @@ Zotero.Item.prototype.getTags = function(){ return false; } var sql = "SELECT tagID AS id, tag, tagType AS type FROM tags WHERE tagID IN " - + "(SELECT tagID FROM itemTags WHERE itemID=" + this.getID() + ") " - + "ORDER BY tag COLLATE NOCASE"; - return Zotero.DB.query(sql); + + "(SELECT tagID FROM itemTags WHERE itemID=" + this.getID() + ")"; + + var tags = Zotero.DB.query(sql); + if (!tags) { + return false; + } + + var collation = Zotero.getLocaleCollation(); + tags.sort(function(a, b) { + return collation.compareString(0, a.tag, b.tag); + }); + return tags; } Zotero.Item.prototype.getTagIDs = function(){ @@ -3635,13 +3644,21 @@ Zotero.Tags = new function(){ if (types) { sql += "WHERE tagType IN (" + types.join() + ") "; } - sql += "ORDER BY tag COLLATE NOCASE"; var tags = Zotero.DB.query(sql); + if (!tags) { + return {}; + } + + var collation = Zotero.getLocaleCollation(); + tags.sort(function(a, b) { + return collation.compareString(0, a.tag, b.tag); + }); + var indexed = {}; - for each(var tag in tags) { - indexed[tag.tagID] = { - tag: tag.tag, - type: tag.tagType + for (var i=0; i