From 024b428fe6320e4ba064dd967b704277849d2f89 Mon Sep 17 00:00:00 2001 From: Dan Stillman Date: Tue, 5 Jun 2018 19:54:46 -0400 Subject: [PATCH] =?UTF-8?q?Mendeley=20import:=20Add=20"Other=E2=80=A6"=20b?= =?UTF-8?q?utton=20for=20selecting=20another=20DB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit E.g., for selecting a DB from a backup Addresses #1451 --- chrome/content/zotero/import/importWizard.js | 28 +++++++++++++++++-- chrome/content/zotero/import/importWizard.xul | 3 ++ chrome/locale/en-US/zotero/zotero.dtd | 1 + chrome/skin/default/zotero/importWizard.css | 5 +++- 4 files changed, 34 insertions(+), 3 deletions(-) diff --git a/chrome/content/zotero/import/importWizard.js b/chrome/content/zotero/import/importWizard.js index cd45adcb2c..c7331d44fa 100644 --- a/chrome/content/zotero/import/importWizard.js +++ b/chrome/content/zotero/import/importWizard.js @@ -57,14 +57,38 @@ var Zotero_Import_Wizard = { }, + /** + * When a file is clicked on in the file list + */ onFileSelected: async function () { this._wizard.canAdvance = true; }, + /** + * When the user clicks "Other…" to choose a file not in the list + */ + chooseMendeleyDB: async function () { + const nsIFilePicker = Components.interfaces.nsIFilePicker; + var fp = Components.classes["@mozilla.org/filepicker;1"] + .createInstance(nsIFilePicker); + fp.init(window, Zotero.getString('fileInterface.import'), nsIFilePicker.modeOpen); + fp.appendFilter("Mendeley Database", "*.sqlite"); // TODO: Localize + var rv = fp.show(); + if (rv != nsIFilePicker.returnOK) { + return false; + } + this._file = fp.file.path; + this._wizard.canAdvance = true; + this._wizard.advance(); + }, + + onFileChosen: async function () { - var index = document.getElementById('file-list').selectedIndex; - this._file = this._dbs[index].path; + if (!this._file) { + let index = document.getElementById('file-list').selectedIndex; + this._file = this._dbs[index].path; + } this._disableCancel(); this._wizard.canRewind = false; this._wizard.canAdvance = false; diff --git a/chrome/content/zotero/import/importWizard.xul b/chrome/content/zotero/import/importWizard.xul index 6e6da62dfc..f907303651 100644 --- a/chrome/content/zotero/import/importWizard.xul +++ b/chrome/content/zotero/import/importWizard.xul @@ -42,6 +42,9 @@ + +