Fix saving to My Library if Zotero pane hasn't been opened
This commit is contained in:
parent
9c53fe893c
commit
23e01fcefd
|
@ -622,17 +622,19 @@ var Zotero_Browser = new function() {
|
||||||
|
|
||||||
// Get libraryID and collectionID
|
// Get libraryID and collectionID
|
||||||
if(libraryID === undefined && ZoteroPane && !Zotero.isConnector) {
|
if(libraryID === undefined && ZoteroPane && !Zotero.isConnector) {
|
||||||
try {
|
// Save to My Library by default if pane hasn't been opened
|
||||||
if (!ZoteroPane.collectionsView.editable) {
|
if (!ZoteroPane.collectionsView || !ZoteroPane.collectionsView.selectedTreeRow) {
|
||||||
Zotero_Browser.progress.cannotEditCollection();
|
libraryID = Zotero.Libraries.userLibraryID;
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
libraryID = ZoteroPane.getSelectedLibraryID();
|
|
||||||
collection = ZoteroPane.getSelectedCollection();
|
|
||||||
} catch(e) {
|
|
||||||
Zotero.debug(e, 1);
|
|
||||||
}
|
}
|
||||||
|
else if (!ZoteroPane.collectionsView.editable) {
|
||||||
|
Zotero_Browser.progress.Translation.cannotEditCollection();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
libraryID = ZoteroPane.getSelectedLibraryID();
|
||||||
|
}
|
||||||
|
|
||||||
|
collection = ZoteroPane.getSelectedCollection();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (libraryID === Zotero.Libraries.publicationsLibraryID) {
|
if (libraryID === Zotero.Libraries.publicationsLibraryID) {
|
||||||
|
|
|
@ -3484,19 +3484,21 @@ var ZoteroPane = new function()
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!row && this.collectionsView && this.collectionsView.selection) {
|
if (row == undefined && this.collectionsView && this.collectionsView.selection) {
|
||||||
row = this.collectionsView.selection.currentIndex;
|
row = this.collectionsView.selection.currentIndex;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!this.canEdit(row)) {
|
if (row !== undefined) {
|
||||||
this.displayCannotEditLibraryMessage();
|
if (!this.canEdit(row)) {
|
||||||
return false;
|
this.displayCannotEditLibraryMessage();
|
||||||
}
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
var collectionTreeRow = this.collectionsView.getRow(row);
|
var collectionTreeRow = this.collectionsView.getRow(row);
|
||||||
if (collectionTreeRow.isPublications()) {
|
if (collectionTreeRow.isPublications()) {
|
||||||
this.displayCannotAddToMyPublicationsMessage();
|
this.displayCannotAddToMyPublicationsMessage();
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return this.addItemFromDocument(window.content.document, itemType, saveSnapshot, row);
|
return this.addItemFromDocument(window.content.document, itemType, saveSnapshot, row);
|
||||||
|
|
|
@ -171,7 +171,7 @@ describe("Zotero.Attachments", function() {
|
||||||
assert.equal(attachment.getField('url'), "file://" + uri);
|
assert.equal(attachment.getField('url'), "file://" + uri);
|
||||||
|
|
||||||
// Check indexing
|
// Check indexing
|
||||||
var matches = yield Zotero.Fulltext.findTextInItems([attachment.id], 'works');
|
var matches = yield Zotero.Fulltext.findTextInItems([attachment.id], 'share your research');
|
||||||
assert.lengthOf(matches, 1);
|
assert.lengthOf(matches, 1);
|
||||||
assert.propertyVal(matches[0], 'id', attachment.id);
|
assert.propertyVal(matches[0], 'id', attachment.id);
|
||||||
})
|
})
|
||||||
|
|
|
@ -1,10 +1,11 @@
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
describe("Zotero_Browser", function () {
|
describe("Zotero_Browser", function () {
|
||||||
var win;
|
var win, collection;
|
||||||
|
|
||||||
before(function* () {
|
before(function* () {
|
||||||
win = yield loadBrowserWindow();
|
win = yield loadBrowserWindow();
|
||||||
|
collection = yield createDataObject('collection');
|
||||||
});
|
});
|
||||||
|
|
||||||
after(function* () {
|
after(function* () {
|
||||||
|
@ -15,6 +16,55 @@ describe("Zotero_Browser", function () {
|
||||||
Zotero.ProgressWindowSet.closeAll();
|
Zotero.ProgressWindowSet.closeAll();
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
|
it("should save webpage to My Library if the Zotero pane hasn't been opened yet in a Firefox window", function* () {
|
||||||
|
var win = yield loadBrowserWindow();
|
||||||
|
|
||||||
|
var uri = OS.Path.join(getTestDataDirectory().path, "snapshot", "index.html");
|
||||||
|
var deferred = Zotero.Promise.defer();
|
||||||
|
win.Zotero_Browser.addDetectCallback(() => deferred.resolve());
|
||||||
|
win.loadURI(uri);
|
||||||
|
yield deferred.promise;
|
||||||
|
|
||||||
|
var promise = waitForWindow('chrome://zotero/content/progressWindow.xul', function (progressWin) {
|
||||||
|
assert.include(
|
||||||
|
progressWin.document.documentElement.textContent,
|
||||||
|
"Test"
|
||||||
|
);
|
||||||
|
});
|
||||||
|
yield win.Zotero_Browser.scrapeThisPage();
|
||||||
|
yield promise;
|
||||||
|
|
||||||
|
win.close();
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should save journal article to My Library if the Zotero pane hasn't been opened yet in a Firefox window", function* () {
|
||||||
|
Zotero.Prefs.set('lastViewedFolder', collection.collectionTreeViewID);
|
||||||
|
|
||||||
|
var win = yield loadBrowserWindow();
|
||||||
|
|
||||||
|
var deferred = Zotero.Promise.defer();
|
||||||
|
win.Zotero_Browser.addDetectCallback(() => deferred.resolve());
|
||||||
|
var uri = OS.Path.join(
|
||||||
|
getTestDataDirectory().path, "metadata", "journalArticle-single.html"
|
||||||
|
);
|
||||||
|
win.loadURI(uri);
|
||||||
|
yield deferred.promise;
|
||||||
|
|
||||||
|
var promise1 = waitForWindow('chrome://zotero/content/progressWindow.xul', function (progressWin) {});
|
||||||
|
var promise2 = waitForItemEvent('add');
|
||||||
|
yield win.Zotero_Browser.scrapeThisPage();
|
||||||
|
yield promise1;
|
||||||
|
var ids = yield promise2;
|
||||||
|
var items = Zotero.Items.get(ids);
|
||||||
|
assert.lengthOf(items, 1);
|
||||||
|
assert.equal(items[0].libraryID, Zotero.Libraries.userLibraryID);
|
||||||
|
assert.equal(Zotero.ItemTypes.getName(items[0].itemTypeID), 'journalArticle');
|
||||||
|
assert.lengthOf(items[0].getCollections(), 0);
|
||||||
|
|
||||||
|
win.close();
|
||||||
|
});
|
||||||
|
|
||||||
it("should save webpage to current collection", function* () {
|
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();
|
||||||
|
|
|
@ -1,16 +1,10 @@
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
||||||
|
<title>Test</title>
|
||||||
|
</head>
|
||||||
<meta name="wpd_version" content="0.2">
|
<body>
|
||||||
<meta name="wpd_baseurl" content="http://209.141.35.188/">
|
<h1>Test</h1>
|
||||||
<meta name="wpd_url" content="http://209.141.35.188/">
|
<p>Zotero [zoh-TAIR-oh] is a free, easy-to-use tool to help you collect, organize, cite, and share your research sources.</p>
|
||||||
<meta name="wpd_date" content="2015-05-05T00:06Z">
|
</body>
|
||||||
</head>
|
|
||||||
<body><h1>It works!</h1>
|
|
||||||
<p>This is the default web page for this server.</p>
|
|
||||||
<p>The web server software is running but no content has been added, yet.</p>
|
|
||||||
|
|
||||||
</body>
|
|
||||||
</html>
|
</html>
|
||||||
|
|
Loading…
Reference in New Issue
Block a user