Preserve explicit annotation author name when copying from group
This commit is contained in:
parent
9cf45c0a0b
commit
bacc5b4428
2 changed files with 33 additions and 1 deletions
|
@ -33,7 +33,7 @@ Zotero.Annotations = new function () {
|
|||
Zotero.defineProperty(this, 'ANNOTATION_TYPE_INK', { value: 4 });
|
||||
|
||||
Zotero.defineProperty(this, 'PROPS', {
|
||||
value: ['type', 'text', 'comment', 'color', 'pageLabel', 'sortIndex', 'position'],
|
||||
value: ['type', 'authorName', 'text', 'comment', 'color', 'pageLabel', 'sortIndex', 'position'],
|
||||
writable: false
|
||||
});
|
||||
|
||||
|
|
|
@ -873,6 +873,7 @@ describe("Zotero.CollectionTree", function() {
|
|||
var annotation = await createAnnotation('highlight', attachment);
|
||||
await Zotero.Users.setName(12345, 'Name');
|
||||
annotation.createdByUserID = 12345;
|
||||
await annotation.saveTx();
|
||||
|
||||
var ids = (await onDrop('item', 'L1', [groupItem.id])).ids;
|
||||
var newItem = Zotero.Items.get(ids[0]);
|
||||
|
@ -882,11 +883,42 @@ describe("Zotero.CollectionTree", function() {
|
|||
// Check annotation
|
||||
var annotations = newAttachment.getAnnotations();
|
||||
assert.lengthOf(annotations, 1);
|
||||
// Name transferred by Zotero.Items.copyChildItems()
|
||||
assert.equal(annotations[0].annotationAuthorName, 'Name');
|
||||
|
||||
return group.eraseTx();
|
||||
});
|
||||
|
||||
it("should preserve an explicit annotation author name when copied from a group to a personal library", async function () {
|
||||
var group = await createGroup();
|
||||
await cv.selectLibrary(group.libraryID);
|
||||
|
||||
var groupItem = await createDataObject('item', { libraryID: group.libraryID });
|
||||
var file = getTestDataDirectory();
|
||||
file.append('test.pdf');
|
||||
var attachment = await Zotero.Attachments.importFromFile({
|
||||
file,
|
||||
parentItemID: groupItem.id
|
||||
});
|
||||
var annotation = await createAnnotation('highlight', attachment);
|
||||
await Zotero.Users.setName(1, 'Name');
|
||||
annotation.createdByUserID = 1;
|
||||
annotation.annotationAuthorName = 'Another Name';
|
||||
|
||||
var ids = (await onDrop('item', 'L1', [groupItem.id])).ids;
|
||||
var newItem = Zotero.Items.get(ids[0]);
|
||||
|
||||
var newAttachment = Zotero.Items.get(newItem.getAttachments())[0];
|
||||
|
||||
// Check annotation
|
||||
var annotations = newAttachment.getAnnotations();
|
||||
assert.lengthOf(annotations, 1);
|
||||
// Name transferred by Zotero.Items.copyChildItems()
|
||||
assert.equal(annotations[0].annotationAuthorName, 'Another Name');
|
||||
|
||||
return group.eraseTx();
|
||||
});
|
||||
|
||||
it("should not copy an item or its attachment to a group twice", function* () {
|
||||
var group = yield getGroup();
|
||||
|
||||
|
|
Loading…
Reference in a new issue