www

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | Submodules | README | LICENSE

commit 4fb9c2877f8ac27ffbfba46556b4285e8ef80146
parent 11ad20a1d847615cc08359970bb815dd21a74e6f
Author: Dan Stillman <dstillman@zotero.org>
Date:   Wed, 19 Oct 2011 22:27:17 +0000

Fix error when changing item types


Diffstat:
Mchrome/content/zotero/xpcom/data/item.js | 17++++++++---------
1 file changed, 8 insertions(+), 9 deletions(-)

diff --git a/chrome/content/zotero/xpcom/data/item.js b/chrome/content/zotero/xpcom/data/item.js @@ -425,12 +425,6 @@ Zotero.Item.prototype.setType = function(itemTypeID, loadIn) { if (loadIn) { throw ('Cannot change type in loadIn mode in Zotero.Item.setType()'); } - } - - this._itemTypeID = itemTypeID; - - // If there's an existing type - if (oldItemTypeID) { if (!this._itemDataLoaded && this.id) { this._loadItemData(); } @@ -460,7 +454,7 @@ Zotero.Item.prototype.setType = function(itemTypeID, loadIn) { for each(var oldFieldID in obsoleteFields) { // Try to get a base type for this field var baseFieldID = - Zotero.ItemFields.getBaseIDFromTypeAndField(this.itemTypeID, oldFieldID); + Zotero.ItemFields.getBaseIDFromTypeAndField(oldItemTypeID, oldFieldID); if (baseFieldID) { var newFieldID = @@ -504,7 +498,12 @@ Zotero.Item.prototype.setType = function(itemTypeID, loadIn) { copiedFields.push([fieldID, this.getField(fieldID)]); } } - + } + + this._itemTypeID = itemTypeID; + + // If there's an existing type + if (oldItemTypeID) { // Reset custom creator types to the default var creators = this.getCreators(); if (creators) { @@ -765,7 +764,7 @@ Zotero.Item.prototype.setField = function(field, value, loadIn) { return false; } else { - throw (msg); + throw new Error(msg); } }