Rename Zotero.Item.prototype.getCreatorsAPIData() to getCreatorsJSON

And add Zotero.Item.prototype.setCreators()
This commit is contained in:
Dan Stillman 2014-10-10 04:32:23 -04:00
parent 3c81067961
commit 7fa931425a

View file

@ -952,7 +952,7 @@ Zotero.Item.prototype.getCreators = function () {
* @return {Array<Object>} 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;