Retracted item citation warning changes

Allows the user to suppress the item retraction warnings from the
citation dialog and makes the retraction warning suppression global.
See #1710
This commit is contained in:
Adomas Venčkauskas 2019-07-03 15:18:39 +03:00
parent 0f9b073073
commit 9efd7cc07d
3 changed files with 63 additions and 44 deletions

View file

@ -604,28 +604,33 @@ var Zotero_Citation_Dialog = new function () {
if (io.citation.citationItems.length) {
for (let item of io.citation.citationItems) {
if (Zotero.Retractions.isRetracted({id: parseInt(item.id)})) {
var ps = Services.prompt;
var buttonFlags = ps.BUTTON_POS_0 * ps.BUTTON_TITLE_IS_STRING
+ ps.BUTTON_POS_1 * ps.BUTTON_TITLE_CANCEL
+ ps.BUTTON_POS_2 * ps.BUTTON_TITLE_IS_STRING;
var result = ps.confirmEx(null,
Zotero.getString('general.warning'),
Zotero.getString('retraction.citeWarning.text1') + '\n\n'
+ Zotero.getString('retraction.citeWarning.text2'),
buttonFlags,
Zotero.getString('general.continue'),
null,
Zotero.getString('pane.items.showItemInLibrary'),
null, {});
if (result > 0) {
if (result == 2) {
_showItemInLibrary(parseInt(item.id));
if (Zotero.Retractions.isRetracted({ id: parseInt(item.id) })) {
if (Zotero.Retractions.shouldShowCitationWarning({ id: parseInt(item.id) })) {
var ps = Services.prompt;
var buttonFlags = ps.BUTTON_POS_0 * ps.BUTTON_TITLE_IS_STRING
+ ps.BUTTON_POS_1 * ps.BUTTON_TITLE_CANCEL
+ ps.BUTTON_POS_2 * ps.BUTTON_TITLE_IS_STRING;
var checkbox = { value: false };
var result = ps.confirmEx(null,
Zotero.getString('general.warning'),
Zotero.getString('retraction.citeWarning.text1') + '\n\n'
+ Zotero.getString('retraction.citeWarning.text2'),
buttonFlags,
Zotero.getString('general.continue'),
null,
Zotero.getString('pane.items.showItemInLibrary'),
Zotero.getString('retraction.citationWarning.dontWarn'), checkbox);
if (result > 0) {
if (result == 2) {
_showItemInLibrary(parseInt(item.id));
}
return false;
}
return false;
if (checkbox.value) {
Zotero.Retractions.disableCitationWarningsForItem({ id: parseInt(item.id) });
}
item.ignoreRetraction = true;
}
item.ignoreRetraction = true;
break;
}
}
}

View file

@ -721,28 +721,39 @@ var Zotero_QuickFormat = new function () {
citationItem.uris = item.cslURIs;
citationItem.itemData = item.cslItemData;
}
else if (Zotero.Retractions.isRetracted({id: parseInt(citationItem.id)})) {
referencePanel.hidden = true;
var ps = Services.prompt;
var buttonFlags = ps.BUTTON_POS_0 * ps.BUTTON_TITLE_IS_STRING
+ ps.BUTTON_POS_1 * ps.BUTTON_TITLE_CANCEL
+ ps.BUTTON_POS_2 * ps.BUTTON_TITLE_IS_STRING;
var result = ps.confirmEx(null,
Zotero.getString('general.warning'),
Zotero.getString('retraction.citeWarning.text1') + '\n\n'
+ Zotero.getString('retraction.citeWarning.text2'),
buttonFlags,
Zotero.getString('general.continue'),
null,
Zotero.getString('pane.items.showItemInLibrary'),
null, {});
referencePanel.hidden = false;
if (result > 0) {
if (result == 2) {
Zotero_QuickFormat.showInLibrary(parseInt(citationItem.id));
else if (Zotero.Retractions.isRetracted({ id: parseInt(citationItem.id) })) {
citationItem.id = parseInt(citationItem.id);
if (Zotero.Retractions.shouldShowCitationWarning(citationItem)) {
referencePanel.hidden = true;
var ps = Services.prompt;
var buttonFlags = ps.BUTTON_POS_0 * ps.BUTTON_TITLE_IS_STRING
+ ps.BUTTON_POS_1 * ps.BUTTON_TITLE_CANCEL
+ ps.BUTTON_POS_2 * ps.BUTTON_TITLE_IS_STRING;
var checkbox = { value: false };
var result = ps.confirmEx(null,
Zotero.getString('general.warning'),
Zotero.getString('retraction.citeWarning.text1') + '\n\n'
+ Zotero.getString('retraction.citeWarning.text2'),
buttonFlags,
Zotero.getString('general.continue'),
null,
Zotero.getString('pane.items.showItemInLibrary'),
Zotero.getString('retraction.citationWarning.dontWarn'), checkbox);
referencePanel.hidden = false;
if (result > 0) {
if (result == 2) {
Zotero_QuickFormat.showInLibrary(parseInt(citationItem.id));
}
return false;
}
return false;
} else {
else {
if (checkbox.value) {
Zotero.Retractions.disableCitationWarningsForItem(citationItem);
}
citationItem.ignoreRetraction = true;
}
}
else {
citationItem.ignoreRetraction = true;
}
}

View file

@ -1145,7 +1145,7 @@ Zotero.Integration.Fields.prototype._updateDocument = async function(forceCitati
// If we're looking to reset the text even if it matches previous text (i.e. style change)
if (forceCitations == FORCE_CITATIONS_RESET_TEXT
// Or metadata has changed thus changing the formatted citation
|| ((citation.properties.formattedCitation !== formattedCitation
|| ((formattedCitation && citation.properties.formattedCitation !== formattedCitation
// Or plaintext has changed and user does not want to keep the change
|| plaintextChanged) && !citation.properties.dontUpdate)) {
@ -1944,6 +1944,9 @@ Zotero.Integration.Session.prototype.handleRetractedItems = async function () {
const dealWithRetracted = (citedItem, inLibrary) => {
let dontPromptAgain = this.promptForRetraction(citedItem, inLibrary);
if (dontPromptAgain) {
if (citedItem.id) {
Zotero.Retractions.disableCitationWarningsForItem(citedItem);
}
let itemID = citedItem.id || citedItem.cslItemID;
for (let citation of this.citationsByItemID[itemID]) {
for (let item of citation.citationItems) {
@ -1970,9 +1973,9 @@ Zotero.Integration.Session.prototype.handleRetractedItems = async function () {
}
}
}
var retractedIndices = await Zotero.Retractions.getRetractionsFromJSON(
var retractedIndices = await Promise.race(Zotero.Retractions.getRetractionsFromJSON(
embeddedZoteroItems.map(item => item.toJSON())
);
), Zotero.Promise.delay(1000).then(() => []));
for (let index of retractedIndices) {
dealWithRetracted(embeddedZoteroItems[index]);
}