Adjustments to citation retraction warning (#1704)

- Fix don't-show-again checkbox for non-DB items
- Tweak warning text
- Don't show comma after year if year is missing (which it shouldn't be)
- Remove redundant try/catch
This commit is contained in:
Dan Stillman 2019-06-12 23:43:48 -04:00
parent 4337362a1b
commit 45f6492494
2 changed files with 12 additions and 14 deletions

View file

@ -971,7 +971,7 @@ Zotero.Integration.Fields.prototype.updateSession = Zotero.Promise.coroutine(fun
yield this._session.handleRetractedItems();
}
catch (e) {
Zotero.debug('Retracted item handling failed');
Zotero.debug('Retracted item handling failed', 2);
Zotero.logError(e);
}
this._session.regenAll = false;
@ -1939,7 +1939,8 @@ Zotero.Integration.Session.prototype.handleRetractedItems = async function () {
const dealWithRetracted = (citedItem, inLibrary) => {
let dontPromptAgain = this.promptForRetraction(citedItem, inLibrary);
if (dontPromptAgain) {
for (let citation of this.citationsByItemID[citedItem.id]) {
let itemID = citedItem.id || citedItem.cslItemID;
for (let citation of this.citationsByItemID[itemID]) {
for (let item of citation.citationItems) {
item.ignoreRetraction = true;
}
@ -1961,13 +1962,9 @@ Zotero.Integration.Session.prototype.handleRetractedItems = async function () {
}
}
}
try {
var retractedIndices = await Zotero.Retractions.getRetractionsFromJSON(
embeddedZoteroItems.map(item => item.toJSON()));
} catch (e) {
Zotero.debug("Retraction for embedded docs lookup failed");
Zotero.logError(e);
}
var retractedIndices = await Zotero.Retractions.getRetractionsFromJSON(
embeddedZoteroItems.map(item => item.toJSON())
);
for (let index of retractedIndices) {
dealWithRetracted(embeddedZoteroItems[index]);
}
@ -1978,10 +1975,11 @@ Zotero.Integration.Session.prototype.promptForRetraction = function (citedItem,
let buttonFlags = (ps.BUTTON_POS_0) * (ps.BUTTON_TITLE_OK);
// Cannot use citedItem.firstCreator since embedded items do not have that
let creator = citedItem.getCreator(0);
let year = citedItem.getField('year');
let itemString = (creator ? creator.lastName + ", " : "")
+ citedItem.getField('year') + ", "
+ (year ? year + ", " : "")
+ citedItem.getDisplayTitle();
let promptText = Zotero.getString('retraction.citedItemWarning')
let promptText = Zotero.getString('retraction.citationWarning')
+ "\n\n"
+ itemString;
if (inLibrary) {
@ -1993,7 +1991,7 @@ Zotero.Integration.Session.prototype.promptForRetraction = function (citedItem,
promptText,
buttonFlags,
null, null, null,
Zotero.getString('retraction.citedItemWarning.dontWarn'), checkbox);
Zotero.getString('retraction.citationWarning.dontWarn'), checkbox);
return checkbox.value;
}

View file

@ -1211,5 +1211,5 @@ retraction.details = More details:
retraction.credit = Data from %S
retraction.citeWarning.text1 = The item you are citing has been retracted. Do you still want to add it to your document?
retraction.citeWarning.text2 = You can view the item in your library for further details on the retraction.
retraction.citedItemWarning = A cited item in your document has been retracted:
retraction.citedItemWarning.dontWarn = Dont warn me about this item again
retraction.citationWarning = A citation in your document has been retracted:
retraction.citationWarning.dontWarn = Dont warn me about this citation again