Add a prompt to import Mendeley DB if mendeley citation found in doc

This commit is contained in:
Adomas Venčkauskas 2022-12-14 16:20:04 +02:00 committed by Dan Stillman
parent dcd6cdbcb3
commit 2082b68dd3
5 changed files with 45 additions and 4 deletions

View file

@ -49,6 +49,10 @@ var Zotero_Import_Wizard = {
document.getElementById('create-collection-checkbox').removeAttribute('checked');
}
}
if (args && args.pageID) {
this._wizard.goTo(args.pageID);
}
if (args && args.mendeleyCode && Zotero.Prefs.get("import.mendeleyUseOAuth")) {
this._mendeleyCode = args.mendeleyCode;

View file

@ -2632,11 +2632,42 @@ Zotero.Integration.URIMap.prototype.getZoteroItemForURIs = async function (uris)
replacer = await Zotero.Relations.getByPredicateAndObject(
'item', 'mendeleyDB:documentUUID', m[1]
);
if (replacer.length && !replacer[0].deleted) {
zoteroItem = replacer[0];
break;
if (replacer.length) {
if (!replacer[0].deleted) {
zoteroItem = replacer[0];
break;
}
}
}
// If not blocked by user having pressed skip in this session,
// or user having checked the checkbox to not be prompted about this,
// or user having imported their library with the new version of importer
else if (!(this.session.dontPromptForMendeley
|| Zotero.Prefs.get('integration.dontPromptMendeleyImport')
|| await Zotero.DB.valueQueryAsync("SELECT value FROM settings WHERE setting='mendeleyImport' AND key='version'")
)) {
// Prompt user to (re)import their mendeley database which might make us recognize
// these items
let checkbox = {};
let result = Zotero.Prompt.confirm({
title: Zotero.getString('integration.mendeleyImport.title'),
text: Zotero.getString('integration.mendeleyImport.description', [Zotero.appName]),
button0: Zotero.getString('integration.mendeleyImport.openImporter'),
button1: Zotero.getString('general.skip'),
checkLabel: Zotero.getString('general.dontAskAgain'),
checkbox
});
if (result === 0) {
setTimeout(() => Zotero.getMainWindow().Zotero_File_Interface.showImportWizard({ pageID: 'mendeley-online-explanation' }));
throw new Zotero.Exception.UserCancelled("Importing mendeley citations");
}
else {
this.session.dontPromptForMendeley = true;
}
if (checkbox.value) {
Zotero.Prefs.set('integration.dontPromptMendeleyImport', true);
}
}
};
}

View file

@ -74,6 +74,7 @@ general.tryLater = Try Later
general.showDirectory = Show Directory
general.showInLibrary = Show in Library
general.continue = Continue
general.skip = Skip
general.copy = Copy
general.copyToClipboard = Copy to Clipboard
general.cancel = Cancel
@ -990,6 +991,9 @@ integration.exportDocument.description1 = Zotero will convert citations in the d
integration.exportDocument.description2 = You should make a backup of the document before proceeding.
integration.importInstructions = The Zotero citations in this document have been converted to a format that can be safely transferred between word processors. Open this document in a supported word processor and press Refresh in the Zotero plugin to continue working with the citations.
integration.upgradeTemplate = The %S plugin for %S is outdated. Reinstall the plugin from Preferences → Cite → Word Processors.
integration.mendeleyImport.title = Missing Mendeley Data
integration.mendeleyImport.description = %1$S detected that the document you are citing with contains Mendeley citations. %1$S will be able to manage these citations if you import your Mendeley database.
integration.mendeleyImport.openImporter = Open Mendeley Importer...
styles.install.title = Install Style
styles.install.unexpectedError = An unexpected error occurred while installing "%1$S"

View file

@ -53,6 +53,7 @@ const xpcomFilesAll = [
'mimeTypeHandler',
'pdfWorker/manager',
'ipc',
'prompt',
'profile',
'progressWindow',
'proxy',

View file

@ -137,6 +137,7 @@ pref("extensions.zotero.integration.autoRegenerate", -1); // -1 = ask; 0 = no; 1
pref("extensions.zotero.integration.useClassicAddCitationDialog", false);
pref("extensions.zotero.integration.keepAddCitationDialogRaised", false);
pref("extensions.zotero.integration.upgradeTemplateDelayedOn", 0);
pref("extensions.zotero.integration.dontPromptMendeleyImport", false);
// Connector settings
pref("extensions.zotero.httpServer.enabled", false); // TODO enabled for testing only