Convert some object ids from strings to integers after 4e1937680
This commit is contained in:
parent
4e1937680f
commit
e1fb28faa9
4 changed files with 24 additions and 4 deletions
|
@ -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');
|
||||
}
|
||||
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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);
|
||||
});
|
||||
})
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue