From a6a69605c65744dd81e2f8a806e2e35361a5ae1f Mon Sep 17 00:00:00 2001 From: Dan Stillman Date: Sat, 17 Dec 2022 02:27:28 -0700 Subject: [PATCH] Mendeley citation relinking tweaks - Show "More information" link next to relink option - Automatically check relink option when coming from integration prompt - Change done message to "[x] items were relinked" instead of "0 items were imported" --- chrome/content/zotero/import/importWizard.js | 16 ++++++++++++---- chrome/content/zotero/import/importWizard.xhtml | 1 + .../zotero/import/mendeley/mendeleyImport.js | 4 +++- chrome/content/zotero/xpcom/integration.js | 9 ++++++++- chrome/locale/en-US/zotero/zotero.dtd | 1 + chrome/locale/en-US/zotero/zotero.ftl | 5 +++++ chrome/locale/en-US/zotero/zotero.properties | 1 + scss/components/_import-wizard.scss | 8 ++++++++ 8 files changed, 39 insertions(+), 6 deletions(-) diff --git a/chrome/content/zotero/import/importWizard.js b/chrome/content/zotero/import/importWizard.js index 482bc31232..dbf7c2d9cd 100644 --- a/chrome/content/zotero/import/importWizard.js +++ b/chrome/content/zotero/import/importWizard.js @@ -61,7 +61,7 @@ const Zotero_Import_Wizard = { // eslint-disable-line no-unused-vars }, async init() { - const { mendeleyCode, libraryID, pageID } = window.arguments[0].wrappedJSObject ?? {}; + const { mendeleyCode, libraryID, pageID, relinkOnly } = window.arguments[0].wrappedJSObject ?? {}; this.libraryID = libraryID; @@ -97,10 +97,10 @@ const Zotero_Import_Wizard = { // eslint-disable-line no-unused-vars document.getElementById('import-other').checked = ev.currentTarget.value.length > 0; }); document - .querySelector('#page-done-error-mendeley > a') + .querySelector('a') .addEventListener('click', this.onURLInteract.bind(this)); document - .querySelector('#page-done-error-mendeley > a') + .querySelector('a') .addEventListener('keydown', this.onURLInteract.bind(this)); document .querySelector('#page-done-error > button') @@ -125,6 +125,11 @@ const Zotero_Import_Wizard = { // eslint-disable-line no-unused-vars this.wizard.shadowRoot .querySelector('.wizard-header-label').style.fontSize = '16px'; + if (relinkOnly) { + document.getElementById('relink-only-checkbox').checked = true; + this.onRelinkOnlyChange(); + } + if (pageID) { this.wizard.goTo(pageID); } @@ -437,9 +442,12 @@ const Zotero_Import_Wizard = { // eslint-disable-line no-unused-vars } const numItems = this.translation.newItems.length; + const numRelinked = this.translation.numRelinked; this.skipToDonePage( 'file-interface-import-complete', - ['file-interface-items-were-imported', { numItems }] + document.getElementById('relink-only-checkbox').checked + ? ['file-interface-items-were-relinked', { numRelinked }] + : ['file-interface-items-were-imported', { numItems }] ); } catch (e) { diff --git a/chrome/content/zotero/import/importWizard.xhtml b/chrome/content/zotero/import/importWizard.xhtml index 836bd172e9..1bd9bf12e1 100644 --- a/chrome/content/zotero/import/importWizard.xhtml +++ b/chrome/content/zotero/import/importWizard.xhtml @@ -56,6 +56,7 @@ >
diff --git a/chrome/content/zotero/import/mendeley/mendeleyImport.js b/chrome/content/zotero/import/mendeley/mendeleyImport.js index 4703808de2..90f93822e1 100644 --- a/chrome/content/zotero/import/mendeley/mendeleyImport.js +++ b/chrome/content/zotero/import/mendeley/mendeleyImport.js @@ -33,6 +33,7 @@ var Zotero_Import_Mendeley = function () { this.mendeleyAuth = null; this.newItemsOnly = false; this.relinkOnly = false; + this.numRelinked = 0; this._tokens = null; this._db = null; @@ -1319,6 +1320,7 @@ Zotero_Import_Mendeley.prototype._saveItems = async function (libraryID, json) { // Update any child items to point to the existing item's key instead of the // new generated one this._updateParentKeys('item', json, i + 1, itemJSON.key, item.key); + this.numRelinked++; // Leave item in any collections it's in itemJSON.collections = item.getCollections() @@ -1337,7 +1339,7 @@ Zotero_Import_Mendeley.prototype._saveItems = async function (libraryID, json) { } } - if(this.relinkOnly && !isMappedToExisting) { + if (this.relinkOnly && !isMappedToExisting) { continue; } diff --git a/chrome/content/zotero/xpcom/integration.js b/chrome/content/zotero/xpcom/integration.js index c3561710d3..5096004c3e 100644 --- a/chrome/content/zotero/xpcom/integration.js +++ b/chrome/content/zotero/xpcom/integration.js @@ -2680,7 +2680,14 @@ Zotero.Integration.URIMap.prototype.getZoteroItemForURIs = async function (uris) checkbox }); if (result === 0) { - setTimeout(() => Zotero.getMainWindow().Zotero_File_Interface.showImportWizard({ pageID: 'page-mendeley-online-intro' })); + setTimeout( + () => Zotero.getMainWindow().Zotero_File_Interface.showImportWizard( + { + pageID: 'page-mendeley-online-intro', + relinkOnly: true + } + ) + ); throw new Zotero.Exception.UserCancelled("Importing mendeley citations"); } else { diff --git a/chrome/locale/en-US/zotero/zotero.dtd b/chrome/locale/en-US/zotero/zotero.dtd index 5b18a80968..9d3f4563a0 100644 --- a/chrome/locale/en-US/zotero/zotero.dtd +++ b/chrome/locale/en-US/zotero/zotero.dtd @@ -15,6 +15,7 @@ + diff --git a/chrome/locale/en-US/zotero/zotero.ftl b/chrome/locale/en-US/zotero/zotero.ftl index e5b6130670..8340988b4a 100644 --- a/chrome/locale/en-US/zotero/zotero.ftl +++ b/chrome/locale/en-US/zotero/zotero.ftl @@ -50,6 +50,10 @@ file-interface-items-were-imported = { $numItems -> [one] item was imported *[other] { $numItems } items were imported } +file-interface-items-were-relinked = { $numRelinked -> + [one] item was relinked + *[other] { $numRelinked } items were relinked + } import-mendeley-encrypted = The selected Mendeley database cannot be read, likely because it is encrypted. See How do I import a Mendeley library into Zotero? for more information. @@ -63,6 +67,7 @@ import-online-wrong-credentials = Login to { $targetApp } failed. Please re-ente import-online-blocked-by-plugin = The import cannot continue with { $plugin } installed. Please disable this plugin and try again. import-online-relink-only = .label = Relink Mendeley Desktop citations +import-online-relink-kb = More Information report-error = .label = Report Error… diff --git a/chrome/locale/en-US/zotero/zotero.properties b/chrome/locale/en-US/zotero/zotero.properties index 7cbe8ec7ac..2e721cb08f 100644 --- a/chrome/locale/en-US/zotero/zotero.properties +++ b/chrome/locale/en-US/zotero/zotero.properties @@ -799,6 +799,7 @@ dragAndDrop.filesNotFound = The following files were not found and could not be fileInterface.importing = Importing… fileInterface.importComplete = Import Complete fileInterface.itemsWereImported = %1$S item was imported;%1$S items were imported +fileInterface.itemsWereRelinked = %1$S item was relinked;%1$S items were relinked fileInterface.itemsExported = Exporting items… fileInterface.import = Import fileInterface.chooseAppDatabaseToImport = Choose the %S database to import diff --git a/scss/components/_import-wizard.scss b/scss/components/_import-wizard.scss index 13f9466082..4f883669e2 100644 --- a/scss/components/_import-wizard.scss +++ b/scss/components/_import-wizard.scss @@ -92,6 +92,14 @@ } } + #page-options-relink-only { + display: flex; + + a { + margin: 4px 1em 4px; + } + } + .page-options-file-handling-description { margin-top: .6em; font-size: 11px;