From 00efd01aafaedc3ec1edefc1cda32ade9b39eb62 Mon Sep 17 00:00:00 2001 From: Martynas Bagdonas Date: Thu, 19 Apr 2018 11:35:03 +0300 Subject: [PATCH] Ask for description when reporting metadata (#1488) --- chrome/content/zotero/xpcom/recognizePDF.js | 4 +-- chrome/content/zotero/zoteroPane.js | 28 ++++++++++---------- chrome/locale/en-US/zotero/zotero.properties | 2 ++ 3 files changed, 18 insertions(+), 16 deletions(-) diff --git a/chrome/content/zotero/xpcom/recognizePDF.js b/chrome/content/zotero/xpcom/recognizePDF.js index 6bf80cab3..2f8674496 100644 --- a/chrome/content/zotero/xpcom/recognizePDF.js +++ b/chrome/content/zotero/xpcom/recognizePDF.js @@ -186,7 +186,7 @@ Zotero.RecognizePDF = new function () { }; - this.report = async function (item) { + this.report = async function (item, description) { var attachment = Zotero.Items.get(item.getAttachments()[0]); var filePath = attachment.getFilePath(); if (!filePath || !await OS.File.exists(filePath)) { @@ -197,7 +197,7 @@ Zotero.RecognizePDF = new function () { var json = await extractJSON(filePath, MAX_PAGES); var metadata = item.toJSON(); - var data = { version, json, metadata }; + var data = { description, version, json, metadata }; var uri = ZOTERO_CONFIG.RECOGNIZE_URL + 'report'; return Zotero.HTTP.request( "POST", diff --git a/chrome/content/zotero/zoteroPane.js b/chrome/content/zotero/zoteroPane.js index f555dc3c5..e06d5ff08 100644 --- a/chrome/content/zotero/zoteroPane.js +++ b/chrome/content/zotero/zoteroPane.js @@ -4600,27 +4600,27 @@ var ZoteroPane = new function() this.reportMetadataForSelected = async function () { - var success = false; - var items = ZoteroPane.getSelectedItems(); - for (let item of items) { - try { - await Zotero.RecognizePDF.report(item); - // If at least one report was submitted, show as success - success = true; - } - catch (e) { - Zotero.logError(e); - } - } + let items = ZoteroPane.getSelectedItems(); + if(!items.length) return; - if (success) { + let input = {value: ''}; + Services.prompt.prompt( + null, + Zotero.getString('recognizePDF.reportMetadata'), + Zotero.getString('general.describeProblem'), + input, null, {} + ); + + try { + await Zotero.RecognizePDF.report(items[0], input.value); Zotero.alert( window, Zotero.getString('general.submitted'), Zotero.getString('general.thanksForHelpingImprove', Zotero.clientName) ); } - else { + catch (e) { + Zotero.logError(e); Zotero.alert( window, Zotero.getString('general.error'), diff --git a/chrome/locale/en-US/zotero/zotero.properties b/chrome/locale/en-US/zotero/zotero.properties index 75f3821fa..bfbe3ec44 100644 --- a/chrome/locale/en-US/zotero/zotero.properties +++ b/chrome/locale/en-US/zotero/zotero.properties @@ -68,6 +68,7 @@ general.clear = Clear general.processing = Processing general.submitted = Submitted general.thanksForHelpingImprove = Thanks for helping to improve %S! +general.describeProblem = Briefly describe the problem: general.operationInProgress = A Zotero operation is currently in progress. general.operationInProgress.waitUntilFinished = Please wait until it has finished. @@ -1065,6 +1066,7 @@ recognizePDF.fileNotFound = File not found recognizePDF.error = An unexpected error occurred recognizePDF.recognizing.label = Retrieving Metadata… recognizePDF.complete.label = Metadata Retrieval Complete +recognizePDF.reportMetadata = Report Incorrect Metadata rtfScan.openTitle = Select a file to scan rtfScan.scanning.label = Scanning RTF Document…