Fix marking of childItems as loaded for non-top-level items
Now that attachments and notes can have child items too
This commit is contained in:
parent
ea04c32c9d
commit
b1e324ddfb
2 changed files with 20 additions and 3 deletions
|
@ -594,6 +594,9 @@ Zotero.Items = function() {
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
//
|
||||||
|
// Attachments
|
||||||
|
//
|
||||||
var sql = "SELECT parentItemID, A.itemID, value AS title, "
|
var sql = "SELECT parentItemID, A.itemID, value AS title, "
|
||||||
+ "CASE WHEN DI.itemID IS NULL THEN 0 ELSE 1 END AS trashed "
|
+ "CASE WHEN DI.itemID IS NULL THEN 0 ELSE 1 END AS trashed "
|
||||||
+ "FROM itemAttachments A "
|
+ "FROM itemAttachments A "
|
||||||
|
@ -742,9 +745,11 @@ Zotero.Items = function() {
|
||||||
ids.forEach(id => setAnnotationItem(id, []));
|
ids.forEach(id => setAnnotationItem(id, []));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Mark all top-level items as having child items loaded
|
// Mark either all passed items or all items as having child items loaded
|
||||||
sql = "SELECT itemID FROM items I WHERE libraryID=?" + idSQL + " AND itemID NOT IN "
|
sql = "SELECT itemID FROM items I WHERE libraryID=?";
|
||||||
+ "(SELECT itemID FROM itemAttachments UNION SELECT itemID FROM itemNotes)";
|
if (idSQL) {
|
||||||
|
sql += idSQL;
|
||||||
|
}
|
||||||
yield Zotero.DB.queryAsync(
|
yield Zotero.DB.queryAsync(
|
||||||
sql,
|
sql,
|
||||||
params,
|
params,
|
||||||
|
|
|
@ -624,4 +624,16 @@ describe("Zotero.Items", function () {
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe("#_loadChildItems()", function () {
|
||||||
|
it("should mark child items as loaded for an attachment", async function () {
|
||||||
|
var attachment = await importPDFAttachment();
|
||||||
|
var itemID = attachment.id;
|
||||||
|
Zotero.Items.unload([itemID]);
|
||||||
|
attachment = await Zotero.Items.getAsync(itemID);
|
||||||
|
await attachment.loadDataType('childItems');
|
||||||
|
assert.isTrue(attachment._loaded.childItems);
|
||||||
|
attachment.getAnnotations();
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue