From 532ad6b30c984802132aa67ed39817ff8d3fea12 Mon Sep 17 00:00:00 2001 From: Dan Stillman Date: Tue, 22 Dec 2009 07:49:33 +0000 Subject: [PATCH] Move title to bookTitle when changing item type from book to bookSection, and move bookTitle to title when going from bookSection to book if there's not also a title http://forums.zotero.org/discussion/78/books-and-book-sections-avoiding-input-of-duplicate-info/#Item_21 --- chrome/content/zotero/bindings/itembox.xml | 16 ++++++++++++++- chrome/content/zotero/xpcom/data/item.js | 24 ++++++++++++++++++++++ 2 files changed, 39 insertions(+), 1 deletion(-) diff --git a/chrome/content/zotero/bindings/itembox.xml b/chrome/content/zotero/bindings/itembox.xml index 9a840c1e41..5519598cd6 100644 --- a/chrome/content/zotero/bindings/itembox.xml +++ b/chrome/content/zotero/bindings/itembox.xml @@ -953,6 +953,20 @@ // Generate list of localized field names for display in pop-up if (fieldsToDelete) { + // Ignore warning for bookTitle when going from bookSection to book + // if there's not also a title, since the book title is transferred + // to title automatically in Zotero.Item.setType() + var bookTypeID = Zotero.ItemTypes.getID('book'); + var bookSectionTypeID = Zotero.ItemTypes.getID('bookSection'); + if (this.item.itemTypeID == bookSectionTypeID && itemTypeID == bookTypeID) { + var titleFieldID = Zotero.ItemFields.getID('title'); + var bookTitleFieldID = Zotero.ItemFields.getID('bookTitle'); + if (this.item.getField(bookTitleFieldID) && !this.item.getField(titleFieldID)) { + var index = fieldsToDelete.indexOf(bookTitleFieldID); + fieldsToDelete.splice(index, 1); + } + } + var fieldNames = ""; for (var i=0; i