www

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | Submodules | README | LICENSE

commit 97b2aff10a4e4df40f50983ac6217146b03613ec
parent 5be1b75b2b8d97451961eb3b44f76367c836dc13
Author: Dan Stillman <dstillman@zotero.org>
Date:   Wed, 16 Sep 2009 04:12:21 +0000

Fix erroneous "You cannot add files to the currently selected library." message when trying to store a file in a group library


Diffstat:
Mchrome/content/zotero/overlay.js | 28+++++++++++++---------------
Mchrome/content/zotero/xpcom/attachments.js | 7+++++--
2 files changed, 18 insertions(+), 17 deletions(-)

diff --git a/chrome/content/zotero/overlay.js b/chrome/content/zotero/overlay.js @@ -2482,12 +2482,8 @@ var ZoteroPane = new function() return; } - // FIXME: temporarily disable file attachment options for groups - var itemGroup = this.collectionsView._getItemAtRow(this.collectionsView.selection.currentIndex); - if (itemGroup.isWithinGroup()) { - var pr = Components.classes["@mozilla.org/network/default-prompt;1"] - .getService(Components.interfaces.nsIPrompt); - pr.alert("", "Files cannot currently be added to group libraries."); + if (!this.canEditFiles()) { + this.displayCannotEditLibraryFilesMessage(); return; } @@ -2597,10 +2593,8 @@ var ZoteroPane = new function() // // - if (libraryID) { - var pr = Components.classes["@mozilla.org/network/default-prompt;1"] - .getService(Components.interfaces.nsIPrompt); - pr.alert("", "Files cannot currently be added to group libraries."); + if (!this.canEditFiles(row)) { + this.displayCannotEditLibraryFilesMessage(); return; } @@ -2611,7 +2605,7 @@ var ZoteroPane = new function() var collectionID = false; } - Zotero.Attachments.importFromDocument(doc, false, false, collectionID); + Zotero.Attachments.importFromDocument(doc, false, false, collectionID, null, libraryID); return; } } @@ -2935,10 +2929,14 @@ var ZoteroPane = new function() this.displayCannotEditLibraryMessage = function () { var pr = Components.classes["@mozilla.org/network/default-prompt;1"] .getService(Components.interfaces.nsIPrompt); - pr.alert( - Zotero.getString('general.accessDenied'), - "You cannot make changes to the currently selected library." - ); + pr.alert("", "You cannot make changes to the currently selected library."); + } + + + this.displayCannotEditLibraryFilesMessage = function () { + var pr = Components.classes["@mozilla.org/network/default-prompt;1"] + .getService(Components.interfaces.nsIPrompt); + pr.alert("", "You cannot add files to the currently selected library."); } diff --git a/chrome/content/zotero/xpcom/attachments.js b/chrome/content/zotero/xpcom/attachments.js @@ -475,7 +475,7 @@ Zotero.Attachments = new function(){ /* * Save a snapshot -- uses synchronous WebPageDump or asynchronous saveURI() */ - function importFromDocument(document, sourceItemID, forceTitle, parentCollectionIDs, callback) { + function importFromDocument(document, sourceItemID, forceTitle, parentCollectionIDs, callback, libraryID) { Zotero.debug('Importing attachment from document'); if (sourceItemID && parentCollectionIDs) { @@ -507,7 +507,10 @@ Zotero.Attachments = new function(){ try { // Create a new attachment var attachmentItem = new Zotero.Item('attachment'); - if (sourceItemID) { + if (libraryID) { + attachmentItem.libraryID = libraryID; + } + else if (sourceItemID) { var parentItem = Zotero.Items.get(sourceItemID); attachmentItem.libraryID = parentItem.libraryID; }