Skip to content

Commit

Permalink
Convert some object ids from strings to integers after 4e19376
Browse files Browse the repository at this point in the history
  • Loading branch information
dstillman committed May 23, 2017
1 parent 4e19376 commit e1fb28f
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 4 deletions.
2 changes: 1 addition & 1 deletion chrome/content/zotero/bindings/relatedbox.xml
Expand Up @@ -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');
}
Expand Down
2 changes: 1 addition & 1 deletion chrome/content/zotero/xpcom/data/item.js
Expand Up @@ -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();
}
Expand Down
4 changes: 2 additions & 2 deletions chrome/content/zotero/xpcom/zotero.js
Expand Up @@ -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 {
Expand Down
20 changes: 20 additions & 0 deletions test/tests/itemTest.js
Expand Up @@ -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);
});
})


Expand Down

0 comments on commit e1fb28f

Please sign in to comment.