- Change invalid creator type for item type to item type's primary creator automatically, since otherwise existing data would cause sync and save errors
- Fix a couple other errors
This commit is contained in:
parent
0ea27b091f
commit
43025db6d5
|
@ -1002,6 +1002,15 @@ Zotero.Item.prototype.setCreator = function(orderIndex, creator, creatorTypeIDOr
|
||||||
creatorTypeID = 1;
|
creatorTypeID = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// If creatorTypeID isn't valid for this type, use the primary type
|
||||||
|
if (!Zotero.CreatorTypes.isValidForItemType(creatorTypeID, this.itemTypeID)) {
|
||||||
|
var msg = "Invalid creator type " + creatorTypeID + " for item type " + this.itemTypeID
|
||||||
|
+ " -- changing to primary creator";
|
||||||
|
Zotero.debug(msg);
|
||||||
|
Components.utils.reportError(msg)
|
||||||
|
creatorTypeID = Zotero.CreatorTypes.getPrimaryIDForType(this.itemTypeID);
|
||||||
|
}
|
||||||
|
|
||||||
// If creator at this position hasn't changed, cancel
|
// If creator at this position hasn't changed, cancel
|
||||||
if (this._creators[orderIndex] &&
|
if (this._creators[orderIndex] &&
|
||||||
this._creators[orderIndex].ref.id == creator.id &&
|
this._creators[orderIndex].ref.id == creator.id &&
|
||||||
|
@ -1011,11 +1020,6 @@ Zotero.Item.prototype.setCreator = function(orderIndex, creator, creatorTypeIDOr
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!Zotero.CreatorTypes.isValidForItemType(creatorTypeID, this.itemTypeID)) {
|
|
||||||
throw ("Invalid creator type for item type in Zotero.Item.setCreator() "
|
|
||||||
+ "(" + creatorTypeID + ", " + this.itemTypeID + ")");
|
|
||||||
}
|
|
||||||
|
|
||||||
this._creators[orderIndex] = {
|
this._creators[orderIndex] = {
|
||||||
ref: creator,
|
ref: creator,
|
||||||
creatorTypeID: creatorTypeID
|
creatorTypeID: creatorTypeID
|
||||||
|
@ -3840,7 +3844,7 @@ Zotero.Item.prototype.clone = function(includePrimary, newItem, unsaved) {
|
||||||
newItem.id = this.id;
|
newItem.id = this.id;
|
||||||
newItem.libraryID = this.libraryID;
|
newItem.libraryID = this.libraryID;
|
||||||
newItem.key = this.key;
|
newItem.key = this.key;
|
||||||
newItem.itemTypeID = itemTypeID;
|
newItem.setType(itemTypeID);
|
||||||
for (var field in obj.primary) {
|
for (var field in obj.primary) {
|
||||||
switch (field) {
|
switch (field) {
|
||||||
case 'itemID':
|
case 'itemID':
|
||||||
|
|
Loading…
Reference in New Issue
Block a user