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.
This commit is contained in:
Dan Stillman 2018-06-08 02:44:13 -04:00
parent 2b49e94a61
commit 7494e4d88c
2 changed files with 20 additions and 4 deletions

View file

@ -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);
};

View file

@ -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
},