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 Dan Stillman
parent 91c385a67a
commit 7262465109
6 changed files with 29 additions and 3 deletions

View file

@ -86,6 +86,11 @@ var Zotero_Import_Wizard = {
document.getElementById('mendeley-password').addEventListener('keyup', this.onMendeleyAuthKeyUp.bind(this));
document.getElementById('relink-only-checkbox').addEventListener('command', this.onRelinkOnlyChange.bind(this));
// Set from integration.js prompt
if (args && args.relinkOnly) {
document.getElementById('relink-only-checkbox').checked = true;
this.onRelinkOnlyChange();
}
Zotero.Translators.init(); // async
},
@ -284,6 +289,10 @@ var Zotero_Import_Wizard = {
const hideExtraMendeleyOptions = !this._mendeleyHasPreviouslyImported || !(this._mendeleyAuth || this._mendeleyCode);
document.getElementById('mendeley-options').hidden = hideExtraMendeleyOptions;
document.getElementById('relink-only-wrapper').hidden = hideExtraMendeleyOptions || this._mendeleyImporterVersion > 0;
document.getElementById('relink-only-more-info').addEventListener('click', function () {
Zotero.launchURL('https://www.zotero.org/support/kb/mendeley_import#using_mendeley_citations');
window.close();
});
if (hideExtraMendeleyOptions) {
document.getElementById('new-items-only-checkbox').removeAttribute('checked');
}
@ -340,9 +349,12 @@ var Zotero_Import_Wizard = {
}
let numItems = this._translation.newItems.length;
let numRelinked = this._translation.numRelinked;
this._onDone(
Zotero.getString('fileInterface.importComplete'),
Zotero.getString(`fileInterface.itemsWereImported`, numItems, numItems)
document.getElementById('relink-only-checkbox').checked
? Zotero.getString(`fileInterface.itemsWereRelinked`, numRelinked, numRelinked)
: Zotero.getString(`fileInterface.itemsWereImported`, numItems, numItems)
);
}
catch (e) {

View file

@ -80,7 +80,10 @@
onpageadvanced="Zotero_Import_Wizard.onImportStart()">
<vbox id="relink-only-wrapper">
<checkbox id="relink-only-checkbox" label="&zotero.import.online.relinkOnly;" />
<hbox align="center">
<checkbox id="relink-only-checkbox" label="&zotero.import.online.relinkOnly;" />
<label id="relink-only-more-info" class="zotero-text-link" value="&zotero.general.moreInformation;"/>
</hbox>
</vbox>
<checkbox id="create-collection-checkbox" label="&zotero.import.createCollection;" checked="true" />

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()

View file

@ -2658,7 +2658,14 @@ Zotero.Integration.URIMap.prototype.getZoteroItemForURIs = async function (uris)
checkbox
});
if (result === 0) {
setTimeout(() => Zotero.getMainWindow().Zotero_File_Interface.showImportWizard({ pageID: 'mendeley-online-explanation' }));
setTimeout(
() => Zotero.getMainWindow().Zotero_File_Interface.showImportWizard(
{
pageID: 'mendeley-online-explanation',
relinkOnly: true
}
)
);
throw new Zotero.Exception.UserCancelled("Importing mendeley citations");
}
else if (result == 1) {

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

@ -784,6 +784,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