Disallow inPublications for linked-file attachments
This commit is contained in:
parent
d715197b2f
commit
9bd01af2a5
2 changed files with 20 additions and 3 deletions
|
@ -1513,9 +1513,14 @@ Zotero.Item.prototype._saveData = Zotero.Promise.coroutine(function* (env) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this._inPublications && !this.isRegularItem() && !parentItemID) {
|
if (this._inPublications) {
|
||||||
|
if (!this.isRegularItem() && !parentItemID) {
|
||||||
throw new Error("Top-level attachments and notes cannot be added to My Publications");
|
throw new Error("Top-level attachments and notes cannot be added to My Publications");
|
||||||
}
|
}
|
||||||
|
if (this.isAttachment() && this.attachmentLinkMode == Zotero.Attachments.LINK_MODE_LINKED_FILE) {
|
||||||
|
throw new Error("Linked-file attachments cannot be added to My Publications");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Trashed status
|
// Trashed status
|
||||||
if (this._changed.deleted) {
|
if (this._changed.deleted) {
|
||||||
|
|
|
@ -363,7 +363,19 @@ describe("Zotero.Item", function () {
|
||||||
"SELECT COUNT(*) FROM publicationsItems WHERE itemID=?", item.id)),
|
"SELECT COUNT(*) FROM publicationsItems WHERE itemID=?", item.id)),
|
||||||
0
|
0
|
||||||
);
|
);
|
||||||
})
|
});
|
||||||
|
|
||||||
|
it("should be invalid for linked-file attachments", function* () {
|
||||||
|
var item = yield createDataObject('item', { inPublications: true });
|
||||||
|
var attachment = yield Zotero.Attachments.linkFromFile({
|
||||||
|
file: OS.Path.join(getTestDataDirectory().path, 'test.png'),
|
||||||
|
parentItemID: item.id
|
||||||
|
});
|
||||||
|
attachment.inPublications = true;
|
||||||
|
var e = yield getPromiseError(attachment.saveTx());
|
||||||
|
assert.ok(e);
|
||||||
|
assert.include(e.message, "Linked-file attachments cannot be added to My Publications");
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("#parentID", function () {
|
describe("#parentID", function () {
|
||||||
|
|
Loading…
Reference in a new issue