commit 7494e4d88cac80d0c9daed49a0e11c3fe9d29c7d
parent 2b49e94a617e31a5f3c98884f1da552d7aa073f0
Author: Dan Stillman <dstillman@zotero.org>
Date: Fri, 8 Jun 2018 02:44:13 -0400
Don't create import collection by default if no collections in library
If the selected library doesn't have collections, "Place imported
collections and items into new collection" will be unchecked in the
import wizard.
Diffstat:
2 files changed, 20 insertions(+), 4 deletions(-)
diff --git a/chrome/content/zotero/fileInterface.js b/chrome/content/zotero/fileInterface.js
@@ -271,14 +271,21 @@ var Zotero_File_Interface = new function() {
this.showImportWizard = function () {
+ var libraryID = Zotero.Libraries.userLibraryID;
try {
- let win = Services.ww.openWindow(null, "chrome://zotero/content/import/importWizard.xul",
- "importFile", "chrome,dialog=yes,centerscreen,width=600,height=400", null);
+ let zp = Zotero.getActiveZoteroPane();
+ libraryID = zp.getSelectedLibraryID();
}
catch (e) {
- Zotero.debug(e, 1);
- throw e;
+ Zotero.logError(e);
}
+ var args = {
+ libraryID
+ };
+ args.wrappedJSObject = args;
+
+ Services.ww.openWindow(null, "chrome://zotero/content/import/importWizard.xul",
+ "importFile", "chrome,dialog=yes,centerscreen,width=600,height=400", args);
};
diff --git a/chrome/content/zotero/import/importWizard.js b/chrome/content/zotero/import/importWizard.js
@@ -13,6 +13,15 @@ var Zotero_Import_Wizard = {
document.getElementById('radio-import-source-mendeley').hidden = false;
}
+ // If no existing collections in the library, don't create a new collection by default
+ var args = window.arguments[0].wrappedJSObject;
+ if (args && args.libraryID) {
+ let sql = "SELECT ROWID FROM collections WHERE libraryID=? LIMIT 1";
+ if (!await Zotero.DB.valueQueryAsync(sql, args.libraryID)) {
+ document.getElementById('create-collection-checkbox').removeAttribute('checked');
+ }
+ }
+
Zotero.Translators.init(); // async
},