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"
This commit is contained in:
Dan Stillman 2022-12-17 02:27:28 -07:00 committed by Tom Najdek
parent e10fc538d0
commit a6a69605c6
No known key found for this signature in database
GPG key ID: EEC61A7B4C667D77
8 changed files with 39 additions and 6 deletions

View file

@ -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) {

View file

@ -56,6 +56,7 @@
>
<div class="options-group" id="page-options-relink-only">
<checkbox id="relink-only-checkbox" data-l10n-id="import-online-relink-only" />
<html:a data-l10n-id="import-online-relink-kb" href="https://www.zotero.org/support/kb/mendeley_import#using_mendeley_citations" />
</div>
<div class="options-group" id="page-options-common">
<checkbox native="true" id="create-collection" data-l10n-id="import-create-collection" />

View file

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

View file

@ -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 {

View file

@ -15,6 +15,7 @@
<!ENTITY zotero.general.advancedOptions.label "Advanced Options">
<!ENTITY zotero.general.tools "Tools">
<!ENTITY zotero.general.more "More">
<!ENTITY zotero.general.moreInformation "More Information">
<!ENTITY zotero.general.loading "Loading…">
<!ENTITY zotero.general.close "Close">
<!ENTITY zotero.general.minimize "Minimize">

View file

@ -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 <a data-l10n-name="mendeley-import-kb">How do I import a Mendeley library into Zotero?</a> 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…

View file

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

View file

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