Prevent items in group libraries from being added to My Publications
And remove existing group items that have been added
This commit is contained in:
parent
3561864542
commit
2eef1702e0
5 changed files with 35 additions and 24 deletions
|
@ -1639,6 +1639,14 @@ Zotero.CollectionTreeView.prototype.canDropCheck = function (row, orient, dataTr
|
||||||
Zotero.debug("FeedItems cannot be added to My Publications");
|
Zotero.debug("FeedItems cannot be added to My Publications");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
if (item.inPublications) {
|
||||||
|
Zotero.debug("Item " + item.id + " already exists in My Publications");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (treeRow.ref.libraryID != item.libraryID) {
|
||||||
|
Zotero.debug("Cross-library drag to My Publications not allowed");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
skip = false;
|
skip = false;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -1662,10 +1670,14 @@ Zotero.CollectionTreeView.prototype.canDropCheck = function (row, orient, dataTr
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Allow drags to collections. Item collection membership is an asynchronous
|
// Make sure there's at least one item that's not already in this destination
|
||||||
// check, so we do that on drop()
|
|
||||||
if (treeRow.isCollection()) {
|
if (treeRow.isCollection()) {
|
||||||
|
if (treeRow.ref.hasItem(item.id)) {
|
||||||
|
Zotero.debug("Item " + item.id + " already exists in collection");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
skip = false;
|
skip = false;
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (skip) {
|
if (skip) {
|
||||||
|
@ -1785,27 +1797,10 @@ Zotero.CollectionTreeView.prototype.canDropCheckAsync = Zotero.Promise.coroutine
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Intra-library drag
|
// Intra-library drags have already been vetted by canDrop(). This 'break' should be
|
||||||
|
// changed to a 'continue' if any asynchronous checks that stop the drag are added above
|
||||||
// Make sure there's at least one item that's not already in this destination
|
|
||||||
if (treeRow.isCollection()) {
|
|
||||||
if (treeRow.ref.hasItem(item.id)) {
|
|
||||||
Zotero.debug("Item " + item.id + " already exists in collection");
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
skip = false;
|
skip = false;
|
||||||
continue;
|
break;
|
||||||
}
|
|
||||||
|
|
||||||
// Make sure there's at least one item that's not already in My Publications
|
|
||||||
if (treeRow.isPublications()) {
|
|
||||||
if (item.inPublications) {
|
|
||||||
Zotero.debug("Item " + item.id + " already exists in My Publications");
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
skip = false;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if (skip) {
|
if (skip) {
|
||||||
Zotero.debug("Drag skipped");
|
Zotero.debug("Drag skipped");
|
||||||
|
|
|
@ -1519,6 +1519,9 @@ Zotero.Item.prototype._saveData = Zotero.Promise.coroutine(function* (env) {
|
||||||
if (this.isAttachment() && this.attachmentLinkMode == Zotero.Attachments.LINK_MODE_LINKED_FILE) {
|
if (this.isAttachment() && this.attachmentLinkMode == Zotero.Attachments.LINK_MODE_LINKED_FILE) {
|
||||||
throw new Error("Linked-file attachments cannot be added to My Publications");
|
throw new Error("Linked-file attachments cannot be added to My Publications");
|
||||||
}
|
}
|
||||||
|
if (Zotero.Libraries.get(this.libraryID).libraryType != 'user') {
|
||||||
|
throw new Error("Only items in user libraries can be added to My Publications");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Trashed status
|
// Trashed status
|
||||||
|
|
|
@ -2416,6 +2416,10 @@ Zotero.Schema = new function(){
|
||||||
}
|
}
|
||||||
yield Zotero.DB.queryAsync("DELETE FROM publicationsItems WHERE itemID IN (SELECT itemID FROM items JOIN itemAttachments USING (itemID) WHERE linkMode=2)");
|
yield Zotero.DB.queryAsync("DELETE FROM publicationsItems WHERE itemID IN (SELECT itemID FROM items JOIN itemAttachments USING (itemID) WHERE linkMode=2)");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
else if (i == 95) {
|
||||||
|
yield Zotero.DB.queryAsync("DELETE FROM publicationsItems WHERE itemID NOT IN (SELECT itemID FROM items WHERE libraryID=1)");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
yield _updateDBVersion('userdata', toVersion);
|
yield _updateDBVersion('userdata', toVersion);
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
-- 94
|
-- 95
|
||||||
|
|
||||||
-- Copyright (c) 2009 Center for History and New Media
|
-- Copyright (c) 2009 Center for History and New Media
|
||||||
-- George Mason University, Fairfax, Virginia, USA
|
-- George Mason University, Fairfax, Virginia, USA
|
||||||
|
|
|
@ -376,6 +376,15 @@ describe("Zotero.Item", function () {
|
||||||
assert.ok(e);
|
assert.ok(e);
|
||||||
assert.include(e.message, "Linked-file attachments cannot be added to My Publications");
|
assert.include(e.message, "Linked-file attachments cannot be added to My Publications");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("should be invalid for group library items", function* () {
|
||||||
|
var group = yield getGroup();
|
||||||
|
var item = yield createDataObject('item', { libraryID: group.libraryID });
|
||||||
|
item.inPublications = true;
|
||||||
|
var e = yield getPromiseError(item.saveTx());
|
||||||
|
assert.ok(e);
|
||||||
|
assert.equal(e.message, "Only items in user libraries can be added to My Publications");
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("#parentID", function () {
|
describe("#parentID", function () {
|
||||||
|
|
Loading…
Reference in a new issue