commit e1fb28faa91da4b50539b3edaf3443b4cb79cc7c
parent 4e1937680f759f5aacb1ab6db43a3f930d6856ec
Author: Dan Stillman <dstillman@zotero.org>
Date: Tue, 23 May 2017 02:10:26 -0400
Convert some object ids from strings to integers after 4e1937680
Diffstat:
4 files changed, 24 insertions(+), 4 deletions(-)
diff --git a/chrome/content/zotero/bindings/relatedbox.xml b/chrome/content/zotero/bindings/relatedbox.xml
@@ -193,7 +193,7 @@
var remove = document.createElement("label");
remove.setAttribute('value','-');
remove.setAttribute('onclick',
- "document.getBindingParent(this).remove('" + id + "');");
+ "document.getBindingParent(this).remove(" + id + ");");
remove.setAttribute('class','zotero-clicky zotero-clicky-minus');
}
diff --git a/chrome/content/zotero/xpcom/data/item.js b/chrome/content/zotero/xpcom/data/item.js
@@ -1792,7 +1792,7 @@ Zotero.Item.prototype._saveData = Zotero.Promise.coroutine(function* (env) {
if (reloadParentChildItems) {
for (let parentItemID in reloadParentChildItems) {
// Keep in sync with Zotero.Items.trash()
- let parentItem = yield this.ObjectsClass.getAsync(parentItemID);
+ let parentItem = yield this.ObjectsClass.getAsync(parseInt(parentItemID));
yield parentItem.reload(['primaryData', 'childItems'], true);
parentItem.clearBestAttachmentState();
}
diff --git a/chrome/content/zotero/xpcom/zotero.js b/chrome/content/zotero/xpcom/zotero.js
@@ -2334,12 +2334,12 @@ Zotero.DragDrop = {
if (dt.types.contains('zotero/collection')) {
dragData.dataType = 'zotero/collection';
- var ids = dt.getData('zotero/collection').split(",");
+ let ids = dt.getData('zotero/collection').split(",").map(id => parseInt(id));
dragData.data = ids;
}
else if (dt.types.contains('zotero/item')) {
dragData.dataType = 'zotero/item';
- var ids = dt.getData('zotero/item').split(",");
+ let ids = dt.getData('zotero/item').split(",").map(id => parseInt(id));
dragData.data = ids;
}
else {
diff --git a/test/tests/itemTest.js b/test/tests/itemTest.js
@@ -1066,6 +1066,26 @@ describe("Zotero.Item", function () {
assert.ok(e);
assert.equal(e.message, "Item type must be set before saving");
})
+
+ it("should reload child items for parent items", function* () {
+ var item = yield createDataObject('item');
+ var attachment = yield importFileAttachment('test.png', { parentItemID: item.id });
+ var note1 = new Zotero.Item('note');
+ note1.parentItemID = item.id;
+ yield note1.saveTx();
+ var note2 = new Zotero.Item('note');
+ note2.parentItemID = item.id;
+ yield note2.saveTx();
+
+ assert.lengthOf(item.getAttachments(), 1);
+ assert.lengthOf(item.getNotes(), 2);
+
+ note2.parentItemID = null;
+ yield note2.saveTx();
+
+ assert.lengthOf(item.getAttachments(), 1);
+ assert.lengthOf(item.getNotes(), 1);
+ });
})