Closes #805, Translation shouldn't create new item in My Publications
And in download overlay, save and switch to My Library if My Publications is selected.
This commit is contained in:
parent
e3033b056e
commit
177dac3fd2
7 changed files with 92 additions and 7 deletions
|
@ -631,6 +631,15 @@ var Zotero_Browser = new function() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (libraryID === Zotero.Libraries.publicationsLibraryID) {
|
||||||
|
Zotero_Browser.progress.changeHeadline(Zotero.getString("ingester.scrapeError"));
|
||||||
|
var desc = Zotero.getString('save.error.cannotAddToMyPublications');
|
||||||
|
Zotero_Browser.progress.addDescription(desc);
|
||||||
|
Zotero_Browser.progress.show();
|
||||||
|
Zotero_Browser.progress.startCloseTimer(8000);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if(Zotero.isConnector) {
|
if(Zotero.isConnector) {
|
||||||
Zotero.Connector.callMethod("getSelectedCollection", {}, function(response, status) {
|
Zotero.Connector.callMethod("getSelectedCollection", {}, function(response, status) {
|
||||||
if(status !== 200) {
|
if(status !== 200) {
|
||||||
|
|
|
@ -64,14 +64,14 @@ var Zotero_DownloadOverlay = new function() {
|
||||||
var libraryID, collection;
|
var libraryID, collection;
|
||||||
try {
|
try {
|
||||||
let itemGroup = win.ZoteroPane.getCollectionTreeRow();
|
let itemGroup = win.ZoteroPane.getCollectionTreeRow();
|
||||||
if (itemGroup.filesEditable) {
|
if (itemGroup.filesEditable && !itemGroup.isPublications()) {
|
||||||
libraryID = win.ZoteroPane.getSelectedLibraryID();
|
libraryID = win.ZoteroPane.getSelectedLibraryID();
|
||||||
collection = win.ZoteroPane.getSelectedCollection();
|
collection = win.ZoteroPane.getSelectedCollection();
|
||||||
}
|
}
|
||||||
// TODO: Just show an error instead?
|
// TODO: Just show an error instead?
|
||||||
else {
|
else {
|
||||||
Zotero.debug("Cannot save files to library " + itemGroup.ref.libraryID
|
Zotero.debug("Cannot save files to library " + itemGroup.ref.libraryID
|
||||||
+ " -- saving to personal library instead", 2);
|
+ " -- saving to My Library instead", 2);
|
||||||
libraryID = Zotero.Libraries.userLibraryID;
|
libraryID = Zotero.Libraries.userLibraryID;
|
||||||
}
|
}
|
||||||
} catch(e) {
|
} catch(e) {
|
||||||
|
@ -98,7 +98,7 @@ var Zotero_DownloadOverlay = new function() {
|
||||||
url,
|
url,
|
||||||
collections: collection ? [collection.id] : [],
|
collections: collection ? [collection.id] : [],
|
||||||
contentType
|
contentType
|
||||||
})
|
});
|
||||||
}
|
}
|
||||||
catch (e) {
|
catch (e) {
|
||||||
if (!win) return;
|
if (!win) return;
|
||||||
|
@ -112,7 +112,11 @@ var Zotero_DownloadOverlay = new function() {
|
||||||
|
|
||||||
progressWin.addLines([item.getDisplayTitle()], [item.getImageSrc()]);
|
progressWin.addLines([item.getDisplayTitle()], [item.getImageSrc()]);
|
||||||
progressWin.startCloseTimer();
|
progressWin.startCloseTimer();
|
||||||
if(collection) collection.addItem(item.id);
|
if (collection) {
|
||||||
|
yield collection.addItem(item.id);
|
||||||
|
}
|
||||||
|
|
||||||
|
yield win.ZoteroPane.selectItem(item.id);
|
||||||
|
|
||||||
if(recognizePDF) {
|
if(recognizePDF) {
|
||||||
var timer = Components.classes["@mozilla.org/timer;1"]
|
var timer = Components.classes["@mozilla.org/timer;1"]
|
||||||
|
|
|
@ -98,6 +98,11 @@ Zotero.ProgressWindowSet = new function() {
|
||||||
_progressWindows[i].instance.startCloseTimer(null, true);
|
_progressWindows[i].instance.startCloseTimer(null, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
this.closeAll = function () {
|
||||||
|
_progressWindows.forEach(pw => pw.instance.close());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -3341,6 +3341,12 @@ var ZoteroPane = new function()
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var collectionTreeRow = this.collectionsView.getRow(row);
|
||||||
|
if (collectionTreeRow.isPublications()) {
|
||||||
|
this.displayCannotAddToMyPublicationsMessage();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
return this.addItemFromDocument(window.content.document, itemType, saveSnapshot, row);
|
return this.addItemFromDocument(window.content.document, itemType, saveSnapshot, row);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -3977,6 +3983,13 @@ var ZoteroPane = new function()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
this.displayCannotAddToMyPublicationsMessage = function () {
|
||||||
|
var ps = Components.classes["@mozilla.org/embedcomp/prompt-service;1"]
|
||||||
|
.getService(Components.interfaces.nsIPromptService);
|
||||||
|
ps.alert(null, "", Zotero.getString('save.error.cannotAddToMyPublications'));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// TODO: Figure out a functioning way to get the original path and just copy the real file
|
// TODO: Figure out a functioning way to get the original path and just copy the real file
|
||||||
this.displayCannotAddShortcutMessage = function (path) {
|
this.displayCannotAddShortcutMessage = function (path) {
|
||||||
Zotero.alert(
|
Zotero.alert(
|
||||||
|
|
|
@ -491,6 +491,7 @@ save.link = Saving Link…
|
||||||
save.link.error = An error occurred while saving this link.
|
save.link.error = An error occurred while saving this link.
|
||||||
save.error.cannotMakeChangesToCollection = You cannot make changes to the currently selected collection.
|
save.error.cannotMakeChangesToCollection = You cannot make changes to the currently selected collection.
|
||||||
save.error.cannotAddFilesToCollection = You cannot add files to the currently selected collection.
|
save.error.cannotAddFilesToCollection = You cannot add files to the currently selected collection.
|
||||||
|
save.error.cannotAddToMyPublications = You cannot save items directly to My Publications. To add items to My Publications, drag them from another library.
|
||||||
|
|
||||||
ingester.saveToZotero = Save to Zotero
|
ingester.saveToZotero = Save to Zotero
|
||||||
ingester.saveToZoteroUsing = Save to Zotero using "%S"
|
ingester.saveToZoteroUsing = Save to Zotero using "%S"
|
||||||
|
|
|
@ -127,7 +127,12 @@ function waitForDialog(onOpen, button='accept', url) {
|
||||||
failure = e;
|
failure = e;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (button != 'cancel') {
|
if (button === false) {
|
||||||
|
if (failure) {
|
||||||
|
throw failure;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (button != 'cancel') {
|
||||||
let deferred = Zotero.Promise.defer();
|
let deferred = Zotero.Promise.defer();
|
||||||
function acceptWhenEnabled() {
|
function acceptWhenEnabled() {
|
||||||
// Handle delayed buttons
|
// Handle delayed buttons
|
||||||
|
|
|
@ -2,14 +2,20 @@
|
||||||
|
|
||||||
describe("Zotero_Browser", function () {
|
describe("Zotero_Browser", function () {
|
||||||
var win;
|
var win;
|
||||||
|
|
||||||
before(function* () {
|
before(function* () {
|
||||||
win = yield loadBrowserWindow();
|
win = yield loadBrowserWindow();
|
||||||
});
|
});
|
||||||
|
|
||||||
after(function* () {
|
after(function* () {
|
||||||
win.close();
|
win.close();
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should save webpage item to current collection", function* () {
|
afterEach(function () {
|
||||||
|
Zotero.ProgressWindowSet.closeAll();
|
||||||
|
})
|
||||||
|
|
||||||
|
it("should save webpage to current collection", function* () {
|
||||||
var uri = OS.Path.join(getTestDataDirectory().path, "snapshot", "index.html");
|
var uri = OS.Path.join(getTestDataDirectory().path, "snapshot", "index.html");
|
||||||
var deferred = Zotero.Promise.defer();
|
var deferred = Zotero.Promise.defer();
|
||||||
win.addEventListener('pageshow', () => deferred.resolve());
|
win.addEventListener('pageshow', () => deferred.resolve());
|
||||||
|
@ -28,7 +34,7 @@ describe("Zotero_Browser", function () {
|
||||||
assert.isTrue(collection.hasItem(items[0].id));
|
assert.isTrue(collection.hasItem(items[0].id));
|
||||||
})
|
})
|
||||||
|
|
||||||
it("should save journalArticle to current collection", function* () {
|
it("should save journal article to current collection", function* () {
|
||||||
var uri = OS.Path.join(
|
var uri = OS.Path.join(
|
||||||
getTestDataDirectory().path, "metadata", "journalArticle-single.html"
|
getTestDataDirectory().path, "metadata", "journalArticle-single.html"
|
||||||
);
|
);
|
||||||
|
@ -48,4 +54,46 @@ describe("Zotero_Browser", function () {
|
||||||
assert.equal(Zotero.ItemTypes.getName(items[0].itemTypeID), 'journalArticle');
|
assert.equal(Zotero.ItemTypes.getName(items[0].itemTypeID), 'journalArticle');
|
||||||
assert.isTrue(collection.hasItem(items[0].id));
|
assert.isTrue(collection.hasItem(items[0].id));
|
||||||
})
|
})
|
||||||
|
|
||||||
|
it("shouldn't save webpage to My Publications", function* () {
|
||||||
|
var uri = OS.Path.join(getTestDataDirectory().path, "snapshot", "index.html");
|
||||||
|
var deferred = Zotero.Promise.defer();
|
||||||
|
win.addEventListener('pageshow', () => deferred.resolve());
|
||||||
|
win.loadURI(uri);
|
||||||
|
yield deferred.promise;
|
||||||
|
|
||||||
|
yield loadZoteroPane(win);
|
||||||
|
yield selectLibrary(win, Zotero.Libraries.publicationsLibraryID);
|
||||||
|
|
||||||
|
var promise = waitForDialog(function (dialog) {
|
||||||
|
assert.include(
|
||||||
|
dialog.document.documentElement.textContent,
|
||||||
|
Zotero.getString('save.error.cannotAddToMyPublications')
|
||||||
|
);
|
||||||
|
});
|
||||||
|
yield win.Zotero_Browser.scrapeThisPage();
|
||||||
|
yield promise;
|
||||||
|
})
|
||||||
|
|
||||||
|
it("shouldn't save journal article to My Publications", function* () {
|
||||||
|
var uri = OS.Path.join(
|
||||||
|
getTestDataDirectory().path, "metadata", "journalArticle-single.html"
|
||||||
|
);
|
||||||
|
var deferred = Zotero.Promise.defer();
|
||||||
|
win.addEventListener('pageshow', () => deferred.resolve());
|
||||||
|
win.loadURI(uri);
|
||||||
|
yield deferred.promise;
|
||||||
|
|
||||||
|
yield loadZoteroPane(win);
|
||||||
|
yield selectLibrary(win, Zotero.Libraries.publicationsLibraryID);
|
||||||
|
|
||||||
|
var promise = waitForDialog(function (dialog) {
|
||||||
|
assert.include(
|
||||||
|
dialog.document.documentElement.textContent,
|
||||||
|
Zotero.getString('save.error.cannotAddToMyPublications')
|
||||||
|
);
|
||||||
|
}, false, 'chrome://zotero/content/progressWindow.xul');
|
||||||
|
yield win.Zotero_Browser.scrapeThisPage();
|
||||||
|
yield promise;
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue