Retraction improvements
- Fix list download logic - Close bar when clicking "View Item" - Don't show "Move to Trash" if item isn't editable - Download new list if cached version differs from client - Reduce height of notification bar - Switch to a slightly darker red
This commit is contained in:
parent
75b38caf6f
commit
47164edea6
6 changed files with 39 additions and 22 deletions
|
@ -2392,7 +2392,7 @@
|
|||
= Zotero.getString('retraction.banner');
|
||||
|
||||
var deleteButton = this._id('retraction-header-delete-button');
|
||||
if (!this.item.deleted) {
|
||||
if (!this.item.deleted && this.item.editable) {
|
||||
deleteButton.hidden = false;
|
||||
deleteButton.textContent = Zotero.getString('pane.items.trash.title');
|
||||
deleteButton.onclick = function () {
|
||||
|
@ -2400,7 +2400,6 @@
|
|||
this.item.saveTx();
|
||||
}.bind(this);
|
||||
}
|
||||
// Already in trash
|
||||
else {
|
||||
deleteButton.hidden = true;
|
||||
}
|
||||
|
|
|
@ -28,9 +28,11 @@ Zotero.Retractions = {
|
|||
TYPE_PMID: 'p',
|
||||
TYPE_NAMES: ['DOI', 'PMID'],
|
||||
|
||||
_initialized: false,
|
||||
_version: 1,
|
||||
|
||||
_cacheFile: null,
|
||||
_cacheVersion: null,
|
||||
_cacheETag: null,
|
||||
_cacheDOIPrefixLength: null,
|
||||
_cachePMIDPrefixLength: null,
|
||||
|
@ -63,10 +65,12 @@ Zotero.Retractions = {
|
|||
var itemIDs = await Zotero.DB.columnQueryAsync("SELECT itemID FROM retractedItems");
|
||||
this._retractedItems = new Set(itemIDs);
|
||||
|
||||
// TEMP
|
||||
Zotero.Schema.schemaUpdatePromise.then(() => {
|
||||
this.updateFromServer();
|
||||
});
|
||||
this._initialized = true;
|
||||
|
||||
// If no cache file or it was created with a different version, download list at startup
|
||||
if (!this._cacheETag || this._cacheVersion != this._version) {
|
||||
Zotero.Schema.schemaUpdatePromise.then(() => this.updateFromServer());
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
|
@ -203,7 +207,11 @@ Zotero.Retractions = {
|
|||
}
|
||||
}, 1000),
|
||||
|
||||
updateFromServer: async function () {
|
||||
updateFromServer: Zotero.serial(async function () {
|
||||
if (!this._initialized) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Download list
|
||||
var headers = {};
|
||||
if (this._cacheETag) {
|
||||
|
@ -240,11 +248,11 @@ Zotero.Retractions = {
|
|||
}
|
||||
}
|
||||
|
||||
// Get possible local matches
|
||||
// Get all keys and compute prefixes to check for possible matches
|
||||
var prefixStrings = new Set([
|
||||
...Object.keys(this._keyItems[this.TYPE_DOI])
|
||||
...Array.from(this._keyItems[this.TYPE_DOI].keys())
|
||||
.map(x => this.TYPE_DOI + x.substr(0, doiPrefixLength)),
|
||||
...Object.keys(this._keyItems[this.TYPE_PMID])
|
||||
...Array.from(this._keyItems[this.TYPE_PMID].keys())
|
||||
.map(x => this.TYPE_PMID + x.substr(0, pmidPrefixLength))
|
||||
]);
|
||||
var prefixesToSend = new Set();
|
||||
|
@ -272,8 +280,8 @@ Zotero.Retractions = {
|
|||
// TODO: Diff list
|
||||
|
||||
await this._downloadPossibleMatches([...prefixesToSend]);
|
||||
await this._cacheList(list, etag, doiPrefixLength, pmidPrefixLength);
|
||||
},
|
||||
await this._saveCacheFile(list, etag, doiPrefixLength, pmidPrefixLength);
|
||||
}),
|
||||
|
||||
/**
|
||||
* @return {Number[]} - Array of added item ids
|
||||
|
@ -298,7 +306,9 @@ Zotero.Retractions = {
|
|||
let ids = this._keyItems[this.TYPE_DOI].get(row.doi);
|
||||
if (ids) {
|
||||
for (let id of ids) {
|
||||
addedItemIDs.add(id);
|
||||
if (!this._retractedItems.has(id)) {
|
||||
addedItemIDs.add(id);
|
||||
}
|
||||
await this._addEntry(id, row);
|
||||
}
|
||||
}
|
||||
|
@ -307,7 +317,9 @@ Zotero.Retractions = {
|
|||
let ids = this._keyItems[this.TYPE_PMID].get(row.pmid.toString());
|
||||
if (ids) {
|
||||
for (let id of ids) {
|
||||
addedItemIDs.add(id);
|
||||
if (!this._retractedItems.has(id)) {
|
||||
addedItemIDs.add(id);
|
||||
}
|
||||
await this._addEntry(id, row);
|
||||
}
|
||||
}
|
||||
|
@ -537,6 +549,7 @@ Zotero.Retractions = {
|
|||
},
|
||||
|
||||
_processCacheData: function (data) {
|
||||
this._cacheVersion = data.version;
|
||||
this._cacheETag = data.etag;
|
||||
this._cacheDOIPrefixLength = data.doiPrefixLength;
|
||||
this._cachePMIDPrefixLength = data.pmidPrefixLength;
|
||||
|
|
|
@ -1127,7 +1127,12 @@ Zotero.Schema = new function(){
|
|||
yield Zotero.DB.waitForTransaction();
|
||||
}
|
||||
|
||||
yield Zotero.Retractions.updateFromServer();
|
||||
try {
|
||||
yield Zotero.Retractions.updateFromServer();
|
||||
}
|
||||
catch (e) {
|
||||
Zotero.logError(e);
|
||||
}
|
||||
|
||||
// Get the last timestamp we got from the server
|
||||
var lastUpdated = yield this.getDBVersion('repository');
|
||||
|
|
|
@ -4767,6 +4767,7 @@ var ZoteroPane = new function()
|
|||
// Pick the first item we find in the current library, or just pick one at random
|
||||
var item = items.find(item => item.libraryID == libraryID) || items[0];
|
||||
this.selectItem(item.id);
|
||||
this.hideRetractionBanner();
|
||||
}.bind(this);
|
||||
|
||||
close.onclick = function () {
|
||||
|
|
|
@ -50,7 +50,7 @@
|
|||
justify-content: space-between;
|
||||
align-items: center;
|
||||
padding: 1.5em 1em;
|
||||
background: #ea3232;
|
||||
background: #d93425;
|
||||
color: white;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
|
|
@ -732,11 +732,11 @@
|
|||
#retracted-items-banner {
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
background: #ea3232;
|
||||
line-height: 2.5em;
|
||||
background: #d93425;
|
||||
line-height: 2.2em;
|
||||
font-weight: bold;
|
||||
color: white;
|
||||
font-size: 16px;
|
||||
font-size: 13.5px;
|
||||
text-align: center;
|
||||
padding: 0 2em;
|
||||
position: relative;
|
||||
|
@ -759,10 +759,9 @@
|
|||
#retracted-items-close {
|
||||
position: absolute;
|
||||
cursor: pointer;
|
||||
top: 3px;
|
||||
top: -2px;
|
||||
right: 9px;
|
||||
font-size: 28px;
|
||||
line-height: 28px;
|
||||
font-size: 22px;
|
||||
}
|
||||
|
||||
/* BEGIN 2X BLOCK -- DO NOT EDIT MANUALLY -- USE 2XIZE */
|
||||
|
|
Loading…
Reference in a new issue