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
|
@ -419,15 +419,6 @@ var Zotero_QuickFormat = new function () {
|
||||||
// necessary data
|
// necessary data
|
||||||
var items = yield Zotero.Items.getAsync(searchResultIDs);
|
var items = yield Zotero.Items.getAsync(searchResultIDs);
|
||||||
yield Zotero.Items.loadDataTypes(items);
|
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();
|
searchString = searchString.toLowerCase();
|
||||||
var collation = Zotero.getLocaleCollation();
|
var collation = Zotero.getLocaleCollation();
|
||||||
|
|
|
@ -1613,9 +1613,11 @@ Zotero.Utilities = {
|
||||||
* is passed
|
* is passed
|
||||||
*/
|
*/
|
||||||
"itemToCSLJSON":function(zoteroItem) {
|
"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) {
|
if (zoteroItem instanceof Zotero.Item) {
|
||||||
return this.itemToCSLJSON(
|
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
|
* @param {Boolean} legacy Add mappings for legacy (pre-4.0.27) translators
|
||||||
* @return {Object}
|
* @return {Object}
|
||||||
*/
|
*/
|
||||||
itemToExportFormat: function (zoteroItem, legacy) {
|
itemToExportFormat: function (zoteroItem, legacy, skipChildItems) {
|
||||||
function addCompatibilityMappings(item, zoteroItem) {
|
function addCompatibilityMappings(item, zoteroItem) {
|
||||||
item.uniqueFields = {};
|
item.uniqueFields = {};
|
||||||
|
|
||||||
|
@ -862,7 +862,7 @@ Zotero.Utilities.Internal = {
|
||||||
item.uri = Zotero.URI.getItemURI(zoteroItem);
|
item.uri = Zotero.URI.getItemURI(zoteroItem);
|
||||||
delete item.key;
|
delete item.key;
|
||||||
|
|
||||||
if (!zoteroItem.isAttachment() && !zoteroItem.isNote()) {
|
if (!skipChildItems && !zoteroItem.isAttachment() && !zoteroItem.isNote()) {
|
||||||
// Include attachments
|
// Include attachments
|
||||||
item.attachments = [];
|
item.attachments = [];
|
||||||
let attachments = zoteroItem.getAttachments();
|
let attachments = zoteroItem.getAttachments();
|
||||||
|
|
Loading…
Reference in New Issue
Block a user