From 7fa931425afdc0fb9e99281cc148cf710b7ea060 Mon Sep 17 00:00:00 2001 From: Dan Stillman Date: Fri, 10 Oct 2014 04:32:23 -0400 Subject: [PATCH] Rename Zotero.Item.prototype.getCreatorsAPIData() to getCreatorsJSON And add Zotero.Item.prototype.setCreators() --- chrome/content/zotero/xpcom/data/item.js | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/chrome/content/zotero/xpcom/data/item.js b/chrome/content/zotero/xpcom/data/item.js index a185858a4..2d210a6d6 100644 --- a/chrome/content/zotero/xpcom/data/item.js +++ b/chrome/content/zotero/xpcom/data/item.js @@ -952,7 +952,7 @@ Zotero.Item.prototype.getCreators = function () { * @return {Array} An array of creator data objects in API JSON format * ('firstName'/'lastName' or 'name', 'creatorType') */ -Zotero.Item.prototype.getCreatorsAPIData = function () { +Zotero.Item.prototype.getCreatorsJSON = function () { this._requireData('creators'); return this._creators.map(function (data) Zotero.Creators.internalToJSON(data)); } @@ -1010,6 +1010,16 @@ Zotero.Item.prototype.setCreator = function (orderIndex, data) { } +/** + * @param {Object[]} data - An array of creator data in internal or API JSON format + */ +Zotero.Item.prototype.setCreators = function (data) { + for (let i = 0; i < data.length; i++) { + this.setCreator(i, data[i]); + } +} + + /* * Remove a creator and shift others down */ @@ -4166,7 +4176,7 @@ Zotero.Item.prototype.toJSON = Zotero.Promise.coroutine(function* (options, patc // Creators if (this.isRegularItem()) { yield this.loadCreators() - obj.creators = this.getCreatorsAPIData(); + obj.creators = this.getCreatorsJSON(); } else { var parent = this.parentKey;