Convert some object ids from strings to integers after 4e1937680

This commit is contained in:
Dan Stillman 2017-05-23 02:10:26 -04:00
parent 4e1937680f
commit e1fb28faa9
4 changed files with 24 additions and 4 deletions

View file

@ -193,7 +193,7 @@
var remove = document.createElement("label"); var remove = document.createElement("label");
remove.setAttribute('value','-'); remove.setAttribute('value','-');
remove.setAttribute('onclick', remove.setAttribute('onclick',
"document.getBindingParent(this).remove('" + id + "');"); "document.getBindingParent(this).remove(" + id + ");");
remove.setAttribute('class','zotero-clicky zotero-clicky-minus'); remove.setAttribute('class','zotero-clicky zotero-clicky-minus');
} }

View file

@ -1792,7 +1792,7 @@ Zotero.Item.prototype._saveData = Zotero.Promise.coroutine(function* (env) {
if (reloadParentChildItems) { if (reloadParentChildItems) {
for (let parentItemID in reloadParentChildItems) { for (let parentItemID in reloadParentChildItems) {
// Keep in sync with Zotero.Items.trash() // 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); yield parentItem.reload(['primaryData', 'childItems'], true);
parentItem.clearBestAttachmentState(); parentItem.clearBestAttachmentState();
} }

View file

@ -2334,12 +2334,12 @@ Zotero.DragDrop = {
if (dt.types.contains('zotero/collection')) { if (dt.types.contains('zotero/collection')) {
dragData.dataType = '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; dragData.data = ids;
} }
else if (dt.types.contains('zotero/item')) { else if (dt.types.contains('zotero/item')) {
dragData.dataType = '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; dragData.data = ids;
} }
else { else {

View file

@ -1066,6 +1066,26 @@ describe("Zotero.Item", function () {
assert.ok(e); assert.ok(e);
assert.equal(e.message, "Item type must be set before saving"); 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);
});
}) })