Skip child items when generating export format for CSL JSON
itemToCSLJSON() doesn't seem to need child items, so when a Zotero.Item is passed to it, don't bother loading child items when calling itemToExportFormat() to convert the item into the necessary format.
This commit is contained in:
parent
0238a2c13c
commit
511222bcaf
3 changed files with 5 additions and 12 deletions
|
@ -419,15 +419,6 @@ var Zotero_QuickFormat = new function () {
|
|||
// necessary data
|
||||
var items = yield Zotero.Items.getAsync(searchResultIDs);
|
||||
yield Zotero.Items.loadDataTypes(items);
|
||||
// Load child items of search matches
|
||||
// TODO: exclude child items from itemToExportFormat() so this isn't necessary?
|
||||
for (let item of items) {
|
||||
let ids = item.getAttachments().concat(item.getNotes());
|
||||
if (ids.length) {
|
||||
let childItems = yield Zotero.Items.getAsync(ids);
|
||||
yield Zotero.Items.loadDataTypes(childItems)
|
||||
}
|
||||
}
|
||||
|
||||
searchString = searchString.toLowerCase();
|
||||
var collation = Zotero.getLocaleCollation();
|
||||
|
|
|
@ -1613,9 +1613,11 @@ Zotero.Utilities = {
|
|||
* is passed
|
||||
*/
|
||||
"itemToCSLJSON":function(zoteroItem) {
|
||||
// If a Zotero.Item was passed, convert it to the proper format (skipping child items) and
|
||||
// call this function again with that object
|
||||
if (zoteroItem instanceof Zotero.Item) {
|
||||
return this.itemToCSLJSON(
|
||||
Zotero.Utilities.Internal.itemToExportFormat(zoteroItem)
|
||||
Zotero.Utilities.Internal.itemToExportFormat(zoteroItem, false, true)
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -765,7 +765,7 @@ Zotero.Utilities.Internal = {
|
|||
* @param {Boolean} legacy Add mappings for legacy (pre-4.0.27) translators
|
||||
* @return {Object}
|
||||
*/
|
||||
itemToExportFormat: function (zoteroItem, legacy) {
|
||||
itemToExportFormat: function (zoteroItem, legacy, skipChildItems) {
|
||||
function addCompatibilityMappings(item, zoteroItem) {
|
||||
item.uniqueFields = {};
|
||||
|
||||
|
@ -862,7 +862,7 @@ Zotero.Utilities.Internal = {
|
|||
item.uri = Zotero.URI.getItemURI(zoteroItem);
|
||||
delete item.key;
|
||||
|
||||
if (!zoteroItem.isAttachment() && !zoteroItem.isNote()) {
|
||||
if (!skipChildItems && !zoteroItem.isAttachment() && !zoteroItem.isNote()) {
|
||||
// Include attachments
|
||||
item.attachments = [];
|
||||
let attachments = zoteroItem.getAttachments();
|
||||
|
|
Loading…
Reference in a new issue