Fix merging of group attachments with annotations created by another user
https://forums.zotero.org/discussion/106197/merge-in-group-library-fails-despite-having-edit-permissions
This commit is contained in:
parent
e5d25f3d66
commit
d7449b4d78
2 changed files with 34 additions and 5 deletions
|
@ -946,10 +946,12 @@ Zotero.Items = function() {
|
||||||
*
|
*
|
||||||
* @param {Zotero.Item} fromItem
|
* @param {Zotero.Item} fromItem
|
||||||
* @param {Zotero.Item} toItem
|
* @param {Zotero.Item} toItem
|
||||||
* @param {Boolean} includeTrashed
|
* @param {Object} options
|
||||||
|
* @param {Boolean} [includeTrashed=false]
|
||||||
|
* @param {Boolean} [skipEditCheck=false]
|
||||||
* @return {Promise}
|
* @return {Promise}
|
||||||
*/
|
*/
|
||||||
this.moveChildItems = async function (fromItem, toItem, includeTrashed = false) {
|
this.moveChildItems = async function (fromItem, toItem, { includeTrashed = false, skipEditCheck = false } = {}) {
|
||||||
Zotero.DB.requireTransaction();
|
Zotero.DB.requireTransaction();
|
||||||
|
|
||||||
// Annotations on files
|
// Annotations on files
|
||||||
|
@ -961,7 +963,7 @@ Zotero.Items = function() {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
annotation.parentItemID = toItem.id;
|
annotation.parentItemID = toItem.id;
|
||||||
await annotation.save();
|
await annotation.save({ skipEditCheck });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1071,7 +1073,14 @@ Zotero.Items = function() {
|
||||||
let doMerge = async (fromAttachment, toAttachment) => {
|
let doMerge = async (fromAttachment, toAttachment) => {
|
||||||
mergedMasterAttachments.add(toAttachment.id);
|
mergedMasterAttachments.add(toAttachment.id);
|
||||||
|
|
||||||
await this.moveChildItems(fromAttachment, toAttachment, true);
|
await this.moveChildItems(
|
||||||
|
fromAttachment,
|
||||||
|
toAttachment,
|
||||||
|
{
|
||||||
|
includeTrashed: true,
|
||||||
|
skipEditCheck: true
|
||||||
|
}
|
||||||
|
);
|
||||||
await this._moveEmbeddedNote(fromAttachment, toAttachment);
|
await this._moveEmbeddedNote(fromAttachment, toAttachment);
|
||||||
await this._moveRelations(fromAttachment, toAttachment);
|
await this._moveRelations(fromAttachment, toAttachment);
|
||||||
|
|
||||||
|
|
|
@ -628,7 +628,27 @@ describe("Zotero.Items", function () {
|
||||||
assert.notInclude(annotation2Note.getNote(), attachment2.key);
|
assert.notInclude(annotation2Note.getNote(), attachment2.key);
|
||||||
assert.include(annotation2Note.getNote(), attachment1.key);
|
assert.include(annotation2Note.getNote(), attachment1.key);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("should merge attachments in group library with annotation created by another user", async function () {
|
||||||
|
var otherUserID = 92624235;
|
||||||
|
await Zotero.Users.setName(otherUserID, 'merged-annotation-user');
|
||||||
|
|
||||||
|
let group = await createGroup();
|
||||||
|
let item1 = await createDataObject('item', { libraryID: group.libraryID });
|
||||||
|
let attachment1 = await importPDFAttachment(item1);
|
||||||
|
let annotation1 = await createAnnotation('note', attachment1);
|
||||||
|
|
||||||
|
let item2 = item1.clone();
|
||||||
|
await item2.saveTx();
|
||||||
|
let attachment2 = await importPDFAttachment(item2);
|
||||||
|
let annotation2 = await createAnnotation('highlight', attachment2, { createdByUserID: otherUserID });
|
||||||
|
|
||||||
|
await Zotero.Items.merge(item1, [item2]);
|
||||||
|
|
||||||
|
assert.equal(annotation2.parentItemID, attachment1.id);
|
||||||
|
assert.equal(annotation2.createdByUserID, otherUserID);
|
||||||
|
});
|
||||||
|
|
||||||
it("should update all item keys when moving notes", async function () {
|
it("should update all item keys when moving notes", async function () {
|
||||||
let attachmentFilenames = [
|
let attachmentFilenames = [
|
||||||
'recognizePDF_test_arXiv.pdf',
|
'recognizePDF_test_arXiv.pdf',
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue