commit 417335baf2cf1b5bafbcbb6e3db7658e65739973
parent d50b6667f0201dac0a46b8ef4ea4c50828b49d5b
Author: Dan Stillman <dstillman@zotero.org>
Date: Tue, 17 Mar 2015 00:04:41 -0400
Some libraryID follow-ups
Diffstat:
2 files changed, 14 insertions(+), 30 deletions(-)
diff --git a/chrome/content/zotero/xpcom/api.js b/chrome/content/zotero/xpcom/api.js
@@ -146,9 +146,16 @@ Zotero.API = {
getLibraryPrefix: function (libraryID) {
- return libraryID
- ? 'groups/' + Zotero.Groups.getGroupIDFromLibraryID(libraryID)
- : 'library';
+ switch (Zotero.Libraries.getType(libraryID)) {
+ case 'user':
+ return 'library';
+
+ case 'publications':
+ return 'publications';
+
+ case 'groups':
+ return 'groups/' + Zotero.Groups.getGroupIDFromLibraryID(libraryID);
+ }
}
};
diff --git a/chrome/content/zotero/zoteroPane.js b/chrome/content/zotero/zoteroPane.js
@@ -1155,13 +1155,7 @@ var ZoteroPane = new function()
// editability of the library
if (collectionTreeRow.isTrash() &&
disableIfNoEdit[i] == 'cmd_zotero_newCollection') {
- if (collectionTreeRow.ref.libraryID) {
- var overrideEditable =
- Zotero.Libraries.isEditable(collectionTreeRow.ref.libraryID);
- }
- else {
- var overrideEditable = true;
- }
+ var overrideEditable = Zotero.Libraries.isEditable(collectionTreeRow.ref.libraryID);
}
else {
var overrideEditable = false;
@@ -3360,14 +3354,7 @@ var ZoteroPane = new function()
}
itemType = Zotero.ItemTypes.getID(itemType);
var item = yield this.newItem(itemType, data, row);
-
- if (item.libraryID) {
- var group = Zotero.Groups.getByLibraryID(item.libraryID);
- var filesEditable = group.filesEditable;
- }
- else {
- var filesEditable = true;
- }
+ var filesEditable = Zotero.Libraries.isFilesEditable(item.libraryID);
if (saveSnapshot) {
var link = false;
@@ -3481,13 +3468,7 @@ var ZoteroPane = new function()
}
var item = yield ZoteroPane_Local.newItem(itemType, {}, row)
- if (item.libraryID) {
- var group = Zotero.Groups.getByLibraryID(item.libraryID);
- filesEditable = group.filesEditable;
- }
- else {
- filesEditable = true;
- }
+ var filesEditable = Zotero.Libraries.isFilesEditable(item.libraryID);
// Save snapshot if explicitly enabled or automatically pref is set and not explicitly disabled
if (saveSnapshot || (saveSnapshot !== false && Zotero.Prefs.get('automaticSnapshots'))) {
@@ -3816,11 +3797,7 @@ var ZoteroPane = new function()
}
var collectionTreeRow = this.collectionsView.getRow(row);
- // TODO: isEditable for user library should just return true
- if (collectionTreeRow.ref.libraryID) {
- return Zotero.Libraries.isEditable(collectionTreeRow.ref.libraryID);
- }
- return true;
+ return Zotero.Libraries.isEditable(collectionTreeRow.ref.libraryID);
}