commit dcfdf27c0b8348fa6e29b7768d0a01339e0ad310
parent bd75d95da9ef4a97caf6d7bae9c3353192cfdd9f
Author: Simon Kornblith <simon@simonster.com>
Date: Wed, 3 Oct 2012 14:53:51 -0400
Make item-specific fields override base fields when specified
Diffstat:
2 files changed, 9 insertions(+), 2 deletions(-)
diff --git a/chrome/content/zotero/xpcom/translation/translate_item.js b/chrome/content/zotero/xpcom/translation/translate_item.js
@@ -385,8 +385,13 @@ Zotero.Translate.ItemSaver.prototype = {
// try to map from base field
if(Zotero.ItemFields.isBaseField(fieldID)) {
fieldID = Zotero.ItemFields.getFieldIDFromTypeAndBase(typeID, fieldID);
+
+ // Skip mapping if item field already exists
+ var fieldName = Zotero.ItemFields.getName(fieldID);
+ if(item[fieldName]) continue;
+
if(fieldID) {
- Zotero.debug("Translate: Mapping "+field+" to "+Zotero.ItemFields.getName(fieldID), 5);
+ Zotero.debug("Translate: Mapping "+field+" to "+fieldName, 5);
}
}
diff --git a/chrome/content/zotero/xpcom/utilities.js b/chrome/content/zotero/xpcom/utilities.js
@@ -1262,7 +1262,9 @@ Zotero.Utilities = {
// map from base field if possible
if((itemFieldID = Zotero.ItemFields.getFieldIDFromTypeAndBase(typeID, fieldID))) {
- newItem[Zotero.ItemFields.getName(itemFieldID)] = val;
+ var fieldName = Zotero.ItemFields.getName(itemFieldID);
+ // Only map if item field does not exist
+ if(!newItem[fieldName]) newItem[fieldName] = val;
continue; // already know this is valid
}